diff --git a/bin/sigPlace.class b/bin/sigPlace.class index 1b6dcb6..b21d2c1 100644 Binary files a/bin/sigPlace.class and b/bin/sigPlace.class differ diff --git a/bin/sigServer.class b/bin/sigServer.class index 99337b0..569748a 100644 Binary files a/bin/sigServer.class and b/bin/sigServer.class differ diff --git a/sigPlace.jar b/sigPlace.jar index c9fe6cb..e19c70b 100644 Binary files a/sigPlace.jar and b/sigPlace.jar differ diff --git a/sigPlace.java b/sigPlace.java index 4cb2676..8abf93b 100644 --- a/sigPlace.java +++ b/sigPlace.java @@ -154,7 +154,7 @@ public class sigPlace { } } else { populateDatabase(); - /*String fontName = "sdvx_EXScore"; + /*String fontName = "sdvx_EXScore"; String value = "00457"; Path f = Paths.get("tests","sdvx8.png"); BufferedImage img; @@ -198,7 +198,7 @@ public class sigPlace { ArcadeReader.submitToDatabase(Paths.get("tests","sdvx4.png"));*/ //System.out.println(RECENT_PLAYS); //System.out.println(RECENT_RECORDS); - /* Path secretFile = Paths.get(".clientsecret"); + Path secretFile = Paths.get(".clientsecret"); List data; try { data = Files.readAllLines(secretFile); @@ -256,256 +256,256 @@ public class sigPlace { System.out.println("\nStarting web server..."); new sigServer(); } + } - private static String JSON(HashMap testMap) { - StringBuilder sb = new StringBuilder(); - String temp = testMap.toString(); - if (temp.charAt(0)=='{') { - sb.append("{"); - int marker=1; - boolean ending=false; - while (marker testMap) { + StringBuilder sb = new StringBuilder(); + String temp = testMap.toString(); + if (temp.charAt(0)=='{') { + sb.append("{"); + int marker=1; + boolean ending=false; + while (marker items) { - while (items.hasNext()) { - Path f = items.next(); - System.out.println(" Found "+f.getFileName()); - if (Files.isRegularFile(f)) { - try { + return sb.toString(); + } + 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()); + System.out.println(" Preparing "+f.getFileName()); - List content = Files.readAllLines(f); - if (isHTMLFile(f)) { - content.addAll(0,Files.readAllLines(ops.get("%NAVBAR"))); - content.addAll(0,Files.readAllLines(ops.get("%DEFAULT"))); - content.addAll(Files.readAllLines(ops.get("%FOOTER"))); - } + List content = Files.readAllLines(f); + if (isHTMLFile(f)) { + content.addAll(0,Files.readAllLines(ops.get("%NAVBAR"))); + content.addAll(0,Files.readAllLines(ops.get("%DEFAULT"))); + content.addAll(Files.readAllLines(ops.get("%FOOTER"))); + } - System.out.println(" Parsing "+f.getFileName()); - for (int i=0;i0&&(isHTMLFile(f)||isArticleFile(f))) { - if (!inCodeBlock) { - if (s.trim().equals("
")) {
-                                        //System.out.println("Inside 
");
-                                        inCodeBlock=true;
-                                        storedCodeBlock="";
-                                        s=s.substring(0,s.indexOf("
"));
-                                    }
+                    System.out.println("  Parsing "+f.getFileName());
+                    for (int i=0;i0&&(isHTMLFile(f)||isArticleFile(f))) {
+                            if (!inCodeBlock) {
+                                if (s.trim().equals("
")) {
+                                    //System.out.println("Inside 
");
+                                    inCodeBlock=true;
+                                    storedCodeBlock="";
+                                    s=s.substring(0,s.indexOf("
"));
                                 }
-                                if (inCodeBlock&&s.trim().equals("
")) { - inCodeBlock=false; - boolean keyword=false; - boolean inString=false; - boolean inComment=false; - boolean inMultiLineComment=false; - char stringChar=' '; - boolean canBeNumericalConstant=false; - int lengthOfConstant=0; - 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=""; - for (int j=0;j")) { + inCodeBlock=false; + boolean keyword=false; + boolean inString=false; + boolean inComment=false; + boolean inMultiLineComment=false; + char stringChar=' '; + boolean canBeNumericalConstant=false; + int lengthOfConstant=0; + 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=""; + 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")+stringChar; + } else { + s+=stringChar; s+=""; - } else - if (storedCodeBlock.charAt(j)=='\n'&&inComment) { - inComment=false; - s+=SPAN("comment")+storedCodeBlock.substring(startPos,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")+stringChar; + } else + 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 { - s+=stringChar; - s+=""; - startPos=j+1; + 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 (!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)=='/'||inComment) { + if (!inComment) { + inComment=true; } - 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)); - 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)=='_'||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 (startPos0&&!(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)=='_'||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..."); - } + } else { + s+=storedCodeBlock.charAt(j); + startPos=j+1; } - for (int j=0;j='0'&&storedCodeBlock.charAt(j)<='9')) { + canBeNumericalConstant=false; } - s="
"+s;
-                                    s+=endText;
-                                    endPreLine=true;
-                                    //System.out.println("Stored code block: "+storedCodeBlock);
-                                } else 
-                                if (inCodeBlock) {
-                                    storedCodeBlock+=s+"\n";
-                                    s=" ";
-                                }
-                            }
-                            if (s.length()>0&&isArticleFile(f)&&!inCodeBlock) {
-                                //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 there's more text to be shown than can fit.
-                                } else
-                                if (s.startsWith("===")) {
-                                    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:
-                                    //:,,,
-                                    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="

\n"+s+"\n

"; } - } else { - if (s.length()==0&&isArticleFile(f)&&!inCodeBlock) { - s="
"; //Setup a line break here. + for (int j=0;j0&&isArticleFile(f)&&!inCodeBlock) { + //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 there's more text to be shown than can fit. + } else + if (s.startsWith("===")) { + 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: + //:,,, + String[] splitter = s.split(Pattern.quote(",")); + StringBuilder captionText = new StringBuilder(splitter[3]); + for (int j=4;j
"+captionText.toString()+"
"; } else { - content.set(i,s); + //It's regular content, so add paragraphs. + s="

\n"+s+"\n

"; + } + } else { + if (s.length()==0&&isArticleFile(f)&&!inCodeBlock) { + s="
"; //Setup a line break here. + } + } + if (!endPreLine) { + for (String key : map.keySet()) { + s=s.replaceAll(Pattern.quote(key),map.get(key)); } } + if (s.trim().length()==0) { + content.remove(i--); + } else { + content.set(i,s); + } + } - System.out.println(" Writing to "+f.toAbsolutePath()); + 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!"); + 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(); - } + } catch (IOException e) { + e.printStackTrace(); } - } */ - } + } + } } private static void populateDatabase() { Iterator files;