Code scrolling background generation

main
sigonasr2 3 years ago
parent 8bf9f62fb2
commit e6289eeedc
  1. 40
      out/codeBackground
  2. 36
      out/otherpage.html
  3. 48
      out/reset.css
  4. 44
      out/sig.css
  5. 16
      out/testfile.html
  6. 11
      ref/DEFAULT.html
  7. 3
      ref/FOOTER.html
  8. 26
      sigPlace.java
  9. 3
      sigServer.java
  10. 10
      sitefiles/otherpage.html
  11. 46
      sitefiles/sig.css
  12. 4
      sitefiles/testfile.html

@ -0,0 +1,40 @@
try {
socket = new ServerSocket(8080);
System.out.println("Listening on port 8080.");
while (true) {
try (Socket client = socket.accept()) {
System.out.println("New client connection detected: "+client.toString());
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
String line;
line=in.readLine(); //Read the first line, this should be our request.
String[] splitter = line.split(Pattern.quote(" "));
if (splitter.length==3) {
//This is valid.
if (splitter[0].equals("GET")) { //This is a GET request.
if (splitter[2].equals("HTTP/1.1")||splitter[2].equals("HTTP/2.0")) {
String requestloc = splitter[1];
if (requestloc.equals("/")) {
//Send default directory.
CreateRequest(client,"200","OK","testfile.html");
} else {
CreateRequest(client,"200","OK",requestloc.replace("/",""));
}
}
} else {
CreateRequest(client,"501","Not Implemented","testfile.html");
}
}
while (!(line=in.readLine()).isBlank()) {
//System.out.println(line);
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
private void CreateRawRequest(OutputStream stream, String statusCode, String statusMsg, String contentType, byte[] content) {
try {
stream.write(("HTTP/1.1 "+statusCode+" "+statusMsg+"\r\n").getBytes());
stream.write(("ContentType: "+contentType+"\r\n").getBytes());

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/reset.css">
<link rel="stylesheet" type="text/css" href="/sig.css">
<script type="text/javascript">
function loadCodeBackground() {
fetch("codeBackground").then((data)=>data.text())
.then((data)=>{
document.getElementById("codeForeground").innerText=data
document.getElementById("codeBackground").innerText=data
})
}
loadCodeBackground();
</script>
</head>
<body>
This is a different webpage.<hr>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque volutpat mollis sem sit amet lacinia. Phasellus vitae varius elit. Proin at vestibulum nunc, in pellentesque orci. Vestibulum efficitur mi vel augue pellentesque eleifend. Aenean eu sem ullamcorper justo consectetur ornare. Donec molestie tincidunt dui eget venenatis. Sed varius est faucibus, blandit turpis non, rhoncus neque. Integer sem felis, cursus in elementum ac, mollis in justo. Pellentesque vel risus turpis. Curabitur lectus neque, lobortis in varius et, tristique convallis erat. Morbi id sodales leo. Cras bibendum bibendum lacus, eu ullamcorper sem tempus sed. Nam ut consectetur nulla.</p>
<p>In dolor erat, malesuada at elit cursus, convallis imperdiet turpis. Ut aliquet magna tellus, at viverra mauris ullamcorper vehicula. Nam quis urna semper magna ornare elementum sed id mauris. Suspendisse faucibus nunc ante, ac rhoncus nisl tristique sed. Vestibulum pretium odio eget scelerisque vestibulum. Aliquam viverra ex ac vestibulum interdum. Donec ligula nunc, dignissim a purus vitae, fermentum laoreet diam. Quisque nec auctor urna. Vestibulum sit amet ligula ullamcorper, congue ipsum et, accumsan ante. Phasellus fermentum, sapien nec pulvinar blandit, elit purus pretium urna, et dapibus orci urna eu metus. Nunc molestie dictum pharetra. Suspendisse luctus felis et ante tristique, vitae commodo diam porttitor. Aliquam orci eros, placerat ac justo vitae, bibendum efficitur metus. Phasellus eget bibendum mauris.</p>
<p>Sed lobortis nisi id nunc tincidunt volutpat. Mauris cursus felis quis condimentum posuere. Pellentesque vitae dolor et justo suscipit ultrices. Integer dapibus leo id felis varius, ut volutpat massa bibendum. Quisque sed nunc arcu. In sit amet faucibus magna, non venenatis massa. Cras sed placerat risus, id consectetur est. Pellentesque in nunc dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque eget lorem ac urna posuere accumsan. Quisque sed imperdiet nisi.</p>
<p>Curabitur suscipit quam tellus, non rhoncus diam vehicula in. Aliquam ut dapibus tortor. Cras accumsan arcu vel ante maximus ornare. Nam tempus fermentum leo maximus euismod. Donec vehicula pretium est a ultrices. Nunc blandit nibh lorem, nec blandit leo posuere quis. Sed mauris ligula, euismod eu aliquam vel, rhoncus eget magna. Proin eget tortor ut ligula suscipit mattis. Integer rutrum aliquet eleifend. Suspendisse leo libero, placerat nec mi id, sagittis malesuada felis. Quisque euismod ante cursus elit lobortis, eu tempus ligula condimentum. Mauris viverra metus et dignissim efficitur. Ut placerat nunc nunc, eu tempus neque ultrices nec. Suspendisse et magna risus. Phasellus in ullamcorper tortor. Sed lobortis ut mi in blandit.</p>
<p>Curabitur vel tempus ex. Duis cursus sapien nisl, ut pulvinar dui porttitor ut. Nullam odio purus, tristique non turpis sit amet, malesuada ultricies purus. Mauris ut nulla nisl. Aenean sit amet est egestas justo volutpat consequat. Suspendisse in sagittis augue, et mattis tortor. Nullam viverra metus et nibh fringilla iaculis.</p>
<div class="codeForeground" id="codeForeground"></div>
<div class="codeBackground" id="codeBackground"></div>
</body>
<footer>
</footer>
</html>

@ -0,0 +1,48 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

@ -1,4 +1,46 @@
.generateTime{ .generateTime{
font-size:10px; font-size:10px;
color:blue; color:blue;
} }
.codeForeground{
font-family:'Courier New', Courier, monospace;
position:absolute;
z-index:-4999;
color:rgba(0,0,0,0);
background: linear-gradient(90deg, rgba(17,17,17,1) 0%, rgba(17,17,17,1) 42%, rgba(17,17,17,0.6825105042016807) 44%, rgba(17,17,17,1) 46%, rgba(17,17,17,1) 100%);
background-size:300% 100%;
user-select:none;
animation-name:backgroundMove;
animation-duration:15s;
animation-iteration-count: infinite;
font-size:32px;
overflow:hidden;
max-width:98vw;
max-height:90vh;
}
.codeBackground{
font-family:'Courier New', Courier, monospace;
position:absolute;
color:#44FF44;
z-index:-5000;
user-select:none;
font-size:32px;
overflow:hidden;
max-width:98vw;
max-height:90vh;
}
@keyframes backgroundMove{
0%{
background-position: 0% 50%;
}
100%{
background-position: 100% 50%;
}
}
body{
background-color:#111;
}

@ -1,12 +1,28 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<link rel="stylesheet" type="text/css" href="/reset.css">
<link rel="stylesheet" type="text/css" href="/sig.css"> <link rel="stylesheet" type="text/css" href="/sig.css">
<script type="text/javascript">
function loadCodeBackground() {
fetch("codeBackground").then((data)=>data.text())
.then((data)=>{
document.getElementById("codeForeground").innerText=data
document.getElementById("codeBackground").innerText=data
})
}
loadCodeBackground();
</script>
</head> </head>
<body> <body>
SigPlace SigPlace
Basic Content Basic Content
<br/><br/>
<a href="otherpage.html">Other Page!</a>
<div class="codeForeground" id="codeForeground"></div>
<div class="codeBackground" id="codeBackground"></div>
</body> </body>
<footer> <footer>

@ -1,7 +1,18 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<link rel="stylesheet" type="text/css" href="/reset.css">
<link rel="stylesheet" type="text/css" href="/sig.css"> <link rel="stylesheet" type="text/css" href="/sig.css">
<script type="text/javascript">
function loadCodeBackground() {
fetch("codeBackground").then((data)=>data.text())
.then((data)=>{
document.getElementById("codeForeground").innerText=data
document.getElementById("codeBackground").innerText=data
})
}
loadCodeBackground();
</script>
</head> </head>
<body> <body>

@ -1,3 +1,6 @@
<div class="codeForeground" id="codeForeground"></div>
<div class="codeBackground" id="codeBackground"></div>
</body> </body>
<footer> <footer>

@ -19,7 +19,8 @@ public class sigPlace {
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"),
new AbstractMap.SimpleEntry<>("$SITE_BACKCOL", "#111")
)); ));
final static HashMap<String,Path> ops = new HashMap<>(Map.ofEntries( final static HashMap<String,Path> ops = new HashMap<>(Map.ofEntries(
new AbstractMap.SimpleEntry<>( new AbstractMap.SimpleEntry<>(
@ -38,8 +39,10 @@ public class sigPlace {
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.addAll(0,Files.readAllLines(ops.get("%DEFAULT"))); if (f.getFileName().toString().contains(".html")) {
content.addAll(Files.readAllLines(ops.get("%FOOTER"))); content.addAll(0,Files.readAllLines(ops.get("%DEFAULT")));
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++) {
@ -63,9 +66,26 @@ public class sigPlace {
} }
} }
System.out.println("Site has been built into the "+OUTDIR+" directory."); System.out.println("Site has been built into the "+OUTDIR+" directory.");
ExportCodeFile();
System.out.println("\nStarting web server..."); System.out.println("\nStarting web server...");
new sigServer(); new sigServer();
} }
private static void ExportCodeFile() {
try {
Path file = Paths.get("sigServer.java");
List<String> data = Files.readAllLines(file);
int i=0;
while (!data.get(i++).contains("sigServer()")&&i<data.size());
if (i<data.size()) {
Files.write(Paths.get(OUTDIR,"codeBackground"),data.subList(i, Math.min(i+40,data.size())),Charset.defaultCharset(),StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE);
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static Set<Path> GetFilesInDir(String directory) { private static Set<Path> GetFilesInDir(String directory) {
Path dir = Paths.get(directory); Path dir = Paths.get(directory);
try { try {

@ -67,7 +67,8 @@ public class sigServer {
if (statusCode.equals("200")) { if (statusCode.equals("200")) {
if (Files.exists(file)) { if (Files.exists(file)) {
CreateRawRequest(clientOutput,statusCode,statusMsg,Files.probeContentType(file),Files.readAllBytes(file)); CreateRawRequest(clientOutput,statusCode,statusMsg,Files.probeContentType(file),Files.readAllBytes(file));
if (Files.probeContentType(file).equals("text/html")) { String contentType = Files.probeContentType(file);
if (contentType!=null&&contentType.equals("text/html")) {
clientOutput.write(("<div class=\"generateTime\">Webpage generated in "+(System.currentTimeMillis()-startTime)+"ms</div>\r\n").getBytes()); clientOutput.write(("<div class=\"generateTime\">Webpage generated in "+(System.currentTimeMillis()-startTime)+"ms</div>\r\n").getBytes());
} }
} else { } else {

@ -0,0 +1,10 @@
This is a different webpage.<hr>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque volutpat mollis sem sit amet lacinia. Phasellus vitae varius elit. Proin at vestibulum nunc, in pellentesque orci. Vestibulum efficitur mi vel augue pellentesque eleifend. Aenean eu sem ullamcorper justo consectetur ornare. Donec molestie tincidunt dui eget venenatis. Sed varius est faucibus, blandit turpis non, rhoncus neque. Integer sem felis, cursus in elementum ac, mollis in justo. Pellentesque vel risus turpis. Curabitur lectus neque, lobortis in varius et, tristique convallis erat. Morbi id sodales leo. Cras bibendum bibendum lacus, eu ullamcorper sem tempus sed. Nam ut consectetur nulla.</p>
<p>In dolor erat, malesuada at elit cursus, convallis imperdiet turpis. Ut aliquet magna tellus, at viverra mauris ullamcorper vehicula. Nam quis urna semper magna ornare elementum sed id mauris. Suspendisse faucibus nunc ante, ac rhoncus nisl tristique sed. Vestibulum pretium odio eget scelerisque vestibulum. Aliquam viverra ex ac vestibulum interdum. Donec ligula nunc, dignissim a purus vitae, fermentum laoreet diam. Quisque nec auctor urna. Vestibulum sit amet ligula ullamcorper, congue ipsum et, accumsan ante. Phasellus fermentum, sapien nec pulvinar blandit, elit purus pretium urna, et dapibus orci urna eu metus. Nunc molestie dictum pharetra. Suspendisse luctus felis et ante tristique, vitae commodo diam porttitor. Aliquam orci eros, placerat ac justo vitae, bibendum efficitur metus. Phasellus eget bibendum mauris.</p>
<p>Sed lobortis nisi id nunc tincidunt volutpat. Mauris cursus felis quis condimentum posuere. Pellentesque vitae dolor et justo suscipit ultrices. Integer dapibus leo id felis varius, ut volutpat massa bibendum. Quisque sed nunc arcu. In sit amet faucibus magna, non venenatis massa. Cras sed placerat risus, id consectetur est. Pellentesque in nunc dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque eget lorem ac urna posuere accumsan. Quisque sed imperdiet nisi.</p>
<p>Curabitur suscipit quam tellus, non rhoncus diam vehicula in. Aliquam ut dapibus tortor. Cras accumsan arcu vel ante maximus ornare. Nam tempus fermentum leo maximus euismod. Donec vehicula pretium est a ultrices. Nunc blandit nibh lorem, nec blandit leo posuere quis. Sed mauris ligula, euismod eu aliquam vel, rhoncus eget magna. Proin eget tortor ut ligula suscipit mattis. Integer rutrum aliquet eleifend. Suspendisse leo libero, placerat nec mi id, sagittis malesuada felis. Quisque euismod ante cursus elit lobortis, eu tempus ligula condimentum. Mauris viverra metus et dignissim efficitur. Ut placerat nunc nunc, eu tempus neque ultrices nec. Suspendisse et magna risus. Phasellus in ullamcorper tortor. Sed lobortis ut mi in blandit.</p>
<p>Curabitur vel tempus ex. Duis cursus sapien nisl, ut pulvinar dui porttitor ut. Nullam odio purus, tristique non turpis sit amet, malesuada ultricies purus. Mauris ut nulla nisl. Aenean sit amet est egestas justo volutpat consequat. Suspendisse in sagittis augue, et mattis tortor. Nullam viverra metus et nibh fringilla iaculis.</p>

@ -0,0 +1,46 @@
.generateTime{
font-size:10px;
color:blue;
}
.codeForeground{
font-family:'Courier New', Courier, monospace;
position:absolute;
z-index:-4999;
color:rgba(0,0,0,0);
background: linear-gradient(90deg, rgba(17,17,17,1) 0%, rgba(17,17,17,1) 42%, rgba(17,17,17,0.6825105042016807) 44%, rgba(17,17,17,1) 46%, rgba(17,17,17,1) 100%);
background-size:300% 100%;
user-select:none;
animation-name:backgroundMove;
animation-duration:15s;
animation-iteration-count: infinite;
font-size:32px;
overflow:hidden;
max-width:98vw;
max-height:90vh;
}
.codeBackground{
font-family:'Courier New', Courier, monospace;
position:absolute;
color:#44FF44;
z-index:-5000;
user-select:none;
font-size:32px;
overflow:hidden;
max-width:98vw;
max-height:90vh;
}
@keyframes backgroundMove{
0%{
background-position: 0% 50%;
}
100%{
background-position: 100% 50%;
}
}
body{
background-color:$SITE_BACKCOL;
}

@ -1,2 +1,4 @@
$SITENAME $SITENAME
Basic Content Basic Content
<br/><br/>
<a href="otherpage.html">Other Page!</a>
Loading…
Cancel
Save