From fb413770d401045cfc291a0c0ff6367b466466b4 Mon Sep 17 00:00:00 2001
From: Martin Lowe <martin.lowe@eclipse-foundation.org>
Date: Tue, 19 Sep 2023 14:18:05 -0400
Subject: [PATCH] Iss #77 - Add EF look and feel template into auto-loaded tags
 template

A new eclipse_base template has been added that makes use of the eclipse
header and footer files that already existed, and adds a few basic
overridable sections for flexibility. As part of Quarkus configs, the
templates/tags folder for Qute templates is auto registered as a source,
meaning that this will be available to consumers of the core package.
---
 .../core/resource/CacheResource.java               |  5 +++--
 core/src/main/resources/templates/cache_keys.html  | 14 ++++++++------
 .../main/resources/templates/eclipse_header.html   |  8 ++++----
 .../resources/templates/tags/eclipse_base.html     | 12 ++++++++++++
 4 files changed, 27 insertions(+), 12 deletions(-)
 create mode 100644 core/src/main/resources/templates/tags/eclipse_base.html

diff --git a/core/src/main/java/org/eclipsefoundation/core/resource/CacheResource.java b/core/src/main/java/org/eclipsefoundation/core/resource/CacheResource.java
index 8f887cc4..93bd1411 100644
--- a/core/src/main/java/org/eclipsefoundation/core/resource/CacheResource.java
+++ b/core/src/main/java/org/eclipsefoundation/core/resource/CacheResource.java
@@ -64,8 +64,9 @@ public class CacheResource {
         return Response
                 .ok()
                 .entity(cacheKeysView
-                        .data("cacheKeys", service.getCacheKeys().stream().map(this::buildWrappedKeys).collect(Collectors.toList()), "key",
-                                passedKey)
+                        .data("cacheKeys", service.getCacheKeys().stream().map(this::buildWrappedKeys).collect(Collectors.toList()))
+                        .data("key", passedKey)
+                        .data("title", "Application Cache Keys")
                         .render())
                 .build();
     }
diff --git a/core/src/main/resources/templates/cache_keys.html b/core/src/main/resources/templates/cache_keys.html
index 8d7efe92..cecd6513 100644
--- a/core/src/main/resources/templates/cache_keys.html
+++ b/core/src/main/resources/templates/cache_keys.html
@@ -1,4 +1,5 @@
-{#include eclipse_header /}
+{#eclipse_base}
+{#insert precontent}
 {|<style>
 .panel.list-group > div {
     background-color: white;
@@ -10,9 +11,8 @@
     color: #c74922;
     border-color: #c74922;
 }</style>|}
-
-<section class="container">
-  <h1>Cache keys</h1>
+{/}
+{#insert content} 
   <table class="table margin-top-30">
     <caption>List of active keys in the Quarkus cache for the current application</caption>
     <thead>
@@ -36,7 +36,8 @@
     {/for}
     </tbody>
   </table>
-</section>
+{/}
+{#insert postcontent}
 {|<script>
   async function postClearRequest(ctx) {
     let k = ctx.getAttribute('data-key');
@@ -62,4 +63,5 @@
   }
 
 </script>|}
-{#include eclipse_footer /}
\ No newline at end of file
+{/}
+{/}
\ No newline at end of file
diff --git a/core/src/main/resources/templates/eclipse_header.html b/core/src/main/resources/templates/eclipse_header.html
index a280d808..25498131 100644
--- a/core/src/main/resources/templates/eclipse_header.html
+++ b/core/src/main/resources/templates/eclipse_header.html
@@ -18,10 +18,10 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
 <meta name="description" content="The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 415 open source projects, including runtimes, tools and frameworks."/>
 <meta property="og:description" content="The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 415 open source projects, including runtimes, tools and frameworks."/>
 <meta property="og:image" content="//www.eclipse.org/eclipse.org-common/themes/solstice/public/images/logo/eclipse-foundation-200x200.png"/>
-<title>{#insert title}HTML Template{/} | The Eclipse Foundation</title>
-<meta property="og:title" content="{#insert title}HTML Template{/} | The Eclipse Foundation"/>
-<meta itemprop="name" content="{#insert title}HTML Template{/} | The Eclipse Foundation"/>
-<meta name="twitter:title" content="{#insert title}HTML Template{/} | The Eclipse Foundation"/>
+<title>{#insert title}{title ?: 'HTML Template'}{/} | The Eclipse Foundation</title>
+<meta property="og:title" content="{#insert title}{title ?: 'HTML Template'}{/} | The Eclipse Foundation"/>
+<meta itemprop="name" content="{#insert title}{title ?: 'HTML Template'}{/} | The Eclipse Foundation"/>
+<meta name="twitter:title" content="{#insert title}{title ?: 'HTML Template'}{/} | The Eclipse Foundation"/>
 <meta property="og:image:width" content="200"/>
 <meta property="og:image:height" content="200"/>
 <meta itemprop="description" content="The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 415 open source projects, including runtimes, tools and frameworks."/>
diff --git a/core/src/main/resources/templates/tags/eclipse_base.html b/core/src/main/resources/templates/tags/eclipse_base.html
new file mode 100644
index 00000000..e794e0c1
--- /dev/null
+++ b/core/src/main/resources/templates/tags/eclipse_base.html
@@ -0,0 +1,12 @@
+{#include eclipse_header /}
+{#insert precontent}{/}
+{#insert content_prewrap}
+<section class="container">
+  <h1>{title}</h1>
+{/}
+{#insert content}{/}
+{#insert content_postwrap}
+</section>
+{/}
+{#insert postcontent}{/}
+{#include eclipse_footer /}
\ No newline at end of file
-- 
GitLab