Updated project to include a jar command runner

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 2 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. 618
      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" ]
then
echo ""
echo " Usage: ./sig <command> {args}"
echo ""
echo " Command List:"
ls -1 ./scripts | sed -e 's/\.sh$//' | sed -e 's/^/ /'
echo ""
exit
fi
export AUTO_UPDATE=true
source utils/define.sh
define PROJECT_NAME "sigPlace"
define PROJECT_DIR "."
define MAIN_CLASS "${PROJECT_NAME}"
define OUT_DIR "bin"
define LIBRARY_PATH "lib"
define CLASS_PATH "${PROJECT_DIR}"
define CUSTOM_PARAMS ""
define LANGUAGE "Java"
./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();
public static void main(String[] args) {
populateDatabase();
/*String fontName = "sdvx_EXScore";
String value = "00457";
Path f = Paths.get("tests","sdvx8.png");
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);
if (args.length>0&&args[0].equals("arcade")) {
System.out.println("Arcade");
} else {
populateDatabase();
/*String fontName = "sdvx_EXScore";
String value = "00457";
Path f = Paths.get("tests","sdvx8.png");
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);
BufferedImage newImg = new BufferedImage(scoreBox.w,scoreBox.h,BufferedImage.TYPE_INT_ARGB);
int width=scoreBox.w;
final ColorRange TARGETCOLOR = new ColorRange(230,255,180,255,20,255);
final ColorRange SEEKINGCOLOR = new ColorRange(180,255,140,255,15,255);
final Color FINALCOLOR = Color.MAGENTA;
for (int i=0;i<arr.length;i++) {
Color col = new Color(arr[i],true);
if (TARGETCOLOR.colorInRange(col)) {
seek(arr,i,SEEKINGCOLOR,FINALCOLOR,width);
BufferedImage newImg = new BufferedImage(scoreBox.w,scoreBox.h,BufferedImage.TYPE_INT_ARGB);
int width=scoreBox.w;
final ColorRange TARGETCOLOR = new ColorRange(230,255,180,255,20,255);
final ColorRange SEEKINGCOLOR = new ColorRange(180,255,140,255,15,255);
final Color FINALCOLOR = Color.MAGENTA;
for (int i=0;i<arr.length;i++) {
Color col = new Color(arr[i],true);
if (TARGETCOLOR.colorInRange(col)) {
seek(arr,i,SEEKINGCOLOR,FINALCOLOR,width);
}
}
}
for (int i=0;i<arr.length;i++) {
Color col = new Color(arr[i],true);
if (!col.equals(Color.MAGENTA)) {
arr[i]=TRANSPARENT;
for (int i=0;i<arr.length;i++) {
Color col = new Color(arr[i],true);
if (!col.equals(Color.MAGENTA)) {
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"));
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();
}
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;
if (args.length>0&&args.length%2==0) {
int i=0;
while (i<args.length) {
String arg1=args[i];
String arg2=args[i+1];
i+=2;
if (arg1.equals("-p")) {
PORT=Integer.parseInt(arg2);
System.out.println("Port set to "+PORT+".");
} else {
System.err.println("Invalid argument \""+arg1+"\".");
return;
}
}
}
}
System.out.println("Copying files over to output directory...");
try {
copyDirectory("sitefiles","out");
Iterator<Path> items = Files.walk(Paths.get("out")).filter((p)->!p.toAbsolutePath().toString().contains("images/")).iterator();
ParseArticleFiles(items);
System.out.println("Copying files over to output directory...");
try {
copyDirectory("sitefiles","out");
Iterator<Path> items = Files.walk(Paths.get("out")).filter((p)->!p.toAbsolutePath().toString().contains("images/")).iterator();
ParseArticleFiles(items);
items = Files.walk(Paths.get("out")).iterator();
ConvertArticleReferences(items);
items = Files.walk(Paths.get("out","articles")).iterator();
GenerateArticleFiles(items);
}catch (IOException e) {
e.printStackTrace();
System.err.println("Copying files over failed!");
return;
}
items = Files.walk(Paths.get("out")).iterator();
ConvertArticleReferences(items);
items = Files.walk(Paths.get("out","articles")).iterator();
GenerateArticleFiles(items);
}catch (IOException e) {
e.printStackTrace();
System.err.println("Copying files over failed!");
return;
}
System.out.println("Building directory listings...");
try {
buildDirectoryListings();
} catch (IOException e) {
e.printStackTrace();
System.err.println("Failed to build directory listings!");
return;
}
System.out.println("Building directory listings...");
try {
buildDirectoryListings();
} catch (IOException e) {
e.printStackTrace();
System.err.println("Failed to build directory listings!");
return;
}
System.out.println("Site has been built into the "+OUTDIR+" directory.");
System.out.println("Site has been built into the "+OUTDIR+" directory.");
ExportCodeFile();
ExportCodeFile();
System.out.println("\nStarting web server...");
new sigServer();
}
System.out.println("\nStarting web server...");
new sigServer();
}
private static String JSON(HashMap<String, Object> testMap) {
StringBuilder sb = new StringBuilder();
String temp = testMap.toString();
if (temp.charAt(0)=='{') {
sb.append("{");
int marker=1;
boolean ending=false;
while (marker<temp.length()) {
if (!ending&&temp.charAt(marker)!=' '&&temp.charAt(marker)!='{'&&temp.charAt(marker)!='}'&&temp.charAt(marker)!=',') {
ending=true;
sb.append("\"");
} else
if (ending&&(temp.charAt(marker)=='='||temp.charAt(marker)==','||temp.charAt(marker)=='}')) {
ending=false;
sb.append("\"");
}
if (!ending&&temp.charAt(marker)=='=') {
sb.append(':');
} else {
sb.append(temp.charAt(marker));
private static String JSON(HashMap<String, Object> testMap) {
StringBuilder sb = new StringBuilder();
String temp = testMap.toString();
if (temp.charAt(0)=='{') {
sb.append("{");
int marker=1;
boolean ending=false;
while (marker<temp.length()) {
if (!ending&&temp.charAt(marker)!=' '&&temp.charAt(marker)!='{'&&temp.charAt(marker)!='}'&&temp.charAt(marker)!=',') {
ending=true;
sb.append("\"");
} else
if (ending&&(temp.charAt(marker)=='='||temp.charAt(marker)==','||temp.charAt(marker)=='}')) {
ending=false;
sb.append("\"");
}
if (!ending&&temp.charAt(marker)=='=') {
sb.append(':');
} else {
sb.append(temp.charAt(marker));
}
marker++;
}
marker++;
} else {
throw new UnsupportedOperationException("Not valid JSON!");
}
} else {
throw new UnsupportedOperationException("Not valid JSON!");
return sb.toString();
}
return sb.toString();
}
private static void ParseArticleFiles(Iterator<Path> items) {
while (items.hasNext()) {
Path f = items.next();
System.out.println(" Found "+f.getFileName());
if (Files.isRegularFile(f)) {
try {
private static void ParseArticleFiles(Iterator<Path> items) {
while (items.hasNext()) {
Path f = items.next();
System.out.println(" Found "+f.getFileName());
if (Files.isRegularFile(f)) {
try {
System.out.println(" Preparing "+f.getFileName());
System.out.println(" Preparing "+f.getFileName());
List<String> 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<String> 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;i<content.size();i++) {
String s = content.get(i);
boolean endPreLine=false;
//System.out.println(s);
if (s.length()>0&&(isHTMLFile(f)||isArticleFile(f))) {
if (!inCodeBlock) {
if (s.trim().equals("<pre>")) {
//System.out.println("Inside <pre>");
inCodeBlock=true;
storedCodeBlock="";
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;
System.out.println(" Parsing "+f.getFileName());
for (int i=0;i<content.size();i++) {
String s = content.get(i);
boolean endPreLine=false;
//System.out.println(s);
if (s.length()>0&&(isHTMLFile(f)||isArticleFile(f))) {
if (!inCodeBlock) {
if (s.trim().equals("<pre>")) {
//System.out.println("Inside <pre>");
inCodeBlock=true;
storedCodeBlock="";
s=s.substring(0,s.indexOf("<pre>"));
}
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;
}
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;
}
} 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;
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 (storedCodeBlock.charAt(j-1)=='*'&&storedCodeBlock.charAt(j)=='/') {
inMultiLineComment=false;
s+=SPAN("comment")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
startPos=j+1;
}
s+=stringChar;
s+="</span>";
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;
if (!inString) {
if (canBeNumericalConstant&&validNumericalConstantCharacters(lengthOfConstant, j)) {
lengthOfConstant++;
//System.out.println("Length of Constant now "+lengthOfConstant);
}
//Stops further execution since we're in a comment.
} else
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));
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)+"</span>"+storedCodeBlock.charAt(j);
startPos=j+1;
} else
if (j>3&&storedCodeBlock.substring(j-3,j+1).equals("true")&&!isAlphanumeric(j-4)&&!isAlphanumeric(j+1)) {
s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
startPos=j+1;
} else
if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) {
s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
startPos=j+1;
} else
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.
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;
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);
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)+"</span>";
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)+"</span>"+storedCodeBlock.charAt(j);
//System.out.println("Setting "+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j));
lengthOfConstant=0;
canBeNumericalConstant=false;
startPos=j+1;
} else
if (!canBeNumericalConstant&&storedCodeBlock.charAt(j)=='.') {
//Previous section was a member.
s+=SPAN("class")+storedCodeBlock.substring(startPos,j)+"</span>"+storedCodeBlock.charAt(j);
startPos=j+1;
} else
if (j>3&&storedCodeBlock.substring(j-3,j+1).equals("true")&&!isAlphanumeric(j-4)&&!isAlphanumeric(j+1)) {
s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
startPos=j+1;
} else
if (j>4&&storedCodeBlock.substring(j-4,j+1).equals("false")&&!isAlphanumeric(j-5)&&!isAlphanumeric(j+1)) {
s+=SPAN("number")+storedCodeBlock.substring(startPos,j)+storedCodeBlock.charAt(j)+"</span>";
startPos=j+1;
} else
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.
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;
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;
}
} else {
s+=storedCodeBlock.charAt(j);
startPos=j+1;
}
if (canBeNumericalConstant&&lengthOfConstant==0&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9')) {
canBeNumericalConstant=false;
}
if (!canBeNumericalConstant&&!isAlphanumeric(j)) {
canBeNumericalConstant=true;
lengthOfConstant=0;
//System.out.println("Found "+storedCodeBlock.charAt(j)+", can be numeric...");
if (canBeNumericalConstant&&lengthOfConstant==0&&!(storedCodeBlock.charAt(j)>='0'&&storedCodeBlock.charAt(j)<='9')) {
canBeNumericalConstant=false;
}
if (!canBeNumericalConstant&&!isAlphanumeric(j)) {
canBeNumericalConstant=true;
lengthOfConstant=0;
//System.out.println("Found "+storedCodeBlock.charAt(j)+", can be numeric...");
}
}
}
for (int j=0;j<s.length();j++) {
if (s.charAt(j)=='\2') {
s=s.substring(0,j)+"&lt;"+s.substring(j+1,s.length());
for (int j=0;j<s.length();j++) {
if (s.charAt(j)=='\2') {
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) {
//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:
//:<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.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:
//:<url>,<left|right|center>,<width>,<caption>
String[] splitter = s.split(Pattern.quote(","));
StringBuilder captionText = new StringBuilder(splitter[3]);
for (int j=4;j<splitter.length;j++) {
captionText.append(",").append(splitter[j]);
}
s="<div><figure style=\"text-align:center;"+((splitter[1].equals("left")||splitter[1].equals("right"))?"width:"+splitter[2]+"%;float:"+splitter[1]+";":"")+"\"><img src=\"/"+splitter[0].substring(1)+"\" style=\"margin:auto;width:100%;\"><figcaption>"+captionText.toString()+"</figcaption></figure></div>";
} else {
//It's regular content, so add paragraphs.
s="<p class=\"color"+(((int)(COLOR_ROTATION=(COLOR_ROTATION+0.4)%6))+1)+"\">\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 {
//It's regular content, so add paragraphs.
s="<p class=\"color"+(((int)(COLOR_ROTATION=(COLOR_ROTATION+0.4)%6))+1)+"\">\n"+s+"\n</p>";
if (s.length()==0&&isArticleFile(f)&&!inCodeBlock) {
s="<br/>"; //Setup a line break here.
}
}
} else {
if (s.length()==0&&isArticleFile(f)&&!inCodeBlock) {
s="<br/>"; //Setup a line break here.
if (!endPreLine) {
for (String key : map.keySet()) {
s=s.replaceAll(Pattern.quote(key),map.get(key));
}
}
}
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);
}
}
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<Path> files;

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