diff --git a/out/DIRECTORY_LISTING b/out/DIRECTORY_LISTING index 23c9d7e..0d8ab62 100644 --- a/out/DIRECTORY_LISTING +++ b/out/DIRECTORY_LISTING @@ -17,14 +17,14 @@
-

Directory Listing for /

📁.. (Previous Directory)
📁articles 2022-07-26T15:21:39.694961518Z codespace 4096
-
📁images 2022-07-26T15:21:39.690961447Z codespace 4096
-
🗎uploadform.html 2022-07-26T15:21:39.618960169Z codespace 884
-
🗎codeBackground 2022-07-26T15:21:39.594959742Z codespace 2635
-
🗎otherpage.html 2022-07-26T15:21:39.598959813Z codespace 941
-
🗎reset.css 2022-07-26T15:21:39.598959813Z codespace 1093
-
🗎sig.css 2022-07-26T15:21:39.614960098Z codespace 6238
-
🗎testfile.html 2022-07-26T15:21:39.626960311Z codespace 804
+

Directory Listing for /

📁.. (Previous Directory)
📁articles 2022-07-26T16:55:19.921725Z gitpod 4096
+
🗎codeBackground 2022-07-26T16:55:19.837725Z gitpod 2635
+
🗎otherpage.html 2022-07-26T16:55:19.841725Z gitpod 941
+
🗎reset.css 2022-07-26T16:55:19.845725Z gitpod 1093
+
🗎uploadform.html 2022-07-26T16:55:19.865725Z gitpod 884
+
📁images 2022-07-26T16:55:19.917725Z gitpod 58
+
🗎sig.css 2022-07-26T16:55:19.857725Z gitpod 6274
+
🗎testfile.html 2022-07-26T16:55:19.869725Z gitpod 804
diff --git a/out/articles/DIRECTORY_LISTING b/out/articles/DIRECTORY_LISTING index 41bfcf9..2ff947a 100644 --- a/out/articles/DIRECTORY_LISTING +++ b/out/articles/DIRECTORY_LISTING @@ -17,13 +17,13 @@
-

Directory Listing for /articles/

📁.. (Previous Directory)
🗎Love Live! Custom Arcade Controller.article.html 2022-07-26T15:21:39.626960311Z codespace 1214
-
🗎Love Live! Custom Arcade Controller.article 2022-07-26T15:21:39.03894987Z codespace 497
-
🗎sigplace1.article.html 2022-07-26T15:21:39.678961234Z codespace 74556
-
🗎curabitur vel tempus ex.article 2022-07-26T15:21:39.054950154Z codespace 734
-
📁test articles 2022-07-26T15:21:39.646960666Z codespace 4096
-
🗎curabitur vel tempus ex.article.html 2022-07-26T15:21:39.638960524Z codespace 1451
-
🗎sigplace1.article 2022-07-26T15:21:39.590959671Z codespace 73839
+

Directory Listing for /articles/

📁.. (Previous Directory)
🗎Love Live! Custom Arcade Controller.article 2022-07-26T16:55:19.405725Z gitpod 497
+
📁test articles 2022-07-26T16:55:19.877725Z gitpod 147
+
🗎curabitur vel tempus ex.article 2022-07-26T16:55:19.433725Z gitpod 734
+
🗎sigplace1.article 2022-07-26T16:55:19.837725Z gitpod 81848
+
🗎Love Live! Custom Arcade Controller.article.html 2022-07-26T16:55:19.869725Z gitpod 1214
+
🗎curabitur vel tempus ex.article.html 2022-07-26T16:55:19.885725Z gitpod 1451
+
🗎sigplace1.article.html 2022-07-26T16:55:19.909725Z gitpod 82565
diff --git a/out/articles/curabitur vel tempus ex.article b/out/articles/curabitur vel tempus ex.article index 063ee1a..464bfd3 100644 --- a/out/articles/curabitur vel tempus ex.article +++ b/out/articles/curabitur vel tempus ex.article @@ -1,11 +1,11 @@

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.


-

+

 <><Test>"</test></test2><test3>"
             
diff --git a/out/articles/curabitur vel tempus ex.article.html b/out/articles/curabitur vel tempus ex.article.html index e94590b..fb19fc4 100644 --- a/out/articles/curabitur vel tempus ex.article.html +++ b/out/articles/curabitur vel tempus ex.article.html @@ -18,13 +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.


-

+

 <><Test>"</test></test2><test3>"
             
diff --git a/out/articles/sigplace1.article b/out/articles/sigplace1.article index e4e49a0..ea5b9c3 100644 --- a/out/articles/sigplace1.article +++ b/out/articles/sigplace1.article @@ -51,7 +51,6 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid
-
@@ -60,7 +59,8 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid -
+ +
@@ -514,24 +514,26 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid 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; + /* Test giant multi-line comment "" + 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\" %ID%>"), + new AbstractMap.SimpleEntry<>("$TITLE_CONTENT_START", "<div class=\"contentWrapper\"><h1>"), + new AbstractMap.SimpleEntry<>("$TITLE_CONTENT_END", "</h1><div class=\"content\" %ID%>"), new AbstractMap.SimpleEntry<>("$CONTENT_END", "</div>"), - new AbstractMap.SimpleEntry<>("$DATE_CONTENT_START", "<div class=\"datebar\"></div><div class=\"date\">") + 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<>( @@ -550,7 +552,7 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid PORT=Integer.parseInt(arg2); System.out.println("Port set to "+PORT+"."); } else { - System.err.println("Invalid argument \""+arg1+"\"."); + System.err.println("Invalid argument \""+arg1+"\"."); return; } } @@ -597,11 +599,11 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid System.out.println(" Parsing "+f.getFileName()); for (int i=0;i<content.size();i++) { String s = content.get(i); - //System.out.println(s); + //System.out.println(s); if (s.length()>0&&(isHTMLFile(f)||isArticleFile(f))) { if (!inCodeBlock) { if (s.contains("<pre>")) { - //System.out.println("Inside <pre>"); + //System.out.println("Inside <pre>"); inCodeBlock=true; storedCodeBlock=""; s=s.substring(0,s.indexOf("<pre>")); @@ -622,12 +624,12 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid String endText=s.substring(s.indexOf("</pre>")+"</pre>".length(),s.length()); s=""; for (int j=0;j<storedCodeBlock.length();j++) { - if (storedCodeBlock.charAt(j)==""") { + if (storedCodeBlock.charAt(j)=='"') { inString=!inString; if (inString) { - s+=SPAN("string")+"\""; - } else { - s+="\"</span>"; + s+=SPAN("string")+"\""; + } else { + s+="\"</span>"; startPos=j+1; } } else @@ -638,13 +640,13 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid } if (canBeNumericalConstant&&lengthOfConstant>0&&!(validNumericalConstantCharacters(lengthOfConstant, j))) { s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j); - //System.out.println("Setting "+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. + if (!canBeNumericalConstant&&storedCodeBlock.charAt(j)=='.') { + //Previous section was a member. s+=SPAN("class")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j); startPos=j+1; } else @@ -656,23 +658,23 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>"; startPos=j+1; } else - if (storedCodeBlock.charAt(j)=="(") { + if (storedCodeBlock.charAt(j)=='(') { s+=SPAN("function")+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. + 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)+"</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; + 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)+"</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)==" ")) { + 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)+"</span>"+storedCodeBlock.charAt(j); startPos=j+1; @@ -689,7 +691,7 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid s+=storedCodeBlock.charAt(j); startPos=j+1; } - if (canBeNumericalConstant&&lengthOfConstant==0&&!(storedCodeBlock.charAt(j)>="0"&&storedCodeBlock.charAt(j)<="9")) { + if (canBeNumericalConstant&&lengthOfConstant==0&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9')) { canBeNumericalConstant=false; } if (!canBeNumericalConstant&&!isAlphanumeric(j)) { @@ -699,7 +701,7 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid } } s+=endText; - //System.out.println("Stored code block: "+storedCodeBlock); + //System.out.println("Stored code block: "+storedCodeBlock); } else if (inCodeBlock) { storedCodeBlock+=s+"\n"; @@ -707,33 +709,33 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid } } if (s.length()>0&&isArticleFile(f)) { - //Check for markdown pieces. - if (s.charAt(0)=="-") { - //Start of a title piece. + //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%","id=\"content_"+f+"\""); - //Use if "s more text to be shown than can fit. + s=s+map.get("$TITLE_CONTENT_END").replace("%ID%","id=\"content_"+f+"\""); + //Use ⤈ if there's more text to be shown than can fit. } else - if (s.contains("===")) { - s=map.get("$CONTENT_END")+map.get("$DATE_CONTENT_START")+s.replace("===","")+map.get("$CONTENT_END")+"%CONDITIONAL_EXPAND%"+map.get("$CONTENT_END"); - } 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]); + if (s.contains("===")) { + s=map.get("$CONTENT_END")+map.get("$DATE_CONTENT_START")+s.replace("===","")+map.get("$CONTENT_END")+"%CONDITIONAL_EXPAND%"+map.get("$CONTENT_END"); + } else + if (s.charAt(0)==':') { + //Image with caption. + //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=\""+(((int)(COLOR_ROTATION=(COLOR_ROTATION+0.4)%6))+1)+"\">"+s+"</p>"; + 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. + s="<br/>"; //Setup a line break here. } for (String key : map.keySet()) { s=s.replaceAll(Pattern.quote(key),map.get(key)); @@ -751,16 +753,16 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid } } 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"; + 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"; + 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. - * **/ + /** + * Writes a span tag with the included class. + * **/ private static String SPAN(String className) { - return "<span class=\""+className+"\">"; + return "<span class=\""+className+"\">"; } private static void GenerateArticleFiles(Iterator<Path> items){ System.out.println(" Generating article files..."); @@ -783,7 +785,7 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid 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("div class=\"content\"","div class=\"expandedContent\""); d=d.replaceFirst("%CONDITIONAL_EXPAND%",""); sb.append(d).append("\n"); } @@ -822,122 +824,122 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid content.add(i+j, newData.get(j)); } String lastline=content.get(i+newData.size()-1); - lastline=lastline.replace("%CONDITIONAL_EXPAND%","<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand(this,""+Paths.get(OUTDIR,article.toString())+"")\"><br/><br/><br/><br/>⤈ Click to expand.</div>"); - content.set(i+newData.size()-1,lastline);//<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand("+i+")\"><br/><br/><br/><br/>&#x2908; Click to expand.</div>"); - } else { - content.set(i,""); + lastline=lastline.replace("%CONDITIONAL_EXPAND%","<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand(this,'"+Paths.get(OUTDIR,article.toString())+"')\"><br/><br/><br/><br/>⤈ 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.")); - for (int j=articlejs.size()-1;j>=0;j--) { - content.add(i,articlejs.get(j)); + 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; + articleJavascriptIncluded=true; } } } - Files.write(f,content); - } catch (IOException e) { - e.printStackTrace(); + 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}); + 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(); + } 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); + 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)); + 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("%DEFAULT")); + List<String> data2 = Files.readAllLines(ops.get("%FOOTER")); + for (String d : data) { + for (String k : sigPlace.map.keySet()) { + d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k)); } - sb.append(d).append("\"); + sb.append(d).append("\n"); } - sb.append("<h2>Directory Listing for "+key+"</h2>"); - sb.append("<div class=\"folderlisting\"><a href=\"") + sb.append("<h2>Directory Listing for "+key+"</h2>"); + sb.append("<div class=\"folderlisting\"><a href=\"") .append(key) - .append("..\" class=\"icon\">&#x1F4C1;</a><a href=\"") + .append("..\" class=\"icon\">📁</a><a href=\"") .append(key) - .append("..\">.. </a><a href=\"") + .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)?"folderlisting":"filelisting")).append("\">") - .append("<a href=\""+(f.toAbsolutePath().toString().replace(Paths.get(OUTDIR).toAbsolutePath().toString(),""))+"\" class=\"icon\">") - .append((Files.isDirectory(f)?"&#x1F4C1;":"&#x1F5CE;")) - .append("</a>") - .append("<a href=\""+(f.toAbsolutePath().toString().replace(Paths.get(OUTDIR).toAbsolutePath().toString(),""))+"\">") - .append(f.getFileName()) - .append("</a>\") - .append(Files.getLastModifiedTime(f)) - .append("\") - .append(Files.getOwner(f)) - .append("\") - .append(Files.size(f)) - .append("</div>\"); + .append("..\" class=\"nounderline\">(Previous Directory)</a></div>"); + for (Path f : map.get(key)) { + sb.append("<div class=\"").append((Files.isDirectory(f)?"folderlisting":"filelisting")).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)); + for (String d : data2) { + for (String k : sigPlace.map.keySet()) { + d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k)); } - sb.append(d).append("\"); + 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()); + 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("."); + private static boolean isArticleFile(Path f) { + return f.getFileName().toString().contains(".article"); } - private static boolean isHTMLFile(Path f) { - return f.getFileName().toString().contains("."); + private static boolean isHTMLFile(Path f) { + return f.getFileName().toString().contains(".html"); } - private static void ExportCodeFile() { - try { - Path file = Paths.get("sigServer."); - 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,""),data.subList(i, Math.min(i+40,data.size())),Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE); + 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(); + } catch (IOException e) { + e.printStackTrace(); } } diff --git a/out/articles/sigplace1.article.html b/out/articles/sigplace1.article.html index 63a6fa5..5e437bc 100644 --- a/out/articles/sigplace1.article.html +++ b/out/articles/sigplace1.article.html @@ -70,7 +70,6 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid
-
@@ -79,7 +78,8 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid -
+ +
@@ -533,24 +533,26 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid 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; + /* Test giant multi-line comment "" + 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\" %ID%>"), + new AbstractMap.SimpleEntry<>("$TITLE_CONTENT_START", "<div class=\"contentWrapper\"><h1>"), + new AbstractMap.SimpleEntry<>("$TITLE_CONTENT_END", "</h1><div class=\"content\" %ID%>"), new AbstractMap.SimpleEntry<>("$CONTENT_END", "</div>"), - new AbstractMap.SimpleEntry<>("$DATE_CONTENT_START", "<div class=\"datebar\"></div><div class=\"date\">") + 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<>( @@ -569,7 +571,7 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid PORT=Integer.parseInt(arg2); System.out.println("Port set to "+PORT+"."); } else { - System.err.println("Invalid argument \""+arg1+"\"."); + System.err.println("Invalid argument \""+arg1+"\"."); return; } } @@ -616,11 +618,11 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid System.out.println(" Parsing "+f.getFileName()); for (int i=0;i<content.size();i++) { String s = content.get(i); - //System.out.println(s); + //System.out.println(s); if (s.length()>0&&(isHTMLFile(f)||isArticleFile(f))) { if (!inCodeBlock) { if (s.contains("<pre>")) { - //System.out.println("Inside <pre>"); + //System.out.println("Inside <pre>"); inCodeBlock=true; storedCodeBlock=""; s=s.substring(0,s.indexOf("<pre>")); @@ -641,12 +643,12 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid String endText=s.substring(s.indexOf("</pre>")+"</pre>".length(),s.length()); s=""; for (int j=0;j<storedCodeBlock.length();j++) { - if (storedCodeBlock.charAt(j)==""") { + if (storedCodeBlock.charAt(j)=='"') { inString=!inString; if (inString) { - s+=SPAN("string")+"\""; - } else { - s+="\"</span>"; + s+=SPAN("string")+"\""; + } else { + s+="\"</span>"; startPos=j+1; } } else @@ -657,13 +659,13 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid } if (canBeNumericalConstant&&lengthOfConstant>0&&!(validNumericalConstantCharacters(lengthOfConstant, j))) { s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j); - //System.out.println("Setting "+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. + if (!canBeNumericalConstant&&storedCodeBlock.charAt(j)=='.') { + //Previous section was a member. s+=SPAN("class")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j); startPos=j+1; } else @@ -675,23 +677,23 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>"; startPos=j+1; } else - if (storedCodeBlock.charAt(j)=="(") { + if (storedCodeBlock.charAt(j)=='(') { s+=SPAN("function")+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. + 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)+"</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; + 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)+"</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)==" ")) { + 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)+"</span>"+storedCodeBlock.charAt(j); startPos=j+1; @@ -708,7 +710,7 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid s+=storedCodeBlock.charAt(j); startPos=j+1; } - if (canBeNumericalConstant&&lengthOfConstant==0&&!(storedCodeBlock.charAt(j)>="0"&&storedCodeBlock.charAt(j)<="9")) { + if (canBeNumericalConstant&&lengthOfConstant==0&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9')) { canBeNumericalConstant=false; } if (!canBeNumericalConstant&&!isAlphanumeric(j)) { @@ -718,7 +720,7 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid } } s+=endText; - //System.out.println("Stored code block: "+storedCodeBlock); + //System.out.println("Stored code block: "+storedCodeBlock); } else if (inCodeBlock) { storedCodeBlock+=s+"\n"; @@ -726,33 +728,33 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid } } if (s.length()>0&&isArticleFile(f)) { - //Check for markdown pieces. - if (s.charAt(0)=="-") { - //Start of a title piece. + //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%","id=\"content_"+f+"\""); - //Use if "s more text to be shown than can fit. + s=s+map.get("$TITLE_CONTENT_END").replace("%ID%","id=\"content_"+f+"\""); + //Use ⤈ if there's more text to be shown than can fit. } else - if (s.contains("===")) { - s=map.get("$CONTENT_END")+map.get("$DATE_CONTENT_START")+s.replace("===","")+map.get("$CONTENT_END")+"%CONDITIONAL_EXPAND%"+map.get("$CONTENT_END"); - } 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]); + if (s.contains("===")) { + s=map.get("$CONTENT_END")+map.get("$DATE_CONTENT_START")+s.replace("===","")+map.get("$CONTENT_END")+"%CONDITIONAL_EXPAND%"+map.get("$CONTENT_END"); + } else + if (s.charAt(0)==':') { + //Image with caption. + //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=\""+(((int)(COLOR_ROTATION=(COLOR_ROTATION+0.4)%6))+1)+"\">"+s+"</p>"; + 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. + s="<br/>"; //Setup a line break here. } for (String key : map.keySet()) { s=s.replaceAll(Pattern.quote(key),map.get(key)); @@ -770,16 +772,16 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid } } 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"; + 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"; + 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. - * **/ + /** + * Writes a span tag with the included class. + * **/ private static String SPAN(String className) { - return "<span class=\""+className+"\">"; + return "<span class=\""+className+"\">"; } private static void GenerateArticleFiles(Iterator<Path> items){ System.out.println(" Generating article files..."); @@ -802,7 +804,7 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid 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("div class=\"content\"","div class=\"expandedContent\""); d=d.replaceFirst("%CONDITIONAL_EXPAND%",""); sb.append(d).append("\n"); } @@ -841,122 +843,122 @@ Here we demonstrate the love live logo. But wait, it's literally like in the mid content.add(i+j, newData.get(j)); } String lastline=content.get(i+newData.size()-1); - lastline=lastline.replace("%CONDITIONAL_EXPAND%","<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand(this,""+Paths.get(OUTDIR,article.toString())+"")\"><br/><br/><br/><br/>⤈ Click to expand.</div>"); - content.set(i+newData.size()-1,lastline);//<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand("+i+")\"><br/><br/><br/><br/>&#x2908; Click to expand.</div>"); - } else { - content.set(i,""); + lastline=lastline.replace("%CONDITIONAL_EXPAND%","<div class=\"unexpanded\" id=\"expand_"+i+"\" onClick=\"expand(this,'"+Paths.get(OUTDIR,article.toString())+"')\"><br/><br/><br/><br/>⤈ 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.")); - for (int j=articlejs.size()-1;j>=0;j--) { - content.add(i,articlejs.get(j)); + 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; + articleJavascriptIncluded=true; } } } - Files.write(f,content); - } catch (IOException e) { - e.printStackTrace(); + 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}); + 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(); + } 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); + 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)); + 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("%DEFAULT")); + List<String> data2 = Files.readAllLines(ops.get("%FOOTER")); + for (String d : data) { + for (String k : sigPlace.map.keySet()) { + d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k)); } - sb.append(d).append("\"); + sb.append(d).append("\n"); } - sb.append("<h2>Directory Listing for "+key+"</h2>"); - sb.append("<div class=\"folderlisting\"><a href=\"") + sb.append("<h2>Directory Listing for "+key+"</h2>"); + sb.append("<div class=\"folderlisting\"><a href=\"") .append(key) - .append("..\" class=\"icon\">&#x1F4C1;</a><a href=\"") + .append("..\" class=\"icon\">📁</a><a href=\"") .append(key) - .append("..\">.. </a><a href=\"") + .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)?"folderlisting":"filelisting")).append("\">") - .append("<a href=\""+(f.toAbsolutePath().toString().replace(Paths.get(OUTDIR).toAbsolutePath().toString(),""))+"\" class=\"icon\">") - .append((Files.isDirectory(f)?"&#x1F4C1;":"&#x1F5CE;")) - .append("</a>") - .append("<a href=\""+(f.toAbsolutePath().toString().replace(Paths.get(OUTDIR).toAbsolutePath().toString(),""))+"\">") - .append(f.getFileName()) - .append("</a>\") - .append(Files.getLastModifiedTime(f)) - .append("\") - .append(Files.getOwner(f)) - .append("\") - .append(Files.size(f)) - .append("</div>\"); + .append("..\" class=\"nounderline\">(Previous Directory)</a></div>"); + for (Path f : map.get(key)) { + sb.append("<div class=\"").append((Files.isDirectory(f)?"folderlisting":"filelisting")).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)); + for (String d : data2) { + for (String k : sigPlace.map.keySet()) { + d=d.replaceAll(Pattern.quote(k),sigPlace.map.get(k)); } - sb.append(d).append("\"); + 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()); + 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("."); + private static boolean isArticleFile(Path f) { + return f.getFileName().toString().contains(".article"); } - private static boolean isHTMLFile(Path f) { - return f.getFileName().toString().contains("."); + private static boolean isHTMLFile(Path f) { + return f.getFileName().toString().contains(".html"); } - private static void ExportCodeFile() { - try { - Path file = Paths.get("sigServer."); - 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,""),data.subList(i, Math.min(i+40,data.size())),Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE); + 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(); + } catch (IOException e) { + e.printStackTrace(); } } diff --git a/out/articles/test articles/DIRECTORY_LISTING b/out/articles/test articles/DIRECTORY_LISTING index 4e27e2a..a772710 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/

🗎test1.article.html 2022-07-26T15:21:39.642960595Z codespace 1802
-
🗎test3.article 2022-07-26T15:21:39.058950225Z codespace 994
-
🗎test2.article.html 2022-07-26T15:21:39.646960666Z codespace 1498
-
🗎test3.article.html 2022-07-26T15:21:39.642960595Z codespace 1711
-
🗎test1.article 2022-07-26T15:21:39.058950225Z codespace 1085
-
🗎test2.article 2022-07-26T15:21:39.062950296Z codespace 781
+

Directory Listing for /articles/test articles/

🗎test1.article 2022-07-26T16:55:19.405725Z gitpod 1085
+
🗎test2.article 2022-07-26T16:55:19.409725Z gitpod 781
+
🗎test3.article 2022-07-26T16:55:19.409725Z gitpod 994
+
🗎test1.article.html 2022-07-26T16:55:19.873725Z gitpod 1802
+
🗎test2.article.html 2022-07-26T16:55:19.873725Z gitpod 1498
+
🗎test3.article.html 2022-07-26T16:55:19.877725Z gitpod 1711
diff --git a/out/articles/test articles/test1.article b/out/articles/test articles/test1.article index 7e7a894..540970a 100644 --- a/out/articles/test articles/test1.article +++ b/out/articles/test articles/test1.article @@ -1,5 +1,5 @@

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
%CONDITIONAL_EXPAND%
diff --git a/out/articles/test articles/test1.article.html b/out/articles/test articles/test1.article.html index 420c747..b094135 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.

2 May 2022 10:16AM
diff --git a/out/articles/test articles/test2.article b/out/articles/test articles/test2.article index 88a8f40..97c3dd5 100644 --- a/out/articles/test articles/test2.article +++ b/out/articles/test articles/test2.article @@ -1,5 +1,5 @@

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
%CONDITIONAL_EXPAND%
diff --git a/out/articles/test articles/test2.article.html b/out/articles/test articles/test2.article.html index 8dcadea..0790e37 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.

1 May 2022 05:13AM
diff --git a/out/images/DIRECTORY_LISTING b/out/images/DIRECTORY_LISTING index 5980e01..1933353 100644 --- a/out/images/DIRECTORY_LISTING +++ b/out/images/DIRECTORY_LISTING @@ -17,7 +17,7 @@
-

Directory Listing for /images/

🗎Love_Live!_Logo.png 2022-07-26T15:15:09.668054Z codespace 12167
+

Directory Listing for /images/

🗎Love_Live!_Logo.png 2022-07-26T15:25:37.713993Z gitpod 12167
diff --git a/out/sig.css b/out/sig.css index 7bb9e20..9d8472b 100644 --- a/out/sig.css +++ b/out/sig.css @@ -245,7 +245,7 @@ sup{ pre{ font-family:'Courier New', Courier, monospace; padding:3px; - font-size:1.25em; + font-size:1.15em; position:relative; width:85vw; color:darkseagreen; @@ -275,3 +275,7 @@ pre .string{ pre .number{ color:#d8f070; } + +pre .comment{ + color:#6b235e; +} diff --git a/sigPlace.java b/sigPlace.java index 716b6f3..5acc2d0 100644 --- a/sigPlace.java +++ b/sigPlace.java @@ -127,8 +127,9 @@ public class sigPlace { inCodeBlock=false; boolean keyword=false; boolean inString=false; + boolean inComment=false; + boolean inMultiLineComment=false; char stringChar=' '; - boolean inChar=false; boolean canBeNumericalConstant=false; int lengthOfConstant=0; storedCodeBlock+=s.substring(0,s.indexOf("")); @@ -138,21 +139,49 @@ public class sigPlace { String endText=s.substring(s.indexOf("")+"".length(),s.length()); s=""; for (int j=0;j"; + startPos=j+1; + } + if (!inComment&&!inMultiLineComment&&(j>0&&storedCodeBlock.charAt(j-1)!='\\'&&(!inString&&(storedCodeBlock.charAt(j)=='"'||storedCodeBlock.charAt(j)=='\'')||inString&&(storedCodeBlock.charAt(j)==stringChar)))) { inString=!inString; if (inString) { stringChar=storedCodeBlock.charAt(j); - s+=SPAN("string")+"\""; + s+=SPAN("string")+stringChar; } else { - s+="\""; + s+=stringChar; + s+=""; startPos=j+1; } } else - if (!inString&&!inChar) { + if (!inString) { if (canBeNumericalConstant&&validNumericalConstantCharacters(lengthOfConstant, j)) { lengthOfConstant++; System.out.println("Length of Constant now "+lengthOfConstant); } + if (j>0&&storedCodeBlock.charAt(j)=='/'&&storedCodeBlock.charAt(j+1)=='*'||inMultiLineComment) { + if (!inMultiLineComment) { + inMultiLineComment=true; + } else { + if (storedCodeBlock.charAt(j-1)=='*'&&storedCodeBlock.charAt(j)=='/') { + inMultiLineComment=false; + s+=SPAN("comment")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+""; + startPos=j+1; + } + } + //Stops further execution since we're in a comment. + } else + if (j>0&&storedCodeBlock.charAt(j)=='/'&&storedCodeBlock.charAt(j+1)=='/'||inComment) { + if (!inComment) { + inComment=true; + } + //Stops further execution since we're in a comment. + } else 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)); @@ -189,7 +218,7 @@ public class sigPlace { 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)==' ')) { + if (keyword&&!(storedCodeBlock.charAt(j)=='_'||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; diff --git a/sitefiles/articles/sigplace1.article b/sitefiles/articles/sigplace1.article index bb908ce..e5c8420 100644 --- a/sitefiles/articles/sigplace1.article +++ b/sitefiles/articles/sigplace1.article @@ -33,7 +33,7 @@ import java.util.Map; import java.util.regex.Pattern; public class sigPlace { - + /* Test giant multi-line comment "" final static String ROOTDIR = "sitefiles"; final static String REFDIR = "ref"; final static String OUTDIR = "out"; @@ -42,7 +42,7 @@ public class sigPlace { 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; diff --git a/sitefiles/sig.css b/sitefiles/sig.css index e3766e0..b1b5643 100644 --- a/sitefiles/sig.css +++ b/sitefiles/sig.css @@ -245,7 +245,7 @@ sup{ pre{ font-family:'Courier New', Courier, monospace; padding:3px; - font-size:1.25em; + font-size:1.15em; position:relative; width:85vw; color:darkseagreen; @@ -274,4 +274,8 @@ pre .string{ pre .number{ color:#d8f070; +} + +pre .comment{ + color:#6b235e; } \ No newline at end of file