io.yupiik.tools.slides.slider.BespokeSlider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of slides-core Show documentation
Show all versions of slides-core Show documentation
Extracts slides logic in a reusable module. Note that it requires an explicit configuration for now.
/*
* Copyright (c) 2020 - Yupiik SAS - https://www.yupiik.com
* 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.
*/
package io.yupiik.tools.slides.slider;
import org.asciidoctor.Options;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Stream;
import static java.util.stream.Collectors.joining;
public class BespokeSlider implements Slider {
@Override
public void postProcess(final Path path, final Path customCss, final Path target, final String[] scripts,
final Options options) {
doBespokePostProcess(path, customCss, scripts, new String[0], extractCustomCss(options));
}
protected void doBespokePostProcess(final Path path, final Path customCss, final String[] scripts,
final String[] additionalPlugins,
final String... cssFiles) {
try {
Files.write(path, String.join("\n", Files.readAllLines(path))
.replace(
"",
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
Stream.of(additionalPlugins).map(it -> "\n").collect(joining()) +
"\n" +
(scripts == null ? "" : (Stream.of(scripts)
.map(it -> "\n")
.collect(joining("\n")) + '\n')))
.replace(
"",
"\n" +
"\n" +
Stream.of(cssFiles).map(it -> "\n").collect(joining()) +
(customCss != null ? "\n" : ""))
.getBytes(StandardCharsets.UTF_8));
} catch (final IOException e) {
throw new IllegalStateException(e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy