This is an automated email from the ASF dual-hosted git repository. wave pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/openoffice-org.git
The following commit(s) were added to refs/heads/main by this push: new 591313a Cache JBake results, add comments to templates 591313a is described below commit 591313a80994824901778f9e0508842f4bddeca3 Author: Dave Fisher <d...@davefisher.tech> AuthorDate: Wed Oct 28 11:46:20 2020 -0700 Cache JBake results, add comments to templates --- .gitignore | 1 + jbake.properties | 16 +++++++++------- templates/breadcrumbs.gsp | 11 +++++++++-- templates/html_page.gsp | 19 +++++++++++++++---- templates/md_page.gsp | 1 + templates/skeleton.gsp | 5 +++++ 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index f4042e3..53f2582 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ output +cache .DS_Store .history .idea \ No newline at end of file diff --git a/jbake.properties b/jbake.properties index c77fa5b..d16a52a 100644 --- a/jbake.properties +++ b/jbake.properties @@ -1,21 +1,23 @@ #site.host=https://www.openofffice.org site.host=http://localhost:8820 -render.tags=false -render.sitemap=false template.brand.file=brand.gsp template.navigator.file=navigator.gsp template.html_page.file=html_page.gsp template.md_page.file=md_page.gsp -template.archive.file=archive.gsp -template.tag.file=tags.gsp -template.sitemap.file=sitemap.gsp +markdown.extensions=ALL,-HARDWRAPS +#template.archive.file=archive.gsp +#template.tag.file=tags.gsp +#template.sitemap.file=sitemap.gsp template.feed.file=feed.gsp +render.encoding=UTF-8 +render.tags=false +render.sitemap=false render.index=false render.archive=false index.file=index.html content.folder=content destination.folder=output -markdown.extensions=ALL,-HARDWRAPS asset.ignore=true default.type=html_page -default.status=published \ No newline at end of file +default.status=published +db.store=plocal \ No newline at end of file diff --git a/templates/breadcrumbs.gsp b/templates/breadcrumbs.gsp index 9936a0b..320b8a6 100644 --- a/templates/breadcrumbs.gsp +++ b/templates/breadcrumbs.gsp @@ -1,14 +1,21 @@ <% String[] dirs = content.uri.split("/") -def breadcrumbs = "<a href=\"/\">home</a>" +// start the breadcrumbs def path = "/" +def breadcrumbs = "<a href=\"${path}\">home</a>" +// save each breadcrumb path for ssi analysis +def ssi = new String[dirs.length] +ssi[0] = path def n = dirs.length - 1; +// only proceed if the page is in a directory if (n > 0) { for (int i=0; i < n; i++) { + // breadcrumb and path for each directory path += dirs[i]+"/"; breadcrumbs += " » <a href=\"${path}\">${dirs[i]}</a>"; + ssi[i+1] = path } } -content.dirs=dirs; content.breadcrumbs=breadcrumbs; +content.ssi=ssi; %> \ No newline at end of file diff --git a/templates/html_page.gsp b/templates/html_page.gsp index 5a01e2b..dcd7870 100644 --- a/templates/html_page.gsp +++ b/templates/html_page.gsp @@ -1,24 +1,35 @@ <% +// Extract the body attributes as content.bodytag def matcher0 = content.body =~ "<body(.*?)>"; assert matcher0 instanceof java.util.regex.Matcher; if (!matcher0) { + // bare html not wrapped in a <body> tag content.extracted_body = content.body + content.bodytag = null + content.header = null } else { //assert matcher0.matches(); content.bodytag = matcher0.group(1); + // Extract the head content as content.header def matcher1 = content.body =~ "<head.*?>([\\S\\s]*?)</head>"; assert matcher1 instanceof java.util.regex.Matcher; if (!matcher1) { - throw new RuntimeException("bodytag='${content.bodytag}' -- head does not match"); + // no head found. + content.header = null + } else { + //assert matcher1.matches(); + content.header = matcher1.group(1); } - //assert matcher1.matches(); - content.header = matcher1.group(1); + // Extract the body content as content.extracted_body def matcher2 = content.body =~ "<body.*?>([\\S\\s]*?)</body>"; assert matcher2 instanceof java.util.regex.Matcher; if (!matcher2) { - throw new RuntimeException("head='${content.header}' -- body does not match"); + matcher2 = content.body =~ "<body.*?>([\\S\\s]*?)"; + if (!matcher2) { + throw new RuntimeException("content body not found"); + } } //assert matcher2.matches(); content.extracted_body= matcher2.group(1); diff --git a/templates/md_page.gsp b/templates/md_page.gsp index 5718e5c..45ef793 100644 --- a/templates/md_page.gsp +++ b/templates/md_page.gsp @@ -1,4 +1,5 @@ <% +// md does not do html extraction content.header=null; content.bodytag=null; content.extracted_body=null; diff --git a/templates/skeleton.gsp b/templates/skeleton.gsp index 8904399..ca70fe8 100644 --- a/templates/skeleton.gsp +++ b/templates/skeleton.gsp @@ -1,6 +1,11 @@ <% + // from jbake - content.uri and content.body + // from page metadata - content.title and content.css + // from html_page template - content.header, content.bodytag, and content.extracted_body // insert breadcrumbs and ssi logic + // using content.uri get content.breadcrumbs and content.ssi[] include "breadcrumbs.gsp" + // using content.ssi[] get content.brand, content.topnav, content.leftnav and content.rightnav include "ssi_paths.gsp" %><!--#include virtual="/doctype.html" --> <html>