You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by wa...@apache.org on 2020/10/28 19:26:39 UTC
[openoffice-org] branch main updated: More template refactoring.
There is now a single page.gsp template.
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 9ea909e More template refactoring. There is now a single page.gsp template.
9ea909e is described below
commit 9ea909e5754159274a558cad9ab11d4c0d017938
Author: Dave Fisher <da...@davefisher.tech>
AuthorDate: Wed Oct 28 12:26:28 2020 -0700
More template refactoring. There is now a single page.gsp template.
---
content/lang.md | 1 -
content/privacy.md | 1 -
content/privacy_old.md | 1 -
content/style-test.md | 1 -
jbake.properties | 5 ++---
templates/html_extract.gsp | 37 +++++++++++++++++++++++++++++++++++
templates/html_page.gsp | 38 ------------------------------------
templates/{skeleton.gsp => page.gsp} | 7 +++++--
8 files changed, 44 insertions(+), 47 deletions(-)
diff --git a/content/lang.md b/content/lang.md
index 19721a3..303ce21 100644
--- a/content/lang.md
+++ b/content/lang.md
@@ -1,4 +1,3 @@
-type=md_page
title=Native Language Sites
~~~~~~
diff --git a/content/privacy.md b/content/privacy.md
index e3651fb..b40af3e 100644
--- a/content/privacy.md
+++ b/content/privacy.md
@@ -1,4 +1,3 @@
-type=md_page
title=Apache OpenOffice - Privacy
notice=http://www.apache.org/licenses/LICENSE-2.0
~~~~~~
diff --git a/content/privacy_old.md b/content/privacy_old.md
index fee14f1..90c47bc 100644
--- a/content/privacy_old.md
+++ b/content/privacy_old.md
@@ -1,4 +1,3 @@
-type=md_page
title=Apache OpenOffice - Privacy (Old)
notice=http://www.apache.org/licenses/LICENSE-2.0
~~~~~~
diff --git a/content/style-test.md b/content/style-test.md
index ccddab9..0cd5ae4 100644
--- a/content/style-test.md
+++ b/content/style-test.md
@@ -1,4 +1,3 @@
-type=md_page
title=This is the title
notice=http://www.apache.org/licenses/LICENSE-2.0
~~~~~~
diff --git a/jbake.properties b/jbake.properties
index 6f5654e..1ed3c6d 100644
--- a/jbake.properties
+++ b/jbake.properties
@@ -2,8 +2,7 @@
site.host=http://localhost:8820
template.brand.file=brand.gsp
template.navigator.file=navigator.gsp
-template.html_page.file=html_page.gsp
-template.md_page.file=skeleton.gsp
+template.page.file=page.gsp
markdown.extensions=ALL,-HARDWRAPS
#template.archive.file=archive.gsp
#template.tag.file=tags.gsp
@@ -18,6 +17,6 @@ index.file=index.html
content.folder=content
destination.folder=output
asset.ignore=true
-default.type=html_page
+default.type=page
default.status=published
db.store=plocal
\ No newline at end of file
diff --git a/templates/html_extract.gsp b/templates/html_extract.gsp
new file mode 100644
index 0000000..b3a2505
--- /dev/null
+++ b/templates/html_extract.gsp
@@ -0,0 +1,37 @@
+<%
+ // 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) {
+ // no head found.
+ content.header = null
+ } else {
+ //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) {
+ 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/html_page.gsp b/templates/html_page.gsp
deleted file mode 100644
index dcd7870..0000000
--- a/templates/html_page.gsp
+++ /dev/null
@@ -1,38 +0,0 @@
-<%
-// 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) {
- // no head found.
- content.header = null
- } else {
- //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) {
- matcher2 = content.body =~ "<body.*?>([\\S\\s]*?)";
- if (!matcher2) {
- throw new RuntimeException("content body not found");
- }
- }
- //assert matcher2.matches();
- content.extracted_body= matcher2.group(1);
-}
-
-include "skeleton.gsp" %>
diff --git a/templates/skeleton.gsp b/templates/page.gsp
similarity index 86%
rename from templates/skeleton.gsp
rename to templates/page.gsp
index ca70fe8..88abb45 100644
--- a/templates/skeleton.gsp
+++ b/templates/page.gsp
@@ -1,7 +1,10 @@
<%
- // from jbake - content.uri and content.body
+ // from jbake - content.file, 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
+ if ( content.file.endsWith(".html") ) {
+ // using content.body if html get content.header, content.bodytag, and content.extracted_body
+ include "html_extract.gsp"
+ }
// insert breadcrumbs and ssi logic
// using content.uri get content.breadcrumbs and content.ssi[]
include "breadcrumbs.gsp"