You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2018/01/26 15:03:58 UTC
[sling-site] branch master updated: Factor out page elements in
'bricks' for reuse in multiple templates
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-site.git
The following commit(s) were added to refs/heads/master by this push:
new 009e228 Factor out page elements in 'bricks' for reuse in multiple templates
009e228 is described below
commit 009e228065ecd7a8901ca7be6bf70f8b3e626bf9
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jan 26 16:03:14 2018 +0100
Factor out page elements in 'bricks' for reuse in multiple templates
---
src/main/jbake/assets/res/css/site.css | 1 +
src/main/jbake/templates/breadcrumbs-brick.tpl | 9 +++++++
src/main/jbake/templates/downloads.tpl | 6 +++++
src/main/jbake/templates/lastmodified-brick.tpl | 7 +++++
src/main/jbake/templates/page.tpl | 36 +++----------------------
src/main/jbake/templates/repolist.tpl | 8 +++++-
src/main/jbake/templates/tags-brick.tpl | 11 ++++++++
src/main/jbake/templates/toc-brick.tpl | 6 +++++
8 files changed, 51 insertions(+), 33 deletions(-)
diff --git a/src/main/jbake/assets/res/css/site.css b/src/main/jbake/assets/res/css/site.css
index e1a1fcb..3dae73e 100644
--- a/src/main/jbake/assets/res/css/site.css
+++ b/src/main/jbake/assets/res/css/site.css
@@ -314,6 +314,7 @@ pre {
.tags a {
background-color: #EEE;
padding: 0.2em;
+ margin-left: 0.2em;
text-decoration: none;
}
diff --git a/src/main/jbake/templates/breadcrumbs-brick.tpl b/src/main/jbake/templates/breadcrumbs-brick.tpl
new file mode 100644
index 0000000..3e65d4f
--- /dev/null
+++ b/src/main/jbake/templates/breadcrumbs-brick.tpl
@@ -0,0 +1,9 @@
+div(class:"breadcrumbs") {
+ def separator = " » "
+ U.getSortedParents(content, published_content).each { item ->
+ a (href:"${config.site_contextPath}${item.value.uri}") {
+ yield item.value.title
+ }
+ yieldUnescaped separator
+ }
+}
\ No newline at end of file
diff --git a/src/main/jbake/templates/downloads.tpl b/src/main/jbake/templates/downloads.tpl
index 4ad5fb3..7116242 100644
--- a/src/main/jbake/templates/downloads.tpl
+++ b/src/main/jbake/templates/downloads.tpl
@@ -274,6 +274,12 @@ def tableHead(String [] headers) {
// ------------------------------------------------------------------------------------------------
layout 'layout/main.tpl', true,
projects: projects,
+ tags : contents {
+ include template: 'tags-brick.tpl'
+ },
+ lastModified: contents {
+ include template : 'lastmodified-brick.tpl'
+ },
bodyContents: contents {
div(class:"row"){
diff --git a/src/main/jbake/templates/lastmodified-brick.tpl b/src/main/jbake/templates/lastmodified-brick.tpl
new file mode 100644
index 0000000..dc08946
--- /dev/null
+++ b/src/main/jbake/templates/lastmodified-brick.tpl
@@ -0,0 +1,7 @@
+div(class:"revisionInfo") {
+ def info = includes.Git.getRevisionInfo(content.file);
+ yield "Last modified by "
+ span(class:"author") { yield info.author }
+ yield " on "
+ span(class:"comment") { yield info.date }
+}
\ No newline at end of file
diff --git a/src/main/jbake/templates/page.tpl b/src/main/jbake/templates/page.tpl
index 440b89b..3a6eef4 100644
--- a/src/main/jbake/templates/page.tpl
+++ b/src/main/jbake/templates/page.tpl
@@ -4,23 +4,10 @@ U = new includes.U(config)
layout 'layout/main.tpl', true,
projects: projects,
breadcrumbs : contents {
- div(class:"breadcrumbs") {
- def separator = " » "
- U.getSortedParents(content, published_content).each { item ->
- a (href:"${config.site_contextPath}${item.value.uri}") {
- yield item.value.title
- }
- yieldUnescaped separator
- }
- }
+ include template : 'breadcrumbs-brick.tpl'
},
tableOfContents : contents {
- // Temporary (?) ToC generation, until we get markdown support for that
- // using https://github.com/nghuuphuoc/tocjs
- div(id:"generatedToC") {}
- yieldUnescaped "<script src='/res/jquery-3.2.1.min.js' type='text/javascript'></script>"
- yieldUnescaped "<script src='/res/tocjs-1-1-2.js' type='text/javascript'></script>"
- yieldUnescaped "<script type='text/javascript'>\$(document).ready(function() { \$('#generatedToC').toc({'selector':'h1[class!=pagetitle],h2,h3'}); } );</script>"
+ include template : 'toc-brick.tpl'
},
bodyContents: contents {
div(class:"row"){
@@ -32,23 +19,8 @@ layout 'layout/main.tpl', true,
}
},
tags : contents {
- div(class:"tags") {
- if(content.tags) {
- content.tags.each { tag ->
- a(href:"${config.site_contextPath}tags/${tag.replace(' ', '-')}.html", class:"label"){
- yield tag
- }
- yield " "
- }
- }
- }
+ include template : 'tags-brick.tpl'
},
lastModified: contents {
- div(class:"revisionInfo") {
- def info = includes.Git.getRevisionInfo(content.file);
- yield "Last modified by "
- span(class:"author") { yield info.author }
- yield " on "
- span(class:"comment") { yield info.date }
- }
+ include template : 'lastmodified-brick.tpl'
}
diff --git a/src/main/jbake/templates/repolist.tpl b/src/main/jbake/templates/repolist.tpl
index 22ef443..6ab338a 100644
--- a/src/main/jbake/templates/repolist.tpl
+++ b/src/main/jbake/templates/repolist.tpl
@@ -8,8 +8,14 @@ U = new includes.U(config)
layout 'layout/main.tpl', true,
projects: projects,
+ breadcrumbs : contents {
+ include template : 'breadcrumbs-brick.tpl'
+ },
tags : contents {
- //include template: 'tags-brick.tpl'
+ include template: 'tags-brick.tpl'
+ },
+ lastModified: contents {
+ include template : 'lastmodified-brick.tpl'
},
bodyContents: contents {
section(class:"wrap"){
diff --git a/src/main/jbake/templates/tags-brick.tpl b/src/main/jbake/templates/tags-brick.tpl
new file mode 100644
index 0000000..ef2b58d
--- /dev/null
+++ b/src/main/jbake/templates/tags-brick.tpl
@@ -0,0 +1,11 @@
+div(class:"tags") {
+ if(content.tags) {
+ content.tags.each {
+ tag ->
+ a(href:"${config.site_contextPath}tags/${tag.replace(' ', '-')}.html", class:"label"){
+ yield tag
+ }
+ yield " "
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/jbake/templates/toc-brick.tpl b/src/main/jbake/templates/toc-brick.tpl
new file mode 100644
index 0000000..b7d8feb
--- /dev/null
+++ b/src/main/jbake/templates/toc-brick.tpl
@@ -0,0 +1,6 @@
+// Temporary (?) ToC generation, until we get markdown support for that
+// using https://github.com/nghuuphuoc/tocjs
+div(id:"generatedToC") {}
+yieldUnescaped "<script src='/res/jquery-3.2.1.min.js' type='text/javascript'></script>"
+yieldUnescaped "<script src='/res/tocjs-1-1-2.js' type='text/javascript'></script>"
+yieldUnescaped "<script type='text/javascript'>\$(document).ready(function() { \$('#generatedToC').toc({'selector':'h1[class!=pagetitle],h2,h3'}); } );</script>"
--
To stop receiving notification emails like this one, please contact
bdelacretaz@apache.org.