diff --git a/docs/modules/ROOT/pages/asciidoctorj-revealjs-plugin.adoc b/docs/modules/ROOT/pages/asciidoctorj-revealjs-plugin.adoc index c1554d1d4..b82c773e3 100644 --- a/docs/modules/ROOT/pages/asciidoctorj-revealjs-plugin.adoc +++ b/docs/modules/ROOT/pages/asciidoctorj-revealjs-plugin.adoc @@ -41,12 +41,12 @@ The version of the Reveal.js GEM and the Reveal.js template is configured via th [source,groovy] ---- revealjs { - version = '1.1.3' // <1> + version = '5.1.0' // <1> templateGitHub { // <2> organisation = 'hakimel' repository = 'reveal.js' - tag = '3.7.0' + tag = '5.1.0' } } ---- @@ -122,3 +122,66 @@ verticalCenter:: Vertical centering of slides. Type is boolean. viewDistance:: Number of slides away from the current that are visible. Type is integer. + +[[RevealJsPlugins]] +== Reveal.js Plugins + +To add additional Reveal.js plugins declare the source in the `revealjsPlugins` block: + +[source,groovy,role="primary"] +.build.gradle +---- +revealjsPlugins { + github("rajgoel") { + setOrganisation("rajgoel") + setRepository("reveal.js-plugins") + setBranch("master") + } + + github("denehyg") { + setOrganisation("denehyg") + setRepository("reveal.js-menu") + setBranch("master") + } +} +---- + +[source,kotlin,role="secondary"] +.build.gradle.kts +---- +revealjsPlugins { + github("rajgoel") { + setOrganisation("rajgoel") + setRepository("reveal.js-plugins") + setBranch("master") + } + + github("denehyg") { + setOrganisation("denehyg") + setRepository("reveal.js-menu") + setBranch("master") + } +} +---- + +The Reveal.js plugins referenced in the `asciidoctorRevealJs` will be downloaded and copied to the Reveal.js plugins folder: + +[source,groovy,role="primary"] +---- +asciidoctorRevealJs { + plugins 'rajgoel/chalkboard', 'denehyg/menu' +} +---- + +[source,kotlin,role="secondary"] +---- +asciidoctorRevealJs { + plugins("rajgoel/chalkboard", "denehyg/menu") +} +---- + +The Reveal.js plugins are be registered and configured by <> files. + +See https://docs.asciidoctor.org/reveal.js-converter/latest/converter/revealjs-plugins/[reveal.js Plugins] in https://docs.asciidoctor.org/reveal.js-converter/latest/[Asciidoctor reveal.js Documentation] for an example. + +NOTE: You have to adopt the plugin links in the docinfo file from `revealjs-plugins/` to `reveal.js/plugin/`. diff --git a/docs/modules/ROOT/pages/docinfo.adoc b/docs/modules/ROOT/pages/docinfo.adoc index 292150fb5..19c3ece5b 100644 --- a/docs/modules/ROOT/pages/docinfo.adoc +++ b/docs/modules/ROOT/pages/docinfo.adoc @@ -1,3 +1,4 @@ +[[docinfo]] = Extra content for HTML & Docbook backends You may need to include extra content into the head of the exported document. diff --git a/jvm-slides/src/gradleTest/basic-slides/build.gradle b/jvm-slides/src/gradleTest/basic-slides/build.gradle index 6722d7f0b..a6d2fdf46 100644 --- a/jvm-slides/src/gradleTest/basic-slides/build.gradle +++ b/jvm-slides/src/gradleTest/basic-slides/build.gradle @@ -33,9 +33,8 @@ asciidoctorRevealJs { } plugins 'rajgoel/chart/Chart.js' -// pluginConfigurationFile 'src/docs/asciidoc/empty-plugin-configuration.js' - toggleBuiltinPlugin 'pdf', true + toggleBuiltinPlugin 'search', true toggleBuiltinPlugin 'notes', false } // end::revealjs-basics[] diff --git a/jvm-slides/src/intTest/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorRevealJSTaskCachingFunctionalSpec.groovy b/jvm-slides/src/intTest/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorRevealJSTaskCachingFunctionalSpec.groovy index a34f89243..d86378502 100644 --- a/jvm-slides/src/intTest/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorRevealJSTaskCachingFunctionalSpec.groovy +++ b/jvm-slides/src/intTest/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorRevealJSTaskCachingFunctionalSpec.groovy @@ -138,9 +138,8 @@ class AsciidoctorRevealJSTaskCachingFunctionalSpec extends FunctionalSpecificati asciidoctorRevealJs { plugins 'rajgoel/chart/Chart.js' - pluginConfigurationFile 'src/docs/asciidoc/empty-plugin-configuration.js' - toggleBuiltinPlugin 'pdf', true - toggleBuiltinPlugin 'notes', false + toggleBuiltinPlugin 'search', false + toggleBuiltinPlugin 'notes', true } ''') diff --git a/jvm-slides/src/intTest/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorRevealJSTaskFunctionalSpec.groovy b/jvm-slides/src/intTest/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorRevealJSTaskFunctionalSpec.groovy index 10884e81f..3cd6b27c8 100644 --- a/jvm-slides/src/intTest/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorRevealJSTaskFunctionalSpec.groovy +++ b/jvm-slides/src/intTest/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorRevealJSTaskFunctionalSpec.groovy @@ -41,7 +41,7 @@ class AsciidoctorRevealJSTaskFunctionalSpec extends FunctionalSpecification { new File(projectDir, 'build/docs/asciidocRevealJs/revealjs.html').exists() new File(projectDir, 'build/docs/asciidocRevealJs/subdir/revealjs2.html').exists() new File(projectDir, "${DEFAULT_REVEALJS_PATH}/css").exists() - new File(projectDir, "${DEFAULT_REVEALJS_PATH}/lib").exists() + new File(projectDir, "${DEFAULT_REVEALJS_PATH}/dist").exists() new File(projectDir, "${DEFAULT_REVEALJS_PATH}/plugin").exists() new File(projectDir, "${DEFAULT_REVEALJS_PATH}/js").exists() } @@ -54,7 +54,7 @@ class AsciidoctorRevealJSTaskFunctionalSpec extends FunctionalSpecification { templateGitHub { organisation = 'hakimel' repository = 'reveal.js' - tag = '3.6.0' + tag = '5.1.0' } } ''') @@ -65,9 +65,10 @@ class AsciidoctorRevealJSTaskFunctionalSpec extends FunctionalSpecification { then: verifyAll { new File(projectDir, 'build/docs/asciidocRevealJs/revealjs.html').exists() - new File(projectDir, 'build/github-cache/hakimel/reveal.js/3.6.0').exists() + new File(projectDir, 'build/github-cache/hakimel/reveal.js/5.1.0').exists() + new File(projectDir, "${DEFAULT_REVEALJS_PATH}/dist").exists() new File(projectDir, "${DEFAULT_REVEALJS_PATH}/js/reveal.js"). - text.contains('var VERSION = \'3.6.0\';') + text.contains('export const VERSION = \'5.1.0\';') } } @@ -85,8 +86,7 @@ class AsciidoctorRevealJSTaskFunctionalSpec extends FunctionalSpecification { asciidoctorRevealJs { plugins 'rajgoel/chart/plugin.js' - pluginConfigurationFile 'src/docs/asciidoc/empty-plugin-configuration.js' - toggleBuiltinPlugin 'pdf', true + toggleBuiltinPlugin 'search', true toggleBuiltinPlugin 'notes', false } ''') @@ -94,16 +94,16 @@ class AsciidoctorRevealJSTaskFunctionalSpec extends FunctionalSpecification { when: build() String revealjsHtml = new File(projectDir, 'build/docs/asciidocRevealJs/revealjs.html').text - String pluginConfig = new File(projectDir, 'src/docs/asciidoc/empty-plugin-configuration.js').text File pluginList = new File(projectDir, "${DEFAULT_REVEALJS_PATH}/revealjs-plugins.js") then: verifyAll { !pluginList.exists() - !revealjsHtml.contains('plugin/notes/notes') - revealjsHtml.contains("src: '${REVEALJS_DIR_NAME}/plugin/print-pdf/") - revealjsHtml.contains("src: '${REVEALJS_DIR_NAME}/plugin/rajgoel/chart/plugin.js'") - revealjsHtml.contains(pluginConfig) + !revealjsHtml.contains('plugin/notes') + revealjsHtml.contains("src: '${REVEALJS_DIR_NAME}/plugin/search/search.js'") + // plugins must be registered using presentation-docinfo-footer, + // see https://docs.asciidoctor.org/reveal.js-converter/5.0/converter/revealjs-plugins/#additional-plugins + // revealjsHtml.contains("src: '${REVEALJS_DIR_NAME}/plugin/rajgoel/chart/plugin.js'") new File(projectDir, "${DEFAULT_REVEALJS_PATH}/plugin/rajgoel/chart/plugin.js").exists() } } diff --git a/jvm-slides/src/main/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorJRevealJSTask.groovy b/jvm-slides/src/main/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorJRevealJSTask.groovy index d727a8b7d..858dda057 100644 --- a/jvm-slides/src/main/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorJRevealJSTask.groovy +++ b/jvm-slides/src/main/groovy/org/asciidoctor/gradle/jvm/slides/AsciidoctorJRevealJSTask.groovy @@ -44,14 +44,12 @@ import static org.gradle.api.tasks.PathSensitivity.RELATIVE @CompileStatic class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask implements SlidesToExportAware { - public static final String PLUGIN_LIST_FILENAME = 'revealjs-plugins.js' public final static String REVEALJS_GEM = 'asciidoctor-revealjs' private static final String BACKEND_NAME = 'revealjs' private Object templateRelativeDir = 'reveal.js' private String theme = 'white' - private Object pluginConfigurationFile private final Map builtinPlugins = [:] private final List requiredPlugins = [] @@ -77,9 +75,6 @@ class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask implements Slides inputs.file( { RevealJSOptions opt -> opt.highlightJsThemeIfFile }.curry(this.revealjsOptions) ).optional() inputs.file( { RevealJSOptions opt -> opt.parallaxBackgroundImageIfFile }. curry(this.revealjsOptions) ).optional() - - // support cleanupPluginTempFiles() in exec() - awaitMode = true } /** Options for Reveal.JS slides. @@ -219,25 +214,6 @@ class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask implements Slides this.builtinPlugins.put(name, pluginState) } - /** Returns the location of the file for configuring external plugins. - * - * @return Location of file. Can be {@code null} - */ - @Optional - @InputFile - @PathSensitive(RELATIVE) - File getPluginConfigurationFile() { - this.pluginConfigurationFile ? project.file(this.pluginConfigurationFile) : null - } - - /** Sets the location of the project configuration file. - * - * @param f Location of the configuration file - */ - void setPluginConfigurationFile(Object f) { - this.pluginConfigurationFile = f - } - @Internal @Override Profile getProfile() { @@ -249,7 +225,6 @@ class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask implements Slides checkRevealJsVersion() processTemplateResources() super.exec() - cleanupPluginTempFiles() } /** A task may add some default attributes. @@ -281,13 +256,7 @@ class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask implements Slides ) } - if (!requiredPlugins.empty) { - attrs.put 'revealjs_plugins', pluginListFile.absolutePath - - if (getPluginConfigurationFile() != null) { - attrs.put 'revealjs_plugins_configuration', getPluginConfigurationFile().absolutePath - } - } + // 'revealjs_plugins not supported by asciidoctor-revealjs >= 5.0 } attrs @@ -334,15 +303,6 @@ class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask implements Slides } } }) - - if (!fromPlugins.empty) { - final String relativePathForPlugins = "${templateRelativeDir}/plugin" - generatePluginList(pluginListFile, relativePathForPlugins) - } - } - - private void cleanupPluginTempFiles() { - pluginListFile.delete() } @Internal @@ -351,22 +311,10 @@ class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask implements Slides } @Internal - protected RevealJSPluginExtension getRevealsjsPluginExtension() { + protected RevealJSPluginExtension getRevealjsPluginExtension() { project.extensions.getByType(RevealJSPluginExtension) } - private void generatePluginList(File targetFile, String relativePathForPlugins) { - targetFile.parentFile.mkdirs() - - String pluginList = Transform.toList(plugins) { String fullName -> - "{ src: '${relativePathForPlugins}/${fullName}' }" - }.join(',\n') - - targetFile.withWriter { Writer w -> - w.println pluginList - } - } - private void checkRevealJsVersion() { if (!pluginSupportAvailable) { project.logger.warn("You are using Reveal.Js converter version ${revealjsExtension.version}, " + @@ -378,10 +326,6 @@ class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask implements Slides Version.of(revealjsExtension.version) >= FIRST_VERSION_WITH_PLUGIN_SUPPORT } - private File getPluginListFile() { - new File(templateDir, PLUGIN_LIST_FILENAME) - } - private Set getPluginBundles() { Transform.toSet(plugins) { it.split('/', 2)[0] @@ -390,7 +334,7 @@ class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask implements Slides private Set getResolvedPlugins() { if (pluginSupportAvailable) { - final RevealJSPluginExtension pluginExtension = revealsjsPluginExtension + final RevealJSPluginExtension pluginExtension = revealjsPluginExtension Transform.toSet(pluginBundles) { pluginExtension.getByName(it) } diff --git a/jvm-slides/src/main/groovy/org/asciidoctor/gradle/jvm/slides/RevealJSPluginExtension.groovy b/jvm-slides/src/main/groovy/org/asciidoctor/gradle/jvm/slides/RevealJSPluginExtension.groovy index ce0a2e7f2..8820ff57b 100644 --- a/jvm-slides/src/main/groovy/org/asciidoctor/gradle/jvm/slides/RevealJSPluginExtension.groovy +++ b/jvm-slides/src/main/groovy/org/asciidoctor/gradle/jvm/slides/RevealJSPluginExtension.groovy @@ -29,17 +29,6 @@ class RevealJSPluginExtension extends AbstractDownloadableComponent