From 0d6d2d2de4568f811ae86b43c60934bf76f36152 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sat, 23 Jul 2022 18:59:53 -0500 Subject: [PATCH] Interpreting
 and 
on individual lines Co-authored-by: sigonasr2 --- sitefiles/articles/sigplace1.article | 42 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/sitefiles/articles/sigplace1.article b/sitefiles/articles/sigplace1.article index 76a50a1..bb908ce 100644 --- a/sitefiles/articles/sigplace1.article +++ b/sitefiles/articles/sigplace1.article @@ -49,18 +49,18 @@ public class sigPlace { static String storedCodeBlock = ""; final static HashMap map = new HashMap<>(Map.ofEntries( - new AbstractMap.SimpleEntry<>("SITENAME", "SigPlace"), - new AbstractMap.SimpleEntry<>("SITE_BACKCOL", "#111"), - new AbstractMap.SimpleEntry<>("TITLE_CONTENT_START", "

"), - new AbstractMap.SimpleEntry<>("TITLE_CONTENT_END", "

"), - new AbstractMap.SimpleEntry<>("CONTENT_END", "
"), - new AbstractMap.SimpleEntry<>("DATE_CONTENT_START", "
") + new AbstractMap.SimpleEntry<>("$SITENAME", "SigPlace"), + new AbstractMap.SimpleEntry<>("$SITE_BACKCOL", "#111"), + new AbstractMap.SimpleEntry<>("$TITLE_CONTENT_START", "

"), + new AbstractMap.SimpleEntry<>("$TITLE_CONTENT_END", "

"), + new AbstractMap.SimpleEntry<>("$CONTENT_END", "
"), + new AbstractMap.SimpleEntry<>("$DATE_CONTENT_START", "
") )); final static HashMap ops = new HashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry<>( - "", Paths.get(REFDIR,"DEFAULT.html")), + "%DEFAULT", Paths.get(REFDIR,"DEFAULT.html")), new AbstractMap.SimpleEntry<>( - "", Paths.get(REFDIR,"FOOTER.html")) + "%FOOTER", Paths.get(REFDIR,"FOOTER.html")) )); public static void main(String[] args) { @@ -123,8 +123,8 @@ public class sigPlace { List content = Files.readAllLines(f); if (isHTMLFile(f)) { - content.addAll(0,Files.readAllLines(ops.get(""))); - content.addAll(Files.readAllLines(ops.get(""))); + content.addAll(0,Files.readAllLines(ops.get("%DEFAULT"))); + content.addAll(Files.readAllLines(ops.get("%FOOTER"))); } System.out.println(" Parsing "+f.getFileName()); @@ -243,12 +243,12 @@ public class sigPlace { //Check for markdown pieces. if (s.charAt(0)=='-') { //Start of a title piece. - s=s.replace("-",map.get("TITLE_CONTENT_START")); - s=s+map.get("TITLE_CONTENT_END").replace("","id=\"content_"+f+"\""); + s=s.replace("-",map.get("$TITLE_CONTENT_START")); + s=s+map.get("$TITLE_CONTENT_END").replace("%ID%","id=\"content_"+f+"\""); //Use ⤈ if there's more text to be shown than can fit. } else if (s.contains("===")) { - s=map.get("CONTENT_END")+map.get("DATE_CONTENT_START")+s.replace("===","")+map.get("CONTENT_END")+""+map.get("CONTENT_END"); + s=map.get("$CONTENT_END")+map.get("$DATE_CONTENT_START")+s.replace("===","")+map.get("$CONTENT_END")+"%CONDITIONAL_EXPAND%"+map.get("$CONTENT_END"); } else if (s.charAt(0)==':') { //Image with caption. @@ -306,8 +306,8 @@ public class sigPlace { if (Files.isRegularFile(f)&&isArticleFile(f)) { System.out.println(" Creating article for "+f.getFileName()); List content = Files.readAllLines(f); - List preContent = Files.readAllLines(ops.get("")); - List postContent = Files.readAllLines(ops.get("")); + List preContent = Files.readAllLines(ops.get("%DEFAULT")); + List postContent = Files.readAllLines(ops.get("%FOOTER")); StringBuilder sb = new StringBuilder(); for (String d : preContent) { for (String k : sigPlace.map.keySet()) { @@ -320,7 +320,7 @@ public class sigPlace { d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k)); } d=d.replaceFirst("div class=\"content\"","div class=\"expandedContent\""); - d=d.replaceFirst("",""); + d=d.replaceFirst("%CONDITIONAL_EXPAND%",""); sb.append(d).append("\n"); } for (String d : postContent) { @@ -347,8 +347,8 @@ public class sigPlace { List content = Files.readAllLines(f); for (int i=0;i0&&s.contains("ARTICLE_PREVIEW")) { - String article = ARTICLESDIR+"/"+s.replace("ARTICLE_PREVIEW ","")+".article"; + if (s.length()>0&&s.contains("$ARTICLE_PREVIEW")) { + String article = ARTICLESDIR+"/"+s.replace("$ARTICLE_PREVIEW ","")+".article"; System.out.println(" Found article preview request in "+f.getFileName()+" for article "+article+"."); Path file = Paths.get(OUTDIR,article); List newData = Files.readAllLines(file); @@ -358,7 +358,7 @@ public class sigPlace { content.add(i+j, newData.get(j)); } String lastline=content.get(i+newData.size()-1); - lastline=lastline.replace("","




⤈ Click to expand.
"); + lastline=lastline.replace("%CONDITIONAL_EXPAND%","




⤈ Click to expand.
"); content.set(i+newData.size()-1,lastline);//




⤈ Click to expand.
"); } else { content.set(i,""); @@ -416,8 +416,8 @@ public class sigPlace { for (String key : map.keySet()) { System.out.println("Creating directory listing for "+key+"..."); StringBuilder sb = new StringBuilder(""); - List data = Files.readAllLines(ops.get("")); - List data2 = Files.readAllLines(ops.get("")); + List data = Files.readAllLines(ops.get("%DEFAULT")); + List data2 = Files.readAllLines(ops.get("%FOOTER")); for (String d : data) { for (String k : sigPlace.map.keySet()) { d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));