Updated project to include a jar command runner

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent 3125dcbfe6
commit cc0f69d8b1
  1. BIN
      JavaProjectTemplate.jar
  2. BIN
      bin/ArcadeReader$1.class
  3. BIN
      bin/ArcadeReader.class
  4. BIN
      bin/readers/DDRReader.class
  5. BIN
      bin/readers/ITGReader.class
  6. BIN
      bin/readers/LoveLiveReader.class
  7. BIN
      bin/readers/SoundVoltexReader.class
  8. BIN
      bin/readers/TestReader.class
  9. BIN
      bin/sigPlace.class
  10. BIN
      bin/sigServer.class
  11. 1
      manifest
  12. BIN
      readers/Box.class
  13. BIN
      readers/ColorRange.class
  14. BIN
      readers/PopnReader.class
  15. BIN
      readers/Reader.class
  16. BIN
      readers/fonts/Font.class
  17. BIN
      readers/fonts/Glyph.class
  18. 17
      scripts/jar.sh
  19. 22
      sig
  20. BIN
      sigPlace.jar
  21. 614
      sigPlace.java
  22. 9
      utils/define.sh

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1 @@
Main-Class: sigPlace

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,17 @@
#Builds a runnable jar file using ${MAIN_CLASS} as an entry point and then runs the newly generated jar.
#Java
source ${LANGUAGE}/scripts/version_info
rm -Rf bin/*
javac -d bin *.java
printf "\n\n\nGenerating Manifest...\n\n"
touch manifest
echo "Main-Class: ${MAIN_CLASS}" > manifest
printf "\n\n\nCreating Jar...\n\n"
ORIGINAL_LOC=$(pwd)
cd ${OUT_DIR}
jar cfm ${PROJECT_NAME}.jar ${ORIGINAL_LOC}/manifest .
jar uf ${PROJECT_NAME}.jar -C ../lib/bin/ .
printf "\n\n\nRunning Program...\n\n"
mv sigPlace.jar ..
cd ..
java ${CUSTOM_PARAMS} -Djava.library.path="${LIBRARY_PATH}" -jar ${PROJECT_NAME}.jar "$@"

22
sig

@ -1,12 +1,14 @@
if [ -z "$1" ] export AUTO_UPDATE=true
then
echo "" source utils/define.sh
echo " Usage: ./sig <command> {args}"
echo "" define PROJECT_NAME "sigPlace"
echo " Command List:" define PROJECT_DIR "."
ls -1 ./scripts | sed -e 's/\.sh$//' | sed -e 's/^/ /' define MAIN_CLASS "${PROJECT_NAME}"
echo "" define OUT_DIR "bin"
exit define LIBRARY_PATH "lib"
fi define CLASS_PATH "${PROJECT_DIR}"
define CUSTOM_PARAMS ""
define LANGUAGE "Java"
./scripts/$1.sh "${*:2}" ./scripts/$1.sh "${*:2}"

Binary file not shown.

@ -86,358 +86,362 @@ public class sigPlace {
final static int TRANSPARENT = new Color(0,0,0,0).getRGB(); final static int TRANSPARENT = new Color(0,0,0,0).getRGB();
public static void main(String[] args) { public static void main(String[] args) {
populateDatabase(); if (args.length>0&&args[0].equals("arcade")) {
/*String fontName = "sdvx_EXScore"; System.out.println("Arcade");
String value = "00457"; } else {
Path f = Paths.get("tests","sdvx8.png"); populateDatabase();
BufferedImage img; /*String fontName = "sdvx_EXScore";
try { String value = "00457";
img = ImageIO.read(f.toFile()); Path f = Paths.get("tests","sdvx8.png");
Box scoreBox = new Box(630,1142,110,16); BufferedImage img;
try {
img = ImageIO.read(f.toFile());
Box scoreBox = new Box(630,1142,110,16);
int[] arr = img.getRGB(scoreBox.x, scoreBox.y, scoreBox.w, scoreBox.h, null, 0, scoreBox.w); int[] arr = img.getRGB(scoreBox.x, scoreBox.y, scoreBox.w, scoreBox.h, null, 0, scoreBox.w);
BufferedImage newImg = new BufferedImage(scoreBox.w,scoreBox.h,BufferedImage.TYPE_INT_ARGB); BufferedImage newImg = new BufferedImage(scoreBox.w,scoreBox.h,BufferedImage.TYPE_INT_ARGB);
int width=scoreBox.w; int width=scoreBox.w;
final ColorRange TARGETCOLOR = new ColorRange(230,255,180,255,20,255); final ColorRange TARGETCOLOR = new ColorRange(230,255,180,255,20,255);
final ColorRange SEEKINGCOLOR = new ColorRange(180,255,140,255,15,255); final ColorRange SEEKINGCOLOR = new ColorRange(180,255,140,255,15,255);
final Color FINALCOLOR = Color.MAGENTA; final Color FINALCOLOR = Color.MAGENTA;
for (int i=0;i<arr.length;i++) { for (int i=0;i<arr.length;i++) {
Color col = new Color(arr[i],true); Color col = new Color(arr[i],true);
if (TARGETCOLOR.colorInRange(col)) { if (TARGETCOLOR.colorInRange(col)) {
seek(arr,i,SEEKINGCOLOR,FINALCOLOR,width); seek(arr,i,SEEKINGCOLOR,FINALCOLOR,width);
}
} }
} for (int i=0;i<arr.length;i++) {
for (int i=0;i<arr.length;i++) { Color col = new Color(arr[i],true);
Color col = new Color(arr[i],true); if (!col.equals(Color.MAGENTA)) {
if (!col.equals(Color.MAGENTA)) { arr[i]=TRANSPARENT;
arr[i]=TRANSPARENT; }
} }
newImg.setRGB(0,0,scoreBox.w,scoreBox.h,arr,0,scoreBox.w);
ImageIO.write(newImg,"png",new File("test.png"));
Font.TrainFont(fontName,value,newImg);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
//new PopnReader().interpretBoxes(Paths.get("tests","popn8.png"),true);
//ArcadeReader.runTests();
/*BufferedImage img;
ArcadeReader.submitToDatabase(Paths.get("tests","sdvx1.png"));
ArcadeReader.submitToDatabase(Paths.get("tests","sdvx2.png"));
ArcadeReader.submitToDatabase(Paths.get("tests","sdvx3.png"));
ArcadeReader.submitToDatabase(Paths.get("tests","sdvx4.png"));*/
//System.out.println(RECENT_PLAYS);
//System.out.println(RECENT_RECORDS);
/* Path secretFile = Paths.get(".clientsecret");
List<String> data;
try {
data = Files.readAllLines(secretFile);
SECRET = data.get(0);
} catch (IOException e1) {
System.out.println("Client secret must be included in .clientsecret!");
e1.printStackTrace();
} }
newImg.setRGB(0,0,scoreBox.w,scoreBox.h,arr,0,scoreBox.w);
ImageIO.write(newImg,"png",new File("test.png")); if (args.length>0&&args.length%2==0) {
Font.TrainFont(fontName,value,newImg); int i=0;
} catch (IOException e) { while (i<args.length) {
// TODO Auto-generated catch block String arg1=args[i];
e.printStackTrace(); String arg2=args[i+1];
}*/ i+=2;
//new PopnReader().interpretBoxes(Paths.get("tests","popn8.png"),true); if (arg1.equals("-p")) {
//ArcadeReader.runTests(); PORT=Integer.parseInt(arg2);
/*BufferedImage img; System.out.println("Port set to "+PORT+".");
ArcadeReader.submitToDatabase(Paths.get("tests","sdvx1.png")); } else {
ArcadeReader.submitToDatabase(Paths.get("tests","sdvx2.png")); System.err.println("Invalid argument \""+arg1+"\".");
ArcadeReader.submitToDatabase(Paths.get("tests","sdvx3.png")); return;
ArcadeReader.submitToDatabase(Paths.get("tests","sdvx4.png"));*/ }
//System.out.println(RECENT_PLAYS);
//System.out.println(RECENT_RECORDS);
/* Path secretFile = Paths.get(".clientsecret");
List<String> data;
try {
data = Files.readAllLines(secretFile);
SECRET = data.get(0);
} catch (IOException e1) {
System.out.println("Client secret must be included in .clientsecret!");
e1.printStackTrace();
}
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..."); System.out.println("Copying files over to output directory...");
try { try {
copyDirectory("sitefiles","out"); copyDirectory("sitefiles","out");
Iterator<Path> items = Files.walk(Paths.get("out")).filter((p)->!p.toAbsolutePath().toString().contains("images/")).iterator(); Iterator<Path> items = Files.walk(Paths.get("out")).filter((p)->!p.toAbsolutePath().toString().contains("images/")).iterator();
ParseArticleFiles(items); ParseArticleFiles(items);
items = Files.walk(Paths.get("out")).iterator(); items = Files.walk(Paths.get("out")).iterator();
ConvertArticleReferences(items); ConvertArticleReferences(items);
items = Files.walk(Paths.get("out","articles")).iterator(); items = Files.walk(Paths.get("out","articles")).iterator();
GenerateArticleFiles(items); GenerateArticleFiles(items);
}catch (IOException e) { }catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
System.err.println("Copying files over failed!"); System.err.println("Copying files over failed!");
return; return;
} }
System.out.println("Building directory listings..."); System.out.println("Building directory listings...");
try { try {
buildDirectoryListings(); buildDirectoryListings();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
System.err.println("Failed to build directory listings!"); System.err.println("Failed to build directory listings!");
return; return;
} }
System.out.println("Site has been built into the "+OUTDIR+" directory."); System.out.println("Site has been built into the "+OUTDIR+" directory.");
ExportCodeFile(); ExportCodeFile();
System.out.println("\nStarting web server..."); System.out.println("\nStarting web server...");
new sigServer(); new sigServer();
} }
private static String JSON(HashMap<String, Object> testMap) { private static String JSON(HashMap<String, Object> testMap) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String temp = testMap.toString(); String temp = testMap.toString();
if (temp.charAt(0)=='{') { if (temp.charAt(0)=='{') {
sb.append("{"); sb.append("{");
int marker=1; int marker=1;
boolean ending=false; boolean ending=false;
while (marker<temp.length()) { while (marker<temp.length()) {
if (!ending&&temp.charAt(marker)!=' '&&temp.charAt(marker)!='{'&&temp.charAt(marker)!='}'&&temp.charAt(marker)!=',') { if (!ending&&temp.charAt(marker)!=' '&&temp.charAt(marker)!='{'&&temp.charAt(marker)!='}'&&temp.charAt(marker)!=',') {
ending=true; ending=true;
sb.append("\""); sb.append("\"");
} else } else
if (ending&&(temp.charAt(marker)=='='||temp.charAt(marker)==','||temp.charAt(marker)=='}')) { if (ending&&(temp.charAt(marker)=='='||temp.charAt(marker)==','||temp.charAt(marker)=='}')) {
ending=false; ending=false;
sb.append("\""); sb.append("\"");
} }
if (!ending&&temp.charAt(marker)=='=') { if (!ending&&temp.charAt(marker)=='=') {
sb.append(':'); sb.append(':');
} else { } else {
sb.append(temp.charAt(marker)); sb.append(temp.charAt(marker));
}
marker++;
} }
marker++; } else {
throw new UnsupportedOperationException("Not valid JSON!");
} }
} else { return sb.toString();
throw new UnsupportedOperationException("Not valid JSON!");
} }
return sb.toString(); private static void ParseArticleFiles(Iterator<Path> items) {
} while (items.hasNext()) {
private static void ParseArticleFiles(Iterator<Path> items) { Path f = items.next();
while (items.hasNext()) { System.out.println(" Found "+f.getFileName());
Path f = items.next(); if (Files.isRegularFile(f)) {
System.out.println(" Found "+f.getFileName()); try {
if (Files.isRegularFile(f)) {
try {
System.out.println(" Preparing "+f.getFileName()); System.out.println(" Preparing "+f.getFileName());
List<String> content = Files.readAllLines(f); List<String> content = Files.readAllLines(f);
if (isHTMLFile(f)) { if (isHTMLFile(f)) {
content.addAll(0,Files.readAllLines(ops.get("%NAVBAR"))); content.addAll(0,Files.readAllLines(ops.get("%NAVBAR")));
content.addAll(0,Files.readAllLines(ops.get("%DEFAULT"))); content.addAll(0,Files.readAllLines(ops.get("%DEFAULT")));
content.addAll(Files.readAllLines(ops.get("%FOOTER"))); content.addAll(Files.readAllLines(ops.get("%FOOTER")));
} }
System.out.println(" Parsing "+f.getFileName()); System.out.println(" Parsing "+f.getFileName());
for (int i=0;i<content.size();i++) { for (int i=0;i<content.size();i++) {
String s = content.get(i); String s = content.get(i);
boolean endPreLine=false; boolean endPreLine=false;
//System.out.println(s); //System.out.println(s);
if (s.length()>0&&(isHTMLFile(f)||isArticleFile(f))) { if (s.length()>0&&(isHTMLFile(f)||isArticleFile(f))) {
if (!inCodeBlock) { if (!inCodeBlock) {
if (s.trim().equals("<pre>")) { if (s.trim().equals("<pre>")) {
//System.out.println("Inside <pre>"); //System.out.println("Inside <pre>");
inCodeBlock=true; inCodeBlock=true;
storedCodeBlock=""; storedCodeBlock="";
s=s.substring(0,s.indexOf("<pre>")); s=s.substring(0,s.indexOf("<pre>"));
}
}
if (inCodeBlock&&s.trim().equals("</pre>")) {
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("</pre>"));
storedCodeBlock=storedCodeBlock.replaceAll(Pattern.quote("<"),"\2");
storedCodeBlock+="</pre>";
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)=='\n'&&inString) {
inString=false;
s+="</span>";
} else
if (storedCodeBlock.charAt(j)=='\n'&&inComment) {
inComment=false;
s+=SPAN("comment")+storedCodeBlock.substring(startPos,j)+"</span>";
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 (inCodeBlock&&s.trim().equals("</pre>")) {
if (inString) { inCodeBlock=false;
stringChar=storedCodeBlock.charAt(j); boolean keyword=false;
s+=SPAN("string")+stringChar; boolean inString=false;
} else { boolean inComment=false;
s+=stringChar; boolean inMultiLineComment=false;
char stringChar=' ';
boolean canBeNumericalConstant=false;
int lengthOfConstant=0;
storedCodeBlock+=s.substring(0,s.indexOf("</pre>"));
storedCodeBlock=storedCodeBlock.replaceAll(Pattern.quote("<"),"\2");
storedCodeBlock+="</pre>";
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)=='\n'&&inString) {
inString=false;
s+="</span>"; s+="</span>";
} else
if (storedCodeBlock.charAt(j)=='\n'&&inComment) {
inComment=false;
s+=SPAN("comment")+storedCodeBlock.substring(startPos,j)+"</span>";
startPos=j+1; startPos=j+1;
} }
} else if (!inComment&&!inMultiLineComment&&(j>0&&storedCodeBlock.charAt(j-1)!='\\'&&(!inString&&(storedCodeBlock.charAt(j)=='"'||storedCodeBlock.charAt(j)=='\'')||inString&&(storedCodeBlock.charAt(j)==stringChar)))) {
if (!inString) { inString=!inString;
if (canBeNumericalConstant&&validNumericalConstantCharacters(lengthOfConstant, j)) { if (inString) {
lengthOfConstant++; stringChar=storedCodeBlock.charAt(j);
//System.out.println("Length of Constant now "+lengthOfConstant); s+=SPAN("string")+stringChar;
}
if (j>0&&storedCodeBlock.charAt(j)=='/'&&storedCodeBlock.charAt(j+1)=='*'||inMultiLineComment) {
if (!inMultiLineComment) {
inMultiLineComment=true;
} else { } else {
if (storedCodeBlock.charAt(j-1)=='*'&&storedCodeBlock.charAt(j)=='/') { s+=stringChar;
inMultiLineComment=false; s+="</span>";
s+=SPAN("comment")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>"; startPos=j+1;
startPos=j+1;
}
} }
//Stops further execution since we're in a comment.
} else } else
if (j>0&&storedCodeBlock.charAt(j)=='/'&&storedCodeBlock.charAt(j+1)=='/'||inComment) { if (!inString) {
if (!inComment) { if (canBeNumericalConstant&&validNumericalConstantCharacters(lengthOfConstant, j)) {
inComment=true; lengthOfConstant++;
//System.out.println("Length of Constant now "+lengthOfConstant);
} }
//Stops further execution since we're in a comment. if (j>0&&storedCodeBlock.charAt(j)=='/'&&storedCodeBlock.charAt(j+1)=='*'||inMultiLineComment) {
} else if (!inMultiLineComment) {
if (canBeNumericalConstant&&lengthOfConstant>0&&!(validNumericalConstantCharacters(lengthOfConstant, j))) { inMultiLineComment=true;
s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j); } else {
//System.out.println("Setting "+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)); if (storedCodeBlock.charAt(j-1)=='*'&&storedCodeBlock.charAt(j)=='/') {
lengthOfConstant=0; inMultiLineComment=false;
canBeNumericalConstant=false; s+=SPAN("comment")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
startPos=j+1; startPos=j+1;
} else }
if (!canBeNumericalConstant&&storedCodeBlock.charAt(j)=='.') { }
//Previous section was a member. //Stops further execution since we're in a comment.
s+=SPAN("class")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j); } else
startPos=j+1; if (j>0&&storedCodeBlock.charAt(j)=='/'&&storedCodeBlock.charAt(j+1)=='/'||inComment) {
} else if (!inComment) {
if (j>3&&storedCodeBlock.substring(j-3,j+1).equals("true")&&!isAlphanumeric(j-4)&&!isAlphanumeric(j+1)) { inComment=true;
s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>"; }
startPos=j+1; //Stops further execution since we're in a comment.
} else } else
if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) { if (canBeNumericalConstant&&lengthOfConstant>0&&!(validNumericalConstantCharacters(lengthOfConstant, j))) {
s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>"; s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
startPos=j+1; //System.out.println("Setting "+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j));
} else lengthOfConstant=0;
if (storedCodeBlock.charAt(j)=='(') { canBeNumericalConstant=false;
s+=SPAN("function")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j); startPos=j+1;
startPos=j+1; } else
} else if (!canBeNumericalConstant&&storedCodeBlock.charAt(j)=='.') {
if (j>0&&isAlphanumeric(j-1) && storedCodeBlock.charAt(j)==' '&&storedCodeBlock.charAt(j-1)!=' ') { //Previous section was a member.
//Previous section was a keyword. s+=SPAN("class")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
keyword=true; startPos=j+1;
s+=SPAN("keyword")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j); } else
startPos=j+1; if (j>3&&storedCodeBlock.substring(j-3,j+1).equals("true")&&!isAlphanumeric(j-4)&&!isAlphanumeric(j+1)) {
} else s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
if (j>0&&isAlphanumeric(j-1) && (storedCodeBlock.charAt(j)==';'||storedCodeBlock.charAt(j)==':')) { startPos=j+1;
//Previous section was a keyword. } else
//keyword=true; if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) {
s+=SPAN("keyword")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j); s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
startPos=j+1; startPos=j+1;
} else } 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)==' ')) { if (storedCodeBlock.charAt(j)=='(') {
keyword=false; s+=SPAN("function")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
s+=SPAN("variable")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j); startPos=j+1;
startPos=j+1; } else
} else if (j>0&&isAlphanumeric(j-1) && storedCodeBlock.charAt(j)==' '&&storedCodeBlock.charAt(j-1)!=' ') {
if (!isAlphanumeric(j)){ //Previous section was a keyword.
if (startPos<j) { keyword=true;
s+=storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j); s+=SPAN("keyword")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
} else { startPos=j+1;
s+=storedCodeBlock.charAt(j); } 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)+"</span>"+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)+"</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; startPos=j+1;
} }
} else { if (canBeNumericalConstant&&lengthOfConstant==0&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9')) {
s+=storedCodeBlock.charAt(j); canBeNumericalConstant=false;
startPos=j+1; }
} if (!canBeNumericalConstant&&!isAlphanumeric(j)) {
if (canBeNumericalConstant&&lengthOfConstant==0&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9')) { canBeNumericalConstant=true;
canBeNumericalConstant=false; lengthOfConstant=0;
} //System.out.println("Found "+storedCodeBlock.charAt(j)+", can be numeric...");
if (!canBeNumericalConstant&&!isAlphanumeric(j)) { }
canBeNumericalConstant=true;
lengthOfConstant=0;
//System.out.println("Found "+storedCodeBlock.charAt(j)+", can be numeric...");
} }
} for (int j=0;j<s.length();j++) {
for (int j=0;j<s.length();j++) { if (s.charAt(j)=='\2') {
if (s.charAt(j)=='\2') { s=s.substring(0,j)+"&lt;"+s.substring(j+1,s.length());
s=s.substring(0,j)+"&lt;"+s.substring(j+1,s.length()); }
} }
s="<pre>"+s;
s+=endText;
endPreLine=true;
//System.out.println("Stored code block: "+storedCodeBlock);
} else
if (inCodeBlock) {
storedCodeBlock+=s+"\n";
s=" ";
} }
s="<pre>"+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) {
if (s.length()>0&&isArticleFile(f)&&!inCodeBlock) { //Check for markdown pieces.
//Check for markdown pieces. if (s.charAt(0)=='-') {
if (s.charAt(0)=='-') { //Start of a title piece.
//Start of a title piece. s=s.replace("-",map.get("$TITLE_CONTENT_START"));
s=s.replace("-",map.get("$TITLE_CONTENT_START")); s=s+map.get("$TITLE_CONTENT_END").replace("%ID%","id=\"content_"+f+"\"");
s=s+map.get("$TITLE_CONTENT_END").replace("%ID%","id=\"content_"+f+"\""); //Use ⤈ if there's more text to be shown than can fit.
//Use ⤈ if there's more text to be shown than can fit. } else
} else if (s.startsWith("===")) {
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");
s=map.get("$CONTENT_END")+map.get("$DATE_CONTENT_START")+s.replace("===","")+map.get("$CONTENT_END")+"%CONDITIONAL_EXPAND%"+map.get("$CONTENT_END"); } else
} else if (s.charAt(0)==':') {
if (s.charAt(0)==':') { //Image with caption.
//Image with caption. //Format:
//Format: //:<url>,<left|right|center>,<width>,<caption>
//:<url>,<left|right|center>,<width>,<caption> String[] splitter = s.split(Pattern.quote(","));
String[] splitter = s.split(Pattern.quote(",")); StringBuilder captionText = new StringBuilder(splitter[3]);
StringBuilder captionText = new StringBuilder(splitter[3]); for (int j=4;j<splitter.length;j++) {
for (int j=4;j<splitter.length;j++) { captionText.append(",").append(splitter[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)+"\">\n"+s+"\n</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 { } else {
//It's regular content, so add paragraphs. if (s.length()==0&&isArticleFile(f)&&!inCodeBlock) {
s="<p class=\"color"+(((int)(COLOR_ROTATION=(COLOR_ROTATION+0.4)%6))+1)+"\">\n"+s+"\n</p>"; s="<br/>"; //Setup a line break here.
}
} }
} else { if (!endPreLine) {
if (s.length()==0&&isArticleFile(f)&&!inCodeBlock) { for (String key : map.keySet()) {
s="<br/>"; //Setup a line break here. s=s.replaceAll(Pattern.quote(key),map.get(key));
}
} }
} if (s.trim().length()==0) {
if (!endPreLine) { content.remove(i--);
for (String key : map.keySet()) { } else {
s=s.replaceAll(Pattern.quote(key),map.get(key)); content.set(i,s);
} }
} }
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); Files.write(f, content, Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE);
System.out.println(" "+f.getFileName() + " conversion complete!"); System.out.println(" "+f.getFileName() + " conversion complete!");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}
} }
} } */
} */ }
} }
private static void populateDatabase() { private static void populateDatabase() {
Iterator<Path> files; Iterator<Path> files;

@ -0,0 +1,9 @@
export VARS=("")
export LANGUAGE=""
function define() {
VARS+=("$1")
value="${*:2}"
eval export "$1"='$value'
}
Loading…
Cancel
Save