Signed-off-by: Minecon724 <git@m724.eu>
This commit is contained in:
parent
42a73ece51
commit
159519c94d
3 changed files with 12 additions and 10 deletions
|
@ -1,3 +1,5 @@
|
|||
# Render options here
|
||||
|
||||
compress: true
|
||||
compress:
|
||||
- gz
|
||||
- zstd
|
|
@ -7,7 +7,6 @@ import eu.m724.blog.data.RenderOptions;
|
|||
import eu.m724.blog.data.Site;
|
||||
import eu.m724.blog.template.TemplateRenderer;
|
||||
import org.apache.commons.compress.compressors.CompressorException;
|
||||
import org.apache.commons.compress.compressors.CompressorStreamFactory;
|
||||
import org.apache.commons.io.file.PathUtils;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.lib.RepositoryBuilder;
|
||||
|
@ -145,7 +144,7 @@ public class BlogBuilder {
|
|||
|
||||
Files.writeString(outputDirectory.resolve("posts.rss"), Feed.generateRss(site, posts));
|
||||
|
||||
if (renderOptions.compress()) {
|
||||
if (!renderOptions.compress().isEmpty()) {
|
||||
System.out.println("Compressing...");
|
||||
compressOutput();
|
||||
}
|
||||
|
@ -191,10 +190,9 @@ public class BlogBuilder {
|
|||
}
|
||||
|
||||
private void compressOutput() throws IOException {
|
||||
var compressors = new FileCompressor[] {
|
||||
new FileCompressor(CompressorStreamFactory.GZIP),
|
||||
new FileCompressor(CompressorStreamFactory.ZSTANDARD)
|
||||
};
|
||||
var compressors = renderOptions.compress().stream()
|
||||
.map(FileCompressor::new)
|
||||
.toList();
|
||||
|
||||
Set<Path> tree;
|
||||
try (var walk = Files.walk(outputDirectory)) {
|
||||
|
|
|
@ -6,10 +6,12 @@ import org.snakeyaml.engine.v2.api.LoadSettings;
|
|||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public record RenderOptions(
|
||||
boolean compress
|
||||
List<String> compress // TODO rename?
|
||||
) {
|
||||
/**
|
||||
* Creates a {@link Site} object by reading and parsing the configuration file at the specified path.<br>
|
||||
|
@ -23,14 +25,14 @@ public record RenderOptions(
|
|||
var load = new Load(LoadSettings.builder().build());
|
||||
var yaml = (Map<String, Object>) load.loadFromInputStream(Files.newInputStream(path));
|
||||
|
||||
boolean compress = true;
|
||||
List<String> compress = new ArrayList<>();
|
||||
|
||||
for (var key : yaml.keySet()) {
|
||||
var value = yaml.get(key);
|
||||
|
||||
switch (key) {
|
||||
case "compress": {
|
||||
compress = (boolean) value;
|
||||
compress = (List<String>) value;
|
||||
}
|
||||
default: {
|
||||
System.out.println("Unrecognized option (render): " + key);
|
||||
|
|
Loading…
Add table
Reference in a new issue