diff --git a/pom.xml b/pom.xml
index bd701c0..b0c73ac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,15 +41,23 @@
commons-io
2.16.1
-
- in.wilsonl.minifyhtml
- minify-html
- 0.15.0
-
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.4.2
+
+
+
+ true
+ eu.m724.blog.Main
+
+
+
+
org.apache.maven.plugins
maven-shade-plugin
diff --git a/src/main/java/eu/m724/blog/Main.java b/src/main/java/eu/m724/blog/Main.java
index 835eb5b..b21b91b 100644
--- a/src/main/java/eu/m724/blog/Main.java
+++ b/src/main/java/eu/m724/blog/Main.java
@@ -3,8 +3,6 @@ package eu.m724.blog;
import eu.m724.blog.data.Feed;
import eu.m724.blog.data.Post;
import eu.m724.blog.data.Site;
-import in.wilsonl.minifyhtml.Configuration;
-import in.wilsonl.minifyhtml.MinifyHtml;
import org.apache.commons.cli.*;
import org.apache.commons.io.file.PathUtils;
import org.eclipse.jgit.api.Git;
@@ -19,17 +17,11 @@ import java.util.Comparator;
import java.util.stream.Collectors;
public class Main {
- // TODO put this somewhere else
- private static final Configuration configuration = new Configuration.Builder()
- .setMinifyCss(true)
- .setMinifyJs(true)
- .build();
-
public static void main(String[] args) throws IOException {
System.out.println("Hello world!");
var options = new Options()
- .addOption("f", "force", false, "Overwrite current build. Default: no")
+ .addOption("f", "force", false, "Overwrite current build")
.addOption("dir", "working-dir", true, "Working directory. Default: current directory")
.addOption("t", "template-dir", true, "Template directory. Default: working directory/template")
.addOption("o", "output-dir", true, "Output directory. Default: working directory/generated_out")
@@ -75,7 +67,7 @@ public class Main {
}
var site = Site.fromConfig(git);
- var template = new TemplateRenderer(outputDirectory, templateDirectory);
+ var template = new TemplateRenderer(templateDirectory);
Files.createDirectory(outputDirectory);
@@ -88,7 +80,8 @@ public class Main {
try (var stream = Files.walk(postDirectory)) {
for (var path : stream.collect(Collectors.toSet())) {
- if (!Files.isRegularFile(path)) continue;
+ if (!Files.isRegularFile(path))
+ continue; // directory is created below
if (!path.toString().endsWith(".html")) {
System.out.println("Post " + path.getFileName() + ": unsupported file type");
@@ -153,22 +146,7 @@ public class Main {
Files.createDirectories(parent);
}
- var type = Files.probeContentType(src);
- String content = null;
-
- if (type.equals("text/html")) {
- content = MinifyHtml.minify(Files.readString(src), configuration);
- } else if (type.equals("text/css")) {
- content = MinifyHtml.minify(Files.readString(src), configuration);
- } else if (type.equals("text/javascript")) {
- content = MinifyHtml.minify(Files.readString(src), configuration);
- }
-
- if (content != null) {
- Files.writeString(dest, content);
- } else {
- Files.copy(src, dest);
- }
+ Files.copy(src, dest);
}
}
}
diff --git a/src/main/java/eu/m724/blog/TemplateRenderer.java b/src/main/java/eu/m724/blog/TemplateRenderer.java
index d0af295..a8eaaf5 100644
--- a/src/main/java/eu/m724/blog/TemplateRenderer.java
+++ b/src/main/java/eu/m724/blog/TemplateRenderer.java
@@ -2,8 +2,6 @@ package eu.m724.blog;
import eu.m724.blog.data.Post;
import eu.m724.blog.data.Site;
-import in.wilsonl.minifyhtml.Configuration;
-import in.wilsonl.minifyhtml.MinifyHtml;
import io.pebbletemplates.pebble.PebbleEngine;
import io.pebbletemplates.pebble.extension.AbstractExtension;
import io.pebbletemplates.pebble.extension.Function;
@@ -19,15 +17,9 @@ import java.util.List;
import java.util.Map;
public class TemplateRenderer {
- private final Configuration configuration;
private final PebbleTemplate indexTemplate, articleTemplate;
- public TemplateRenderer(Path outputDirectory, Path templateDirectory) {
- this.configuration = new Configuration.Builder()
- .setMinifyCss(true)
- .setMinifyJs(true)
- .build();
-
+ public TemplateRenderer(Path templateDirectory) {
var loader = new FileLoader();
loader.setPrefix(templateDirectory.toString());
loader.setSuffix(".html");
@@ -78,7 +70,7 @@ public class TemplateRenderer {
var writer = new StringWriter();
indexTemplate.evaluate(writer, context);
- return MinifyHtml.minify(writer.toString(), configuration);
+ return writer.toString();
}
public String renderPost(Site site, Post post) throws IOException {
@@ -90,6 +82,6 @@ public class TemplateRenderer {
var writer = new StringWriter();
articleTemplate.evaluate(writer, context);
- return MinifyHtml.minify(writer.toString(), configuration);
+ return writer.toString();
}
}