Skip to content

Commit

Permalink
Adding a Keycloak High Availability section to Keycloak's docs (#433)
Browse files Browse the repository at this point in the history
* Adding a Keycloak High Availability section to Keycloak's docs

Related to keycloak/keycloak#24844

Signed-off-by: Alexander Schwartz <[email protected]>

* Make visibility of a guide's tile optional

Signed-off-by: Alexander Schwartz <[email protected]>

---------

Signed-off-by: Alexander Schwartz <[email protected]>
  • Loading branch information
ahus1 authored Nov 23, 2023
1 parent 5850956 commit 8046aa2
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 24 deletions.
38 changes: 20 additions & 18 deletions pages/guides.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,30 @@
<div class="row guide-category" id="${c.id}">
<h2>${c.label}</h2>
<#list guides.getGuides(c) as g>
<div class="col-sm-4">
<div class="card shadow-sm mb-4">
<div class="card-body">
<h5 class="card-title">
${g.title}
<#if g.community><span class="float-end badge bg-primary fs-xsmall"><i class="fa fa-users"></i> community</span></#if>
<#if g.external><span class="float-end badge bg-primary fs-xsmall"><i class="fa fa-link"></i> external</span></#if>
</h5>
<#if g.summary??>
<span class="card-text">${g.summary}</span>
</#if>
<div>
<#if g.tags??>
<#list g.tags as tag>
<span class="badge bg-light text-muted fs-xsmall mt-3">${tag}</span>
</#list>
<#if g.tileVisible>
<div class="col-sm-4">
<div class="card shadow-sm mb-4">
<div class="card-body">
<h5 class="card-title">
${g.title}
<#if g.community><span class="float-end badge bg-primary fs-xsmall"><i class="fa fa-users"></i> community</span></#if>
<#if g.external><span class="float-end badge bg-primary fs-xsmall"><i class="fa fa-link"></i> external</span></#if>
</h5>
<#if g.summary??>
<span class="card-text">${g.summary}</span>
</#if>
<div>
<#if g.tags??>
<#list g.tags as tag>
<span class="badge bg-light text-muted fs-xsmall mt-3">${tag}</span>
</#list>
</#if>
</div>
<a href="${links.get(g)}" <#if g.external>target="_blank"</#if> class="stretched-link link-dark"></a>
</div>
<a href="${links.get(g)}" <#if g.external>target="_blank"</#if> class="stretched-link link-dark"></a>
</div>
</div>
</div>
</#if>
</#list>
</div>
</#list>
Expand Down
73 changes: 73 additions & 0 deletions resources/css/keycloak.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/org/keycloak/webbuilder/Guides.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -75,8 +76,12 @@ private void loadGuides(AsciiDoctor asciiDoctor, File d, GuideCategory category)
Map<String, Object> 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());
Expand Down Expand Up @@ -147,8 +152,9 @@ public class Guide {
private List<String> 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;
Expand All @@ -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() {
Expand Down Expand Up @@ -215,6 +222,10 @@ public String getExternalLink() {
public boolean isExternal() {
return externalLink != null;
}

public boolean isTileVisible() {
return tileVisible;
}
}

public enum GuideCategory {
Expand All @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/keycloak/webbuilder/Links.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ private void setCommonAttributes(Map<String, Object> attributes) {
attributes.put("fragment", "yes");
attributes.put("notitle", "yes");
attributes.put("icons", "font");
attributes.put("section", "guide");
attributes.put("sections", "guides");

setGuideLinkAttributes(attributes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -24,7 +28,11 @@ protected void build() throws Exception {
Optional<File> 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);
}
}
}

Expand Down

0 comments on commit 8046aa2

Please sign in to comment.