Prepare article reference replacement.

main
sigonasr2, Sig, Sigo 3 years ago
parent 75d1745cb4
commit 70e50c0f52
  1. 14
      out/DIRECTORY_LISTING
  2. 8
      out/articles/DIRECTORY_LISTING
  3. 8
      out/articles/test articles/DIRECTORY_LISTING
  4. 10
      out/otherpage.html
  5. 63
      sigPlace.java
  6. 10
      sitefiles/otherpage.html

@ -1,4 +1,4 @@
<!DOCTYPE html><!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/reset.css">
@ -18,12 +18,12 @@
<body>
<div class="contentBody">
<h2>Directory Listing for /</h2><div class="folderlisting"><a href="/.." class="icon">&#x1F4C1;</a><a href="/..">.. </a><a href="/.." class="nounderline">(Previous Directory)</a></div><div class="folderlisting"><a href="/articles" class="icon">&#x1F4C1;</a><a href="/articles">articles</a> 2022-05-04T19:35:50.868925Z gitpod 116</div>
<div class="filelisting"><a href="/codeBackground" class="icon">&#x1F5CE;</a><a href="/codeBackground">codeBackground</a> 2022-05-04T19:35:50.828925Z gitpod 2635</div>
<div class="filelisting"><a href="/otherpage.html" class="icon">&#x1F5CE;</a><a href="/otherpage.html">otherpage.html</a> 2022-05-04T19:35:50.836925Z gitpod 901</div>
<div class="filelisting"><a href="/reset.css" class="icon">&#x1F5CE;</a><a href="/reset.css">reset.css</a> 2022-05-04T19:35:50.840925Z gitpod 1093</div>
<div class="filelisting"><a href="/sig.css" class="icon">&#x1F5CE;</a><a href="/sig.css">sig.css</a> 2022-05-04T19:35:50.852925Z gitpod 4314</div>
<div class="filelisting"><a href="/testfile.html" class="icon">&#x1F5CE;</a><a href="/testfile.html">testfile.html</a> 2022-05-04T19:35:50.856925Z gitpod 829</div>
<h2>Directory Listing for /</h2><div class="folderlisting"><a href="/.." class="icon">&#x1F4C1;</a><a href="/..">.. </a><a href="/.." class="nounderline">(Previous Directory)</a></div><div class="folderlisting"><a href="/articles" class="icon">&#x1F4C1;</a><a href="/articles">articles</a> 2022-05-04T20:08:17.510417Z gitpod 116</div>
<div class="filelisting"><a href="/codeBackground" class="icon">&#x1F5CE;</a><a href="/codeBackground">codeBackground</a> 2022-05-04T20:08:17.482417Z gitpod 2635</div>
<div class="filelisting"><a href="/otherpage.html" class="icon">&#x1F5CE;</a><a href="/otherpage.html">otherpage.html</a> 2022-05-04T20:08:17.490417Z gitpod 941</div>
<div class="filelisting"><a href="/reset.css" class="icon">&#x1F5CE;</a><a href="/reset.css">reset.css</a> 2022-05-04T20:08:17.494417Z gitpod 1093</div>
<div class="filelisting"><a href="/sig.css" class="icon">&#x1F5CE;</a><a href="/sig.css">sig.css</a> 2022-05-04T20:08:17.498417Z gitpod 4314</div>
<div class="filelisting"><a href="/testfile.html" class="icon">&#x1F5CE;</a><a href="/testfile.html">testfile.html</a> 2022-05-04T20:08:17.502417Z gitpod 829</div>
</div> <!--End Content Body-->
<div class="codeForeground" id="codeForeground"></div>

@ -1,4 +1,4 @@
<!DOCTYPE html><!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/reset.css">
@ -18,9 +18,9 @@
<body>
<div class="contentBody">
<h2>Directory Listing for /articles/</h2><div class="folderlisting"><a href="/articles/.." class="icon">&#x1F4C1;</a><a href="/articles/..">.. </a><a href="/articles/.." class="nounderline">(Previous Directory)</a></div><div class="filelisting"><a href="/articles/curabitur vel tempus ex.article" class="icon">&#x1F5CE;</a><a href="/articles/curabitur vel tempus ex.article">curabitur vel tempus ex.article</a> 2022-05-04T19:35:50.808925Z gitpod 618</div>
<div class="filelisting"><a href="/articles/sigplace1.article" class="icon">&#x1F5CE;</a><a href="/articles/sigplace1.article">sigplace1.article</a> 2022-05-04T19:35:50.812925Z gitpod 1559</div>
<div class="folderlisting"><a href="/articles/test articles" class="icon">&#x1F4C1;</a><a href="/articles/test articles">test articles</a> 2022-05-04T19:35:50.716925Z gitpod 69</div>
<h2>Directory Listing for /articles/</h2><div class="folderlisting"><a href="/articles/.." class="icon">&#x1F4C1;</a><a href="/articles/..">.. </a><a href="/articles/.." class="nounderline">(Previous Directory)</a></div><div class="filelisting"><a href="/articles/curabitur vel tempus ex.article" class="icon">&#x1F5CE;</a><a href="/articles/curabitur vel tempus ex.article">curabitur vel tempus ex.article</a> 2022-05-04T20:08:17.466417Z gitpod 618</div>
<div class="filelisting"><a href="/articles/sigplace1.article" class="icon">&#x1F5CE;</a><a href="/articles/sigplace1.article">sigplace1.article</a> 2022-05-04T20:08:17.474417Z gitpod 1559</div>
<div class="folderlisting"><a href="/articles/test articles" class="icon">&#x1F4C1;</a><a href="/articles/test articles">test articles</a> 2022-05-04T20:08:17.398417Z gitpod 69</div>
</div> <!--End Content Body-->
<div class="codeForeground" id="codeForeground"></div>

@ -1,4 +1,4 @@
<!DOCTYPE html><!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/reset.css">
@ -18,9 +18,9 @@
<body>
<div class="contentBody">
<h2>Directory Listing for /articles/test articles/</h2><div class="folderlisting"><a href="/articles/test articles/.." class="icon">&#x1F4C1;</a><a href="/articles/test articles/..">.. </a><a href="/articles/test articles/.." class="nounderline">(Previous Directory)</a></div><div class="filelisting"><a href="/articles/test articles/test1.article" class="icon">&#x1F5CE;</a><a href="/articles/test articles/test1.article">test1.article</a> 2022-05-04T19:35:50.816925Z gitpod 1111</div>
<div class="filelisting"><a href="/articles/test articles/test2.article" class="icon">&#x1F5CE;</a><a href="/articles/test articles/test2.article">test2.article</a> 2022-05-04T19:35:50.820925Z gitpod 807</div>
<div class="filelisting"><a href="/articles/test articles/test3.article" class="icon">&#x1F5CE;</a><a href="/articles/test articles/test3.article">test3.article</a> 2022-05-04T19:35:50.820925Z gitpod 1020</div>
<h2>Directory Listing for /articles/test articles/</h2><div class="folderlisting"><a href="/articles/test articles/.." class="icon">&#x1F4C1;</a><a href="/articles/test articles/..">.. </a><a href="/articles/test articles/.." class="nounderline">(Previous Directory)</a></div><div class="filelisting"><a href="/articles/test articles/test1.article" class="icon">&#x1F5CE;</a><a href="/articles/test articles/test1.article">test1.article</a> 2022-05-04T20:08:17.474417Z gitpod 1111</div>
<div class="filelisting"><a href="/articles/test articles/test2.article" class="icon">&#x1F5CE;</a><a href="/articles/test articles/test2.article">test2.article</a> 2022-05-04T20:08:17.474417Z gitpod 807</div>
<div class="filelisting"><a href="/articles/test articles/test3.article" class="icon">&#x1F5CE;</a><a href="/articles/test articles/test3.article">test3.article</a> 2022-05-04T20:08:17.478417Z gitpod 1020</div>
</div> <!--End Content Body-->
<div class="codeForeground" id="codeForeground"></div>

@ -19,11 +19,11 @@
<div class="contentBody">
This is a different webpage.<hr>
$ARTICLE sigplace1
$ARTICLE test articles/test1
$ARTICLE test articles/test2
$ARTICLE test articles/test3
$ARTICLE curabitur vel tempus ex
$ARTICLE_PREVIEW sigplace1
$ARTICLE_PREVIEW test articles/test1
$ARTICLE_PREVIEW test articles/test2
$ARTICLE_PREVIEW test articles/test3
$ARTICLE_PREVIEW curabitur vel tempus ex
</div> <!--End Content Body-->
<div class="codeForeground" id="codeForeground"></div>

@ -58,6 +58,33 @@ public class sigPlace {
try {
copyDirectory("sitefiles","out");
Iterator<Path> items = Files.walk(Paths.get("out")).iterator();
ParseArticleFiles(items);
items = Files.walk(Paths.get("out")).iterator();
ConvertArticleReferences(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("Site has been built into the "+OUTDIR+" directory.");
ExportCodeFile();
System.out.println("\nStarting web server...");
new sigServer();
}
private static void ParseArticleFiles(Iterator<Path> items) {
while (items.hasNext()) {
Path f = items.next();
System.out.println(" Found "+f.getFileName());
@ -104,27 +131,29 @@ public class sigPlace {
}
}
}
}catch (IOException e) {
e.printStackTrace();
System.err.println("Copying files over failed!");
return;
}
System.out.println("Building directory listings...");
private static void ConvertArticleReferences(Iterator<Path> items) {
while (items.hasNext()) {
Path f = items.next();
System.out.println(" Looking for Article References..."+f.getFileName());
if (Files.isRegularFile(f)&&isHTMLFile(f)) {
System.out.println(" Searching "+f.getFileName());
try {
buildDirectoryListings();
List<String> content = Files.readAllLines(f);
for (int i=0;i<content.size();i++) {
String s = content.get(i);
if (s.length()>0&&s.contains("$ARTICLE_PREVIEW")) {
String article = s.replace("$ARTICLE_PREVIEW ","");
System.out.println(" Found article preview request in "+f.getFileName()+" for article "+article+".");
Path file = Paths.get(OUTDIR,article);
content.remove(i--);
}
}
} 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.");
ExportCodeFile();
System.out.println("\nStarting web server...");
new sigServer();
}
}
}
static void copyDirectory(String sourceDirectoryLocation, String destinationDirectoryLocation)
throws IOException {
@ -162,7 +191,7 @@ public class sigPlace {
System.out.println(" "+map);
for (String key : map.keySet()) {
System.out.println("Creating directory listing for "+key+"...");
StringBuilder sb = new StringBuilder("<!DOCTYPE html>");
StringBuilder sb = new StringBuilder("");
List<String> data = Files.readAllLines(ops.get("%DEFAULT"));
List<String> data2 = Files.readAllLines(ops.get("%FOOTER"));
for (String d : data) {

@ -1,6 +1,6 @@
This is a different webpage.<hr>
$ARTICLE sigplace1
$ARTICLE test articles/test1
$ARTICLE test articles/test2
$ARTICLE test articles/test3
$ARTICLE curabitur vel tempus ex
$ARTICLE_PREVIEW sigplace1
$ARTICLE_PREVIEW test articles/test1
$ARTICLE_PREVIEW test articles/test2
$ARTICLE_PREVIEW test articles/test3
$ARTICLE_PREVIEW curabitur vel tempus ex
Loading…
Cancel
Save