KEYCLOAK-5574 Added edit this page on GitHub link

This commit is contained in:
stianst 2018-02-13 13:31:04 +01:00 committed by Stian Thorgersen
parent f4fd499238
commit 09eb0e2749
30 changed files with 353 additions and 7 deletions

View file

@ -119,4 +119,38 @@ span.image img {
box-shadow: 3px 3px 15px 0px rgba(0,0,0,0.5);
}
.sect1+.sect1 {
border-top: none;
}
.page-links {
border-bottom: 1px solid #efefed;
border-top: none;
background: none;
position: relative;
left: 0em;
width: 100%;
top: -5em;
height: 0;
margin: 0;
padding: 0;
}
.sect2 .page-links {
top: -3.5em;
}
.page-links .content {
background: #f8f8f7;
border: 1px solid #e0e0dc;
float: right;
font-size: 0.8em;
margin: 0;
padding: 5px;
}
.page-links a {
display: block;
padding: 5px;
}
</style>

View file

@ -1,7 +1,8 @@
include::topics/templates/document-attributes-community.adoc[]
:api_documentation:
:linkattrs:
= {apidocs_name}
include::topics/overview.adoc[]
include::topics.adoc[]

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-product.adoc[]

View file

@ -15,6 +15,15 @@
<build>
<plugins>
<plugin>
<groupId>org.keycloak.documentation</groupId>
<artifactId>header-maven-plugin</artifactId>
<executions>
<execution>
<id>add-file-headers</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>

View file

@ -0,0 +1 @@
include::topics/overview.adoc[]

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-community.adoc[]

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-product.adoc[]

View file

@ -15,6 +15,15 @@
<build>
<plugins>
<plugin>
<groupId>org.keycloak.documentation</groupId>
<artifactId>header-maven-plugin</artifactId>
<executions>
<execution>
<id>add-file-headers</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-community.adoc[]
include::topics.adoc[]

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-product.adoc[]

View file

@ -15,6 +15,15 @@
<build>
<plugins>
<plugin>
<groupId>org.keycloak.documentation</groupId>
<artifactId>header-maven-plugin</artifactId>
<executions>
<execution>
<id>add-file-headers</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>

View file

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>documentation-parent</artifactId>
<groupId>org.keycloak.documentation</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>org.keycloak.documentation</groupId>
<artifactId>header-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>github-maven-plugin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.24</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.4</version>
<configuration>
<goalPrefix>header-maven-plugin</goalPrefix>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
<execution>
<id>header-goal</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,130 @@
package sample.plugin;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
/**
* Goal which touches a timestamp file.
*/
@Mojo(name = "header", defaultPhase = LifecyclePhase.PROCESS_SOURCES)
public class HeaderMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true)
private MavenProject mavenProject;
@Parameter(defaultValue = "index", property = "masterFile", required = true)
private String masterFileName;
@Parameter(defaultValue = "${project.build.directory}/sources", property = "outputDir", required = true)
private File outputDir;
private File baseDir;
private File topicsFile;
private File topicsDir;
public void execute() throws MojoExecutionException {
try {
baseDir = mavenProject.getBasedir();
copy(new File(baseDir, masterFileName + ".adoc"));
copy(new File(baseDir, "topics.adoc"));
File docInfo = new File(baseDir, "docinfo.html");
if (docInfo.isFile()) {
copy(docInfo);
copy(new File(baseDir, "docinfo-footer.html"));
}
topicsDir = new File(baseDir, "topics");
processTopics(topicsDir);
} catch (IOException e) {
e.printStackTrace();
throw new MojoExecutionException(e.getMessage(), e);
}
}
private void copy(File file) throws IOException {
File out = new File(outputDir, file.getName());
out.mkdirs();
Files.copy(file.toPath(), out.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
private void processTopics(File f) throws IOException {
File out = new File(outputDir, f.getAbsolutePath().replaceFirst(topicsDir.getParentFile().getAbsolutePath(), ""));
if (f.isFile() && f.getAbsolutePath().contains("/templates/")) {
out.getParentFile().mkdirs();
Files.copy(f.toPath(), out.toPath(), StandardCopyOption.REPLACE_EXISTING);
} else if (f.isDirectory()) {
for (File c : f.listFiles()) {
processTopics(c);
}
} else if (f.getName().endsWith(".adoc")) {
out.getParentFile().mkdirs();
String filePath = f.getAbsolutePath().replace(baseDir.getParent(), "").substring(1);
String includeHeaderPath = filePath.substring(baseDir.getName().length() + 7);
includeHeaderPath = includeHeaderPath.substring(0, includeHeaderPath.lastIndexOf('/'));
includeHeaderPath = includeHeaderPath.replaceAll("/[^/]+", "../");
includeHeaderPath = includeHeaderPath + "templates/header.adoc";
String header = "\n\n:include_filename: " + filePath + "\ninclude::" + includeHeaderPath + "[]\n\n";
PrintStream ps = new PrintStream(new FileOutputStream(out));
BufferedReader br = new BufferedReader(new FileReader(f));
for (String l = br.readLine(); l != null; l = br.readLine()) {
ps.println(l);
if (l.contains("=")) {
break;
}
}
ps.print(header);
for (String l = br.readLine(); l != null; l = br.readLine()) {
ps.println(l);
}
br.close();
ps.close();
}
}
}

21
pom.xml
View file

@ -28,6 +28,7 @@
</properties>
<modules>
<module>header-maven-plugin</module>
<module>api_documentation</module>
<module>authorization_services</module>
<module>getting_started</module>
@ -77,7 +78,6 @@
<artifactId>maven-install-plugin</artifactId>
<version>${version.install.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
@ -102,6 +102,23 @@
<artifactId>maven-dependency-plugin</artifactId>
<version>${version.plugin.dependency}</version>
</plugin>
<plugin>
<groupId>org.keycloak.documentation</groupId>
<artifactId>header-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<executions>
<execution>
<id>add-file-headers</id>
<goals>
<goal>header</goal>
</goals>
<configuration>
<masterFile>${masterFile}</masterFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
@ -114,7 +131,7 @@
<goal>process-asciidoc</goal>
</goals>
<configuration>
<sourceDirectory>${basedir}</sourceDirectory>
<sourceDirectory>${basedir}/target/sources</sourceDirectory>
<sourceDocumentName>${masterFile}.adoc</sourceDocumentName>
<backend>html5</backend>
<sourceHighlighter>coderay</sourceHighlighter>

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-community.adoc[]
include::topics.adoc[]

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-product.adoc[]

View file

@ -15,6 +15,15 @@
<build>
<plugins>
<plugin>
<groupId>org.keycloak.documentation</groupId>
<artifactId>header-maven-plugin</artifactId>
<executions>
<execution>
<id>add-file-headers</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-community.adoc[]
include::topics.adoc[]

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-product.adoc[]

View file

@ -15,6 +15,15 @@
<build>
<plugins>
<plugin>
<groupId>org.keycloak.documentation</groupId>
<artifactId>header-maven-plugin</artifactId>
<executions>
<execution>
<id>add-file-headers</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-community.adoc[]
include::topics.adoc[]

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-product.adoc[]

View file

@ -11,10 +11,19 @@
<name>Server Developer</name>
<artifactId>server-development</artifactId>
<packaging>pom</packaging>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.keycloak.documentation</groupId>
<artifactId>header-maven-plugin</artifactId>
<executions>
<execution>
<id>add-file-headers</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-community.adoc[]
include::topics.adoc[]

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-product.adoc[]

View file

@ -15,6 +15,15 @@
<build>
<plugins>
<plugin>
<groupId>org.keycloak.documentation</groupId>
<artifactId>header-maven-plugin</artifactId>
<executions>
<execution>
<id>add-file-headers</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>

View file

@ -0,0 +1,3 @@
[sidebar,role="page-links"]
link:https://github.com/keycloak/keycloak-documentation/blob/master/{include_filename}[Edit this section, window="_blank"]
link:https://issues.jboss.org/secure/CreateIssueDetails!init.jspa?pid=12313920&components=12323375&issuetype=1&priority=3&description=File:%20{include_filename}[Report an issue, window="_blank"]

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 3
:numbered:
:linkattrs:
include::topics/templates/document-attributes-community.adoc[]
include::topics.adoc[]

View file

@ -1,6 +1,7 @@
:toc:
:toclevels: 2
:numbered:
:linkattrs:
include::topics/templates/document-attributes-product.adoc[]

View file

@ -15,6 +15,15 @@
<build>
<plugins>
<plugin>
<groupId>org.keycloak.documentation</groupId>
<artifactId>header-maven-plugin</artifactId>
<executions>
<execution>
<id>add-file-headers</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>