From 8046aa211b522f366e9aa396df2180aa97aa0177 Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Thu, 23 Nov 2023 16:17:45 +0100 Subject: [PATCH] Adding a Keycloak High Availability section to Keycloak's docs (#433) * Adding a Keycloak High Availability section to Keycloak's docs Related to keycloak/keycloak#24844 Signed-off-by: Alexander Schwartz * Make visibility of a guide's tile optional Signed-off-by: Alexander Schwartz --------- Signed-off-by: Alexander Schwartz --- pages/guides.ftl | 38 +++++----- resources/css/keycloak.css | 73 +++++++++++++++++++ .../java/org/keycloak/webbuilder/Guides.java | 18 ++++- .../java/org/keycloak/webbuilder/Links.java | 2 + .../webbuilder/builders/GuideBuilder.java | 2 - .../webbuilder/builders/ResourcesBuilder.java | 10 ++- 6 files changed, 119 insertions(+), 24 deletions(-) diff --git a/pages/guides.ftl b/pages/guides.ftl index 044c09ee..3058e8b8 100644 --- a/pages/guides.ftl +++ b/pages/guides.ftl @@ -27,28 +27,30 @@

${c.label}

<#list guides.getGuides(c) as g> -
-
-
-
- ${g.title} - <#if g.community> community - <#if g.external> external -
- <#if g.summary??> - ${g.summary} - -
- <#if g.tags??> - <#list g.tags as tag> - ${tag} - + <#if g.tileVisible> +
+
+
+
+ ${g.title} + <#if g.community> community + <#if g.external> external +
+ <#if g.summary??> + ${g.summary} +
+ <#if g.tags??> + <#list g.tags as tag> + ${tag} + + +
+ target="_blank" class="stretched-link link-dark">
- target="_blank" class="stretched-link link-dark">
-
+
diff --git a/resources/css/keycloak.css b/resources/css/keycloak.css index e813feed..3f92142f 100644 --- a/resources/css/keycloak.css +++ b/resources/css/keycloak.css @@ -353,6 +353,79 @@ dl dd { margin-left: 1.125em; } +/* allow callout numbers for listings - taken from the AsciiDoc stylesheet */ +.conum[data-value] { + display: inline-block; + color: #fff !important; + background-color: rgba(0, 0, 0, .8); + -webkit-border-radius: 100px; + border-radius: 100px; + text-align: center; + font-size: .75em; + width: 1.67em; + height: 1.67em; + line-height: 1.67em; + font-family: "Open Sans", "DejaVu Sans", sans-serif; + font-style: normal; + font-weight: bold +} + +.conum[data-value] * { + color: #fff !important +} + +.conum[data-value] + b { + display: none +} + +.conum[data-value]::after { + content: attr(data-value) +} + +pre .conum[data-value] { + position: relative; + top: -.125em +} + +b.conum * { + color: inherit !important +} + +.conum:not([data-value]):empty { + display: none +} + +.colist > table { + border: 0; + background: none +} + +.colist > table > tbody > tr { + background: none +} + +.literalblock + .colist, .listingblock + .colist { + margin-top: -.5em +} + +.colist td:not([class]):first-child { + padding: .4em .75em 0; + line-height: 1; + vertical-align: top +} + +.colist td:not([class]):first-child img { + max-width: none +} + +.colist td:not([class]):last-child { + padding: .25em 0 +} + +.colist td { + border: 0 +} + @media (prefers-contrast: more) { .kc-bg-triangles { background-image: none; diff --git a/src/main/java/org/keycloak/webbuilder/Guides.java b/src/main/java/org/keycloak/webbuilder/Guides.java index 340bd34f..a663e91d 100644 --- a/src/main/java/org/keycloak/webbuilder/Guides.java +++ b/src/main/java/org/keycloak/webbuilder/Guides.java @@ -36,6 +36,7 @@ public Guides(File tmpDir, File guidesDir, AsciiDoctor asciiDoctor) throws IOExc loadGuides(asciiDoctor, new File(f, "generated-guides/operator"), GuideCategory.OPERATOR); loadGuides(asciiDoctor, new File(f, "generated-guides/migration"), GuideCategory.MIGRATION); loadGuides(asciiDoctor, new File(f, "generated-guides/getting-started"), GuideCategory.GETTING_STARTED); + loadGuides(asciiDoctor, new File(f, "generated-guides/high-availability"), GuideCategory.HIGH_AVAILABILITY); } catch (IOException e) { e.printStackTrace(); } @@ -75,8 +76,12 @@ private void loadGuides(AsciiDoctor asciiDoctor, File d, GuideCategory category) Map attributes = asciiDoctor.parseAttributes(f, sharedAttributes); boolean community = "true".equals(attributes.get("community")); + + Object isTileVisibileAttribute = attributes.get("guide-tile-visible"); + boolean isTileVisibile = isTileVisibileAttribute == null || "true".equals(isTileVisibileAttribute); try { - Guide g = new Guide(category, f, (String) attributes.get("guide-title"), (String) attributes.get("guide-summary"), (String) attributes.get("guide-tags"), (String) attributes.get("author"), community, (String) attributes.get("external-link")); + Guide g = new Guide(category, f, (String) attributes.get("guide-title"), (String) attributes.get("guide-summary"), (String) attributes.get("guide-tags"), (String) attributes.get("author"), community, + (String) attributes.get("external-link"), isTileVisibile); if (guidePriorities != null) { Integer priority = guidePriorities.get(g.getName()); @@ -147,8 +152,9 @@ public class Guide { private List tags; private int priority = Integer.MAX_VALUE; private String externalLink; + private boolean tileVisible; - public Guide(GuideCategory category, File source, String title, String summary, String tags, String author, boolean community, String externalLink) { + public Guide(GuideCategory category, File source, String title, String summary, String tags, String author, boolean community, String externalLink, boolean tileVisible) { this.category = category; this.name = source.getName().replace(".adoc", ""); this.author = author; @@ -162,6 +168,7 @@ public Guide(GuideCategory category, File source, String title, String summary, } this.path = category.getId() + "/" + name; this.externalLink = externalLink; + this.tileVisible = tileVisible; } public String getName() { @@ -215,6 +222,10 @@ public String getExternalLink() { public boolean isExternal() { return externalLink != null; } + + public boolean isTileVisible() { + return tileVisible; + } } public enum GuideCategory { @@ -223,7 +234,8 @@ public enum GuideCategory { GETTING_STARTED("getting-started", "Getting started"), SERVER("server", "Server"), OPERATOR("operator", "Operator"), - SECURING_APPS("securing-apps", "Securing applications"); + SECURING_APPS("securing-apps", "Securing applications"), + HIGH_AVAILABILITY("high-availability", "High availability"); private String label; diff --git a/src/main/java/org/keycloak/webbuilder/Links.java b/src/main/java/org/keycloak/webbuilder/Links.java index d4f57ad7..1037be2c 100644 --- a/src/main/java/org/keycloak/webbuilder/Links.java +++ b/src/main/java/org/keycloak/webbuilder/Links.java @@ -68,6 +68,8 @@ public String getGuideEdit(Guides.Guide guide) { return "https://github.com/keycloak/keycloak/tree/main/docs/guides/operator/" + guide.getName() + ".adoc"; case GETTING_STARTED: return "https://github.com/keycloak/keycloak/tree/main/docs/guides/getting-started/" + guide.getName() + ".adoc"; + case HIGH_AVAILABILITY: + return "https://github.com/keycloak/keycloak/tree/main/docs/guides/high-availability/" + guide.getName() + ".adoc"; default: return null; } diff --git a/src/main/java/org/keycloak/webbuilder/builders/GuideBuilder.java b/src/main/java/org/keycloak/webbuilder/builders/GuideBuilder.java index 4ad7f4fc..b417f752 100644 --- a/src/main/java/org/keycloak/webbuilder/builders/GuideBuilder.java +++ b/src/main/java/org/keycloak/webbuilder/builders/GuideBuilder.java @@ -44,8 +44,6 @@ private void setCommonAttributes(Map attributes) { attributes.put("fragment", "yes"); attributes.put("notitle", "yes"); attributes.put("icons", "font"); - attributes.put("section", "guide"); - attributes.put("sections", "guides"); setGuideLinkAttributes(attributes); } diff --git a/src/main/java/org/keycloak/webbuilder/builders/ResourcesBuilder.java b/src/main/java/org/keycloak/webbuilder/builders/ResourcesBuilder.java index db30ecf9..cea0ebcb 100644 --- a/src/main/java/org/keycloak/webbuilder/builders/ResourcesBuilder.java +++ b/src/main/java/org/keycloak/webbuilder/builders/ResourcesBuilder.java @@ -3,8 +3,12 @@ import org.apache.commons.io.FileUtils; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Arrays; import java.util.Optional; +import java.util.stream.Stream; public class ResourcesBuilder extends AbstractBuilder { @@ -24,7 +28,11 @@ protected void build() throws Exception { Optional genGuidesImagesDir = genGuidesDir.flatMap( d -> Arrays.stream(new File(d, "generated-guides").listFiles(n -> n.getName().equals("images"))).findAny()); if (genGuidesImagesDir.isPresent()) { for (File f : genGuidesImagesDir.get().listFiles()) { - FileUtils.copyFileToDirectory(f, guidesImageDir); + if (f.isFile()) { + FileUtils.copyFileToDirectory(f, guidesImageDir); + } else { + FileUtils.copyDirectoryToDirectory(f, guidesImageDir); + } } }