diff --git a/out/DIRECTORY_LISTING b/out/DIRECTORY_LISTING
index ce002f1..994dad1 100644
--- a/out/DIRECTORY_LISTING
+++ b/out/DIRECTORY_LISTING
@@ -17,14 +17,14 @@
-
Directory Listing for /
🗎reset.css 2022-07-23T22:42:49.256861486Z niconiconii 1093
-
📁articles 2022-07-23T22:42:49.400858932Z niconiconii 4096
-
-
🗎sig.css 2022-07-23T22:42:49.356859712Z niconiconii 6238
-
-
-
📁images 2022-07-23T22:42:49.396859003Z niconiconii 4096
-
+
Directory Listing for /
🗎reset.css 2022-07-23T23:57:41.43284476Z niconiconii 1093
+
📁articles 2022-07-23T23:57:42.292829103Z niconiconii 4096
+
+
🗎sig.css 2022-07-23T23:57:42.22483034Z niconiconii 6238
+
+
+
📁images 2022-07-23T23:57:42.288829174Z niconiconii 4096
+
diff --git a/out/articles/DIRECTORY_LISTING b/out/articles/DIRECTORY_LISTING
index f5fd199..ed1c3bc 100644
--- a/out/articles/DIRECTORY_LISTING
+++ b/out/articles/DIRECTORY_LISTING
@@ -17,13 +17,13 @@
-
Directory Listing for /articles/
-
-
-
-
-
-
+
Directory Listing for /articles/
+
+
+
+
+
+
diff --git a/out/articles/Love Live! Custom Arcade Controller.article b/out/articles/Love Live! Custom Arcade Controller.article
index e8fb854..b8f4254 100644
--- a/out/articles/Love Live! Custom Arcade Controller.article
+++ b/out/articles/Love Live! Custom Arcade Controller.article
@@ -1,5 +1,5 @@
My Love Live! Custom Arcade Controller
-
For over a year since I first got into Love Live! School Idol Festival ~after school ACTIVITY~ Wai-Wai!Home Meeting!! Try saying that one 10 times fast!Subscript
+
For over a year since I first got into Love Live! School Idol Festival ~after school ACTIVITY~ Wai-Wai!Home Meeting!! Try saying that one 10 times fast!Subscript
15 July 2022 1:53PM
%CONDITIONAL_EXPAND%
diff --git a/out/articles/Love Live! Custom Arcade Controller.article.html b/out/articles/Love Live! Custom Arcade Controller.article.html
index cf08a1c..57af782 100644
--- a/out/articles/Love Live! Custom Arcade Controller.article.html
+++ b/out/articles/Love Live! Custom Arcade Controller.article.html
@@ -19,7 +19,7 @@
My Love Live! Custom Arcade Controller
-
For over a year since I first got into Love Live! School Idol Festival ~after school ACTIVITY~ Wai-Wai!Home Meeting!! Try saying that one 10 times fast!Subscript
+
For over a year since I first got into Love Live! School Idol Festival ~after school ACTIVITY~ Wai-Wai!Home Meeting!! Try saying that one 10 times fast!Subscript
15 July 2022 1:53PM
diff --git a/out/articles/curabitur vel tempus ex.article b/out/articles/curabitur vel tempus ex.article
index c112e7b..546297a 100644
--- a/out/articles/curabitur vel tempus ex.article
+++ b/out/articles/curabitur vel tempus ex.article
@@ -1,13 +1,9 @@
Curabitur vel tempus ex
-
Curabitur vel tempus ex. Duis cursus sapien nisl, ut pulvinar dui porttitor ut. Nullam odio purus, tristique non turpis sit amet, malesuada ultricies purus. Mauris ut nulla nisl. Aenean sit amet est egestas justo volutpat consequat. Suspendisse in sagittis augue, et mattis tortor. Nullam viverra metus et nibh fringilla iaculis.
+
Curabitur vel tempus ex. Duis cursus sapien nisl, ut pulvinar dui porttitor ut. Nullam odio purus, tristique non turpis sit amet, malesuada ultricies purus. Mauris ut nulla nisl. Aenean sit amet est egestas justo volutpat consequat. Suspendisse in sagittis augue, et mattis tortor. Nullam viverra metus et nibh fringilla iaculis.
-
-
-
-
-if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) {
- s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"";
- startPos=j+1;
-}
+
+
+<><Test>"</test></test2><test3>"
+
29 Apr 2022 7:37PM
%CONDITIONAL_EXPAND%
diff --git a/out/articles/curabitur vel tempus ex.article.html b/out/articles/curabitur vel tempus ex.article.html
index a102d50..af8d4ec 100644
--- a/out/articles/curabitur vel tempus ex.article.html
+++ b/out/articles/curabitur vel tempus ex.article.html
@@ -18,17 +18,13 @@
Curabitur vel tempus ex
-
Curabitur vel tempus ex. Duis cursus sapien nisl, ut pulvinar dui porttitor ut. Nullam odio purus, tristique non turpis sit amet, malesuada ultricies purus. Mauris ut nulla nisl. Aenean sit amet est egestas justo volutpat consequat. Suspendisse in sagittis augue, et mattis tortor. Nullam viverra metus et nibh fringilla iaculis.
+
Curabitur vel tempus ex. Duis cursus sapien nisl, ut pulvinar dui porttitor ut. Nullam odio purus, tristique non turpis sit amet, malesuada ultricies purus. Mauris ut nulla nisl. Aenean sit amet est egestas justo volutpat consequat. Suspendisse in sagittis augue, et mattis tortor. Nullam viverra metus et nibh fringilla iaculis.
-
-
-
-
-if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) {
- s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"";
- startPos=j+1;
-}
+
+
+<><Test>"</test></test2><test3>"
+
29 Apr 2022 7:37PM
diff --git a/out/articles/sigplace1.article b/out/articles/sigplace1.article
index d33b8f1..c8aae14 100644
--- a/out/articles/sigplace1.article
+++ b/out/articles/sigplace1.article
@@ -20,10 +20,908 @@
-
-test
-test
- test</pre><h1>We can't make a big header</h1>
- testing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.CopyOption;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+public class sigPlace {
+ final static String ROOTDIR = "sitefiles";
+ final static String REFDIR = "ref";
+ final static String OUTDIR = "out";
+ final static String ARTICLESDIR = "articles";
+ final static String UPLOADSDIR = "uploads";
+ final static String COMMENTSDIR = "comments";
+ final static String DIRECTORYLISTING_FILENAME = "DIRECTORY_LISTING";
+ static int PORT = 8080;
+ static double COLOR_ROTATION = 0;
+ static boolean inCodeBlock = false;
+ static String storedCodeBlock = "";
+ final static HashMap<String,String> map = new HashMap<>(Map.ofEntries(
+ new AbstractMap.SimpleEntry<>("SITENAME", "SigPlace"),
+ new AbstractMap.SimpleEntry<>("SITE_BACKCOL", "#111"),
+ new AbstractMap.SimpleEntry<>("TITLE_CONTENT_START", "<div class=\"contentWrapper\"><h1>"),
+ new AbstractMap.SimpleEntry<>("TITLE_CONTENT_END", "</h1><div class=\"content\" >"),
+ new AbstractMap.SimpleEntry<>("CONTENT_END", "</div>"),
+ new AbstractMap.SimpleEntry<>("DATE_CONTENT_START", "<div class=\"datebar\"></div><div class=\"date\">")
+ ));
+ final static HashMap<String,Path> ops = new HashMap<>(Map.ofEntries(
+ new AbstractMap.SimpleEntry<>(
+ "", Paths.get(REFDIR,"DEFAULT.html")),
+ new AbstractMap.SimpleEntry<>(
+ "", Paths.get(REFDIR,"FOOTER.html"))
+ ));
+ public static void main(String[] args) {
+ if (args.length>0&&args.length%2==0) {
+ int i=0;
+ while (i<args.length) {
+ String arg1=args[i];
+ String arg2=args[i+1];
+ i+=2;
+ if (arg1.equals("-p")) {
+ PORT=Integer.parseInt(arg2);
+ System.out.println("Port set to "+PORT+".");
+ } else {
+ System.err.println("Invalid argument \""+arg1+"\".");
+ return;
+ }
+ }
+ }
+ System.out.println("Copying files over to output directory...");
+ try {
+ copyDirectory("sitefiles","out");
+ Iterator<Path> items = Files.walk(Paths.get("out")).filter((p)->!p.toAbsolutePath().toString().contains("images/")).iterator();
+ ParseArticleFiles(items);
+ items = Files.walk(Paths.get("out")).iterator();
+ ConvertArticleReferences(items);
+ items = Files.walk(Paths.get("out","articles")).iterator();
+ GenerateArticleFiles(items);
+ }catch (IOException e) {
+ e.printStackTrace();
+ System.err.println("Copying files over failed!");
+ return;
+ }
+ System.out.println("Building directory listings...");
+ try {
+ buildDirectoryListings();
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.err.println("Failed to build directory listings!");
+ return;
+ }
+ System.out.println("Site has been built into the "+OUTDIR+" directory.");
+ ExportCodeFile();
+ System.out.println("\nStarting web server...");
+ new sigServer();
+ }
+ private static void ParseArticleFiles(Iterator<Path> items) {
+ while (items.hasNext()) {
+ Path f = items.next();
+ System.out.println(" Found "+f.getFileName());
+ if (Files.isRegularFile(f)) {
+ try {
+ System.out.println(" Preparing "+f.getFileName());
+ List<String> content = Files.readAllLines(f);
+ if (isHTMLFile(f)) {
+ content.addAll(0,Files.readAllLines(ops.get("")));
+ content.addAll(Files.readAllLines(ops.get("")));
+ }
+ System.out.println(" Parsing "+f.getFileName());
+ for (int i=0;i<content.size();i++) {
+ String s = content.get(i);
+ //System.out.println(s);
+ if (s.length()>0&&(isHTMLFile(f)||isArticleFile(f))) {
+ if (!inCodeBlock) {
+ if (s.contains("<pre>")) {
+ //System.out.println("Inside <pre>");
+ inCodeBlock=true;
+ storedCodeBlock="";
+ s=s.substring(0,s.indexOf("<pre>"));
+ }
+ }
+ if (inCodeBlock&&s.contains("</pre>")) {
+ inCodeBlock=false;
+ boolean keyword=false;
+ boolean inString=false;
+ boolean inChar=false;
+ boolean canBeNumericalConstant=false;
+ int lengthOfConstant=0;
+ storedCodeBlock+=s.substring(0,s.indexOf("</pre>"));
+ storedCodeBlock=storedCodeBlock.replaceAll(Pattern.quote("<"),"<");
+ s+="</pre>";
+ storedCodeBlock="<pre>"+storedCodeBlock;
+ int startPos=0;
+ String endText=s.substring(s.indexOf("</pre>")+"</pre>".length(),s.length());
+ s="";
+ for (int j=0;j<storedCodeBlock.length();j++) {
+ if (storedCodeBlock.charAt(j)=='"') {
+ inString=!inString;
+ if (inString) {
+ s+=SPAN("")+"\"";
+ } else {
+ s+="\"</span>";
+ startPos=j+1;
+ }
+ } else
+ if (!inString&&!inChar) {
+ if (canBeNumericalConstant&&validNumericalConstantCharacters(lengthOfConstant, j)) {
+ lengthOfConstant++;
+ System.out.println("Length of Constant now "+lengthOfConstant);
+ }
+ if (canBeNumericalConstant&&lengthOfConstant>0&&!(validNumericalConstantCharacters(lengthOfConstant, j))) {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ //System.out.println("Setting "+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j));
+ lengthOfConstant=0;
+ canBeNumericalConstant=false;
+ startPos=j+1;
+ } else
+ if (!canBeNumericalConstant&&storedCodeBlock.charAt(j)=='.') {
+ //Previous section was a member.
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>3&&storedCodeBlock.substring(j-3,j+1).equals("true")&&!isAlphanumeric(j-4)&&!isAlphanumeric(j+1)) {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
+ startPos=j+1;
+ } else
+ if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
+ startPos=j+1;
+ } else
+ if (storedCodeBlock.charAt(j)=='(') {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>0&&isAlphanumeric(j-1) && storedCodeBlock.charAt(j)==' '&&storedCodeBlock.charAt(j-1)!=' ') {
+ //Previous section was a keyword.
+ keyword=true;
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>0&&isAlphanumeric(j-1) && (storedCodeBlock.charAt(j)==';'||storedCodeBlock.charAt(j)==':')) {
+ //Previous section was a keyword.
+ //keyword=true;
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (keyword&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||storedCodeBlock.charAt(j)>='A'&&storedCodeBlock.charAt(j)<='Z'||storedCodeBlock.charAt(j)>='a'&&storedCodeBlock.charAt(j)<='z'||storedCodeBlock.charAt(j)==' ')) {
+ keyword=false;
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (!isAlphanumeric(j)){
+ if (startPos<j) {
+ s+=storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j);
+ } else {
+ s+=storedCodeBlock.charAt(j);
+ }
+ startPos=j+1;
+ }
+ } else {
+ s+=storedCodeBlock.charAt(j);
+ startPos=j+1;
+ }
+ if (canBeNumericalConstant&&lengthOfConstant==0&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9')) {
+ canBeNumericalConstant=false;
+ }
+ if (!canBeNumericalConstant&&!isAlphanumeric(j)) {
+ canBeNumericalConstant=true;
+ lengthOfConstant=0;
+ System.out.println("Found "+storedCodeBlock.charAt(j)+", can be numeric...");
+ }
+ }
+ s+=endText;
+ //System.out.println("Stored code block: "+storedCodeBlock);
+ } else
+ if (inCodeBlock) {
+ storedCodeBlock+=s+"\";
+ s=" ";
+ }
+ }
+ if (s.length()>0&&isArticleFile(f)) {
+ //Check for markdown pieces.
+ if (s.charAt(0)=='-') {
+ //Start of a title piece.
+ s=s.replace("-",map.get("TITLE_CONTENT_"));
+ s=s+map.get("TITLE_CONTENT_").replace("","id=\"content_"+f+"\"");
+ //Use ⤈ if there's more text to be shown than can fit.
+ } else
+ if (s.contains("===")) {
+ s=map.get("CONTENT_")+map.get("DATE_CONTENT_")+s.replace("===","")+map.get("CONTENT_")+""+map.get("CONTENT_");
+ } else
+ if (s.charAt(0)==':') {
+ //Image with caption.
+ //Format:
+ //:<url>,<left|right|center>,<width>,<caption>
+ String[] splitter = s.split(Pattern.quote(","));
+ StringBuilder captionText = new StringBuilder(splitter[3]);
+ for (int j=4;j<splitter.length;j++) {
+ captionText.append(",").append(splitter[j]);
+ }
+ s="<div><figure style=\"text-align:center;"+((splitter[1].equals("left")||splitter[1].equals("right"))?"width:"+splitter[2]+"%;float:"+splitter[1]+";":"")+"\"><img src=\"/"+splitter[0].substring(1)+"\" style=\"margin:auto;width:100%;\"><figcaption>"+captionText.toString()+"</figcaption></figure></div>";
+ } else {
+ //It's regular content, so add paragraphs.
+ s="<p class=\"color"+(((int)(COLOR_ROTATION=(COLOR_ROTATION+0.4)%6))+1)+"\">"+s+"</p>";
+ }
+ } else
+ if (s.length()==0&&isArticleFile(f)) {
+ s="<br/>"; //Setup a line break here.
+ }
+ for (String key : map.keySet()) {
+ s=s.replaceAll(Pattern.quote(key),map.get(key));
+ }
+ content.set(i,s);
+ }
+ System.out.println(" Writing to "+f.toAbsolutePath());
+ Files.write(f, content, Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE);
+
+ System.out.println(" "+f.getFileName() + " conversion complete!");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ private static boolean validNumericalConstantCharacters(int lengthOfConstant, int j) {
+ return storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='.'||lengthOfConstant>0&&storedCodeBlock.charAt(j)>='A'&&lengthOfConstant>0&&storedCodeBlock.charAt(j)<='F'||lengthOfConstant>0&&storedCodeBlock.charAt(j)>='a'&&lengthOfConstant>0&&storedCodeBlock.charAt(j)<='f'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='x'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='X';
+ }
+ private static boolean isAlphanumeric(int j) {
+ return storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||storedCodeBlock.charAt(j)>='A'&&storedCodeBlock.charAt(j)<='Z'||storedCodeBlock.charAt(j)>='a'&&storedCodeBlock.charAt(j)<='z';
+ }
+ /**
+ * Writes a span tag with the included class.
+ * **/
+ private static String SPAN(String className) {
+ return "<span class=\""+className+"\">";
+ }
+ private static void GenerateArticleFiles(Iterator<Path> items){
+ System.out.println(" Generating article files...");
+ while (items.hasNext()) {
+ Path f = items.next();
+ try {
+ if (Files.isRegularFile(f)&&isArticleFile(f)) {
+ System.out.println(" Creating article for "+f.getFileName());
+ List<String> content = Files.readAllLines(f);
+ List<String> preContent = Files.readAllLines(ops.get(""));
+ List<String> postContent = Files.readAllLines(ops.get(""));
+ StringBuilder sb = new StringBuilder();
+ for (String d : preContent) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\");
+ }
+ for (String d : content) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ d=d.replaceFirst("div class=\"content\"","div class=\"expandedContent\"");
+ d=d.replaceFirst("","");
+ sb.append(d).append("\");
+ }
+ for (String d : postContent) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\");
+ }
+ Files.write(Paths.get(f.getParent().toString(),f.getFileName()+"."),sb.toString().getBytes());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ private static void ConvertArticleReferences(Iterator<Path> items) {
+ while (items.hasNext()) {
+ Path f = items.next();
+ System.out.println(" Looking for Article References..."+f.getFileName());
+ boolean articleJavascriptIncluded=false;
+ if (Files.isRegularFile(f)&&isHTMLFile(f)) {
+ System.out.println(" Searching "+f.getFileName());
+ try {
+ List<String> content = Files.readAllLines(f);
+ for (int i=0;i<content.size();i++) {
+ String s = content.get(i);
+ if (s.length()>0&&s.contains("ARTICLE_")) {
+ String article = ARTICLESDIR+"/"+s.replace("ARTICLE_PREVIEW ","")+".";
+ System.out.println(" Found article preview request in "+f.getFileName()+" for article "+article+".");
+ Path file = Paths.get(OUTDIR,article);
+ List<String> newData = Files.readAllLines(file);
+ if (newData.size()>0) {
+ content.set(i,newData.get(0));
+ for (int j=1;j<newData.size();j++) {
+ content.add(i+j, newData.get(j));
+ }
+ String lastline=content.get(i+newData.size()-1);
+ lastline=lastline.replace("","<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand(this,'"+Paths.get(OUTDIR,article.toString())+"')\"><br/><br/><br/><br/>x2908; Click to expand.</div>");
+ content.set(i+newData.size()-1,lastline);//<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand("+i+")\"><br/><br/><br/><br/>⤈ Click to expand.</div>");
+ } else {
+ content.set(i,"");
+ }
+ if (!articleJavascriptIncluded) {
+ List<String> articlejs = Files.readAllLines(Paths.get(REFDIR,"article.js"));
+ for (int j=articlejs.size()-1;j>=0;j--) {
+ content.add(i,articlejs.get(j));
+ }
+ articleJavascriptIncluded=true;
+ }
+ }
+ }
+ Files.write(f,content);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ static void copyDirectory(String sourceDirectoryLocation, String destinationDirectoryLocation)
+ throws IOException {
+ Files.walk(Paths.get(sourceDirectoryLocation))
+ .forEach(source -> {
+ Path destination = Paths.get(destinationDirectoryLocation, source.toString()
+ .substring(sourceDirectoryLocation.length()));
+ try {
+ if (Files.isDirectory(destination)) {
+ Files.createDirectories(destination);
+ } else {
+ Files.copy(source, destination, new CopyOption[]{StandardCopyOption.COPY_ATTRIBUTES,StandardCopyOption.REPLACE_EXISTING});
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ }
+ static void buildDirectoryListings()
+ throws IOException {
+ String startingPath=Paths.get(sigPlace.OUTDIR).toAbsolutePath().toString();
+ HashMap<String,List<Path>> map = new HashMap<>();
+ Iterator<Path> it = Files.walk(Paths.get(sigPlace.OUTDIR)).iterator();
+ map.put("/",new ArrayList<Path>());
+ while (it.hasNext()) {
+ Path f = it.next();
+ if (!f.getFileName().toString().equals(OUTDIR)) {
+ String myKey = f.toAbsolutePath().toString().replace(startingPath,"").replace(f.getFileName().toString(),"");
+ //System.out.println(myKey+","+f);
+ map.putIfAbsent(myKey,new ArrayList<Path>());
+ map.get(myKey).add(f);
+ }
+ }
+ System.out.println("Directory structure determined:");
+ System.out.println(" "+map);
+ for (String key : map.keySet()) {
+ System.out.println("Creating directory listing for "+key+"...");
+ StringBuilder sb = new StringBuilder("");
+ List<String> data = Files.readAllLines(ops.get(""));
+ List<String> data2 = Files.readAllLines(ops.get(""));
+ for (String d : data) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\n");
+ }
+ sb.append("<h2>Directory Listing for "+key+"</h2>");
+ sb.append("<div class=\"folderlisting\"><a href=\"")
+ .append(key)
+ .append("..\" class=\"icon\">📁</a><a href=\"")
+ .append(key)
+ .append("..\">.. </a><a href=\"")
+ .append(key)
+ .append("..\" class=\"nounderline\">(Previous Directory)</a></div>");
+ for (Path f : map.get(key)) {
+ sb.append("<div class=\"").append((Files.isDirectory(f)?"":"")).append("\">")
+ .append("<a href=\""+(f.toAbsolutePath().toString().replace(Paths.get(OUTDIR).toAbsolutePath().toString(),""))+"\" class=\"icon\">")
+ .append((Files.isDirectory(f)?"📁":"🗎"))
+ .append("</a>")
+ .append("<a href=\""+(f.toAbsolutePath().toString().replace(Paths.get(OUTDIR).toAbsolutePath().toString(),""))+"\">")
+ .append(f.getFileName())
+ .append("</a>\t")
+ .append(Files.getLastModifiedTime(f))
+ .append("\t")
+ .append(Files.getOwner(f))
+ .append("\t")
+ .append(Files.size(f))
+ .append("</div>\n");
+ }
+ for (String d : data2) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\n");
+ }
+ Path newf = Files.write(Paths.get(OUTDIR,key,DIRECTORYLISTING_FILENAME),sb.toString().getBytes());
+ System.out.println(" Added info for ("+map.size()+") files to "+newf.toAbsolutePath());
+ }
+ }
+ private static boolean isArticleFile(Path f) {
+ return f.getFileName().toString().contains(".article");
+ }
+ private static boolean isHTMLFile(Path f) {
+ return f.getFileName().toString().contains(".html");
+ }
+ private static void ExportCodeFile() {
+ try {
+ Path file = Paths.get("sigServer.java");
+ List<String> data = Files.readAllLines(file);
+ int i=0;
+ while (!data.get(i++).contains("sigServer()")&&i<data.size());
+ if (i<data.size()) {
+ Files.write(Paths.get(OUTDIR,"codeBackground"),data.subList(i, Math.min(i+40,data.size())),Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
3 May 2022 10:25AM
%CONDITIONAL_EXPAND%
diff --git a/out/articles/sigplace1.article.html b/out/articles/sigplace1.article.html
index b9dde0b..143775e 100644
--- a/out/articles/sigplace1.article.html
+++ b/out/articles/sigplace1.article.html
@@ -39,11 +39,909 @@
-
-test
-test
- test</pre><h1>We can't make a big header</h1>
- testing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.CopyOption;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+public class sigPlace {
+ final static String ROOTDIR = "sitefiles";
+ final static String REFDIR = "ref";
+ final static String OUTDIR = "out";
+ final static String ARTICLESDIR = "articles";
+ final static String UPLOADSDIR = "uploads";
+ final static String COMMENTSDIR = "comments";
+ final static String DIRECTORYLISTING_FILENAME = "DIRECTORY_LISTING";
+ static int PORT = 8080;
+ static double COLOR_ROTATION = 0;
+ static boolean inCodeBlock = false;
+ static String storedCodeBlock = "";
+ final static HashMap<String,String> map = new HashMap<>(Map.ofEntries(
+ new AbstractMap.SimpleEntry<>("SITENAME", "SigPlace"),
+ new AbstractMap.SimpleEntry<>("SITE_BACKCOL", "#111"),
+ new AbstractMap.SimpleEntry<>("TITLE_CONTENT_START", "<div class=\"contentWrapper\"><h1>"),
+ new AbstractMap.SimpleEntry<>("TITLE_CONTENT_END", "</h1><div class=\"content\" >"),
+ new AbstractMap.SimpleEntry<>("CONTENT_END", "</div>"),
+ new AbstractMap.SimpleEntry<>("DATE_CONTENT_START", "<div class=\"datebar\"></div><div class=\"date\">")
+ ));
+ final static HashMap<String,Path> ops = new HashMap<>(Map.ofEntries(
+ new AbstractMap.SimpleEntry<>(
+ "", Paths.get(REFDIR,"DEFAULT.html")),
+ new AbstractMap.SimpleEntry<>(
+ "", Paths.get(REFDIR,"FOOTER.html"))
+ ));
+ public static void main(String[] args) {
+ if (args.length>0&&args.length%2==0) {
+ int i=0;
+ while (i<args.length) {
+ String arg1=args[i];
+ String arg2=args[i+1];
+ i+=2;
+ if (arg1.equals("-p")) {
+ PORT=Integer.parseInt(arg2);
+ System.out.println("Port set to "+PORT+".");
+ } else {
+ System.err.println("Invalid argument \""+arg1+"\".");
+ return;
+ }
+ }
+ }
+ System.out.println("Copying files over to output directory...");
+ try {
+ copyDirectory("sitefiles","out");
+ Iterator<Path> items = Files.walk(Paths.get("out")).filter((p)->!p.toAbsolutePath().toString().contains("images/")).iterator();
+ ParseArticleFiles(items);
+ items = Files.walk(Paths.get("out")).iterator();
+ ConvertArticleReferences(items);
+ items = Files.walk(Paths.get("out","articles")).iterator();
+ GenerateArticleFiles(items);
+ }catch (IOException e) {
+ e.printStackTrace();
+ System.err.println("Copying files over failed!");
+ return;
+ }
+ System.out.println("Building directory listings...");
+ try {
+ buildDirectoryListings();
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.err.println("Failed to build directory listings!");
+ return;
+ }
+ System.out.println("Site has been built into the "+OUTDIR+" directory.");
+ ExportCodeFile();
+ System.out.println("\nStarting web server...");
+ new sigServer();
+ }
+ private static void ParseArticleFiles(Iterator<Path> items) {
+ while (items.hasNext()) {
+ Path f = items.next();
+ System.out.println(" Found "+f.getFileName());
+ if (Files.isRegularFile(f)) {
+ try {
+ System.out.println(" Preparing "+f.getFileName());
+ List<String> content = Files.readAllLines(f);
+ if (isHTMLFile(f)) {
+ content.addAll(0,Files.readAllLines(ops.get("")));
+ content.addAll(Files.readAllLines(ops.get("")));
+ }
+ System.out.println(" Parsing "+f.getFileName());
+ for (int i=0;i<content.size();i++) {
+ String s = content.get(i);
+ //System.out.println(s);
+ if (s.length()>0&&(isHTMLFile(f)||isArticleFile(f))) {
+ if (!inCodeBlock) {
+ if (s.contains("<pre>")) {
+ //System.out.println("Inside <pre>");
+ inCodeBlock=true;
+ storedCodeBlock="";
+ s=s.substring(0,s.indexOf("<pre>"));
+ }
+ }
+ if (inCodeBlock&&s.contains("</pre>")) {
+ inCodeBlock=false;
+ boolean keyword=false;
+ boolean inString=false;
+ boolean inChar=false;
+ boolean canBeNumericalConstant=false;
+ int lengthOfConstant=0;
+ storedCodeBlock+=s.substring(0,s.indexOf("</pre>"));
+ storedCodeBlock=storedCodeBlock.replaceAll(Pattern.quote("<"),"<");
+ s+="</pre>";
+ storedCodeBlock="<pre>"+storedCodeBlock;
+ int startPos=0;
+ String endText=s.substring(s.indexOf("</pre>")+"</pre>".length(),s.length());
+ s="";
+ for (int j=0;j<storedCodeBlock.length();j++) {
+ if (storedCodeBlock.charAt(j)=='"') {
+ inString=!inString;
+ if (inString) {
+ s+=SPAN("")+"\"";
+ } else {
+ s+="\"</span>";
+ startPos=j+1;
+ }
+ } else
+ if (!inString&&!inChar) {
+ if (canBeNumericalConstant&&validNumericalConstantCharacters(lengthOfConstant, j)) {
+ lengthOfConstant++;
+ System.out.println("Length of Constant now "+lengthOfConstant);
+ }
+ if (canBeNumericalConstant&&lengthOfConstant>0&&!(validNumericalConstantCharacters(lengthOfConstant, j))) {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ //System.out.println("Setting "+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j));
+ lengthOfConstant=0;
+ canBeNumericalConstant=false;
+ startPos=j+1;
+ } else
+ if (!canBeNumericalConstant&&storedCodeBlock.charAt(j)=='.') {
+ //Previous section was a member.
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>3&&storedCodeBlock.substring(j-3,j+1).equals("true")&&!isAlphanumeric(j-4)&&!isAlphanumeric(j+1)) {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
+ startPos=j+1;
+ } else
+ if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
+ startPos=j+1;
+ } else
+ if (storedCodeBlock.charAt(j)=='(') {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>0&&isAlphanumeric(j-1) && storedCodeBlock.charAt(j)==' '&&storedCodeBlock.charAt(j-1)!=' ') {
+ //Previous section was a keyword.
+ keyword=true;
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>0&&isAlphanumeric(j-1) && (storedCodeBlock.charAt(j)==';'||storedCodeBlock.charAt(j)==':')) {
+ //Previous section was a keyword.
+ //keyword=true;
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (keyword&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||storedCodeBlock.charAt(j)>='A'&&storedCodeBlock.charAt(j)<='Z'||storedCodeBlock.charAt(j)>='a'&&storedCodeBlock.charAt(j)<='z'||storedCodeBlock.charAt(j)==' ')) {
+ keyword=false;
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (!isAlphanumeric(j)){
+ if (startPos<j) {
+ s+=storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j);
+ } else {
+ s+=storedCodeBlock.charAt(j);
+ }
+ startPos=j+1;
+ }
+ } else {
+ s+=storedCodeBlock.charAt(j);
+ startPos=j+1;
+ }
+ if (canBeNumericalConstant&&lengthOfConstant==0&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9')) {
+ canBeNumericalConstant=false;
+ }
+ if (!canBeNumericalConstant&&!isAlphanumeric(j)) {
+ canBeNumericalConstant=true;
+ lengthOfConstant=0;
+ System.out.println("Found "+storedCodeBlock.charAt(j)+", can be numeric...");
+ }
+ }
+ s+=endText;
+ //System.out.println("Stored code block: "+storedCodeBlock);
+ } else
+ if (inCodeBlock) {
+ storedCodeBlock+=s+"\";
+ s=" ";
+ }
+ }
+ if (s.length()>0&&isArticleFile(f)) {
+ //Check for markdown pieces.
+ if (s.charAt(0)=='-') {
+ //Start of a title piece.
+ s=s.replace("-",map.get("TITLE_CONTENT_"));
+ s=s+map.get("TITLE_CONTENT_").replace("","id=\"content_"+f+"\"");
+ //Use ⤈ if there's more text to be shown than can fit.
+ } else
+ if (s.contains("===")) {
+ s=map.get("CONTENT_")+map.get("DATE_CONTENT_")+s.replace("===","")+map.get("CONTENT_")+""+map.get("CONTENT_");
+ } else
+ if (s.charAt(0)==':') {
+ //Image with caption.
+ //Format:
+ //:<url>,<left|right|center>,<width>,<caption>
+ String[] splitter = s.split(Pattern.quote(","));
+ StringBuilder captionText = new StringBuilder(splitter[3]);
+ for (int j=4;j<splitter.length;j++) {
+ captionText.append(",").append(splitter[j]);
+ }
+ s="<div><figure style=\"text-align:center;"+((splitter[1].equals("left")||splitter[1].equals("right"))?"width:"+splitter[2]+"%;float:"+splitter[1]+";":"")+"\"><img src=\"/"+splitter[0].substring(1)+"\" style=\"margin:auto;width:100%;\"><figcaption>"+captionText.toString()+"</figcaption></figure></div>";
+ } else {
+ //It's regular content, so add paragraphs.
+ s="<p class=\"color"+(((int)(COLOR_ROTATION=(COLOR_ROTATION+0.4)%6))+1)+"\">"+s+"</p>";
+ }
+ } else
+ if (s.length()==0&&isArticleFile(f)) {
+ s="<br/>"; //Setup a line break here.
+ }
+ for (String key : map.keySet()) {
+ s=s.replaceAll(Pattern.quote(key),map.get(key));
+ }
+ content.set(i,s);
+ }
+ System.out.println(" Writing to "+f.toAbsolutePath());
+ Files.write(f, content, Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE);
+
+ System.out.println(" "+f.getFileName() + " conversion complete!");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ private static boolean validNumericalConstantCharacters(int lengthOfConstant, int j) {
+ return storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='.'||lengthOfConstant>0&&storedCodeBlock.charAt(j)>='A'&&lengthOfConstant>0&&storedCodeBlock.charAt(j)<='F'||lengthOfConstant>0&&storedCodeBlock.charAt(j)>='a'&&lengthOfConstant>0&&storedCodeBlock.charAt(j)<='f'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='x'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='X';
+ }
+ private static boolean isAlphanumeric(int j) {
+ return storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||storedCodeBlock.charAt(j)>='A'&&storedCodeBlock.charAt(j)<='Z'||storedCodeBlock.charAt(j)>='a'&&storedCodeBlock.charAt(j)<='z';
+ }
+ /**
+ * Writes a span tag with the included class.
+ * **/
+ private static String SPAN(String className) {
+ return "<span class=\""+className+"\">";
+ }
+ private static void GenerateArticleFiles(Iterator<Path> items){
+ System.out.println(" Generating article files...");
+ while (items.hasNext()) {
+ Path f = items.next();
+ try {
+ if (Files.isRegularFile(f)&&isArticleFile(f)) {
+ System.out.println(" Creating article for "+f.getFileName());
+ List<String> content = Files.readAllLines(f);
+ List<String> preContent = Files.readAllLines(ops.get(""));
+ List<String> postContent = Files.readAllLines(ops.get(""));
+ StringBuilder sb = new StringBuilder();
+ for (String d : preContent) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\");
+ }
+ for (String d : content) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ d=d.replaceFirst("div class=\"content\"","div class=\"expandedContent\"");
+ d=d.replaceFirst("","");
+ sb.append(d).append("\");
+ }
+ for (String d : postContent) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\");
+ }
+ Files.write(Paths.get(f.getParent().toString(),f.getFileName()+"."),sb.toString().getBytes());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ private static void ConvertArticleReferences(Iterator<Path> items) {
+ while (items.hasNext()) {
+ Path f = items.next();
+ System.out.println(" Looking for Article References..."+f.getFileName());
+ boolean articleJavascriptIncluded=false;
+ if (Files.isRegularFile(f)&&isHTMLFile(f)) {
+ System.out.println(" Searching "+f.getFileName());
+ try {
+ List<String> content = Files.readAllLines(f);
+ for (int i=0;i<content.size();i++) {
+ String s = content.get(i);
+ if (s.length()>0&&s.contains("ARTICLE_")) {
+ String article = ARTICLESDIR+"/"+s.replace("ARTICLE_PREVIEW ","")+".";
+ System.out.println(" Found article preview request in "+f.getFileName()+" for article "+article+".");
+ Path file = Paths.get(OUTDIR,article);
+ List<String> newData = Files.readAllLines(file);
+ if (newData.size()>0) {
+ content.set(i,newData.get(0));
+ for (int j=1;j<newData.size();j++) {
+ content.add(i+j, newData.get(j));
+ }
+ String lastline=content.get(i+newData.size()-1);
+ lastline=lastline.replace("","<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand(this,'"+Paths.get(OUTDIR,article.toString())+"')\"><br/><br/><br/><br/>x2908; Click to expand.</div>");
+ content.set(i+newData.size()-1,lastline);//<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand("+i+")\"><br/><br/><br/><br/>⤈ Click to expand.</div>");
+ } else {
+ content.set(i,"");
+ }
+ if (!articleJavascriptIncluded) {
+ List<String> articlejs = Files.readAllLines(Paths.get(REFDIR,"article.js"));
+ for (int j=articlejs.size()-1;j>=0;j--) {
+ content.add(i,articlejs.get(j));
+ }
+ articleJavascriptIncluded=true;
+ }
+ }
+ }
+ Files.write(f,content);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ static void copyDirectory(String sourceDirectoryLocation, String destinationDirectoryLocation)
+ throws IOException {
+ Files.walk(Paths.get(sourceDirectoryLocation))
+ .forEach(source -> {
+ Path destination = Paths.get(destinationDirectoryLocation, source.toString()
+ .substring(sourceDirectoryLocation.length()));
+ try {
+ if (Files.isDirectory(destination)) {
+ Files.createDirectories(destination);
+ } else {
+ Files.copy(source, destination, new CopyOption[]{StandardCopyOption.COPY_ATTRIBUTES,StandardCopyOption.REPLACE_EXISTING});
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ }
+ static void buildDirectoryListings()
+ throws IOException {
+ String startingPath=Paths.get(sigPlace.OUTDIR).toAbsolutePath().toString();
+ HashMap<String,List<Path>> map = new HashMap<>();
+ Iterator<Path> it = Files.walk(Paths.get(sigPlace.OUTDIR)).iterator();
+ map.put("/",new ArrayList<Path>());
+ while (it.hasNext()) {
+ Path f = it.next();
+ if (!f.getFileName().toString().equals(OUTDIR)) {
+ String myKey = f.toAbsolutePath().toString().replace(startingPath,"").replace(f.getFileName().toString(),"");
+ //System.out.println(myKey+","+f);
+ map.putIfAbsent(myKey,new ArrayList<Path>());
+ map.get(myKey).add(f);
+ }
+ }
+ System.out.println("Directory structure determined:");
+ System.out.println(" "+map);
+ for (String key : map.keySet()) {
+ System.out.println("Creating directory listing for "+key+"...");
+ StringBuilder sb = new StringBuilder("");
+ List<String> data = Files.readAllLines(ops.get(""));
+ List<String> data2 = Files.readAllLines(ops.get(""));
+ for (String d : data) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\n");
+ }
+ sb.append("<h2>Directory Listing for "+key+"</h2>");
+ sb.append("<div class=\"folderlisting\"><a href=\"")
+ .append(key)
+ .append("..\" class=\"icon\">📁</a><a href=\"")
+ .append(key)
+ .append("..\">.. </a><a href=\"")
+ .append(key)
+ .append("..\" class=\"nounderline\">(Previous Directory)</a></div>");
+ for (Path f : map.get(key)) {
+ sb.append("<div class=\"").append((Files.isDirectory(f)?"":"")).append("\">")
+ .append("<a href=\""+(f.toAbsolutePath().toString().replace(Paths.get(OUTDIR).toAbsolutePath().toString(),""))+"\" class=\"icon\">")
+ .append((Files.isDirectory(f)?"📁":"🗎"))
+ .append("</a>")
+ .append("<a href=\""+(f.toAbsolutePath().toString().replace(Paths.get(OUTDIR).toAbsolutePath().toString(),""))+"\">")
+ .append(f.getFileName())
+ .append("</a>\t")
+ .append(Files.getLastModifiedTime(f))
+ .append("\t")
+ .append(Files.getOwner(f))
+ .append("\t")
+ .append(Files.size(f))
+ .append("</div>\n");
+ }
+ for (String d : data2) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\n");
+ }
+ Path newf = Files.write(Paths.get(OUTDIR,key,DIRECTORYLISTING_FILENAME),sb.toString().getBytes());
+ System.out.println(" Added info for ("+map.size()+") files to "+newf.toAbsolutePath());
+ }
+ }
+ private static boolean isArticleFile(Path f) {
+ return f.getFileName().toString().contains(".article");
+ }
+ private static boolean isHTMLFile(Path f) {
+ return f.getFileName().toString().contains(".html");
+ }
+ private static void ExportCodeFile() {
+ try {
+ Path file = Paths.get("sigServer.java");
+ List<String> data = Files.readAllLines(file);
+ int i=0;
+ while (!data.get(i++).contains("sigServer()")&&i<data.size());
+ if (i<data.size()) {
+ Files.write(Paths.get(OUTDIR,"codeBackground"),data.subList(i, Math.min(i+40,data.size())),Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
3 May 2022 10:25AM
diff --git a/out/articles/test articles/DIRECTORY_LISTING b/out/articles/test articles/DIRECTORY_LISTING
index 3b8a939..3d46be7 100644
--- a/out/articles/test articles/DIRECTORY_LISTING
+++ b/out/articles/test articles/DIRECTORY_LISTING
@@ -17,12 +17,12 @@
-
Directory Listing for /articles/test articles/
-
-
-
-
-
+
Directory Listing for /articles/test articles/
+
+
+
+
+
diff --git a/out/articles/test articles/test1.article b/out/articles/test articles/test1.article
index f0c1ac6..93bba3b 100644
--- a/out/articles/test articles/test1.article
+++ b/out/articles/test articles/test1.article
@@ -1,3 +1,3 @@
A Test Title
-
In dolor erat, malesuada at elit cursus, convallis imperdiet turpis. Ut aliquet magna tellus, at viverra mauris ullamcorper vehicula. Nam quis urna semper magna ornare elementum sed id mauris. Suspendisse faucibus nunc ante, ac rhoncus nisl tristique sed. Vestibulum pretium odio eget scelerisque vestibulum. Aliquam viverra ex ac vestibulum interdum. Donec ligula nunc, dignissim a purus vitae, fermentum laoreet diam. Quisque nec auctor urna. Vestibulum sit amet ligula ullamcorper, congue ipsum et, accumsan ante. Phasellus fermentum, sapien nec pulvinar blandit, elit purus pretium urna, et dapibus orci urna eu metus. Nunc molestie dictum pharetra. Suspendisse luctus felis et ante tristique, vitae commodo diam porttitor. Aliquam orci eros, placerat ac justo vitae, bibendum efficitur metus. Phasellus eget bibendum mauris.
+
In dolor erat, malesuada at elit cursus, convallis imperdiet turpis. Ut aliquet magna tellus, at viverra mauris ullamcorper vehicula. Nam quis urna semper magna ornare elementum sed id mauris. Suspendisse faucibus nunc ante, ac rhoncus nisl tristique sed. Vestibulum pretium odio eget scelerisque vestibulum. Aliquam viverra ex ac vestibulum interdum. Donec ligula nunc, dignissim a purus vitae, fermentum laoreet diam. Quisque nec auctor urna. Vestibulum sit amet ligula ullamcorper, congue ipsum et, accumsan ante. Phasellus fermentum, sapien nec pulvinar blandit, elit purus pretium urna, et dapibus orci urna eu metus. Nunc molestie dictum pharetra. Suspendisse luctus felis et ante tristique, vitae commodo diam porttitor. Aliquam orci eros, placerat ac justo vitae, bibendum efficitur metus. Phasellus eget bibendum mauris.
2 May 2022 10:16AM
%CONDITIONAL_EXPAND%
diff --git a/out/articles/test articles/test1.article.html b/out/articles/test articles/test1.article.html
index 8d445f1..43e8d87 100644
--- a/out/articles/test articles/test1.article.html
+++ b/out/articles/test articles/test1.article.html
@@ -18,7 +18,7 @@
A Test Title
-
In dolor erat, malesuada at elit cursus, convallis imperdiet turpis. Ut aliquet magna tellus, at viverra mauris ullamcorper vehicula. Nam quis urna semper magna ornare elementum sed id mauris. Suspendisse faucibus nunc ante, ac rhoncus nisl tristique sed. Vestibulum pretium odio eget scelerisque vestibulum. Aliquam viverra ex ac vestibulum interdum. Donec ligula nunc, dignissim a purus vitae, fermentum laoreet diam. Quisque nec auctor urna. Vestibulum sit amet ligula ullamcorper, congue ipsum et, accumsan ante. Phasellus fermentum, sapien nec pulvinar blandit, elit purus pretium urna, et dapibus orci urna eu metus. Nunc molestie dictum pharetra. Suspendisse luctus felis et ante tristique, vitae commodo diam porttitor. Aliquam orci eros, placerat ac justo vitae, bibendum efficitur metus. Phasellus eget bibendum mauris.
+
In dolor erat, malesuada at elit cursus, convallis imperdiet turpis. Ut aliquet magna tellus, at viverra mauris ullamcorper vehicula. Nam quis urna semper magna ornare elementum sed id mauris. Suspendisse faucibus nunc ante, ac rhoncus nisl tristique sed. Vestibulum pretium odio eget scelerisque vestibulum. Aliquam viverra ex ac vestibulum interdum. Donec ligula nunc, dignissim a purus vitae, fermentum laoreet diam. Quisque nec auctor urna. Vestibulum sit amet ligula ullamcorper, congue ipsum et, accumsan ante. Phasellus fermentum, sapien nec pulvinar blandit, elit purus pretium urna, et dapibus orci urna eu metus. Nunc molestie dictum pharetra. Suspendisse luctus felis et ante tristique, vitae commodo diam porttitor. Aliquam orci eros, placerat ac justo vitae, bibendum efficitur metus. Phasellus eget bibendum mauris.
2 May 2022 10:16AM
diff --git a/out/articles/test articles/test2.article b/out/articles/test articles/test2.article
index 80bd924..d80674a 100644
--- a/out/articles/test articles/test2.article
+++ b/out/articles/test articles/test2.article
@@ -1,3 +1,3 @@
Another test title
-
Sed lobortis nisi id nunc tincidunt volutpat. Mauris cursus felis quis condimentum posuere. Pellentesque vitae dolor et justo suscipit ultrices. Integer dapibus leo id felis varius, ut volutpat massa bibendum. Quisque sed nunc arcu. In sit amet faucibus magna, non venenatis massa. Cras sed placerat risus, id consectetur est. Pellentesque in nunc dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque eget lorem ac urna posuere accumsan. Quisque sed imperdiet nisi.
+
Sed lobortis nisi id nunc tincidunt volutpat. Mauris cursus felis quis condimentum posuere. Pellentesque vitae dolor et justo suscipit ultrices. Integer dapibus leo id felis varius, ut volutpat massa bibendum. Quisque sed nunc arcu. In sit amet faucibus magna, non venenatis massa. Cras sed placerat risus, id consectetur est. Pellentesque in nunc dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque eget lorem ac urna posuere accumsan. Quisque sed imperdiet nisi.
1 May 2022 05:13AM
%CONDITIONAL_EXPAND%
diff --git a/out/articles/test articles/test2.article.html b/out/articles/test articles/test2.article.html
index 5e65982..b48b084 100644
--- a/out/articles/test articles/test2.article.html
+++ b/out/articles/test articles/test2.article.html
@@ -18,7 +18,7 @@
Another test title
-
Sed lobortis nisi id nunc tincidunt volutpat. Mauris cursus felis quis condimentum posuere. Pellentesque vitae dolor et justo suscipit ultrices. Integer dapibus leo id felis varius, ut volutpat massa bibendum. Quisque sed nunc arcu. In sit amet faucibus magna, non venenatis massa. Cras sed placerat risus, id consectetur est. Pellentesque in nunc dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque eget lorem ac urna posuere accumsan. Quisque sed imperdiet nisi.
+
Sed lobortis nisi id nunc tincidunt volutpat. Mauris cursus felis quis condimentum posuere. Pellentesque vitae dolor et justo suscipit ultrices. Integer dapibus leo id felis varius, ut volutpat massa bibendum. Quisque sed nunc arcu. In sit amet faucibus magna, non venenatis massa. Cras sed placerat risus, id consectetur est. Pellentesque in nunc dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque eget lorem ac urna posuere accumsan. Quisque sed imperdiet nisi.
1 May 2022 05:13AM
diff --git a/out/articles/test articles/test3.article b/out/articles/test articles/test3.article
index 2b9b733..8ec6af0 100644
--- a/out/articles/test articles/test3.article
+++ b/out/articles/test articles/test3.article
@@ -1,3 +1,3 @@
And More
-
Curabitur suscipit quam tellus, non rhoncus diam vehicula in. Aliquam ut dapibus tortor. Cras accumsan arcu vel ante maximus ornare. Nam tempus fermentum leo maximus euismod. Donec vehicula pretium est a ultrices. Nunc blandit nibh lorem, nec blandit leo posuere quis. Sed mauris ligula, euismod eu aliquam vel, rhoncus eget magna. Proin eget tortor ut ligula suscipit mattis. Integer rutrum aliquet eleifend. Suspendisse leo libero, placerat nec mi id, sagittis malesuada felis. Quisque euismod ante cursus elit lobortis, eu tempus ligula condimentum. Mauris viverra metus et dignissim efficitur. Ut placerat nunc nunc, eu tempus neque ultrices nec. Suspendisse et magna risus. Phasellus in ullamcorper tortor. Sed lobortis ut mi in blandit.
+
Curabitur suscipit quam tellus, non rhoncus diam vehicula in. Aliquam ut dapibus tortor. Cras accumsan arcu vel ante maximus ornare. Nam tempus fermentum leo maximus euismod. Donec vehicula pretium est a ultrices. Nunc blandit nibh lorem, nec blandit leo posuere quis. Sed mauris ligula, euismod eu aliquam vel, rhoncus eget magna. Proin eget tortor ut ligula suscipit mattis. Integer rutrum aliquet eleifend. Suspendisse leo libero, placerat nec mi id, sagittis malesuada felis. Quisque euismod ante cursus elit lobortis, eu tempus ligula condimentum. Mauris viverra metus et dignissim efficitur. Ut placerat nunc nunc, eu tempus neque ultrices nec. Suspendisse et magna risus. Phasellus in ullamcorper tortor. Sed lobortis ut mi in blandit.
30 Apr 2022 6:14PM
%CONDITIONAL_EXPAND%
diff --git a/out/articles/test articles/test3.article.html b/out/articles/test articles/test3.article.html
index 7234487..5fa5dfa 100644
--- a/out/articles/test articles/test3.article.html
+++ b/out/articles/test articles/test3.article.html
@@ -18,7 +18,7 @@
And More
-
Curabitur suscipit quam tellus, non rhoncus diam vehicula in. Aliquam ut dapibus tortor. Cras accumsan arcu vel ante maximus ornare. Nam tempus fermentum leo maximus euismod. Donec vehicula pretium est a ultrices. Nunc blandit nibh lorem, nec blandit leo posuere quis. Sed mauris ligula, euismod eu aliquam vel, rhoncus eget magna. Proin eget tortor ut ligula suscipit mattis. Integer rutrum aliquet eleifend. Suspendisse leo libero, placerat nec mi id, sagittis malesuada felis. Quisque euismod ante cursus elit lobortis, eu tempus ligula condimentum. Mauris viverra metus et dignissim efficitur. Ut placerat nunc nunc, eu tempus neque ultrices nec. Suspendisse et magna risus. Phasellus in ullamcorper tortor. Sed lobortis ut mi in blandit.
+
Curabitur suscipit quam tellus, non rhoncus diam vehicula in. Aliquam ut dapibus tortor. Cras accumsan arcu vel ante maximus ornare. Nam tempus fermentum leo maximus euismod. Donec vehicula pretium est a ultrices. Nunc blandit nibh lorem, nec blandit leo posuere quis. Sed mauris ligula, euismod eu aliquam vel, rhoncus eget magna. Proin eget tortor ut ligula suscipit mattis. Integer rutrum aliquet eleifend. Suspendisse leo libero, placerat nec mi id, sagittis malesuada felis. Quisque euismod ante cursus elit lobortis, eu tempus ligula condimentum. Mauris viverra metus et dignissim efficitur. Ut placerat nunc nunc, eu tempus neque ultrices nec. Suspendisse et magna risus. Phasellus in ullamcorper tortor. Sed lobortis ut mi in blandit.
30 Apr 2022 6:14PM
diff --git a/out/otherpage.html b/out/otherpage.html
index bd3a1cb..bacf9c9 100644
--- a/out/otherpage.html
+++ b/out/otherpage.html
@@ -48,35 +48,929 @@ This is a different webpage.
-
-test
-test
- test</pre><h1>We can't make a big header</h1>
- testing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.CopyOption;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+public class sigPlace {
+ final static String ROOTDIR = "sitefiles";
+ final static String REFDIR = "ref";
+ final static String OUTDIR = "out";
+ final static String ARTICLESDIR = "articles";
+ final static String UPLOADSDIR = "uploads";
+ final static String COMMENTSDIR = "comments";
+ final static String DIRECTORYLISTING_FILENAME = "DIRECTORY_LISTING";
+ static int PORT = 8080;
+ static double COLOR_ROTATION = 0;
+ static boolean inCodeBlock = false;
+ static String storedCodeBlock = "";
+ final static HashMap<String,String> map = new HashMap<>(Map.ofEntries(
+ new AbstractMap.SimpleEntry<>("SITENAME", "SigPlace"),
+ new AbstractMap.SimpleEntry<>("SITE_BACKCOL", "#111"),
+ new AbstractMap.SimpleEntry<>("TITLE_CONTENT_START", "<div class=\"contentWrapper\"><h1>"),
+ new AbstractMap.SimpleEntry<>("TITLE_CONTENT_END", "</h1><div class=\"content\" >"),
+ new AbstractMap.SimpleEntry<>("CONTENT_END", "</div>"),
+ new AbstractMap.SimpleEntry<>("DATE_CONTENT_START", "<div class=\"datebar\"></div><div class=\"date\">")
+ ));
+ final static HashMap<String,Path> ops = new HashMap<>(Map.ofEntries(
+ new AbstractMap.SimpleEntry<>(
+ "", Paths.get(REFDIR,"DEFAULT.html")),
+ new AbstractMap.SimpleEntry<>(
+ "", Paths.get(REFDIR,"FOOTER.html"))
+ ));
+ public static void main(String[] args) {
+ if (args.length>0&&args.length%2==0) {
+ int i=0;
+ while (i<args.length) {
+ String arg1=args[i];
+ String arg2=args[i+1];
+ i+=2;
+ if (arg1.equals("-p")) {
+ PORT=Integer.parseInt(arg2);
+ System.out.println("Port set to "+PORT+".");
+ } else {
+ System.err.println("Invalid argument \""+arg1+"\".");
+ return;
+ }
+ }
+ }
+ System.out.println("Copying files over to output directory...");
+ try {
+ copyDirectory("sitefiles","out");
+ Iterator<Path> items = Files.walk(Paths.get("out")).filter((p)->!p.toAbsolutePath().toString().contains("images/")).iterator();
+ ParseArticleFiles(items);
+ items = Files.walk(Paths.get("out")).iterator();
+ ConvertArticleReferences(items);
+ items = Files.walk(Paths.get("out","articles")).iterator();
+ GenerateArticleFiles(items);
+ }catch (IOException e) {
+ e.printStackTrace();
+ System.err.println("Copying files over failed!");
+ return;
+ }
+ System.out.println("Building directory listings...");
+ try {
+ buildDirectoryListings();
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.err.println("Failed to build directory listings!");
+ return;
+ }
+ System.out.println("Site has been built into the "+OUTDIR+" directory.");
+ ExportCodeFile();
+ System.out.println("\nStarting web server...");
+ new sigServer();
+ }
+ private static void ParseArticleFiles(Iterator<Path> items) {
+ while (items.hasNext()) {
+ Path f = items.next();
+ System.out.println(" Found "+f.getFileName());
+ if (Files.isRegularFile(f)) {
+ try {
+ System.out.println(" Preparing "+f.getFileName());
+ List<String> content = Files.readAllLines(f);
+ if (isHTMLFile(f)) {
+ content.addAll(0,Files.readAllLines(ops.get("")));
+ content.addAll(Files.readAllLines(ops.get("")));
+ }
+ System.out.println(" Parsing "+f.getFileName());
+ for (int i=0;i<content.size();i++) {
+ String s = content.get(i);
+ //System.out.println(s);
+ if (s.length()>0&&(isHTMLFile(f)||isArticleFile(f))) {
+ if (!inCodeBlock) {
+ if (s.contains("<pre>")) {
+ //System.out.println("Inside <pre>");
+ inCodeBlock=true;
+ storedCodeBlock="";
+ s=s.substring(0,s.indexOf("<pre>"));
+ }
+ }
+ if (inCodeBlock&&s.contains("</pre>")) {
+ inCodeBlock=false;
+ boolean keyword=false;
+ boolean inString=false;
+ boolean inChar=false;
+ boolean canBeNumericalConstant=false;
+ int lengthOfConstant=0;
+ storedCodeBlock+=s.substring(0,s.indexOf("</pre>"));
+ storedCodeBlock=storedCodeBlock.replaceAll(Pattern.quote("<"),"<");
+ s+="</pre>";
+ storedCodeBlock="<pre>"+storedCodeBlock;
+ int startPos=0;
+ String endText=s.substring(s.indexOf("</pre>")+"</pre>".length(),s.length());
+ s="";
+ for (int j=0;j<storedCodeBlock.length();j++) {
+ if (storedCodeBlock.charAt(j)=='"') {
+ inString=!inString;
+ if (inString) {
+ s+=SPAN("")+"\"";
+ } else {
+ s+="\"</span>";
+ startPos=j+1;
+ }
+ } else
+ if (!inString&&!inChar) {
+ if (canBeNumericalConstant&&validNumericalConstantCharacters(lengthOfConstant, j)) {
+ lengthOfConstant++;
+ System.out.println("Length of Constant now "+lengthOfConstant);
+ }
+ if (canBeNumericalConstant&&lengthOfConstant>0&&!(validNumericalConstantCharacters(lengthOfConstant, j))) {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ //System.out.println("Setting "+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j));
+ lengthOfConstant=0;
+ canBeNumericalConstant=false;
+ startPos=j+1;
+ } else
+ if (!canBeNumericalConstant&&storedCodeBlock.charAt(j)=='.') {
+ //Previous section was a member.
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>3&&storedCodeBlock.substring(j-3,j+1).equals("true")&&!isAlphanumeric(j-4)&&!isAlphanumeric(j+1)) {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
+ startPos=j+1;
+ } else
+ if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
+ startPos=j+1;
+ } else
+ if (storedCodeBlock.charAt(j)=='(') {
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>0&&isAlphanumeric(j-1) && storedCodeBlock.charAt(j)==' '&&storedCodeBlock.charAt(j-1)!=' ') {
+ //Previous section was a keyword.
+ keyword=true;
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>0&&isAlphanumeric(j-1) && (storedCodeBlock.charAt(j)==';'||storedCodeBlock.charAt(j)==':')) {
+ //Previous section was a keyword.
+ //keyword=true;
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (keyword&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||storedCodeBlock.charAt(j)>='A'&&storedCodeBlock.charAt(j)<='Z'||storedCodeBlock.charAt(j)>='a'&&storedCodeBlock.charAt(j)<='z'||storedCodeBlock.charAt(j)==' ')) {
+ keyword=false;
+ s+=SPAN("")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (!isAlphanumeric(j)){
+ if (startPos<j) {
+ s+=storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j);
+ } else {
+ s+=storedCodeBlock.charAt(j);
+ }
+ startPos=j+1;
+ }
+ } else {
+ s+=storedCodeBlock.charAt(j);
+ startPos=j+1;
+ }
+ if (canBeNumericalConstant&&lengthOfConstant==0&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9')) {
+ canBeNumericalConstant=false;
+ }
+ if (!canBeNumericalConstant&&!isAlphanumeric(j)) {
+ canBeNumericalConstant=true;
+ lengthOfConstant=0;
+ System.out.println("Found "+storedCodeBlock.charAt(j)+", can be numeric...");
+ }
+ }
+ s+=endText;
+ //System.out.println("Stored code block: "+storedCodeBlock);
+ } else
+ if (inCodeBlock) {
+ storedCodeBlock+=s+"\";
+ s=" ";
+ }
+ }
+ if (s.length()>0&&isArticleFile(f)) {
+ //Check for markdown pieces.
+ if (s.charAt(0)=='-') {
+ //Start of a title piece.
+ s=s.replace("-",map.get("TITLE_CONTENT_"));
+ s=s+map.get("TITLE_CONTENT_").replace("","id=\"content_"+f+"\"");
+ //Use ⤈ if there's more text to be shown than can fit.
+ } else
+ if (s.contains("===")) {
+ s=map.get("CONTENT_")+map.get("DATE_CONTENT_")+s.replace("===","")+map.get("CONTENT_")+""+map.get("CONTENT_");
+ } else
+ if (s.charAt(0)==':') {
+ //Image with caption.
+ //Format:
+ //:<url>,<left|right|center>,<width>,<caption>
+ String[] splitter = s.split(Pattern.quote(","));
+ StringBuilder captionText = new StringBuilder(splitter[3]);
+ for (int j=4;j<splitter.length;j++) {
+ captionText.append(",").append(splitter[j]);
+ }
+ s="<div><figure style=\"text-align:center;"+((splitter[1].equals("left")||splitter[1].equals("right"))?"width:"+splitter[2]+"%;float:"+splitter[1]+";":"")+"\"><img src=\"/"+splitter[0].substring(1)+"\" style=\"margin:auto;width:100%;\"><figcaption>"+captionText.toString()+"</figcaption></figure></div>";
+ } else {
+ //It's regular content, so add paragraphs.
+ s="<p class=\"color"+(((int)(COLOR_ROTATION=(COLOR_ROTATION+0.4)%6))+1)+"\">"+s+"</p>";
+ }
+ } else
+ if (s.length()==0&&isArticleFile(f)) {
+ s="<br/>"; //Setup a line break here.
+ }
+ for (String key : map.keySet()) {
+ s=s.replaceAll(Pattern.quote(key),map.get(key));
+ }
+ content.set(i,s);
+ }
+ System.out.println(" Writing to "+f.toAbsolutePath());
+ Files.write(f, content, Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE);
+
+ System.out.println(" "+f.getFileName() + " conversion complete!");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ private static boolean validNumericalConstantCharacters(int lengthOfConstant, int j) {
+ return storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='.'||lengthOfConstant>0&&storedCodeBlock.charAt(j)>='A'&&lengthOfConstant>0&&storedCodeBlock.charAt(j)<='F'||lengthOfConstant>0&&storedCodeBlock.charAt(j)>='a'&&lengthOfConstant>0&&storedCodeBlock.charAt(j)<='f'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='x'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='X';
+ }
+ private static boolean isAlphanumeric(int j) {
+ return storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||storedCodeBlock.charAt(j)>='A'&&storedCodeBlock.charAt(j)<='Z'||storedCodeBlock.charAt(j)>='a'&&storedCodeBlock.charAt(j)<='z';
+ }
+ /**
+ * Writes a span tag with the included class.
+ * **/
+ private static String SPAN(String className) {
+ return "<span class=\""+className+"\">";
+ }
+ private static void GenerateArticleFiles(Iterator<Path> items){
+ System.out.println(" Generating article files...");
+ while (items.hasNext()) {
+ Path f = items.next();
+ try {
+ if (Files.isRegularFile(f)&&isArticleFile(f)) {
+ System.out.println(" Creating article for "+f.getFileName());
+ List<String> content = Files.readAllLines(f);
+ List<String> preContent = Files.readAllLines(ops.get(""));
+ List<String> postContent = Files.readAllLines(ops.get(""));
+ StringBuilder sb = new StringBuilder();
+ for (String d : preContent) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\");
+ }
+ for (String d : content) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ d=d.replaceFirst("div class=\"content\"","div class=\"expandedContent\"");
+ d=d.replaceFirst("","");
+ sb.append(d).append("\");
+ }
+ for (String d : postContent) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\");
+ }
+ Files.write(Paths.get(f.getParent().toString(),f.getFileName()+"."),sb.toString().getBytes());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ private static void ConvertArticleReferences(Iterator<Path> items) {
+ while (items.hasNext()) {
+ Path f = items.next();
+ System.out.println(" Looking for Article References..."+f.getFileName());
+ boolean articleJavascriptIncluded=false;
+ if (Files.isRegularFile(f)&&isHTMLFile(f)) {
+ System.out.println(" Searching "+f.getFileName());
+ try {
+ List<String> content = Files.readAllLines(f);
+ for (int i=0;i<content.size();i++) {
+ String s = content.get(i);
+ if (s.length()>0&&s.contains("ARTICLE_")) {
+ String article = ARTICLESDIR+"/"+s.replace("ARTICLE_PREVIEW ","")+".";
+ System.out.println(" Found article preview request in "+f.getFileName()+" for article "+article+".");
+ Path file = Paths.get(OUTDIR,article);
+ List<String> newData = Files.readAllLines(file);
+ if (newData.size()>0) {
+ content.set(i,newData.get(0));
+ for (int j=1;j<newData.size();j++) {
+ content.add(i+j, newData.get(j));
+ }
+ String lastline=content.get(i+newData.size()-1);
+ lastline=lastline.replace("","<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand(this,'"+Paths.get(OUTDIR,article.toString())+"')\"><br/><br/><br/><br/>x2908; Click to expand.</div>");
+ content.set(i+newData.size()-1,lastline);//<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand("+i+")\"><br/><br/><br/><br/>⤈ Click to expand.</div>");
+ } else {
+ content.set(i,"");
+ }
+ if (!articleJavascriptIncluded) {
+ List<String> articlejs = Files.readAllLines(Paths.get(REFDIR,"article.js"));
+ for (int j=articlejs.size()-1;j>=0;j--) {
+ content.add(i,articlejs.get(j));
+ }
+ articleJavascriptIncluded=true;
+ }
+ }
+ }
+ Files.write(f,content);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ static void copyDirectory(String sourceDirectoryLocation, String destinationDirectoryLocation)
+ throws IOException {
+ Files.walk(Paths.get(sourceDirectoryLocation))
+ .forEach(source -> {
+ Path destination = Paths.get(destinationDirectoryLocation, source.toString()
+ .substring(sourceDirectoryLocation.length()));
+ try {
+ if (Files.isDirectory(destination)) {
+ Files.createDirectories(destination);
+ } else {
+ Files.copy(source, destination, new CopyOption[]{StandardCopyOption.COPY_ATTRIBUTES,StandardCopyOption.REPLACE_EXISTING});
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ }
+ static void buildDirectoryListings()
+ throws IOException {
+ String startingPath=Paths.get(sigPlace.OUTDIR).toAbsolutePath().toString();
+ HashMap<String,List<Path>> map = new HashMap<>();
+ Iterator<Path> it = Files.walk(Paths.get(sigPlace.OUTDIR)).iterator();
+ map.put("/",new ArrayList<Path>());
+ while (it.hasNext()) {
+ Path f = it.next();
+ if (!f.getFileName().toString().equals(OUTDIR)) {
+ String myKey = f.toAbsolutePath().toString().replace(startingPath,"").replace(f.getFileName().toString(),"");
+ //System.out.println(myKey+","+f);
+ map.putIfAbsent(myKey,new ArrayList<Path>());
+ map.get(myKey).add(f);
+ }
+ }
+ System.out.println("Directory structure determined:");
+ System.out.println(" "+map);
+ for (String key : map.keySet()) {
+ System.out.println("Creating directory listing for "+key+"...");
+ StringBuilder sb = new StringBuilder("");
+ List<String> data = Files.readAllLines(ops.get(""));
+ List<String> data2 = Files.readAllLines(ops.get(""));
+ for (String d : data) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\n");
+ }
+ sb.append("<h2>Directory Listing for "+key+"</h2>");
+ sb.append("<div class=\"folderlisting\"><a href=\"")
+ .append(key)
+ .append("..\" class=\"icon\">📁</a><a href=\"")
+ .append(key)
+ .append("..\">.. </a><a href=\"")
+ .append(key)
+ .append("..\" class=\"nounderline\">(Previous Directory)</a></div>");
+ for (Path f : map.get(key)) {
+ sb.append("<div class=\"").append((Files.isDirectory(f)?"":"")).append("\">")
+ .append("<a href=\""+(f.toAbsolutePath().toString().replace(Paths.get(OUTDIR).toAbsolutePath().toString(),""))+"\" class=\"icon\">")
+ .append((Files.isDirectory(f)?"📁":"🗎"))
+ .append("</a>")
+ .append("<a href=\""+(f.toAbsolutePath().toString().replace(Paths.get(OUTDIR).toAbsolutePath().toString(),""))+"\">")
+ .append(f.getFileName())
+ .append("</a>\t")
+ .append(Files.getLastModifiedTime(f))
+ .append("\t")
+ .append(Files.getOwner(f))
+ .append("\t")
+ .append(Files.size(f))
+ .append("</div>\n");
+ }
+ for (String d : data2) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\n");
+ }
+ Path newf = Files.write(Paths.get(OUTDIR,key,DIRECTORYLISTING_FILENAME),sb.toString().getBytes());
+ System.out.println(" Added info for ("+map.size()+") files to "+newf.toAbsolutePath());
+ }
+ }
+ private static boolean isArticleFile(Path f) {
+ return f.getFileName().toString().contains(".article");
+ }
+ private static boolean isHTMLFile(Path f) {
+ return f.getFileName().toString().contains(".html");
+ }
+ private static void ExportCodeFile() {
+ try {
+ Path file = Paths.get("sigServer.java");
+ List<String> data = Files.readAllLines(file);
+ int i=0;
+ while (!data.get(i++).contains("sigServer()")&&i<data.size());
+ if (i<data.size()) {
+ Files.write(Paths.get(OUTDIR,"codeBackground"),data.subList(i, Math.min(i+40,data.size())),Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
3 May 2022 10:25AM
⤈ Click to expand.
A Test Title
-
In dolor erat, malesuada at elit cursus, convallis imperdiet turpis. Ut aliquet magna tellus, at viverra mauris ullamcorper vehicula. Nam quis urna semper magna ornare elementum sed id mauris. Suspendisse faucibus nunc ante, ac rhoncus nisl tristique sed. Vestibulum pretium odio eget scelerisque vestibulum. Aliquam viverra ex ac vestibulum interdum. Donec ligula nunc, dignissim a purus vitae, fermentum laoreet diam. Quisque nec auctor urna. Vestibulum sit amet ligula ullamcorper, congue ipsum et, accumsan ante. Phasellus fermentum, sapien nec pulvinar blandit, elit purus pretium urna, et dapibus orci urna eu metus. Nunc molestie dictum pharetra. Suspendisse luctus felis et ante tristique, vitae commodo diam porttitor. Aliquam orci eros, placerat ac justo vitae, bibendum efficitur metus. Phasellus eget bibendum mauris.
-
2 May 2022 10:16AM
⤈ Click to expand.
+ In dolor erat, malesuada at elit cursus, convallis imperdiet turpis. Ut aliquet magna tellus, at viverra mauris ullamcorper vehicula. Nam quis urna semper magna ornare elementum sed id mauris. Suspendisse faucibus nunc ante, ac rhoncus nisl tristique sed. Vestibulum pretium odio eget scelerisque vestibulum. Aliquam viverra ex ac vestibulum interdum. Donec ligula nunc, dignissim a purus vitae, fermentum laoreet diam. Quisque nec auctor urna. Vestibulum sit amet ligula ullamcorper, congue ipsum et, accumsan ante. Phasellus fermentum, sapien nec pulvinar blandit, elit purus pretium urna, et dapibus orci urna eu metus. Nunc molestie dictum pharetra. Suspendisse luctus felis et ante tristique, vitae commodo diam porttitor. Aliquam orci eros, placerat ac justo vitae, bibendum efficitur metus. Phasellus eget bibendum mauris.
+2 May 2022 10:16AM
⤈ Click to expand.
Another test title
-
Sed lobortis nisi id nunc tincidunt volutpat. Mauris cursus felis quis condimentum posuere. Pellentesque vitae dolor et justo suscipit ultrices. Integer dapibus leo id felis varius, ut volutpat massa bibendum. Quisque sed nunc arcu. In sit amet faucibus magna, non venenatis massa. Cras sed placerat risus, id consectetur est. Pellentesque in nunc dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque eget lorem ac urna posuere accumsan. Quisque sed imperdiet nisi.
-
1 May 2022 05:13AM
⤈ Click to expand.
+ Sed lobortis nisi id nunc tincidunt volutpat. Mauris cursus felis quis condimentum posuere. Pellentesque vitae dolor et justo suscipit ultrices. Integer dapibus leo id felis varius, ut volutpat massa bibendum. Quisque sed nunc arcu. In sit amet faucibus magna, non venenatis massa. Cras sed placerat risus, id consectetur est. Pellentesque in nunc dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque eget lorem ac urna posuere accumsan. Quisque sed imperdiet nisi.
+1 May 2022 05:13AM
⤈ Click to expand.
And More
-
Curabitur suscipit quam tellus, non rhoncus diam vehicula in. Aliquam ut dapibus tortor. Cras accumsan arcu vel ante maximus ornare. Nam tempus fermentum leo maximus euismod. Donec vehicula pretium est a ultrices. Nunc blandit nibh lorem, nec blandit leo posuere quis. Sed mauris ligula, euismod eu aliquam vel, rhoncus eget magna. Proin eget tortor ut ligula suscipit mattis. Integer rutrum aliquet eleifend. Suspendisse leo libero, placerat nec mi id, sagittis malesuada felis. Quisque euismod ante cursus elit lobortis, eu tempus ligula condimentum. Mauris viverra metus et dignissim efficitur. Ut placerat nunc nunc, eu tempus neque ultrices nec. Suspendisse et magna risus. Phasellus in ullamcorper tortor. Sed lobortis ut mi in blandit.
-
30 Apr 2022 6:14PM
⤈ Click to expand.
+ Curabitur suscipit quam tellus, non rhoncus diam vehicula in. Aliquam ut dapibus tortor. Cras accumsan arcu vel ante maximus ornare. Nam tempus fermentum leo maximus euismod. Donec vehicula pretium est a ultrices. Nunc blandit nibh lorem, nec blandit leo posuere quis. Sed mauris ligula, euismod eu aliquam vel, rhoncus eget magna. Proin eget tortor ut ligula suscipit mattis. Integer rutrum aliquet eleifend. Suspendisse leo libero, placerat nec mi id, sagittis malesuada felis. Quisque euismod ante cursus elit lobortis, eu tempus ligula condimentum. Mauris viverra metus et dignissim efficitur. Ut placerat nunc nunc, eu tempus neque ultrices nec. Suspendisse et magna risus. Phasellus in ullamcorper tortor. Sed lobortis ut mi in blandit.
+30 Apr 2022 6:14PM
⤈ Click to expand.
Curabitur vel tempus ex
-
Curabitur vel tempus ex. Duis cursus sapien nisl, ut pulvinar dui porttitor ut. Nullam odio purus, tristique non turpis sit amet, malesuada ultricies purus. Mauris ut nulla nisl. Aenean sit amet est egestas justo volutpat consequat. Suspendisse in sagittis augue, et mattis tortor. Nullam viverra metus et nibh fringilla iaculis.
+
Curabitur vel tempus ex. Duis cursus sapien nisl, ut pulvinar dui porttitor ut. Nullam odio purus, tristique non turpis sit amet, malesuada ultricies purus. Mauris ut nulla nisl. Aenean sit amet est egestas justo volutpat consequat. Suspendisse in sagittis augue, et mattis tortor. Nullam viverra metus et nibh fringilla iaculis.
-
-
-
-
-if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) {
- s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"";
- startPos=j+1;
-}
-
29 Apr 2022 7:37PM
⤈ Click to expand.
+
+
+<><Test>"</test></test2><test3>"
+
+29 Apr 2022 7:37PM
⤈ Click to expand.
diff --git a/sigPlace.class b/sigPlace.class
index cc44c66..fd6b83e 100644
Binary files a/sigPlace.class and b/sigPlace.class differ
diff --git a/sigPlace.java b/sigPlace.java
index b81ccae..192bc5c 100644
--- a/sigPlace.java
+++ b/sigPlace.java
@@ -112,24 +112,27 @@ public class sigPlace {
System.out.println(" Parsing "+f.getFileName());
for (int i=0;i0&&(isHTMLFile(f)||isArticleFile(f))) {
if (!inCodeBlock) {
- if (s.contains("")) {
+ if (s.trim().equals("")) {
//System.out.println("Inside ");
inCodeBlock=true;
- storedCodeBlock=s.substring(s.indexOf(""));
+ storedCodeBlock="";
s=s.substring(0,s.indexOf(""));
}
}
- if (inCodeBlock&&s.contains("
")) {
+ if (inCodeBlock&&s.trim().equals("
")) {
inCodeBlock=false;
boolean keyword=false;
boolean inString=false;
boolean inChar=false;
boolean canBeNumericalConstant=false;
int lengthOfConstant=0;
- storedCodeBlock+=s.substring(0,s.indexOf("
")+"
".length());
+ storedCodeBlock+=s.substring(0,s.indexOf("
"));
+ storedCodeBlock=storedCodeBlock.replaceAll(Pattern.quote("<"),"\2");
+ storedCodeBlock+="
";
int startPos=0;
String endText=s.substring(s.indexOf("
")+"".length(),s.length());
s="";
@@ -210,7 +213,14 @@ public class sigPlace {
System.out.println("Found "+storedCodeBlock.charAt(j)+", can be numeric...");
}
}
+ for (int j=0;j"+s+"";
}
- } else
- if (s.length()==0&&isArticleFile(f)) {
- s="
"; //Setup a line break here.
+ } else {
+ if (s.length()==0&&isArticleFile(f)) {
+ s="
"; //Setup a line break here.
+ }
}
- for (String key : map.keySet()) {
- s=s.replaceAll(Pattern.quote(key),map.get(key));
+ if (!isPreLine) {
+ for (String key : map.keySet()) {
+ s=s.replaceAll(Pattern.quote(key),map.get(key));
+ }
}
content.set(i,s);
}
diff --git a/sitefiles/articles/curabitur vel tempus ex.article b/sitefiles/articles/curabitur vel tempus ex.article
index 8c8b847..91735e6 100644
--- a/sitefiles/articles/curabitur vel tempus ex.article
+++ b/sitefiles/articles/curabitur vel tempus ex.article
@@ -2,8 +2,6 @@
Curabitur vel tempus ex. Duis cursus sapien nisl, ut pulvinar dui porttitor ut. Nullam odio purus, tristique non turpis sit amet, malesuada ultricies purus. Mauris ut nulla nisl. Aenean sit amet est egestas justo volutpat consequat. Suspendisse in sagittis augue, et mattis tortor. Nullam viverra metus et nibh fringilla iaculis.
-if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) {
- s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"";
- startPos=j+1;
-}
+<>""
+
===29 Apr 2022 7:37PM
\ No newline at end of file
diff --git a/sitefiles/articles/sigplace1.article b/sitefiles/articles/sigplace1.article
index 96d33b8..76a50a1 100644
--- a/sitefiles/articles/sigplace1.article
+++ b/sitefiles/articles/sigplace1.article
@@ -16,9 +16,467 @@ Vestibulum laoreet lorem consequat, mollis augue finibus, luctus libero. Praesen
Here we demonstrate the love live logo. But wait, it's literally like in the middle wtf is going on.Here we demonstrate the love live logo. But wait, it's literally like in the middle wtf is going on.Here we demonstrate the love live logo. But wait, it's literally like in the middle wtf is going on.
-test
-test
- test</pre><h1>We can't make a big header</h1>
- testing
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.CopyOption;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+public class sigPlace {
+
+ final static String ROOTDIR = "sitefiles";
+ final static String REFDIR = "ref";
+ final static String OUTDIR = "out";
+ final static String ARTICLESDIR = "articles";
+ final static String UPLOADSDIR = "uploads";
+ final static String COMMENTSDIR = "comments";
+ final static String DIRECTORYLISTING_FILENAME = "DIRECTORY_LISTING";
+ static int PORT = 8080;
+
+ static double COLOR_ROTATION = 0;
+
+ static boolean inCodeBlock = false;
+ 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", "
")
+ ));
+ final static HashMap
ops = new HashMap<>(Map.ofEntries(
+ new AbstractMap.SimpleEntry<>(
+ "", Paths.get(REFDIR,"DEFAULT.html")),
+ new AbstractMap.SimpleEntry<>(
+ "", Paths.get(REFDIR,"FOOTER.html"))
+ ));
+ public static void main(String[] args) {
+
+ if (args.length>0&&args.length%2==0) {
+ int i=0;
+ while (i items = Files.walk(Paths.get("out")).filter((p)->!p.toAbsolutePath().toString().contains("images/")).iterator();
+ ParseArticleFiles(items);
+
+ items = Files.walk(Paths.get("out")).iterator();
+ ConvertArticleReferences(items);
+ items = Files.walk(Paths.get("out","articles")).iterator();
+ GenerateArticleFiles(items);
+ }catch (IOException e) {
+ e.printStackTrace();
+ System.err.println("Copying files over failed!");
+ return;
+ }
+
+ System.out.println("Building directory listings...");
+ try {
+ buildDirectoryListings();
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.err.println("Failed to build directory listings!");
+ return;
+ }
+
+ System.out.println("Site has been built into the "+OUTDIR+" directory.");
+
+ ExportCodeFile();
+
+ System.out.println("\nStarting web server...");
+ new sigServer();
+ }
+ private static void ParseArticleFiles(Iterator items) {
+ while (items.hasNext()) {
+ Path f = items.next();
+ System.out.println(" Found "+f.getFileName());
+ if (Files.isRegularFile(f)) {
+ try {
+
+ System.out.println(" Preparing "+f.getFileName());
+
+ List content = Files.readAllLines(f);
+ if (isHTMLFile(f)) {
+ content.addAll(0,Files.readAllLines(ops.get("")));
+ content.addAll(Files.readAllLines(ops.get("")));
+ }
+
+ System.out.println(" Parsing "+f.getFileName());
+ for (int i=0;i0&&(isHTMLFile(f)||isArticleFile(f))) {
+ if (!inCodeBlock) {
+ if (s.contains("")) {
+ //System.out.println("Inside ");
+ inCodeBlock=true;
+ storedCodeBlock="";
+ s=s.substring(0,s.indexOf(""));
+ }
+ }
+ if (inCodeBlock&&s.contains("
")) {
+ inCodeBlock=false;
+ boolean keyword=false;
+ boolean inString=false;
+ boolean inChar=false;
+ boolean canBeNumericalConstant=false;
+ int lengthOfConstant=0;
+ storedCodeBlock+=s.substring(0,s.indexOf("
"));
+ storedCodeBlock=storedCodeBlock.replaceAll(Pattern.quote("<"),"<");
+ s+="
";
+ storedCodeBlock=""+storedCodeBlock;
+ int startPos=0;
+ String endText=s.substring(s.indexOf("
")+"".length(),s.length());
+ s="";
+ for (int j=0;j";
+ startPos=j+1;
+ }
+ } else
+ if (!inString&&!inChar) {
+ if (canBeNumericalConstant&&validNumericalConstantCharacters(lengthOfConstant, j)) {
+ lengthOfConstant++;
+ System.out.println("Length of Constant now "+lengthOfConstant);
+ }
+ if (canBeNumericalConstant&&lengthOfConstant>0&&!(validNumericalConstantCharacters(lengthOfConstant, j))) {
+ s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+""+storedCodeBlock.charAt(j);
+ //System.out.println("Setting "+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j));
+ lengthOfConstant=0;
+ canBeNumericalConstant=false;
+ startPos=j+1;
+ } else
+ if (!canBeNumericalConstant&&storedCodeBlock.charAt(j)=='.') {
+ //Previous section was a member.
+ s+=SPAN("class")+storedCodeBlock.substring(startPos,j)+""+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>3&&storedCodeBlock.substring(j-3,j+1).equals("true")&&!isAlphanumeric(j-4)&&!isAlphanumeric(j+1)) {
+ s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"";
+ startPos=j+1;
+ } else
+ if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) {
+ s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"";
+ startPos=j+1;
+ } else
+ if (storedCodeBlock.charAt(j)=='(') {
+ s+=SPAN("function")+storedCodeBlock.substring(startPos,j)+""+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>0&&isAlphanumeric(j-1) && storedCodeBlock.charAt(j)==' '&&storedCodeBlock.charAt(j-1)!=' ') {
+ //Previous section was a keyword.
+ keyword=true;
+ s+=SPAN("keyword")+storedCodeBlock.substring(startPos,j)+""+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (j>0&&isAlphanumeric(j-1) && (storedCodeBlock.charAt(j)==';'||storedCodeBlock.charAt(j)==':')) {
+ //Previous section was a keyword.
+ //keyword=true;
+ s+=SPAN("keyword")+storedCodeBlock.substring(startPos,j)+""+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (keyword&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||storedCodeBlock.charAt(j)>='A'&&storedCodeBlock.charAt(j)<='Z'||storedCodeBlock.charAt(j)>='a'&&storedCodeBlock.charAt(j)<='z'||storedCodeBlock.charAt(j)==' ')) {
+ keyword=false;
+ s+=SPAN("variable")+storedCodeBlock.substring(startPos,j)+""+storedCodeBlock.charAt(j);
+ startPos=j+1;
+ } else
+ if (!isAlphanumeric(j)){
+ if (startPos='0'&&storedCodeBlock.charAt(j)<='9')) {
+ canBeNumericalConstant=false;
+ }
+ if (!canBeNumericalConstant&&!isAlphanumeric(j)) {
+ canBeNumericalConstant=true;
+ lengthOfConstant=0;
+ System.out.println("Found "+storedCodeBlock.charAt(j)+", can be numeric...");
+ }
+ }
+ s+=endText;
+ //System.out.println("Stored code block: "+storedCodeBlock);
+ } else
+ if (inCodeBlock) {
+ storedCodeBlock+=s+"\n";
+ s=" ";
+ }
+ }
+ if (s.length()>0&&isArticleFile(f)) {
+ //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+"\"");
+ //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");
+ } else
+ if (s.charAt(0)==':') {
+ //Image with caption.
+ //Format:
+ //:,,,
+ String[] splitter = s.split(Pattern.quote(","));
+ StringBuilder captionText = new StringBuilder(splitter[3]);
+ for (int j=4;j
"+captionText.toString()+"";
+ } else {
+ //It's regular content, so add paragraphs.
+ s="
"+s+"
";
+ }
+ } else
+ if (s.length()==0&&isArticleFile(f)) {
+ s="
"; //Setup a line break here.
+ }
+ for (String key : map.keySet()) {
+ s=s.replaceAll(Pattern.quote(key),map.get(key));
+ }
+ content.set(i,s);
+ }
+
+ System.out.println(" Writing to "+f.toAbsolutePath());
+
+ Files.write(f, content, Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE);
+
+ System.out.println(" "+f.getFileName() + " conversion complete!");
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ private static boolean validNumericalConstantCharacters(int lengthOfConstant, int j) {
+ return storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='.'||lengthOfConstant>0&&storedCodeBlock.charAt(j)>='A'&&lengthOfConstant>0&&storedCodeBlock.charAt(j)<='F'||lengthOfConstant>0&&storedCodeBlock.charAt(j)>='a'&&lengthOfConstant>0&&storedCodeBlock.charAt(j)<='f'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='x'||lengthOfConstant>0&&storedCodeBlock.charAt(j)=='X';
+ }
+ private static boolean isAlphanumeric(int j) {
+ return storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9'||storedCodeBlock.charAt(j)>='A'&&storedCodeBlock.charAt(j)<='Z'||storedCodeBlock.charAt(j)>='a'&&storedCodeBlock.charAt(j)<='z';
+ }
+ /**
+ * Writes a span tag with the included class.
+ * **/
+ private static String SPAN(String className) {
+ return "
";
+ }
+ private static void GenerateArticleFiles(Iterator items){
+ System.out.println(" Generating article files...");
+ while (items.hasNext()) {
+ Path f = items.next();
+ try {
+ 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(""));
+ StringBuilder sb = new StringBuilder();
+ for (String d : preContent) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\n");
+ }
+ for (String d : content) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ d=d.replaceFirst("div class=\"content\"","div class=\"expandedContent\"");
+ d=d.replaceFirst("","");
+ sb.append(d).append("\n");
+ }
+ for (String d : postContent) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\n");
+ }
+ Files.write(Paths.get(f.getParent().toString(),f.getFileName()+".html"),sb.toString().getBytes());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ private static void ConvertArticleReferences(Iterator items) {
+ while (items.hasNext()) {
+ Path f = items.next();
+ System.out.println(" Looking for Article References..."+f.getFileName());
+ boolean articleJavascriptIncluded=false;
+ if (Files.isRegularFile(f)&&isHTMLFile(f)) {
+ System.out.println(" Searching "+f.getFileName());
+ try {
+ List content = Files.readAllLines(f);
+ for (int i=0;i0&&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);
+ if (newData.size()>0) {
+ content.set(i,newData.get(0));
+ for (int j=1;j
⤈ Click to expand. ");
+ content.set(i+newData.size()-1,lastline);//
⤈ Click to expand.
");
+ } else {
+ content.set(i,"");
+ }
+ if (!articleJavascriptIncluded) {
+ List articlejs = Files.readAllLines(Paths.get(REFDIR,"article.js"));
+ for (int j=articlejs.size()-1;j>=0;j--) {
+ content.add(i,articlejs.get(j));
+ }
+ articleJavascriptIncluded=true;
+ }
+ }
+ }
+ Files.write(f,content);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ static void copyDirectory(String sourceDirectoryLocation, String destinationDirectoryLocation)
+ throws IOException {
+ Files.walk(Paths.get(sourceDirectoryLocation))
+ .forEach(source -> {
+ Path destination = Paths.get(destinationDirectoryLocation, source.toString()
+ .substring(sourceDirectoryLocation.length()));
+ try {
+ if (Files.isDirectory(destination)) {
+ Files.createDirectories(destination);
+ } else {
+ Files.copy(source, destination, new CopyOption[]{StandardCopyOption.COPY_ATTRIBUTES,StandardCopyOption.REPLACE_EXISTING});
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ }
+ static void buildDirectoryListings()
+ throws IOException {
+ String startingPath=Paths.get(sigPlace.OUTDIR).toAbsolutePath().toString();
+ HashMap> map = new HashMap<>();
+ Iterator it = Files.walk(Paths.get(sigPlace.OUTDIR)).iterator();
+ map.put("/",new ArrayList());
+ while (it.hasNext()) {
+ Path f = it.next();
+ if (!f.getFileName().toString().equals(OUTDIR)) {
+ String myKey = f.toAbsolutePath().toString().replace(startingPath,"").replace(f.getFileName().toString(),"");
+ //System.out.println(myKey+","+f);
+ map.putIfAbsent(myKey,new ArrayList());
+ map.get(myKey).add(f);
+ }
+ }
+ System.out.println("Directory structure determined:");
+ System.out.println(" "+map);
+ 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(""));
+ for (String d : data) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\n");
+ }
+ sb.append("Directory Listing for "+key+"
");
+ sb.append("");
+ for (Path f : map.get(key)) {
+ sb.append("\n");
+ }
+ for (String d : data2) {
+ for (String k : sigPlace.map.keySet()) {
+ d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k));
+ }
+ sb.append(d).append("\n");
+ }
+ Path newf = Files.write(Paths.get(OUTDIR,key,DIRECTORYLISTING_FILENAME),sb.toString().getBytes());
+ System.out.println(" Added info for ("+map.size()+") files to "+newf.toAbsolutePath());
+ }
+ }
+ private static boolean isArticleFile(Path f) {
+ return f.getFileName().toString().contains(".article");
+ }
+ private static boolean isHTMLFile(Path f) {
+ return f.getFileName().toString().contains(".html");
+ }
+ private static void ExportCodeFile() {
+ try {
+ Path file = Paths.get("sigServer.java");
+ List data = Files.readAllLines(file);
+ int i=0;
+ while (!data.get(i++).contains("sigServer()")&&i
===3 May 2022 10:25AM
\ No newline at end of file