From 2869655406e966960a12e0d7e2464037cbcf8f43 Mon Sep 17 00:00:00 2001 From: yashTEF Date: Wed, 10 Jan 2024 23:25:15 +0530 Subject: [PATCH 1/5] Fetch Header/Footer Functionality --- ui/pom.xml | 38 ++++ .../eclipse/starter/ui/FetchHtmlUtility.java | 53 ++++++ ui/src/main/webapp/WEB-INF/footer.xhtml | 100 +--------- ui/src/main/webapp/WEB-INF/template.xhtml | 3 +- ui/src/main/webapp/WEB-INF/topbar.xhtml | 178 +----------------- 5 files changed, 104 insertions(+), 268 deletions(-) create mode 100644 ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java diff --git a/ui/pom.xml b/ui/pom.xml index 434b70fe..c2fa4abc 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -98,6 +98,13 @@ maven-resolver-connector-basic 1.9.16 + + + org.jsoup + jsoup + 1.17.2 + + org.apache.maven.resolver maven-resolver-transport-http @@ -135,6 +142,37 @@ + + com.googlecode.maven-download-plugin + download-maven-plugin + 1.3.0 + + + my-id-0 + process-resources + + wget + + + https://jakarta.ee/templates/header/ + _template_header_.html + ${project.build.directory}/jakarta-starter-ui + + + + my-id-1 + process-resources + + wget + + + https://jakarta.ee/templates/footer/ + _template_footer_.html + ${project.build.directory}/jakarta-starter-ui + + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java b/ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java new file mode 100644 index 00000000..fdfc8021 --- /dev/null +++ b/ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java @@ -0,0 +1,53 @@ +package org.eclipse.starter.ui; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; + +import javax.enterprise.context.ApplicationScoped; +import javax.faces.context.FacesContext; +import javax.inject.Named; + +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.select.Elements; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Named +@ApplicationScoped +public class FetchHtmlUtility { + + private static final String FOOTER_TEMPLATE = "_template_footer_.html"; + private static final String HEADER_TEMPLATE = "_template_header_.html"; + + Logger logger = LoggerFactory.getLogger(FetchHtmlUtility.class.getName()); + + public String getHeaderHtml() throws IOException { + String absoluteDiskPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath(HEADER_TEMPLATE); + String content = readFile(absoluteDiskPath, Charset.defaultCharset()); + Document document = Jsoup.parse(content); + Elements headerFragment = document.select("body"); + StringBuilder headerHtml = new StringBuilder(); + headerHtml.append(headerFragment.html()); + logger.info("element: {}", headerHtml); + return headerHtml.toString(); + } + + public String getFooterHtml() throws IOException { + String absoluteDiskPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath(FOOTER_TEMPLATE); + String content = readFile(absoluteDiskPath, Charset.defaultCharset()); + Document document = Jsoup.parse(content); + Elements footerFragment = document.select("body"); + StringBuilder footerHtml = new StringBuilder(); + footerHtml.append(footerFragment.html()); + logger.info("element: {}", footerFragment.html()); + return footerHtml.toString(); + } + + private static String readFile(String path, Charset encoding) throws IOException { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded, encoding); + } +} diff --git a/ui/src/main/webapp/WEB-INF/footer.xhtml b/ui/src/main/webapp/WEB-INF/footer.xhtml index 18902e0e..af07541c 100644 --- a/ui/src/main/webapp/WEB-INF/footer.xhtml +++ b/ui/src/main/webapp/WEB-INF/footer.xhtml @@ -1,100 +1,6 @@ - + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://xmlns.jcp.org/jsf/html"> + \ No newline at end of file diff --git a/ui/src/main/webapp/WEB-INF/template.xhtml b/ui/src/main/webapp/WEB-INF/template.xhtml index 5bd553be..a3353692 100644 --- a/ui/src/main/webapp/WEB-INF/template.xhtml +++ b/ui/src/main/webapp/WEB-INF/template.xhtml @@ -51,7 +51,6 @@ text-align: center; } - Eclipse Starter for Jakarta EE @@ -92,4 +91,4 @@ - + \ No newline at end of file diff --git a/ui/src/main/webapp/WEB-INF/topbar.xhtml b/ui/src/main/webapp/WEB-INF/topbar.xhtml index bb8ec6e7..4caf13ad 100644 --- a/ui/src/main/webapp/WEB-INF/topbar.xhtml +++ b/ui/src/main/webapp/WEB-INF/topbar.xhtml @@ -1,176 +1,17 @@ - + - Skip to main content -
-
- -
+ +
- + -
\ No newline at end of file From c44903b30ce91b770953e7b356235337f8a0c947 Mon Sep 17 00:00:00 2001 From: yashTEF Date: Wed, 10 Jan 2024 23:35:35 +0530 Subject: [PATCH 2/5] Fix Indent --- ui/pom.xml | 74 ++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/ui/pom.xml b/ui/pom.xml index c2fa4abc..dcf1d257 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -98,13 +98,11 @@ maven-resolver-connector-basic 1.9.16
- - - org.jsoup - jsoup - 1.17.2 - - + + org.jsoup + jsoup + 1.17.2 + org.apache.maven.resolver maven-resolver-transport-http @@ -142,37 +140,37 @@ - - com.googlecode.maven-download-plugin - download-maven-plugin - 1.3.0 - - - my-id-0 - process-resources - - wget - - - https://jakarta.ee/templates/header/ - _template_header_.html - ${project.build.directory}/jakarta-starter-ui - - - - my-id-1 - process-resources - - wget - - - https://jakarta.ee/templates/footer/ - _template_footer_.html - ${project.build.directory}/jakarta-starter-ui - - - - + + com.googlecode.maven-download-plugin + download-maven-plugin + 1.3.0 + + + my-id-0 + process-resources + + wget + + + https://jakarta.ee/templates/header/ + _template_header_.html + ${project.build.directory}/jakarta-starter-ui + + + + my-id-1 + process-resources + + wget + + + https://jakarta.ee/templates/footer/ + _template_footer_.html + ${project.build.directory}/jakarta-starter-ui + + + + org.apache.maven.plugins maven-compiler-plugin From 2440d6a5d5e3a63efa2fd2fd15d5ff3b8cb89952 Mon Sep 17 00:00:00 2001 From: yashTEF Date: Sat, 1 Jun 2024 21:56:00 +0530 Subject: [PATCH 3/5] overwrite header/footer with updated files from remote url --- ui/pom.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/pom.xml b/ui/pom.xml index 59d8004e..bd625d4a 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -6,7 +6,7 @@ 4.0.0 org.eclipse.starter jakarta-starter-ui - 2.0.5 + 2.1.0-SNAPSHOT war @@ -155,6 +155,8 @@ https://jakarta.ee/templates/header/ _template_header_.html ${project.build.directory}/jakarta-starter-ui + true + true @@ -167,6 +169,8 @@ https://jakarta.ee/templates/footer/ _template_footer_.html ${project.build.directory}/jakarta-starter-ui + true + true From 7a58a5152b77ac5b16ee108b71d724b28e38f00f Mon Sep 17 00:00:00 2001 From: yashTEF Date: Sat, 1 Jun 2024 21:56:52 +0530 Subject: [PATCH 4/5] change to debug logs --- ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java b/ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java index fdfc8021..faa11892 100644 --- a/ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java +++ b/ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java @@ -31,7 +31,7 @@ public String getHeaderHtml() throws IOException { Elements headerFragment = document.select("body"); StringBuilder headerHtml = new StringBuilder(); headerHtml.append(headerFragment.html()); - logger.info("element: {}", headerHtml); + logger.debug("element: {}", headerHtml); return headerHtml.toString(); } @@ -42,7 +42,7 @@ public String getFooterHtml() throws IOException { Elements footerFragment = document.select("body"); StringBuilder footerHtml = new StringBuilder(); footerHtml.append(footerFragment.html()); - logger.info("element: {}", footerFragment.html()); + logger.debug("element: {}", footerFragment.html()); return footerHtml.toString(); } From c43ddea3f54144d1e6a014128f9bd69e1e19a1d2 Mon Sep 17 00:00:00 2001 From: yashTEF Date: Sat, 30 Nov 2024 22:05:16 +0530 Subject: [PATCH 5/5] fetch-changes --- ui/pom.xml | 35 +++++++++--- .../eclipse/starter/ui/FetchHtmlUtility.java | 53 ------------------- ui/src/main/webapp/WEB-INF/footer.xhtml | 7 ++- ui/src/main/webapp/WEB-INF/topbar.xhtml | 49 ++++++++--------- 4 files changed, 56 insertions(+), 88 deletions(-) delete mode 100644 ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java diff --git a/ui/pom.xml b/ui/pom.xml index bd625d4a..29c93eda 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -59,7 +59,6 @@ ivar.grimstad@eclipse-foundation.org - scm:git:git://github.com/eclipse-ee4j/starter.git scm:git:ssh://github.com:eclipse-ee4j/starter.git @@ -98,11 +97,6 @@ maven-resolver-connector-basic 1.9.16 - - org.jsoup - jsoup - 1.17.2 - org.apache.maven.resolver maven-resolver-transport-http @@ -158,7 +152,7 @@ true true - + my-id-1 process-resources @@ -175,6 +169,33 @@ + + com.cosium.html + html-to-xhtml-maven-plugin + 1.2 + + + + convert-html-to-xhtml + package + + html-to-xhtml + + + + + + + ${project.build.directory}/jakarta-starter-ui/_template_header_.html + ${project.build.directory}/jakarta-starter-ui/WEB-INF/header_fragment.xhtml + + + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java b/ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java deleted file mode 100644 index faa11892..00000000 --- a/ui/src/main/java/org/eclipse/starter/ui/FetchHtmlUtility.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.eclipse.starter.ui; - -import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Paths; - -import javax.enterprise.context.ApplicationScoped; -import javax.faces.context.FacesContext; -import javax.inject.Named; - -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.select.Elements; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Named -@ApplicationScoped -public class FetchHtmlUtility { - - private static final String FOOTER_TEMPLATE = "_template_footer_.html"; - private static final String HEADER_TEMPLATE = "_template_header_.html"; - - Logger logger = LoggerFactory.getLogger(FetchHtmlUtility.class.getName()); - - public String getHeaderHtml() throws IOException { - String absoluteDiskPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath(HEADER_TEMPLATE); - String content = readFile(absoluteDiskPath, Charset.defaultCharset()); - Document document = Jsoup.parse(content); - Elements headerFragment = document.select("body"); - StringBuilder headerHtml = new StringBuilder(); - headerHtml.append(headerFragment.html()); - logger.debug("element: {}", headerHtml); - return headerHtml.toString(); - } - - public String getFooterHtml() throws IOException { - String absoluteDiskPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath(FOOTER_TEMPLATE); - String content = readFile(absoluteDiskPath, Charset.defaultCharset()); - Document document = Jsoup.parse(content); - Elements footerFragment = document.select("body"); - StringBuilder footerHtml = new StringBuilder(); - footerHtml.append(footerFragment.html()); - logger.debug("element: {}", footerFragment.html()); - return footerHtml.toString(); - } - - private static String readFile(String path, Charset encoding) throws IOException { - byte[] encoded = Files.readAllBytes(Paths.get(path)); - return new String(encoded, encoding); - } -} diff --git a/ui/src/main/webapp/WEB-INF/footer.xhtml b/ui/src/main/webapp/WEB-INF/footer.xhtml index af07541c..4dd5b46c 100644 --- a/ui/src/main/webapp/WEB-INF/footer.xhtml +++ b/ui/src/main/webapp/WEB-INF/footer.xhtml @@ -1,6 +1,5 @@ - - +xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns="http://www.w3.org/1999/xhtml" +xmlns:h="http://xmlns.jcp.org/jsf/html"> + \ No newline at end of file diff --git a/ui/src/main/webapp/WEB-INF/topbar.xhtml b/ui/src/main/webapp/WEB-INF/topbar.xhtml index 4caf13ad..d1da4bc0 100644 --- a/ui/src/main/webapp/WEB-INF/topbar.xhtml +++ b/ui/src/main/webapp/WEB-INF/topbar.xhtml @@ -1,32 +1,33 @@ - - -