From d0fea306cc97df9967cbad4e5ef43bf4ac9a922f Mon Sep 17 00:00:00 2001
From: Adam Coldrick
Date: Wed, 16 Dec 2015 15:40:43 +0000
Subject: [PATCH] Display the most recent commit SHA on the about page
Change-Id: Idca471882a6b06df5d840649efabcf3a6696b5d6
---
.gitignore | 3 +-
Gruntfile.js | 39 +++++++++++++++++++
package.json | 2 +
.../template/{about.html => about.html.tpl} | 5 ++-
4 files changed, 46 insertions(+), 3 deletions(-)
rename src/app/pages/template/{about.html => about.html.tpl} (95%)
diff --git a/.gitignore b/.gitignore
index 4375552d..83be980a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,4 +11,5 @@ cover
.tox
src/theme/custom/**.less
src/theme/custom/**.ico
-src/config.json
\ No newline at end of file
+src/config.json
+src/app/pages/template/about.html
diff --git a/Gruntfile.js b/Gruntfile.js
index 8f9505cf..be26f52e 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -114,6 +114,37 @@ module.exports = function (grunt) {
]
},
+ /**
+ * grunt gitinfo
+ *
+ * Gets information about the current state of the source repository.
+ */
+ gitinfo: {
+ options: {
+ cwd: '.'
+ }
+ },
+
+ /**
+ * grunt template
+ *
+ * Interpolate variables into any templates we have defined.
+ */
+ template: {
+ 'process-html-template': {
+ options: {
+ data: {
+ sha: '<%= gitinfo.local.branch.current.SHA %>'
+ }
+ },
+ files: {
+ 'src/app/pages/template/about.html': [
+ 'src/app/pages/template/about.html.tpl'
+ ]
+ }
+ }
+ },
+
/**
* grunt concat
*
@@ -417,6 +448,12 @@ module.exports = function (grunt) {
* when necessary.
*/
watch: {
+ template: {
+ files: [
+ dir.source + '/**/*.tpl'
+ ],
+ tasks: ['compile']
+ },
concat: {
files: [
dir.source + '/app/**/module.js',
@@ -571,6 +608,8 @@ module.exports = function (grunt) {
* Compiles all of our sources.
*/
grunt.registerTask('compile', [
+ 'gitinfo',
+ 'template',
'useminPrepare',
'concat',
'less',
diff --git a/package.json b/package.json
index 0d8fa917..acb1bf85 100644
--- a/package.json
+++ b/package.json
@@ -43,11 +43,13 @@
"grunt-contrib-watch": "0.6.1",
"grunt-env": "0.4.1",
"grunt-eslint": "7.0.1",
+ "grunt-gitinfo": "^0.1.7",
"grunt-html2js": "0.2.9",
"grunt-karma": "0.9.0",
"grunt-open": "0.2.3",
"grunt-protractor-runner": "1.1.4",
"grunt-shell": "1.1.1",
+ "grunt-template": "^0.2.3",
"grunt-usemin": "2.4.0",
"grunt-webfont": "0.4.8",
"karma": "0.12.23",
diff --git a/src/app/pages/template/about.html b/src/app/pages/template/about.html.tpl
similarity index 95%
rename from src/app/pages/template/about.html
rename to src/app/pages/template/about.html.tpl
index 213036a6..45cfd58e 100644
--- a/src/app/pages/template/about.html
+++ b/src/app/pages/template/about.html.tpl
@@ -58,12 +58,13 @@
is not well served. This system uses the best concepts
from existing tools and goes beyond to support the needs
of the OpenStack project.
-
See project README
-
+
+ Webclient version: <%- sha %>