Skip to content

Commit 8046aa2

Browse files
authored
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 <[email protected]> * Make visibility of a guide's tile optional Signed-off-by: Alexander Schwartz <[email protected]> --------- Signed-off-by: Alexander Schwartz <[email protected]>
1 parent 5850956 commit 8046aa2

File tree

6 files changed

+119
-24
lines changed

6 files changed

+119
-24
lines changed

pages/guides.ftl

+20-18
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,30 @@
2727
<div class="row guide-category" id="${c.id}">
2828
<h2>${c.label}</h2>
2929
<#list guides.getGuides(c) as g>
30-
<div class="col-sm-4">
31-
<div class="card shadow-sm mb-4">
32-
<div class="card-body">
33-
<h5 class="card-title">
34-
${g.title}
35-
<#if g.community><span class="float-end badge bg-primary fs-xsmall"><i class="fa fa-users"></i> community</span></#if>
36-
<#if g.external><span class="float-end badge bg-primary fs-xsmall"><i class="fa fa-link"></i> external</span></#if>
37-
</h5>
38-
<#if g.summary??>
39-
<span class="card-text">${g.summary}</span>
40-
</#if>
41-
<div>
42-
<#if g.tags??>
43-
<#list g.tags as tag>
44-
<span class="badge bg-light text-muted fs-xsmall mt-3">${tag}</span>
45-
</#list>
30+
<#if g.tileVisible>
31+
<div class="col-sm-4">
32+
<div class="card shadow-sm mb-4">
33+
<div class="card-body">
34+
<h5 class="card-title">
35+
${g.title}
36+
<#if g.community><span class="float-end badge bg-primary fs-xsmall"><i class="fa fa-users"></i> community</span></#if>
37+
<#if g.external><span class="float-end badge bg-primary fs-xsmall"><i class="fa fa-link"></i> external</span></#if>
38+
</h5>
39+
<#if g.summary??>
40+
<span class="card-text">${g.summary}</span>
4641
</#if>
42+
<div>
43+
<#if g.tags??>
44+
<#list g.tags as tag>
45+
<span class="badge bg-light text-muted fs-xsmall mt-3">${tag}</span>
46+
</#list>
47+
</#if>
48+
</div>
49+
<a href="${links.get(g)}" <#if g.external>target="_blank"</#if> class="stretched-link link-dark"></a>
4750
</div>
48-
<a href="${links.get(g)}" <#if g.external>target="_blank"</#if> class="stretched-link link-dark"></a>
4951
</div>
5052
</div>
51-
</div>
53+
</#if>
5254
</#list>
5355
</div>
5456
</#list>

resources/css/keycloak.css

+73
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,79 @@ dl dd {
353353
margin-left: 1.125em;
354354
}
355355

356+
/* allow callout numbers for listings - taken from the AsciiDoc stylesheet */
357+
.conum[data-value] {
358+
display: inline-block;
359+
color: #fff !important;
360+
background-color: rgba(0, 0, 0, .8);
361+
-webkit-border-radius: 100px;
362+
border-radius: 100px;
363+
text-align: center;
364+
font-size: .75em;
365+
width: 1.67em;
366+
height: 1.67em;
367+
line-height: 1.67em;
368+
font-family: "Open Sans", "DejaVu Sans", sans-serif;
369+
font-style: normal;
370+
font-weight: bold
371+
}
372+
373+
.conum[data-value] * {
374+
color: #fff !important
375+
}
376+
377+
.conum[data-value] + b {
378+
display: none
379+
}
380+
381+
.conum[data-value]::after {
382+
content: attr(data-value)
383+
}
384+
385+
pre .conum[data-value] {
386+
position: relative;
387+
top: -.125em
388+
}
389+
390+
b.conum * {
391+
color: inherit !important
392+
}
393+
394+
.conum:not([data-value]):empty {
395+
display: none
396+
}
397+
398+
.colist > table {
399+
border: 0;
400+
background: none
401+
}
402+
403+
.colist > table > tbody > tr {
404+
background: none
405+
}
406+
407+
.literalblock + .colist, .listingblock + .colist {
408+
margin-top: -.5em
409+
}
410+
411+
.colist td:not([class]):first-child {
412+
padding: .4em .75em 0;
413+
line-height: 1;
414+
vertical-align: top
415+
}
416+
417+
.colist td:not([class]):first-child img {
418+
max-width: none
419+
}
420+
421+
.colist td:not([class]):last-child {
422+
padding: .25em 0
423+
}
424+
425+
.colist td {
426+
border: 0
427+
}
428+
356429
@media (prefers-contrast: more) {
357430
.kc-bg-triangles {
358431
background-image: none;

src/main/java/org/keycloak/webbuilder/Guides.java

+15-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public Guides(File tmpDir, File guidesDir, AsciiDoctor asciiDoctor) throws IOExc
3636
loadGuides(asciiDoctor, new File(f, "generated-guides/operator"), GuideCategory.OPERATOR);
3737
loadGuides(asciiDoctor, new File(f, "generated-guides/migration"), GuideCategory.MIGRATION);
3838
loadGuides(asciiDoctor, new File(f, "generated-guides/getting-started"), GuideCategory.GETTING_STARTED);
39+
loadGuides(asciiDoctor, new File(f, "generated-guides/high-availability"), GuideCategory.HIGH_AVAILABILITY);
3940
} catch (IOException e) {
4041
e.printStackTrace();
4142
}
@@ -75,8 +76,12 @@ private void loadGuides(AsciiDoctor asciiDoctor, File d, GuideCategory category)
7576
Map<String, Object> attributes = asciiDoctor.parseAttributes(f, sharedAttributes);
7677

7778
boolean community = "true".equals(attributes.get("community"));
79+
80+
Object isTileVisibileAttribute = attributes.get("guide-tile-visible");
81+
boolean isTileVisibile = isTileVisibileAttribute == null || "true".equals(isTileVisibileAttribute);
7882
try {
79-
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"));
83+
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,
84+
(String) attributes.get("external-link"), isTileVisibile);
8085

8186
if (guidePriorities != null) {
8287
Integer priority = guidePriorities.get(g.getName());
@@ -147,8 +152,9 @@ public class Guide {
147152
private List<String> tags;
148153
private int priority = Integer.MAX_VALUE;
149154
private String externalLink;
155+
private boolean tileVisible;
150156

151-
public Guide(GuideCategory category, File source, String title, String summary, String tags, String author, boolean community, String externalLink) {
157+
public Guide(GuideCategory category, File source, String title, String summary, String tags, String author, boolean community, String externalLink, boolean tileVisible) {
152158
this.category = category;
153159
this.name = source.getName().replace(".adoc", "");
154160
this.author = author;
@@ -162,6 +168,7 @@ public Guide(GuideCategory category, File source, String title, String summary,
162168
}
163169
this.path = category.getId() + "/" + name;
164170
this.externalLink = externalLink;
171+
this.tileVisible = tileVisible;
165172
}
166173

167174
public String getName() {
@@ -215,6 +222,10 @@ public String getExternalLink() {
215222
public boolean isExternal() {
216223
return externalLink != null;
217224
}
225+
226+
public boolean isTileVisible() {
227+
return tileVisible;
228+
}
218229
}
219230

220231
public enum GuideCategory {
@@ -223,7 +234,8 @@ public enum GuideCategory {
223234
GETTING_STARTED("getting-started", "Getting started"),
224235
SERVER("server", "Server"),
225236
OPERATOR("operator", "Operator"),
226-
SECURING_APPS("securing-apps", "Securing applications");
237+
SECURING_APPS("securing-apps", "Securing applications"),
238+
HIGH_AVAILABILITY("high-availability", "High availability");
227239

228240
private String label;
229241

src/main/java/org/keycloak/webbuilder/Links.java

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public String getGuideEdit(Guides.Guide guide) {
6868
return "https://github.com/keycloak/keycloak/tree/main/docs/guides/operator/" + guide.getName() + ".adoc";
6969
case GETTING_STARTED:
7070
return "https://github.com/keycloak/keycloak/tree/main/docs/guides/getting-started/" + guide.getName() + ".adoc";
71+
case HIGH_AVAILABILITY:
72+
return "https://github.com/keycloak/keycloak/tree/main/docs/guides/high-availability/" + guide.getName() + ".adoc";
7173
default:
7274
return null;
7375
}

src/main/java/org/keycloak/webbuilder/builders/GuideBuilder.java

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ private void setCommonAttributes(Map<String, Object> attributes) {
4444
attributes.put("fragment", "yes");
4545
attributes.put("notitle", "yes");
4646
attributes.put("icons", "font");
47-
attributes.put("section", "guide");
48-
attributes.put("sections", "guides");
4947

5048
setGuideLinkAttributes(attributes);
5149
}

src/main/java/org/keycloak/webbuilder/builders/ResourcesBuilder.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
import org.apache.commons.io.FileUtils;
44

55
import java.io.File;
6+
import java.io.IOException;
7+
import java.nio.file.Files;
8+
import java.nio.file.Path;
69
import java.util.Arrays;
710
import java.util.Optional;
11+
import java.util.stream.Stream;
812

913
public class ResourcesBuilder extends AbstractBuilder {
1014

@@ -24,7 +28,11 @@ protected void build() throws Exception {
2428
Optional<File> genGuidesImagesDir = genGuidesDir.flatMap( d -> Arrays.stream(new File(d, "generated-guides").listFiles(n -> n.getName().equals("images"))).findAny());
2529
if (genGuidesImagesDir.isPresent()) {
2630
for (File f : genGuidesImagesDir.get().listFiles()) {
27-
FileUtils.copyFileToDirectory(f, guidesImageDir);
31+
if (f.isFile()) {
32+
FileUtils.copyFileToDirectory(f, guidesImageDir);
33+
} else {
34+
FileUtils.copyDirectoryToDirectory(f, guidesImageDir);
35+
}
2836
}
2937
}
3038

0 commit comments

Comments
 (0)