From 903dee3f6e24ac7d50382fac8be2540dfe0d512a Mon Sep 17 00:00:00 2001
From: Shane Tomlinson <stomlinson@mozilla.com>
Date: Fri, 13 Jul 2012 15:41:52 +0100
Subject: [PATCH] Add a link to the repo and current source in the top level of
 each served up HTML resource.

* in each top level layout or ejs template, include a link to a partial that contains the license.
* The bottom of the license contains a link to the repo and the current SHA's commit.
---
 lib/static/views.js                               | 9 ++++++++-
 resources/views/authenticate_with_primary.ejs     | 4 +---
 resources/views/communication_iframe.ejs          | 4 +---
 resources/views/dialog_layout.ejs                 | 5 +----
 resources/views/layout.ejs                        | 4 +---
 resources/views/partial/license_with_code_ver.ejs | 7 +++++++
 resources/views/relay.ejs                         | 4 +---
 7 files changed, 20 insertions(+), 17 deletions(-)
 create mode 100644 resources/views/partial/license_with_code_ver.ejs

diff --git a/lib/static/views.js b/lib/static/views.js
index 957bfb09c..65fe37fa4 100644
--- a/lib/static/views.js
+++ b/lib/static/views.js
@@ -13,7 +13,8 @@ und = require('underscore'),
 util = require('util'),
 httputils = require('../httputils.js'),
 etagify = require('etagify'),
-secrets = require('../secrets');
+secrets = require('../secrets'),
+version = require('../version');
 
 require("jwcrypto/lib/algs/rs");
 
@@ -43,6 +44,12 @@ function renderCachableView(req, res, template, options) {
 
   options.enable_development_menu = config.get('enable_development_menu');
 
+  // The real version number is not ready until sometime after initial load,
+  // until it is ready a fake randomly generated string is used. Go get
+  // the real SHA whenever it is actually needed so that the randomly
+  // generated SHA is not returned to the user.
+  options.commit = version();
+
   res.local('util', util);
   res.render(template, options);
 }
diff --git a/resources/views/authenticate_with_primary.ejs b/resources/views/authenticate_with_primary.ejs
index 45f8dab1d..57ef4cc40 100644
--- a/resources/views/authenticate_with_primary.ejs
+++ b/resources/views/authenticate_with_primary.ejs
@@ -1,7 +1,5 @@
 <!DOCTYPE html>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
-   - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<%- partial('partial/license_with_code_ver') %>
 <html>
 <head>
   <meta charset="utf-8">
diff --git a/resources/views/communication_iframe.ejs b/resources/views/communication_iframe.ejs
index 147b0228a..66c8e0f40 100644
--- a/resources/views/communication_iframe.ejs
+++ b/resources/views/communication_iframe.ejs
@@ -1,7 +1,5 @@
 <!DOCTYPE html>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
-   - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<%- partial('partial/license_with_code_ver') %>
 <html>
 <head><title>non-interactive iframe</title>
   <meta charset="utf-8">
diff --git a/resources/views/dialog_layout.ejs b/resources/views/dialog_layout.ejs
index 6e567ccba..5700e6d41 100644
--- a/resources/views/dialog_layout.ejs
+++ b/resources/views/dialog_layout.ejs
@@ -1,8 +1,5 @@
 <!DOCTYPE html>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
-   - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
+<%- partial('partial/license_with_code_ver') %>
 <html LANG="<%= lang %>" dir="<%= lang_dir %>">
 <head>
   <meta charset="utf-8">
diff --git a/resources/views/layout.ejs b/resources/views/layout.ejs
index cbc7cc078..bea90bcae 100644
--- a/resources/views/layout.ejs
+++ b/resources/views/layout.ejs
@@ -1,7 +1,5 @@
 <!DOCTYPE html>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
-   - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<%- partial('partial/license_with_code_ver') %>
 <html>
 <head>
   <meta charset="utf-8">
diff --git a/resources/views/partial/license_with_code_ver.ejs b/resources/views/partial/license_with_code_ver.ejs
new file mode 100644
index 000000000..7cc908f73
--- /dev/null
+++ b/resources/views/partial/license_with_code_ver.ejs
@@ -0,0 +1,7 @@
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/.
+   - Source: https://github.com/mozilla/browserid/
+   - Current Commit: https://github.com/mozilla/browserid/commit/<%- commit %>
+-->
+
diff --git a/resources/views/relay.ejs b/resources/views/relay.ejs
index 4ee25e8a7..a530006e7 100644
--- a/resources/views/relay.ejs
+++ b/resources/views/relay.ejs
@@ -1,7 +1,5 @@
 <!DOCTYPE html>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
-   - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<%- partial('partial/license_with_code_ver') %>
 <html>
 <head>
   <meta charset="utf-8">
-- 
GitLab