Skip to content

Commit

Permalink
Adding keycloak-client guides
Browse files Browse the repository at this point in the history
Signed-off-by: rmartinc <[email protected]>
  • Loading branch information
rmartinc committed Aug 16, 2024
1 parent a51320f commit 7f746cc
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 16 deletions.
22 changes: 22 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<version.commons-compress>1.26.0</version.commons-compress>

<version.keycloak>25.0.2</version.keycloak>
<version.keycloak.client>26.0.0-SNAPSHOT</version.keycloak.client>

<version.frontend-maven-plugin>1.12.1</version.frontend-maven-plugin>
<version.node>v16.13.1</version.node>
Expand Down Expand Up @@ -169,6 +170,12 @@
</executions>
<configuration>
<mainClass>org.keycloak.webbuilder.WebBuilder</mainClass>
<systemProperties>
<systemProperty>
<key>version.keycloak.client</key>
<value>${version.keycloak.client}</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -218,6 +225,15 @@
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-client-guides</artifactId>
<version>${version.keycloak.client}</version>
<classifier>asciidoc</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
Expand Down Expand Up @@ -245,6 +261,12 @@
</executions>
<configuration>
<mainClass>org.keycloak.webbuilder.AutoBuilder</mainClass>
<systemProperties>
<systemProperty>
<key>version.keycloak.client</key>
<value>${version.keycloak.client}</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
</plugins>
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/org/keycloak/webbuilder/Guides.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public Guides(File tmpDir, File guidesDir, AsciiDoctor asciiDoctor) throws IOExc
}
});

Arrays.stream(tmpDir.getParentFile().listFiles((f, s) -> s.startsWith("keycloak-client-guides"))).findFirst().ifPresent(f -> {
try {
loadGuides(asciiDoctor, new File(f, "generated-guides/keycloak-client"), GuideCategory.KEYCLOAK_CLIENT);
} catch (IOException e) {
e.printStackTrace();
}
});

Collections.sort(guides, (o1, o2) -> {
if (o1.getPriority() == o2.getPriority()) {
return o1.getTitle().compareTo(o2.getTitle());
Expand Down Expand Up @@ -236,7 +244,8 @@ public enum GuideCategory {
SERVER("server", "Server"),
OPERATOR("operator", "Operator"),
SECURING_APPS("securing-apps", "Securing applications"),
HIGH_AVAILABILITY("high-availability", "High availability");
HIGH_AVAILABILITY("high-availability", "High availability"),
KEYCLOAK_CLIENT("keycloak-client", "Keycloak client");

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 @@ -70,6 +70,8 @@ public String getGuideEdit(Guides.Guide guide) {
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";
case KEYCLOAK_CLIENT:
return "https://github.com/keycloak/keycloak/tree/main/docs/guides/keycloak-client/" + guide.getName() + ".adoc";
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

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;
import java.util.List;
import java.util.stream.Collectors;

public class ResourcesBuilder extends AbstractBuilder {

Expand All @@ -23,17 +21,19 @@ protected void build() throws Exception {

FileUtils.copyDirectory(new File(context.getBlogDir(), "images"), new File(new File(targetResourcesDir, "images"), "blog"));
FileUtils.copyDirectory(new File(context.getGuidesDir(), "images"), guidesImageDir);
Optional<File> genGuidesDir = Arrays.stream(context.getTmpDir().getParentFile().listFiles((f, s) -> s.startsWith("keycloak-guides"))).findFirst();

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()) {
if (f.isFile()) {
FileUtils.copyFileToDirectory(f, guidesImageDir);
} else {
FileUtils.copyDirectoryToDirectory(f, guidesImageDir);
}
}
List<File> genGuidesImagesDirs = Arrays.stream(context.getTmpDir().getParentFile()
.listFiles((f, s) -> s.startsWith("keycloak-guides") || s.startsWith("keycloak-client-guides")))
.flatMap(d -> Arrays.stream(new File(d, "generated-guides").listFiles(n -> n.getName().equals("images"))))
.collect(Collectors.toList());

for (File genGuidesImagesDir : genGuidesImagesDirs) {
for (File f : genGuidesImagesDir.listFiles()) {
if (f.isFile()) {
FileUtils.copyFileToDirectory(f, guidesImageDir);
} else {
FileUtils.copyDirectoryToDirectory(f, guidesImageDir);
}
}
}

printStep("copied", "blog images");
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/keycloak/webbuilder/utils/AsciiDoctor.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ private Map<String, Object> parseAttributes(String content, Map<String, Object>
public void init(Context context) {
globalAttributes = new HashMap<>();
globalAttributes.put("version", context.versions().getLatest().getVersion());

globalAttributes.put("version-client", System.getProperty("version.keycloak.client", context.versions().getLatest().getVersion()));
globalAttributes.put("majorMinorVersion", context.versions().getLatest().getVersionShorter());

// The attribute 'project_community' was missing in 24.0.2. Will be added in 25.x in the attributes.adoc,
Expand Down

0 comments on commit 7f746cc

Please sign in to comment.