From 48fefb76c0a908cc3fa00abc9c090ce3ac8cb560 Mon Sep 17 00:00:00 2001
From: FChannel <>
Date: Sun, 24 Oct 2021 10:40:45 -0700
Subject: gofiber conversion, index, board posts, board post hooked up
---
views/css/themes/default.css | 249 +++++++++++++++++++++++++++++
views/css/themes/gruvbox.css | 235 +++++++++++++++++++++++++++
views/index.html | 53 +++++++
views/js/footerscript.js | 44 +++++
views/js/posts.js | 344 ++++++++++++++++++++++++++++++++++++++++
views/js/themes.js | 40 +++++
views/js/timer.js | 38 +++++
views/layouts/main.html | 50 ++++++
views/npost.html | 66 ++++++++
views/nposts.html | 70 ++++++++
views/partials/bottom.html | 48 ++++++
views/partials/footer.html | 13 ++
views/partials/posts.html | 122 ++++++++++++++
views/partials/postscripts.html | 3 +
views/partials/top.html | 128 +++++++++++++++
15 files changed, 1503 insertions(+)
create mode 100644 views/css/themes/default.css
create mode 100644 views/css/themes/gruvbox.css
create mode 100644 views/index.html
create mode 100644 views/js/footerscript.js
create mode 100644 views/js/posts.js
create mode 100644 views/js/themes.js
create mode 100644 views/js/timer.js
create mode 100644 views/layouts/main.html
create mode 100644 views/npost.html
create mode 100644 views/nposts.html
create mode 100644 views/partials/bottom.html
create mode 100644 views/partials/footer.html
create mode 100644 views/partials/posts.html
create mode 100644 views/partials/postscripts.html
create mode 100644 views/partials/top.html
(limited to 'views')
diff --git a/views/css/themes/default.css b/views/css/themes/default.css
new file mode 100644
index 0000000..98edc29
--- /dev/null
+++ b/views/css/themes/default.css
@@ -0,0 +1,249 @@
+a, a:link, a:visited, a:hover, a:active {
+ text-decoration: none
+}
+
+a:link, a:visited, a:active {
+ color: black;
+}
+
+a:hover {
+ color: #de0808;
+}
+
+body {
+ background-color: #eef2fe;
+ color: black;
+}
+
+body.nsfw {
+ background-color: #ffffee;
+ color: #820404
+}
+
+h1, h2, h3, h4, h5, h6 {
+ color: #af0a0f;
+}
+
+.popup-box {
+ border: 4px solid #d3caf0;
+ background-color: #eff5ff;
+}
+
+.nsfw .popup-box {
+ border: 4px solid #f0e2d9;
+ background-color: #f9f9e0;
+}
+
+.box {
+ background-color: #eff5ff;
+}
+
+.nsfw .box {
+ background-color: #f9f9e0;
+}
+
+.box-alt {
+ background-color: #d3caf0;
+}
+
+.nsfw .box-alt {
+ background-color: #f0e2d9;
+}
+
+
+.quote {
+ color: #789922;
+}
+
+.post {
+ background-color: #d5daf0;
+}
+
+.nsfw .post {
+ background-color: #f0e0d6;
+}
+
+:target > div > .post {
+ background-color: #d6bad0;
+}
+
+.nsfw :target > div > .post {
+ background-color: #f0c0b0;
+}
+
+.title {
+ color: #0f0c5d;
+}
+
+.name, .tripcode {
+ color: #117743;
+}
+
+a.reply {
+ color: #af0a0f;
+ text-decoration: 1px underline;
+}
+
+.replyLink {
+ color: #000080;
+ font-size: 0.8em;
+}
+
+#newpostbtn {
+ text-align: center;
+ margin-top: 80px;
+}
+
+#postForm {
+ margin: auto;
+}
+
+#postForm tr > td:first-child {
+ background-color: #98e;
+ border: 1px black;
+ padding-left: 0.5em;
+ padding-right: 0.5em;
+}
+
+.nsfw #postForm tr > td:first-child {
+ background-color: #ea8;
+}
+
+#postForm input[type="text"],
+#postForm textarea,
+#reply-name, #reply-options, #reply-comment {
+ box-sizing: border-box;
+ -webkit-box-sizing:border-box;
+ -moz-box-sizing: border-box;
+}
+
+#postForm input[type="text"],
+#postForm textarea,
+#reply-name, #reply-options, #reply-comment {
+ box-sizing: border-box;
+ -webkit-box-sizing:border-box;
+ -moz-box-sizing: border-box;
+}
+
+#reply-comment {
+ min-width: 300px;
+ width: 396px;
+ height: 200px;
+}
+
+#reply-name {
+ width: 75%;
+ float: left;
+}
+
+#reply-options {
+ width: 25%;
+ float: right;
+}
+
+#reply-header {
+ display: inline-block;
+ width: 100%;
+ cursor: move;
+}
+
+#postForm #captcha {
+ display: block;
+ width: 100%;
+}
+
+.popup-box {
+ position: fixed;
+ min-width: 300px;
+ width: min-content;
+ z-index: 9;
+ display: block;
+}
+
+/* TODO: rename */
+.box2 {
+ border: 4px solid #f0e2d9;
+ background-color: #f9f9e0;
+}
+
+.newsbox {
+ padding: 25px;
+ border: 4px solid #f0e2d9;
+ background-color: #f9f9e0;
+}
+
+.newsbox h2 {
+ margin: 0;
+ padding: 0;
+}
+
+.newsbox-news {
+ text-align: left;
+ margin-top: 25px;
+ padding: 25px;
+}
+
+.newsbox-news p,
+.newsbox-news h3 {
+ margin: 0;
+}
+
+#stopTablePost {
+ float: right;
+ display: none;
+}
+
+#boardGrid {
+ display: grid;
+ grid-auto-columns: 1fr;
+ border: 4px solid #820404;
+ background-color: #f9f9e0;
+}
+
+#boardGridHeader {
+ border-bottom: 2px solid #820404;
+ display: inline-grid;
+}
+
+.boardGridCell {
+ white-space: nowrap;
+ display: inline-grid;
+ text-align: left;
+ padding: 5px;
+ border-top: 2px solid #820404;
+ border-left: 2px solid #820404;
+}
+
+/* these may or may not work. my CSS is poor so i just kinda did stuff until it worked. */
+.boardGridCell:nth-child(-n+4) {
+ border-top: none;
+}
+
+.boardGridCell:nth-child(3n+2) {
+ border-left: none;
+}
+
+#threadfooter {
+ width: 100%;
+ table-layout: fixed;
+ border-collapse: collapse;
+}
+
+#threadfooter td {
+ padding: 0;
+ margin: 0;
+}
+
+#threadfooter #threadStats {
+ float: right;
+}
+
+#navlinks, #boardlinks {
+ padding: 0;
+ margin: 0;
+}
+
+#navlinks > li,
+#boardlinks > li {
+ display: inline;
+}
diff --git a/views/css/themes/gruvbox.css b/views/css/themes/gruvbox.css
new file mode 100644
index 0000000..8704482
--- /dev/null
+++ b/views/css/themes/gruvbox.css
@@ -0,0 +1,235 @@
+a, a:link, a:visited, a:active {
+ color: #b16286;
+ text-decoration: none
+}
+
+a.reply {
+ color: #cc241d;
+ text-decoration: 1px underline;
+}
+
+a:hover.reply {
+ color: #fb4934;
+}
+
+body {
+ background: #282828;
+ color: #ebdbb2;
+
+ font-family: monospace, sans-serif;
+ font-size: 0.9em;
+}
+
+.popup-box {
+ border: 4px solid #928374;
+ background-color: #3c3836;
+}
+
+.box, .box-alt {
+ background-color: #3c3836;
+}
+
+.quote {
+ color: #98971a;
+}
+
+.post {
+ background-color: #1d2021;
+}
+
+:target > div > .post {
+ background-color: #504945;
+}
+
+.subject {
+ color: #458588;
+}
+
+.name {
+ color: #b8bb26;
+}
+
+.tripcode {
+ color: #689d6a;
+}
+
+h1,h2,h3,h4,h5,h6 {
+ color: #fb4934;
+ margin-bottom: 0.1em;
+}
+
+.replyLink {
+ color: #83a598;
+ font-size: 0.8em;
+}
+
+#newpostbtn {
+ text-align: center;
+ margin-top: 80px;
+}
+
+input[type="text"] {
+ -webkit-appearance: none;
+ -webkit-border-radius: 0;
+}
+
+#postForm {
+ border: 4px solid #928374;
+ background-color: #3c3836;
+ margin: auto;
+}
+
+#postForm tr > td:first-child {
+ background-color: #504945;
+ padding-left: 0.5em;
+ padding-right: 0.5em;
+}
+
+#postForm input[type="text"],
+#postForm textarea,
+#reply-name, #reply-options, #reply-comment {
+ background-color: #504945;
+ color: #ebdbb2;
+ border: 0;
+ border-bottom: 2px solid #3c3836;
+ font-family: monospace, sans-serif;
+
+ box-sizing: border-box;
+ -webkit-box-sizing:border-box;
+ -moz-box-sizing: border-box;
+}
+
+#postForm input[type="text"]:focus,
+#postForm textarea:focus,
+#reply-name:focus, #reply-options:focus, #reply-comment:focus {
+ outline: none;
+}
+
+#reply-comment {
+ min-width: 300px;
+ width: 396px;
+ height: 200px;
+}
+
+#reply-name {
+ width: 75%;
+ float: left;
+}
+
+#reply-options {
+ width: 25%;
+ border-left: 2px solid #3c3836;
+ float: right;
+}
+
+#reply-header {
+ display: inline-block;
+ width: 100%;
+ cursor: move;
+}
+
+#postForm #captcha {
+ display: block;
+ width: 100%;
+}
+
+.popup-box {
+ position: fixed;
+ min-width: 300px;
+ width: min-content;
+ z-index: 9;
+ display: block;
+}
+
+/* TODO: rename */
+.box2 {
+ border: 4px solid #928374;
+ background-color: #3c3836;
+}
+
+.newsbox {
+ padding: 25px;
+ border: 4px solid #928374;
+ background-color: #3c3836;
+}
+
+.newsbox h2 {
+ margin: 0;
+ padding: 0;
+}
+
+.newsbox-news {
+ text-align: left;
+ background-color: #504945;
+ margin-top: 25px;
+ padding: 25px;
+}
+
+.newsbox-news p,
+.newsbox-news h3 {
+ margin: 0;
+}
+
+#stopTablePost {
+ float: right;
+ display: none;
+}
+
+#boardGrid {
+ display: grid;
+ grid-auto-columns: 1fr;
+ border: 4px solid #928374;
+ background-color: #3c3836;
+}
+
+#boardGridHeader {
+ border-bottom: 2px solid #928374;
+ display: inline-grid;
+}
+
+.boardGridCell {
+ white-space: nowrap;
+ display: inline-grid;
+ text-align: left;
+ padding: 5px;
+ border-top: 2px solid #928374;
+ border-left: 2px solid #928374;
+}
+
+/* these may or may not work. my CSS is poor so i just kinda did stuff until it worked. */
+.boardGridCell:nth-child(-n+4) {
+ border-top: none;
+}
+
+.boardGridCell:nth-child(3n+2) {
+ border-left: none;
+}
+
+#threadfooter {
+ width: 100%;
+ table-layout: fixed;
+ border-collapse: collapse;
+}
+
+#threadfooter td {
+ padding: 0;
+ margin: 0;
+}
+
+#threadfooter #threadStats {
+ float: right;
+}
+
+#navlinks, #boardlinks {
+ padding: 0;
+ margin: 0;
+}
+
+#navlinks > li,
+#boardlinks > li {
+ display: inline;
+}
+
+hr {
+ border: 1px solid #928374;
+}
diff --git a/views/index.html b/views/index.html
new file mode 100644
index 0000000..f426d5d
--- /dev/null
+++ b/views/index.html
@@ -0,0 +1,53 @@
+
+
{{ .page.Title }}
+
{{ .page.PreferredUsername }} is a federated image board based on ActivityPub . The current version of the code running on the server is still a work-in-progress product, expect a bumpy ride for the time being. Get the server code here: https://github.com/FChannel0 .
+
+ {{ if .page.Boards }}
+ {{ $l := len .page.Boards }}
+
+
+ {{ if lt $l 2 }}
+
+ {{ else if eq $l 2 }}
+
+ {{ else }}
+
+ {{ end }}
+ {{ range .page.Boards }}
+
+ {{ end }}
+ {{ if gt $l 2 }}
+ {{ range .page.BoardRemainer }}
+
+ {{ end }}
+ {{ end }}
+
+
+ {{ end }}
+
+ {{ if .page.NewsItems }}
+
+
+ {{ range $i, $e := .page.NewsItems }}
+
+ {{ end }}
+
+ {{ end }}
+
+
+
Current known instances
+
(always use a proxy)
+
+ {{ range .page.InstanceIndex }}
+
+ {{ .Id }}
+
+ {{ end }}
+
+
+
diff --git a/views/js/footerscript.js b/views/js/footerscript.js
new file mode 100644
index 0000000..69e56e7
--- /dev/null
+++ b/views/js/footerscript.js
@@ -0,0 +1,44 @@
+var imgs = document.querySelectorAll('#img');
+var imgArray = [].slice.call(imgs);
+
+imgArray.forEach(function(img, i){
+ img.addEventListener("click", function(e){
+ var id = img.getAttribute("id");
+ var media = document.getElementById("media-" + id);
+ var sensitive = document.getElementById("sensitive-" + id);
+
+ if(img.getAttribute("enlarge") == "0")
+ {
+ var attachment = img.getAttribute("attachment");
+ img.setAttribute("enlarge", "1");
+ img.setAttribute("style", "float: left; margin-right: 10px; cursor: pointer;");
+ img.src = attachment;
+ }
+ else
+ {
+ var preview = img.getAttribute("preview");
+ img.setAttribute("enlarge", "0");
+ if(img.getAttribute("main") == 1)
+ {
+ img.setAttribute("style", "float: left; margin-right: 10px; max-width: 250px; max-height: 250px; cursor: pointer;");
+ img.src = preview;
+ }
+ else
+ {
+ img.setAttribute("style", "float: left; margin-right: 10px; max-width: 125px; max-height: 125px; cursor: pointer;");
+ img.src = preview;
+ }
+ }
+ });
+});
+
+
+function viewLink(board, actor) {
+ var posts = document.querySelectorAll('#view');
+ var postsArray = [].slice.call(posts);
+
+ postsArray.forEach(function(p, i){
+ var id = p.getAttribute("post");
+ p.href = "/" + board + "/" + shortURL(actor, id);
+ });
+}
diff --git a/views/js/posts.js b/views/js/posts.js
new file mode 100644
index 0000000..87f6228
--- /dev/null
+++ b/views/js/posts.js
@@ -0,0 +1,344 @@
+function startNewPost(){
+ var el = document.getElementById("newpostbtn");
+ el.style="display:none;";
+ el.setAttribute("state", "1");
+ document.getElementById("newpost").style = "";
+ document.getElementById("stopTablePost").style = "display:unset;";
+ sessionStorage.setItem("newpostState", true);
+}
+
+function stopNewPost(){
+ var el = document.getElementById("newpostbtn");
+ el.style="display:block;margin-bottom:100px;";
+ el.setAttribute("state", "0");
+ document.getElementById("newpost").style = "display: none;";
+ sessionStorage.setItem("newpostState", false);
+}
+
+function shortURL(actorName, url)
+{
+ re = /.+\//g;
+ temp = re.exec(url);
+
+ var output;
+
+ if(stripTransferProtocol(temp[0]) == stripTransferProtocol(actorName) + "/")
+ {
+ var short = url.replace("https://", "");
+ short = short.replace("http://", "");
+ short = short.replace("www.", "");
+
+ var re = /^.{3}/g;
+
+ var u = re.exec(short);
+
+ re = /\w+$/g;
+
+ output = re.exec(short);
+ }else{
+ var short = url.replace("https://", "");
+ short = short.replace("http://", "");
+ short = short.replace("www.", "");
+
+ var re = /^.{3}/g;
+
+ var u = re.exec(short);
+
+ re = /\w+$/g;
+
+ u = re.exec(short);
+
+ str = short.replace(/\/+/g, " ");
+
+ str = str.replace(u, " ").trim();
+
+ re = /(\w|[!@#$%^&*<>])+$/;
+
+ v = re.exec(str);
+
+ output = "f" + v[0] + "-" + u
+ }
+
+ return output;
+}
+
+function getBoardId(url)
+{
+ var re = /\/([^/\n]+)(.+)?/gm;
+ var matches = re.exec(url);
+ return matches[1];
+}
+
+function convertContent(actorName, content, opid)
+{
+ var re = /(>>)(https?:\/\/)?(www\.)?.+\/\w+/gm;
+ var match = content.match(re);
+ var newContent = content;
+ if(match)
+ {
+ match.forEach(function(quote, i){
+ var link = quote.replace('>>', '');
+ var isOP = "";
+ if(link == opid)
+ {
+ isOP = " (OP)";
+ }
+
+ var q = link;
+
+ if(document.getElementById(link + "-content") != null) {
+ q = document.getElementById(link + "-content").innerText;
+ q = q.replaceAll('>', '/\>');
+ q = q.replaceAll('"', '');
+ q = q.replaceAll("'", "");
+ }
+ newContent = newContent.replace(quote, '>>' + shortURL(actorName, link) + isOP + ' ');
+
+ });
+ }
+
+ re = /^(\s+)?>.+/gm;
+
+ match = newContent.match(re);
+ if(match)
+ {
+ match.forEach(function(quote, i) {
+
+ newContent = newContent.replace(quote, '' + quote + ' ');
+ });
+ }
+
+ return newContent.replaceAll('/\>', '>');
+}
+
+function convertContentNoLink(actorName, content, opid)
+{
+ var re = /(>>)(https?:\/\/)?(www\.)?.+\/\w+/gm;
+ var match = content.match(re);
+ var newContent = content;
+ if(match)
+ {
+ match.forEach(function(quote, i){
+ var link = quote.replace('>>', '');
+ var isOP = "";
+ if(link == opid)
+ {
+ isOP = " (OP)";
+ }
+
+ var q = link;
+
+ if(document.getElementById(link + "-content") != null) {
+ q = document.getElementById(link + "-content").innerText;
+ }
+
+ newContent = newContent.replace(quote, '>>' + shortURL(actorName, link) + isOP);
+ });
+ }
+ newContent = newContent.replaceAll("'", "");
+ return newContent.replaceAll('"', '');
+}
+
+function closeReply()
+{
+ document.getElementById("reply-box").style.display = "none";
+ document.getElementById("reply-comment").value = "";
+
+ sessionStorage.setItem("element-closed-reply", true);
+}
+
+function closeReport()
+{
+ document.getElementById("report-box").style.display = "none";
+ document.getElementById("report-comment").value = "";
+
+ sessionStorage.setItem("element-closed-report", true);
+}
+
+function quote(actorName, opid, id)
+{
+ sessionStorage.setItem("element-closed-reply", false);
+ var box = document.getElementById("reply-box");
+ var header = document.getElementById("reply-header");
+ var header_text = document.getElementById("reply-header-text");
+ var comment = document.getElementById("reply-comment");
+ var inReplyTo = document.getElementById("inReplyTo-box");
+
+ var w = window.innerWidth / 2 - 200;
+ var h = 300; //document.getElementById(id + "-content").offsetTop - 348;
+
+ const boxStyle = "top: " + h + "px; left: " + w + "px;";
+ box.setAttribute("style", boxStyle);
+ sessionStorage.setItem("element-reply-style", boxStyle);
+ sessionStorage.setItem("reply-top", h);
+ sessionStorage.setItem("reply-left", w);
+
+
+ if (inReplyTo.value != opid)
+ comment.value = "";
+
+ header_text.innerText = "Replying to Thread No. " + shortURL(actorName, opid);
+ inReplyTo.value = opid;
+ sessionStorage.setItem("element-reply-actor", actorName);
+ sessionStorage.setItem("element-reply-id", inReplyTo.value);
+
+ if(id != "reply")
+ comment.value += ">>" + id + "\n";
+ sessionStorage.setItem("element-reply-comment", comment.value);
+
+ dragElement(header);
+}
+
+function report(actorName, id)
+{
+ sessionStorage.setItem("element-closed-report", false);
+ var box = document.getElementById("report-box");
+ var header = document.getElementById("report-header");
+ var comment = document.getElementById("report-comment");
+ var inReplyTo = document.getElementById("report-inReplyTo-box");
+
+ var w = window.innerWidth / 2 - 200;
+ var h = 300; //document.getElementById(id + "-content").offsetTop - 348;
+
+ const boxStyle = "top: " + h + "px; left: " + w + "px;";
+ box.setAttribute("style", boxStyle);
+ sessionStorage.setItem("element-report-style", boxStyle);
+ sessionStorage.setItem("report-top", h);
+ sessionStorage.setItem("report-left", w);
+
+ header.innerText = "Report Post No. " + shortURL(actorName, id);
+ inReplyTo.value = id;
+ sessionStorage.setItem("element-report-actor", actorName);
+ sessionStorage.setItem("element-report-id", id);
+
+ dragElement(header);
+}
+
+var pos1, pos2, pos3, pos4;
+var elmnt;
+
+function closeDragElement(e) {
+ // stop moving when mouse button is released:
+ document.onmouseup = null;
+ document.onmousemove = null;
+ sessionStorage.setItem("eventhandler", false);
+}
+
+function elementDrag(e) {
+ e = e || window.event;
+ e.preventDefault();
+ // calculate the new cursor position:
+ pos1 = pos3 - e.clientX;
+ pos2 = pos4 - e.clientY;
+ pos3 = e.clientX;
+ pos4 = e.clientY;
+ sessionStorage.setItem("pos1", pos1);
+ sessionStorage.setItem("pos2", pos2);
+ sessionStorage.setItem("pos3", pos3);
+ sessionStorage.setItem("pos4", pos4);
+
+ // set the element's new position:
+ elmnt.parentElement.style.top = (elmnt.parentElement.offsetTop - pos2) + "px";
+ elmnt.parentElement.style.left = (elmnt.parentElement.offsetLeft - pos1) + "px";
+ if(elmnt.id.startsWith("report")){
+ sessionStorage.setItem("report-top", elmnt.parentElement.style.top);
+ sessionStorage.setItem("report-left", elmnt.parentElement.style.left);
+ }else if(elmnt.id.startsWith("reply")){
+ sessionStorage.setItem("reply-top", elmnt.parentElement.style.top);
+ sessionStorage.setItem("reply-left", elmnt.parentElement.style.left);
+ }
+}
+
+function dragMouseDown(e) {
+ e = e || window.event;
+ e.preventDefault();
+
+ // get the mouse cursor position at startup:
+ pos3 = e.clientX;
+ pos4 = e.clientY;
+ sessionStorage.setItem("pos3", pos3);
+ sessionStorage.setItem("pos4", pos4);
+
+ elmnt = e.currentTarget;
+
+ // call a function whenever the cursor moves:
+ document.onmouseup = closeDragElement;
+ document.onmousemove = elementDrag;
+ sessionStorage.setItem("eventhandler", true);
+
+}
+
+function dragElement(elmnt) {
+ elmnt.onmousedown = dragMouseDown;
+}
+
+const stateLoadHandler = function(event){
+ pos1 = parseInt(sessionStorage.getItem("pos1"));
+ pos2 = parseInt(sessionStorage.getItem("pos2"));
+ pos3 = parseInt(sessionStorage.getItem("pos3"));
+ pos4 = parseInt(sessionStorage.getItem("pos4"));
+
+ if(sessionStorage.getItem("element-closed-report") === "false"){
+ var box = document.getElementById("report-box");
+ var header = document.getElementById("report-header");
+ var comment = document.getElementById("report-comment");
+ var inReplyTo = document.getElementById("report-inReplyTo-box");
+
+ header.onmousedown = dragMouseDown;
+ inReplyTo.value = parseInt(sessionStorage.getItem("element-report-id"));
+ header.innerText = "Report Post No. " + shortURL(sessionStorage.getItem("element-report-actor"), sessionStorage.getItem("element-report-id"));
+ comment.value = sessionStorage.getItem("element-report-comment");
+
+ box.setAttribute("style", sessionStorage.getItem("element-report-style"));
+
+ box.style.top = sessionStorage.getItem("report-top");
+ box.style.left = sessionStorage.getItem("report-left");
+
+ if(sessionStorage.getItem("eventhandler") === "true"){
+ elmnt = header;
+ document.onmouseup = closeDragElement;
+ document.onmousemove = elementDrag;
+ }else{
+ document.onmouseup = null;
+ document.onmousemove = null;
+ }
+ }
+ if(sessionStorage.getItem("element-closed-reply") === "false"){
+ var box = document.getElementById("reply-box");
+ var header = document.getElementById("reply-header");
+ var header_text = document.getElementById("reply-header-text");
+ var comment = document.getElementById("reply-comment");
+ var inReplyTo = document.getElementById("inReplyTo-box");
+
+ header.onmousedown = dragMouseDown;
+ inReplyTo.value = parseInt(sessionStorage.getItem("element-reply-id"));
+ header_text.innerText = "Replying to Thread No. " + shortURL(sessionStorage.getItem("element-reply-actor"), sessionStorage.getItem("element-reply-id"));
+ comment.value = sessionStorage.getItem("element-reply-comment");
+
+ pos1 = parseInt(sessionStorage.getItem("pos1"));
+ pos2 = parseInt(sessionStorage.getItem("pos2"));
+ pos3 = parseInt(sessionStorage.getItem("pos3"));
+ pos4 = parseInt(sessionStorage.getItem("pos4"));
+
+ box.setAttribute("style", sessionStorage.getItem("element-reply-style"));
+
+ box.style.top = sessionStorage.getItem("reply-top");
+ box.style.left = sessionStorage.getItem("reply-left");
+
+ if(sessionStorage.getItem("eventhandler") === "true"){
+ elmnt = header;
+ document.onmouseup = closeDragElement;
+ document.onmousemove = elementDrag;
+ }else{
+ document.onmouseup = null;
+ document.onmousemove = null;
+ }
+ }
+};
+
+document.addEventListener("DOMContentLoaded", stateLoadHandler, false);
+
+function stripTransferProtocol(value){
+ var re = /(https:\/\/|http:\/\/)?(www.)?/;
+ return value.replace(re, "");
+}
diff --git a/views/js/themes.js b/views/js/themes.js
new file mode 100644
index 0000000..ccdd277
--- /dev/null
+++ b/views/js/themes.js
@@ -0,0 +1,40 @@
+function setCookie(key, value, age) {
+ document.cookie = key + "=" + encodeURIComponent(value) + ";sameSite=strict;max-age=" + (60 * 60 * 24 * age) + ";path=/";
+}
+
+function getCookie(key) {
+ if (document.cookie.length != 0) {
+ return document.cookie.split('; ').find(row => row.startsWith(key)).split('=')[1];
+ }
+ return "";
+}
+
+function setTheme(name) {
+ for (let i = 0, tags = document.getElementsByTagName("link"); i < tags.length; i++) {
+ if (tags[i].type === "text/css" && tags[i].title) {
+ tags[i].disabled = !(tags[i].title === name);
+ }
+ }
+
+ setCookie("theme", name, 3650);
+}
+
+function applyTheme() {
+ // HACK: disable all of the themes first. this for some reason makes things work.
+ for (let i = 0, tags = document.getElementsByTagName("link"); i < tags.length; i++) {
+ if (tags[i].type === "text/css" && tags[i].title) {
+ tags[i].disabled = true;
+ }
+ }
+ let theme = getCookie("theme") || "default";
+ setTheme(theme);
+
+ // reflect this in the switcher
+ let switcher = document.getElementById("themeSwitcher");
+ for(var i = 0; i < switcher.options.length; i++) {
+ if (switcher.options[i].value === theme) {
+ switcher.selectedIndex = i;
+ break;
+ }
+ }
+}
diff --git a/views/js/timer.js b/views/js/timer.js
new file mode 100644
index 0000000..d8be9de
--- /dev/null
+++ b/views/js/timer.js
@@ -0,0 +1,38 @@
+var timerCount;
+var timerToggle = false;
+var timer;
+const contentLoadHandler = function(event){
+ timerToggle = !!document.getElementById("autoreload-checkbox").checked;
+ if(timerToggle){
+ timerCount = 45;
+ document.getElementById("autoreload-countdown").innerHTML = "45";
+ document.getElementById("autoreload-countdown").style.visibility = "visible";
+ timer = setInterval(timerFunction, 1000);
+ document.removeEventListener("DOMContentLoaded", contentLoadHandler, false);
+ }
+};
+
+document.addEventListener("DOMContentLoaded", contentLoadHandler, false);
+
+function timerFunction(){
+ timerCount--;
+ document.getElementById("autoreload-countdown").innerHTML = timerCount;
+ if(timerCount <= 0){
+ document.getElementById("autoreload-countdown").innerHTML = "Refreshing...";
+ clearInterval(timer);
+ location.reload();
+ }
+}
+
+function autoTimer(){
+ timerToggle = !timerToggle;
+ if(timerToggle === true){
+ timerCount = 45;
+ document.getElementById("autoreload-countdown").innerHTML = "45";
+ document.getElementById("autoreload-countdown").style.visibility = "visible";
+ timer = setInterval(timerFunction, 1000);
+ }else{
+ clearInterval(timer);
+ document.getElementById("autoreload-countdown").style.visibility = "hidden";
+ }
+}
diff --git a/views/layouts/main.html b/views/layouts/main.html
new file mode 100644
index 0000000..4cd48f9
--- /dev/null
+++ b/views/layouts/main.html
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+ {{ if gt (len .page.ThemeCookie) 0 }}
+
+ {{ else }}
+
+ {{ end }}
+ {{ range .page.Themes }}
+
+ {{ end }}
+
+ {{ template "header" .page }}
+
+
+
+ {{ $l := len .page.Boards }}
+ [Home ]
+ {{range $i, $e := .page.Boards}}
+ {{ if eq (sub $l 1) 0 }}
+ [ {{$e.Name}} ]
+ {{ else if eq $i 0 }}
+ [{{$e.Name}} /
+ {{ else if eq $i (sub $l 1) }}
+ {{$e.Name}} ]
+ {{ else }}
+ {{$e.Name}} /
+ {{ end }}
+ {{ end }}
+
+ {{ if .page.Board.ModCred }}
+ {{ if eq .page.Board.ModCred .page.Board.Domain .page.Board.Actor.Id }}
+ [Manage Board ]
+ {{ end }}
+ {{ end }}
+
+ {{ embed }}
+
+ {{ template "partials/footer" .page }}
+
+
+ {{ template "scripts" .page }}
+
+
diff --git a/views/npost.html b/views/npost.html
new file mode 100644
index 0000000..5a382ed
--- /dev/null
+++ b/views/npost.html
@@ -0,0 +1,66 @@
+{{ define "header" }}
+/{{ .Board.Name }}/ - {{ .PostId }}
+
+
+
+
+
+
+
+
+
+
+
+{{ if (index .Posts 0).Preview }}
+
+
+{{ end }}
+{{ end }}
+
+{{ template "partials/top" .page }}
+
+{{ $board := .Board }}
+
+
+
+
+
+{{ template "partials/posts" .page }}
+
+
+
+
+
+
+
+{{ template "partials/bottom" .page }}
+
+{{ define "scripts" }}
+{{ template "partials/postscripts" . }}
+{{ end }}
diff --git a/views/nposts.html b/views/nposts.html
new file mode 100644
index 0000000..ae5a9b6
--- /dev/null
+++ b/views/nposts.html
@@ -0,0 +1,70 @@
+{{ define "header" }}
+{{ .Title }}
+
+
+
+
+
+
+
+
+
+
+{{ end }}
+
+{{ template "partials/top" .page }}
+
+{{ $board := .page.Board }}
+
+
+
+{{ template "partials/posts" .page }}
+
+
+
+
+
+
+{{ if gt .page.TotalPage 0 }}
+{{ $totalPage := .page.TotalPage }}
+
+ {{ $page := .page.CurrentPage }}
+ {{ if gt $page 0 }}
+ [< ]
+ {{ end }}
+ {{ range $i, $e := .page.Pages }}
+ {{ if eq $i $page}}
+ [{{ $i }} ]
+ {{ else }}
+ [{{ $i }} ]
+ {{ end }}
+ {{ end }}
+ {{ if lt .page.CurrentPage .page.TotalPage }}
+ [> ]
+ {{ end }}
+
+{{ end }}
+
+{{ template "partials/bottom" .page }}
+
+{{ define "scripts" }}
+{{ template "partials/postscripts" . }}
+{{ end }}
diff --git a/views/partials/bottom.html b/views/partials/bottom.html
new file mode 100644
index 0000000..35e8c4a
--- /dev/null
+++ b/views/partials/bottom.html
@@ -0,0 +1,48 @@
+
+
+
diff --git a/views/partials/footer.html b/views/partials/footer.html
new file mode 100644
index 0000000..efbde4f
--- /dev/null
+++ b/views/partials/footer.html
@@ -0,0 +1,13 @@
+
+ [
Home ] [
Rules ] [
FAQ ]
+
All trademarks and copyrights on this page are owned by their respective parties.
+
+
+
+ Theme:
+
+ {{ range .Themes }}
+ {{.}}
+ {{ end }}
+
+
diff --git a/views/partials/posts.html b/views/partials/posts.html
new file mode 100644
index 0000000..f82d2d5
--- /dev/null
+++ b/views/partials/posts.html
@@ -0,0 +1,122 @@
+{{ $board := .Board }}
+{{ $len := len .Posts }}
+{{ range .Posts }}
+{{ $thread := . }}
+{{ $opId := .Id }}
+{{ if eq $board.InReplyTo "" }}
+
+{{ end }}
+
+
+ {{ if eq $board.ModCred $board.Domain $board.Actor.Id }}
+ [
Delete Post ]
+ {{ end }}
+ {{ if .Attachment }}
+ {{ if eq $board.ModCred $board.Domain $board.Actor.Id }}
+ [
Ban Media ]
+ [
Delete Attachment ]
+ [
Mark Sensitive ]
+ {{ end }}
+
File: {{ shortImg (index .Attachment 0).Name }} ({{ convertSize (index .Attachment 0).Size }})
+
[Hide]
+
NSFW Content
+
{{ parseAttachment . false }}
+
+ {{ end }}
+
{{ .Name }}
+
{{ if .AttributedTo }} {{.AttributedTo }} {{ else }} Anonymous {{ end }}
+
{{ .TripCode }}
+
{{ .Published | timeToReadableLong }} No. {{ short $board.Actor.Outbox .Id }} {{ if ne .Type "Tombstone" }}[Report ]{{ end }}
+
{{ parseContent $board.Actor $opId .Content $thread }}
+ {{ if .Replies }}
+ {{ $replies := .Replies }}
+ {{ if gt $replies.TotalItems 5 }}
+ {{ if gt $len 1 }}
+
{{ $replies.TotalItems }} replies{{ if gt $replies.TotalImgs 0}} and {{ $replies.TotalImgs }} images{{ end }}, Click here to view all.
+ {{ end }}
+ {{ end }}
+ {{ range $replies.OrderedItems }}
+
+
+
>>
+
+ {{ if eq $board.ModCred $board.Domain $board.Actor.Id }}
+ [
Delete Post ]
+ {{ end }}
+ {{ if .Attachment }}
+ {{ if eq $board.ModCred $board.Domain $board.Actor.Id }}
+ [
Ban Media ]
+ [
Delete Attachment ]
+ [
Mark Sensitive ]
+ {{ end }}
+
File {{ shortImg (index .Attachment 0).Name }} ({{ convertSize (index .Attachment 0).Size }})
+
[Hide]
+
NSFW Content
+
+
{{ parseAttachment . false }}
+
+ {{ end }}
+
{{ .Name }}
+
{{ if .AttributedTo }} {{.AttributedTo }} {{ else }} Anonymous {{ end }}
+
{{ .TripCode }}
+
{{ .Published | timeToReadableLong }} No. {{ short $board.Actor.Outbox .Id }} {{ if ne .Type "Tombstone" }}[Report ]{{ end }}
+ {{ $parentId := .Id }}
+ {{ if .Replies.OrderedItems }}
+ {{ range .Replies.OrderedItems }}
+
+
+
+ {{ end }}
+ {{ end }}
+
{{ parseContent $board.Actor $opId .Content $thread }}
+
+
+
+ {{ end }}
+ {{ end }}
+
+
+{{ end }}
diff --git a/views/partials/postscripts.html b/views/partials/postscripts.html
new file mode 100644
index 0000000..f26e354
--- /dev/null
+++ b/views/partials/postscripts.html
@@ -0,0 +1,3 @@
+
+
+
diff --git a/views/partials/top.html b/views/partials/top.html
new file mode 100644
index 0000000..7c03c36
--- /dev/null
+++ b/views/partials/top.html
@@ -0,0 +1,128 @@
+
+
/{{ .Board.Name }}/ - {{ .Board.PrefName }}
+
{{ .Board.Summary }}
+ {{ $len := len .Posts }}
+ {{ if eq $len 0 }}
+ {{ if .Board.InReplyTo }}
+
+ {{ else }}
+
+ {{ end }}
+
+
+ {{ else }}
+
+ {{ if eq (index .Posts 0).Type "Note" }}
+ {{ if .Board.InReplyTo }}
+
+ {{ else }}
+
+ {{ end }}
+ {{ $len := len .Posts }}
+
+
+
+ {{ else }}
+ Archived Post
+ {{ end }}
+ {{ end }}
+
+
--
cgit v1.2.3