sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject [4/8] sling-site git commit: Add support for tags
Date Fri, 29 Sep 2017 14:00:13 GMT
Add support for tags


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

Branch: refs/heads/master
Commit: bab2e26b503eff7a3e1a618ab980b661ab7a522f
Parents: 3239c71
Author: Bertrand Delacretaz <bdelacretaz@apache.org>
Authored: Fri Sep 29 15:35:53 2017 +0200
Committer: Bertrand Delacretaz <bdelacretaz@apache.org>
Committed: Fri Sep 29 15:35:53 2017 +0200

----------------------------------------------------------------------
 src/main/jbake/assets/res/css/site.css   | 23 ++++++++++++++
 src/main/jbake/templates/layout/main.tpl |  7 +++--
 src/main/jbake/templates/page.tpl        | 12 ++++++++
 src/main/jbake/templates/tags.tpl        | 44 +++++++++++++++++++++++++--
 4 files changed, 82 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sling-site/blob/bab2e26b/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 2e0bf1a..b718c19 100644
--- a/src/main/jbake/assets/res/css/site.css
+++ b/src/main/jbake/assets/res/css/site.css
@@ -292,3 +292,26 @@ pre {
 .footer {
     padding-top: 1em; 
 }
+
+.badge {
+    border-radius: 2px;
+    background-color: #EEE;
+    text-align: center;
+    padding-left: 3px;
+    padding-right: 3px;
+	margin-left: 3px;
+}
+
+.tags {
+	font-size:80%;
+}
+
+.tags a {
+    background-color: #EEE;
+	padding: 0.5em;
+	text-decoration: none;
+}
+
+.taglink {
+	margin-left:2em;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sling-site/blob/bab2e26b/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 b7046b3..a6f9874 100644
--- a/src/main/jbake/templates/layout/main.tpl
+++ b/src/main/jbake/templates/layout/main.tpl
@@ -10,10 +10,13 @@ html(lang:'en'){
 		div(class:"main") {
 			breadcrumbs()
 			
-			h1(class:"pagetitle") {
-            	yield "${ content ? content.title : "<MISSING CONTENT OBJECT??>" }"
+			if(content && content.title) {
+				h1(class:"pagetitle") {
+					yield "${ content.title }"
+				}
 			}
 			
+			tags()
 			tableOfContents()
 			bodyContents()
 

http://git-wip-us.apache.org/repos/asf/sling-site/blob/bab2e26b/src/main/jbake/templates/page.tpl
----------------------------------------------------------------------
diff --git a/src/main/jbake/templates/page.tpl b/src/main/jbake/templates/page.tpl
index 8bb6795..dd7c134 100644
--- a/src/main/jbake/templates/page.tpl
+++ b/src/main/jbake/templates/page.tpl
@@ -40,6 +40,18 @@ 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 " "
+					}
+				}
+			}
+		},
 		tableOfContents : contents {
 			// Temporary (?) ToC generation, until we get markdown support for that
 			// using https://github.com/nghuuphuoc/tocjs

http://git-wip-us.apache.org/repos/asf/sling-site/blob/bab2e26b/src/main/jbake/templates/tags.tpl
----------------------------------------------------------------------
diff --git a/src/main/jbake/templates/tags.tpl b/src/main/jbake/templates/tags.tpl
index 97d88d1..08bd503 100644
--- a/src/main/jbake/templates/tags.tpl
+++ b/src/main/jbake/templates/tags.tpl
@@ -1,5 +1,45 @@
 layout 'layout/main.tpl', true,
         projects: projects,
         bodyContents: contents {
-			p("TODO - blog tag rendering disabled as it failed")
-		}
+
+            div(class:"row"){
+                div(class:"small-12 columns"){
+                    div(class:"wrap"){
+
+                        div(class:"row"){
+                            div(class:"small-12 columns"){
+                                div(class:"tags"){
+                                    alltags.sort().each { tag ->
+                                        tag = tag.trim()
+                                        def count = all_content.findAll { p -> p.tags
&& p.tags.contains(tag) }.size()
+                                        span{
+                                            a(href:"${config.site_contextPath}tags/${tag.replace('
', '-')}.html", class:"label"){
+                                                yield "$tag"
+                                                span(class:"badge","${count}")
+                                            }
+											yield " "
+											newLine()
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                        div(class:"taglinks"){
+                            div(class:"small-12 columns"){
+								h2("Tagged with '${tag}'")
+                                all_content.each { p ->
+                                    if ( p.status == 'published' && p.tags &&
p.tags.contains(tag) ) {
+                                        div(class:"taglink"){
+                                            a(href:"${config.site_contextPath}${p.uri}"){
+                                                yield p.title
+                                            }
+                                        }
+										newLine()
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
\ No newline at end of file


Mime
View raw message