From 5e03334f468fe0955b47cf0cce9052d677092da9 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Mon, 2 May 2022 18:16:03 +0000 Subject: [PATCH] Implement site parser --- out/testfile | 2 -- out/testfile.html | 14 ++++++++++++++ ref/DEFAULT.html | 7 +++++++ ref/FOOTER.html | 5 +++++ sigPlace.java | 38 ++++++++++++++++++++++++-------------- sitefiles/testfile | 1 - sitefiles/testfile.html | 2 ++ 7 files changed, 52 insertions(+), 17 deletions(-) delete mode 100644 out/testfile create mode 100644 out/testfile.html create mode 100644 ref/DEFAULT.html create mode 100644 ref/FOOTER.html delete mode 100644 sitefiles/testfile create mode 100644 sitefiles/testfile.html diff --git a/out/testfile b/out/testfile deleted file mode 100644 index 5564c5f..0000000 --- a/out/testfile +++ /dev/null @@ -1,2 +0,0 @@ - -Basic Content diff --git a/out/testfile.html b/out/testfile.html new file mode 100644 index 0000000..ddb8d10 --- /dev/null +++ b/out/testfile.html @@ -0,0 +1,14 @@ + + + + + + + +SigPlace +Basic Content + + + diff --git a/ref/DEFAULT.html b/ref/DEFAULT.html new file mode 100644 index 0000000..6155e56 --- /dev/null +++ b/ref/DEFAULT.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ref/FOOTER.html b/ref/FOOTER.html new file mode 100644 index 0000000..f24e41b --- /dev/null +++ b/ref/FOOTER.html @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/sigPlace.java b/sigPlace.java index e363b2d..223d194 100644 --- a/sigPlace.java +++ b/sigPlace.java @@ -1,6 +1,5 @@ import java.io.IOException; import java.nio.charset.Charset; -import java.nio.file.FileStore; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -10,49 +9,60 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Pattern; import java.util.stream.Collectors; public class sigPlace { final static String ROOTDIR = "sitefiles"; + final static String REFDIR = "ref"; final static String OUTDIR = "out"; final static HashMap map = new HashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry<>("$SITENAME", "SigPlace") )); - final static HashMap ops = new HashMap<>(Map.ofEntries( + final static HashMap ops = new HashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry<>( - "%DEFAULT", - ""+ - ""+ - ""+ - ""+ - "") + "%DEFAULT", Paths.get(REFDIR,"DEFAULT.html")), + new AbstractMap.SimpleEntry<>( + "%FOOTER", Paths.get(REFDIR,"FOOTER.html")) )); public static void main(String[] args) { Set files = GetFilesInDir(ROOTDIR); for (Path f : files) { - System.out.println("Found "+f.getFileName()); + System.out.println(" Found "+f.getFileName()); try { - System.out.println("Preparing "+f.getFileName()); + System.out.println(" Preparing "+f.getFileName()); List content = Files.readAllLines(f); - content.add(0,ops.get("%DEFAULT")); + content.addAll(0,Files.readAllLines(ops.get("%DEFAULT"))); + content.addAll(Files.readAllLines(ops.get("%FOOTER"))); + + System.out.println(" Parsing "+f.getFileName()); + for (int i=0;i GetFilesInDir(String directory) { Path dir = Paths.get(directory); diff --git a/sitefiles/testfile b/sitefiles/testfile deleted file mode 100644 index cb86278..0000000 --- a/sitefiles/testfile +++ /dev/null @@ -1 +0,0 @@ -Basic Content diff --git a/sitefiles/testfile.html b/sitefiles/testfile.html new file mode 100644 index 0000000..258944b --- /dev/null +++ b/sitefiles/testfile.html @@ -0,0 +1,2 @@ +$SITENAME +Basic Content \ No newline at end of file