Repository: sling-site
Updated Branches:
  refs/heads/master 444eb637f -> 5427600d1


Add revision info - executes git command to get it, shows <MISSING> if that 
fails


Project: http://git-wip-us.apache.org/repos/asf/sling-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/sling-site/commit/5427600d
Tree: http://git-wip-us.apache.org/repos/asf/sling-site/tree/5427600d
Diff: http://git-wip-us.apache.org/repos/asf/sling-site/diff/5427600d

Branch: refs/heads/master
Commit: 5427600d1ee92c41dd0093ddc7380b564a9bdf87
Parents: 444eb63
Author: Bertrand Delacretaz <[email protected]>
Authored: Mon Oct 2 11:59:18 2017 +0200
Committer: Bertrand Delacretaz <[email protected]>
Committed: Mon Oct 2 11:59:18 2017 +0200

----------------------------------------------------------------------
 src/main/jbake/assets/res/css/site.css   |  6 +++++
 src/main/jbake/jbake.properties          |  1 +
 src/main/jbake/templates/layout/main.tpl |  1 +
 src/main/jbake/templates/page.tpl        | 38 ++++++++++++++++++++++++++-
 4 files changed, 45 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sling-site/blob/5427600d/src/main/jbake/assets/res/css/site.css
----------------------------------------------------------------------
diff --git a/src/main/jbake/assets/res/css/site.css 
b/src/main/jbake/assets/res/css/site.css
index b718c19..85f1c62 100644
--- a/src/main/jbake/assets/res/css/site.css
+++ b/src/main/jbake/assets/res/css/site.css
@@ -314,4 +314,10 @@ pre {
 
 .taglink {
        margin-left:2em;
+}
+
+.revisionInfo {
+       text-align:right;
+       font-size:80%;
+       font-style:italic;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sling-site/blob/5427600d/src/main/jbake/jbake.properties
----------------------------------------------------------------------
diff --git a/src/main/jbake/jbake.properties b/src/main/jbake/jbake.properties
index 7e4fab8..e08d76b 100644
--- a/src/main/jbake/jbake.properties
+++ b/src/main/jbake/jbake.properties
@@ -18,3 +18,4 @@ render.index=false
 index.paginate=false
 markdown.extensions=WIKILINKS,TABLES,ANCHORLINKS
 template.downloads.file=downloads.tpl
+sling.lastCommitBaseUrl=https://github.com/apache/sling-site/commit/

http://git-wip-us.apache.org/repos/asf/sling-site/blob/5427600d/src/main/jbake/templates/layout/main.tpl
----------------------------------------------------------------------
diff --git a/src/main/jbake/templates/layout/main.tpl 
b/src/main/jbake/templates/layout/main.tpl
index a6f9874..49733e6 100644
--- a/src/main/jbake/templates/layout/main.tpl
+++ b/src/main/jbake/templates/layout/main.tpl
@@ -19,6 +19,7 @@ html(lang:'en'){
                        tags()
                        tableOfContents()
                        bodyContents()
+                       lastModified()
 
                        newLine()
                        include template: 'footer.tpl'

http://git-wip-us.apache.org/repos/asf/sling-site/blob/5427600d/src/main/jbake/templates/page.tpl
----------------------------------------------------------------------
diff --git a/src/main/jbake/templates/page.tpl 
b/src/main/jbake/templates/page.tpl
index dd7c134..57e0099 100644
--- a/src/main/jbake/templates/page.tpl
+++ b/src/main/jbake/templates/page.tpl
@@ -27,6 +27,29 @@ def getSortedParents(content, published_content) {
        return result
 }
 
+def exec(cmd, defaultText) {
+       try {
+           def p = cmd.execute()
+           p.waitFor()
+           return p.text
+       } catch(Exception e) {
+               return defaultText
+       }
+}
+
+def getRevisionInfo(filename) {
+    def lastCommit = "444eb637ff1ddcf11a0f37f02dd4b3fe89eb149f"
+       def gitCmd = 'git log -1 --format=%h####%ad####%an####%s ' + filename
+       def defaultText = "0####0000####<MISSING>####<MISSING>"
+       def gitInfo = exec(gitCmd, defaultText).split("####")
+       return [
+               lastCommit : gitInfo[0],
+               date : gitInfo[1],
+               author : gitInfo[2],
+               comment : gitInfo[3]
+       ]
+}
+
 layout 'layout/main.tpl', true,
         projects: projects,
                breadcrumbs : contents {
@@ -68,4 +91,17 @@ layout 'layout/main.tpl', true,
                     }
                 }
             }
-        }
+        },
+               lastModified: contents {
+                       div(class:"revisionInfo") {
+                               def info = getRevisionInfo(content.file);
+                               yield "Last modified by "
+                               span(class:"author") { yield info.author }
+                               yield " on "
+                               
a(href:"${config.sling_lastCommitBaseUrl}${info.lastCommit}") {
+                                   yield info.date
+                               }
+                               yield " : "
+                               span(class:"comment") { yield info.comment }
+                       }
+               }
\ No newline at end of file

Reply via email to