|
|
@ -1,6 +1,5 @@ |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.nio.file.FileStore; |
|
|
|
|
|
|
|
import java.nio.file.Files; |
|
|
|
import java.nio.file.Files; |
|
|
|
import java.nio.file.Path; |
|
|
|
import java.nio.file.Path; |
|
|
|
import java.nio.file.Paths; |
|
|
|
import java.nio.file.Paths; |
|
|
@ -10,49 +9,60 @@ import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
public class sigPlace { |
|
|
|
public class sigPlace { |
|
|
|
|
|
|
|
|
|
|
|
final static String ROOTDIR = "sitefiles"; |
|
|
|
final static String ROOTDIR = "sitefiles"; |
|
|
|
|
|
|
|
final static String REFDIR = "ref"; |
|
|
|
final static String OUTDIR = "out"; |
|
|
|
final static String OUTDIR = "out"; |
|
|
|
|
|
|
|
|
|
|
|
final static HashMap<String,String> map = new HashMap<>(Map.ofEntries( |
|
|
|
final static HashMap<String,String> map = new HashMap<>(Map.ofEntries( |
|
|
|
new AbstractMap.SimpleEntry<>("$SITENAME", "SigPlace") |
|
|
|
new AbstractMap.SimpleEntry<>("$SITENAME", "SigPlace") |
|
|
|
)); |
|
|
|
)); |
|
|
|
final static HashMap<String,String> ops = new HashMap<>(Map.ofEntries( |
|
|
|
final static HashMap<String,Path> ops = new HashMap<>(Map.ofEntries( |
|
|
|
new AbstractMap.SimpleEntry<>( |
|
|
|
new AbstractMap.SimpleEntry<>( |
|
|
|
"%DEFAULT", |
|
|
|
"%DEFAULT", Paths.get(REFDIR,"DEFAULT.html")), |
|
|
|
"<!DOCTYPE html>"+ |
|
|
|
new AbstractMap.SimpleEntry<>( |
|
|
|
"<html>"+ |
|
|
|
"%FOOTER", Paths.get(REFDIR,"FOOTER.html")) |
|
|
|
"<head>"+ |
|
|
|
|
|
|
|
"<link rel=\"stylesheet\" href=\"sig.css\">"+ |
|
|
|
|
|
|
|
"</head>") |
|
|
|
|
|
|
|
)); |
|
|
|
)); |
|
|
|
public static void main(String[] args) { |
|
|
|
public static void main(String[] args) { |
|
|
|
Set<Path> files = GetFilesInDir(ROOTDIR); |
|
|
|
Set<Path> files = GetFilesInDir(ROOTDIR); |
|
|
|
for (Path f : files) { |
|
|
|
for (Path f : files) { |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("Found "+f.getFileName()); |
|
|
|
System.out.println(" Found "+f.getFileName()); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
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); |
|
|
|
content.add(0,ops.get("%DEFAULT")); |
|
|
|
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); |
|
|
|
|
|
|
|
for (String key : map.keySet()) { |
|
|
|
|
|
|
|
s=s.replaceAll(Pattern.quote(key),map.get(key)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
content.set(i,s); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Path newf = Paths.get(OUTDIR,f.getFileName().toString()); |
|
|
|
Path newf = Paths.get(OUTDIR,f.getFileName().toString()); |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("Writing to "+newf); |
|
|
|
System.out.println(" Writing to "+newf); |
|
|
|
|
|
|
|
|
|
|
|
Files.write(newf, content, Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE) |
|
|
|
Files.write(newf, content, Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE); |
|
|
|
|
|
|
|
|
|
|
|
System.out.println(newf.getFileName() + " conversion complete!"); |
|
|
|
System.out.println(" "+newf.getFileName() + " conversion complete!"); |
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
System.out.println("Site has been built into the "+OUTDIR+" directory."); |
|
|
|
} |
|
|
|
} |
|
|
|
private static Set<Path> GetFilesInDir(String directory) { |
|
|
|
private static Set<Path> GetFilesInDir(String directory) { |
|
|
|
Path dir = Paths.get(directory); |
|
|
|
Path dir = Paths.get(directory); |
|
|
|