diff --git a/agrest-asciidoc-postprocessor/pom.xml b/agrest-asciidoc-postprocessor/pom.xml deleted file mode 100644 index 1c513d6..0000000 --- a/agrest-asciidoc-postprocessor/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - 4.0.0 - - agrest-docs - io.agrest.docs - 5.0 - - - agrest-asciidoc-postprocessor - jar - - - - org.asciidoctor - asciidoctorj - - - org.jsoup - jsoup - - - - \ No newline at end of file diff --git a/agrest-asciidoc-postprocessor/src/main/java/io/agrest/docs/AgrestPostprocessor.java b/agrest-asciidoc-postprocessor/src/main/java/io/agrest/docs/AgrestPostprocessor.java deleted file mode 100644 index 2c7508e..0000000 --- a/agrest-asciidoc-postprocessor/src/main/java/io/agrest/docs/AgrestPostprocessor.java +++ /dev/null @@ -1,92 +0,0 @@ -package io.agrest.docs; - -import org.asciidoctor.Options; -import org.asciidoctor.ast.Document; -import org.asciidoctor.extension.Postprocessor; -import org.jsoup.Jsoup; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.util.Collections; -import java.util.Map; - -public class AgrestPostprocessor extends Postprocessor { - - private static final String FRONT_MATTER = "front-matter"; - private static final String EMPTY_FRONT_MATTER = "---\n---\n\n"; - - @Override - public String process(Document document, String output) { - output = extractTableOfContents(document, output); - output = processHeader(document, output); - return output; - } - - protected String processHeader(Document document, String output) { - String headerFile = (String) document.getAttribute("agrest-header", ""); - - if(headerFile.isEmpty()) { - return output; - } - - String header; - // inject empty front matter - if(FRONT_MATTER.equals(headerFile.trim())) { - header = EMPTY_FRONT_MATTER ; - } else { - // treat as a file - header = document.readAsset(headerFile, Collections.emptyMap()); - } - - return header + output; - } - - protected String extractTableOfContents(Document document, String output) { - int start = output.indexOf("
"); - if(start == -1) { - // no toc found, exit - return output; - } - - String tocEndString = "\n
"; - int end = output.indexOf(tocEndString, start); - if(end == -1) { - // bad, no end.. - return output; - } - - end += tocEndString.length() + 1; - - org.jsoup.nodes.Document tocDoc = Jsoup.parseBodyFragment(output.substring(start, end)); - tocDoc.select("ul").addClass("nav"); - tocDoc.select("a").addClass("nav-link"); - tocDoc.select("div#toc").addClass("toc-side"); - String toc = tocDoc.body().html(); - - Object destDir = document.getOptions().get(Options.DESTINATION_DIR); - Object docname = ((Map)document.getOptions().get(Options.ATTRIBUTES)).get("docname"); - - Path path = FileSystems.getDefault().getPath((String) destDir, docname + ".toc.html"); - StandardOpenOption[] options = { - StandardOpenOption.TRUNCATE_EXISTING, - StandardOpenOption.CREATE, - StandardOpenOption.WRITE - }; - try(BufferedWriter br = Files.newBufferedWriter(path, options)) { - br.write(toc, 0, toc.length()); - br.flush(); - } catch (IOException ex) { - ex.printStackTrace(System.err); - } - - if(start == 0) { - return output.substring(end); - } - - return output.substring(0, start) + output.substring(end); - } -} diff --git a/agrest-docs-framework/src/docs/asciidoc/framework.adoc b/agrest-docs-framework/src/docs/asciidoc/framework.adoc index b7bbbf0..9aa6fad 100644 --- a/agrest-docs-framework/src/docs/asciidoc/framework.adoc +++ b/agrest-docs-framework/src/docs/asciidoc/framework.adoc @@ -1,4 +1,4 @@ -:agrest-header: _chapters/header.html +:hugo-font-awesome-icons: false = Agrest Framework diff --git a/agrest-docs-get-started-cayenne-sb/src/docs/asciidoc/getting-started.adoc b/agrest-docs-get-started-cayenne-sb/src/docs/asciidoc/getting-started.adoc index 3a5be21..ae59fe0 100644 --- a/agrest-docs-get-started-cayenne-sb/src/docs/asciidoc/getting-started.adoc +++ b/agrest-docs-get-started-cayenne-sb/src/docs/asciidoc/getting-started.adoc @@ -1,4 +1,4 @@ -:agrest-header: _chapters/header.html +:hugo-font-awesome-icons: false = Getting Started diff --git a/agrest-docs-protocol/src/docs/asciidoc/protocol.adoc b/agrest-docs-protocol/src/docs/asciidoc/protocol.adoc index e938a31..37aafb3 100644 --- a/agrest-docs-protocol/src/docs/asciidoc/protocol.adoc +++ b/agrest-docs-protocol/src/docs/asciidoc/protocol.adoc @@ -1,4 +1,4 @@ -:agrest-header: _chapters/header.html +:hugo-font-awesome-icons: false = Agrest Protocol diff --git a/pom.xml b/pom.xml index 6e4e37b..9e807de 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,6 @@ pom - agrest-asciidoc-postprocessor agrest-docs-get-started-cayenne-sb agrest-docs-protocol agrest-docs-framework @@ -20,10 +19,9 @@ UTF-8 UTF-8 - 2.5.3 - 2.2.2 - 1.6.2 - 9.2.20.1 + 2.5.12 + 2.2.6 + 2.1.4 1.14.3 5.0.M19 @@ -78,11 +76,6 @@ asciidoctor-maven-plugin ${asciidoctor.maven.plugin.version} - - org.jruby - jruby-complete - ${jruby.version} - org.asciidoctor asciidoctorj @@ -94,9 +87,9 @@ ${asciidoctorj.pdf.version} - io.agrest.docs - agrest-asciidoc-postprocessor - ${project.version} + io.bootique.tools + hugo-asciidoctorj-extension + 1.0-M2 @@ -121,11 +114,12 @@ font auto ${project.version} + 5.x + _chapters/header.html - - io.agrest.docs.AgrestPostprocessor + io.bootique.tools.asciidoctorj.HugoExtension