From 2566e314e8351ffbceae9a2688d90a5c811d49e5 Mon Sep 17 00:00:00 2001 From: FChannel <=> Date: Fri, 22 Jan 2021 21:12:26 -0800 Subject: client to server conversion --- static/admin.html | 77 +++++++++++++++ static/bottom.html | 23 +++++ static/catalog.html | 189 ++++++++++++++++++++++++++++++++++++ static/index.html | 14 +++ static/js/footerscript.js | 40 ++++++++ static/js/posts.js | 239 ++++++++++++++++++++++++++++++++++++++++++++++ static/main.html | 42 ++++++++ static/manage.html | 81 ++++++++++++++++ static/nadmin.html | 76 +++++++++++++++ static/ncatalog.html | 93 ++++++++++++++++++ static/npost.html | 39 ++++++++ static/nposts.html | 51 ++++++++++ static/posts.html | 179 ++++++++++++++++++++++++++++++++++ static/top.html | 37 +++++++ static/verify.html | 17 ++++ 15 files changed, 1197 insertions(+) create mode 100644 static/admin.html create mode 100644 static/bottom.html create mode 100644 static/catalog.html create mode 100644 static/index.html create mode 100644 static/js/footerscript.js create mode 100644 static/js/posts.js create mode 100644 static/main.html create mode 100644 static/manage.html create mode 100644 static/nadmin.html create mode 100644 static/ncatalog.html create mode 100644 static/npost.html create mode 100644 static/nposts.html create mode 100644 static/posts.html create mode 100644 static/top.html create mode 100644 static/verify.html (limited to 'static') diff --git a/static/admin.html b/static/admin.html new file mode 100644 index 0000000..f7db70c --- /dev/null +++ b/static/admin.html @@ -0,0 +1,77 @@ + + + + + + +
+

Add Board

+
+
+
+
+
+
+
+
+ +
+ + + +
+ +
+

Following

+
+
+
+ +
+ +
+ + + + + + + + diff --git a/static/bottom.html b/static/bottom.html new file mode 100644 index 0000000..0542c41 --- /dev/null +++ b/static/bottom.html @@ -0,0 +1,23 @@ +{{ define "bottom" }} + +{{ end }} diff --git a/static/catalog.html b/static/catalog.html new file mode 100644 index 0000000..b5b361e --- /dev/null +++ b/static/catalog.html @@ -0,0 +1,189 @@ + + + + {{ .Title }} + + + + + + {{ $board := .Board }} + {{ if $board.IsMod }} + [Manage Board] + {{ end }} +
+

/{{ $board.Name }}/ - {{ $board.PrefName }}

+
+
+
+
+
+
+
+
+
+ + + + +

+
+
+
+ +
+
+
+ +
+ +
+ +
+ {{ range .Posts }} +
+ {{ if $board.IsMod }} + [Delete Post] + {{ end }} + {{ if .Attachment }} + {{ if $board.IsMod }} + [Delete Attachment] + {{ end }} + +
+ + + + {{ end }} +
+ {{ $replies := .Replies }} + R: {{ $replies.TotalItems }}{{ if $replies.TotalImgs }}/ A: {{ $replies.TotalImgs }}{{ end }} + {{ if .Name }} + {{ .Name }} + {{ end }} + {{ if .Content }} + {{.Content}} + {{ end }} +
+
+
+ + {{ end }} +
+
+ +
+ + + diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..2840a83 --- /dev/null +++ b/static/index.html @@ -0,0 +1,14 @@ +{{ define "header" }} +{{ end }} + +{{ define "top" }}{{ end }} +{{ define "content" }} +
+

{{ .Title }}

+

{{.Message}}

+
+{{ end }} +{{ define "bottom" }}{{ end }} + +{{ define "script" }} +{{ end }} diff --git a/static/js/footerscript.js b/static/js/footerscript.js new file mode 100644 index 0000000..bd36daa --- /dev/null +++ b/static/js/footerscript.js @@ -0,0 +1,40 @@ +var imgs = document.querySelectorAll('#img'); +var imgArray = [].slice.call(imgs); + +imgArray.forEach(function(img, i){ + img.addEventListener("click", function(e){ + if(img.getAttribute("enlarge") == "0") + { + var attachment = img.getAttribute("attachment") + img.setAttribute("enlarge", "1"); + img.setAttribute("style", "float: left; margin-right: 10px; cursor: move;"); + 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: move;"); + img.src = preview + } + else + { + img.setAttribute("style", "float: left; margin-right: 10px; max-width: 125px; max-height: 125px; cursor: move;"); + 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/static/js/posts.js b/static/js/posts.js new file mode 100644 index 0000000..7c1a3e8 --- /dev/null +++ b/static/js/posts.js @@ -0,0 +1,239 @@ +function newpost() +{ + var el = document.getElementById("newpostbtn") + var state = el.getAttribute("state") + if(state = "0") + { + el.style="display:none;" + el.setAttribute("state", "1") + document.getElementById("newpost").style = "display: block;"; + } + else + { + el.style="display:block;" + el.setAttribute("state", "0") + document.getElementById("newpost").style = "display: hidden;"; + } +} + +function getMIMEType(type) +{ + re = /\/.+/g + return type.replace(re, "") +} + +function shortURL(actorName, url) +{ + var check = url.replace(actorName + "/", "") + re = /.+\//g; + temp = re.exec(url) + + + 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; + + u = re.exec(short); + + return u; + }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); + + + replace = short.replace(/\/+/g, " ") + replace = replace.replace(u, " ").trim() + re = /\w+$/; + v = re.exec(replace) + + v = "f" + v[0] + "-" + u + + return v; + } +} + +function shortImg(url) +{ + var u = url; + if(url.length > 26) + { + var re = /^.{26}/g; + + u = re.exec(url); + + re = /\..+$/g; + + var v = re.exec(url); + + u += "(...)" + v; + } + return u; +} + +function convertSize(size) +{ + var convert = size / 1024.0; + if(convert > 1024) + { + convert = convert / 1024.0 + convert = convert.toFixed(2) + " MB" + } + else + { + convert = convert.toFixed(2) + " KB" + } + + return convert +} + +function getBoardId(url) +{ + var re = /\/([^/\n]+)(.+)?/gm + var matches = re.exec(url); + return matches[1] +} + +function convertContent(actorName, content, opid) +{ + var re = /(>>)(https:\/\/|http:\/\/)?(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)"; + } + + newContent = newContent.replace(quote, '>>' + shortURL(actorName, link) + isOP + ''); + + }) + } + + re = /^>.+/gm; + + match = newContent.match(re); + if(match) + { + match.forEach(function(quote, i) { + newContent = newContent.replace(quote, '' + quote + ''); + }) + } + + return newContent +} + +function closeReply() +{ + document.getElementById("reply-box").style.display = "none"; + document.getElementById("reply-comment").value = ""; +} + + +function previous(actorName, page) +{ + var prev = parseInt(page) - 1; + if(prev < 0) + prev = 0; + window.location.href = "/" + actorName + "/" + prev; +} + +function next(actorName, totalPage, page) +{ + var next = parseInt(page) + 1; + if(next > parseInt(totalPage)) + next = parseInt(totalPage); + window.location.href = "/" + actorName + "/" + next; +} + +function quote(actorName, opid, id) +{ + var box = document.getElementById("reply-box"); + var header = document.getElementById("reply-header"); + var comment = document.getElementById("reply-comment"); + var inReplyTo = document.getElementById("inReplyTo-box"); + + var w = window.innerWidth / 2 - 200; + var h = document.getElementById(id + "-content").offsetTop - 448; + + box.setAttribute("style", "display: block; position: absolute; background-color: #eff5ff; width: 400px; height: 550px; z-index: 9; top: " + h + "px; left: " + w + "px; padding: 5px; border: 4px solid #d3caf0;"); + + + if (inReplyTo.value != opid) + comment.value = ""; + + header.innerText = "Replying to Thread No. " + shortURL(actorName, opid); + inReplyTo.value = opid; + + if(comment.value != "") + comment.value += "\n>>" + id; + else + comment.value += ">>" + id; + + dragElement(header); + +} + +function dragElement(elmnt) { + var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; + + elmnt.onmousedown = dragMouseDown; + + function dragMouseDown(e) { + e = e || window.event; + e.preventDefault(); + // get the mouse cursor position at startup: + pos3 = e.clientX; + pos4 = e.clientY; + document.onmouseup = closeDragElement; + // call a function whenever the cursor moves: + document.onmousemove = elementDrag; + } + + 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; + // set the element's new position: + elmnt.parentElement.style.top = (elmnt.parentElement.offsetTop - pos2) + "px"; + elmnt.parentElement.style.left = (elmnt.parentElement.offsetLeft - pos1) + "px"; + } + + function closeDragElement() { + // stop moving when mouse button is released: + document.onmouseup = null; + document.onmousemove = null; + } +} + +function stripTransferProtocol(value){ + var re = /(https:\/\/|http:\/\/)?(www.)?/ + + return value.replace(re, "") +} + diff --git a/static/main.html b/static/main.html new file mode 100644 index 0000000..f4007d1 --- /dev/null +++ b/static/main.html @@ -0,0 +1,42 @@ +{{ define "layout" }} + + + + + {{ .Title }} + + {{ template "header" . }} + + + + {{ if .Board.ModCred }} + {{ if eq .Board.ModCred .Board.Domain .Board.Actor }} + [Manage Board] + {{ end }} + {{ end }} + {{ template "top" . }} + + {{ template "content" . }} + + {{ template "bottom" . }} + + + +{{ template "script" . }} +{{ end }} diff --git a/static/manage.html b/static/manage.html new file mode 100644 index 0000000..43ff766 --- /dev/null +++ b/static/manage.html @@ -0,0 +1,81 @@ +{{ define "title" }}{{ .Title }}{{ end }} +{{ define "header" }} + +{{ end }} +{{ define "top" }}{{ end }} +{{ define "content" }} +
+

Manage /{{ .Board.Name }}/

+ + +
+[Return] +
+

Subscribed

+
+
+ +
+ +
+ +
+ + + + +{{ end }} +{{ define "bottom" }}{{ end }} + +{{ define "script" }} + +{{ end }} diff --git a/static/nadmin.html b/static/nadmin.html new file mode 100644 index 0000000..0583efc --- /dev/null +++ b/static/nadmin.html @@ -0,0 +1,76 @@ +{{ define "title" }}{{ .Title }}{{ end }} +{{ define "header" }} {{ end }} +{{ define "top" }}{{ end }} +{{ define "content" }} +
+

Add Board

+
+
+
+
+
+
+
+
+ +
+ + +
+ +
+

Following

+
+
+
+ +
+ +
+ + + + +{{ end }} +{{ define "bottom" }}{{ end }} + +{{ define "script" }} + +{{ end }} diff --git a/static/ncatalog.html b/static/ncatalog.html new file mode 100644 index 0000000..a57e291 --- /dev/null +++ b/static/ncatalog.html @@ -0,0 +1,93 @@ +{{ define "header" }} + +{{ end }} + +{{ define "content" }} +{{ $board := .Board }} +
+ +
+ +
+ {{ range .Posts }} +
+ {{ if eq $board.ModCred $board.Domain $board.Actor }} + [Delete Post] + {{ end }} + {{ if .Attachment }} + {{ if eq $board.ModCred $board.Domain $board.Actor }} + [Delete Attachment] + {{ end }} + +
+ + {{ end }} +
+ {{ $replies := .Replies }} + R: {{ $replies.TotalItems }}{{ if $replies.TotalImgs }}/ A: {{ $replies.TotalImgs }}{{ end }} + {{ if .Name }} + {{ .Name }} + {{ end }} + + {{ if .Content }} + {{.Content}} + {{ end }} + +
+
+
+ + {{ end }} +
+
+ +
+{{ end }} +{{ define "bottom" }} +{{ end }} + +{{ define "script" }} +{{ end }} diff --git a/static/npost.html b/static/npost.html new file mode 100644 index 0000000..bf07c63 --- /dev/null +++ b/static/npost.html @@ -0,0 +1,39 @@ +{{ define "header" }} + +{{ end }} + +{{ define "content" }} +{{ $board := .Board }} + +
+ +
+ +{{ template "posts" . }} + +
+ +
+ [Post a Reply] + {{ $replies := (index .Posts 0).Replies }} + {{ $replies.TotalItems }} / {{ $replies.TotalImgs }} +
+
+{{ end }} + +{{ define "script" }} + + +{{ end }} diff --git a/static/nposts.html b/static/nposts.html new file mode 100644 index 0000000..2296df5 --- /dev/null +++ b/static/nposts.html @@ -0,0 +1,51 @@ +{{ define "header" }} + +{{ end }} + + +{{ define "content" }} +{{ $board := .Board }} +
+ + +{{ template "posts" . }} + +
+ +
+{{ if gt .TotalPage 0 }} +{{ $totalPage := .TotalPage }} + +{{ end }} +{{ end }} + +{{ define "script" }} + + +{{ end }} diff --git a/static/posts.html b/static/posts.html new file mode 100644 index 0000000..ebe8f4e --- /dev/null +++ b/static/posts.html @@ -0,0 +1,179 @@ +{{ define "posts" }} +{{ $board := .Board }} +{{ $len := len .Posts }} +{{ range .Posts }} +{{ $opId := .Id }} +{{ if eq $board.InReplyTo "" }} +
+{{ end }} +
+
+ {{ if eq $board.ModCred $board.Domain $board.Actor }} + [Delete Post] + {{ end }} + {{ if .Attachment }} + {{ if eq $board.ModCred $board.Domain $board.Actor }} + [Delete Attachment] + {{ end }} + File: {{ (index .Attachment 0).Name }}({{ (index .Attachment 0).Size }}) +
+ + {{ end }} + {{ .Name }}{{ if .AttributedTo }} {{.AttributedTo }} {{ else }} Anonymous {{ end }}{{ .Published }} No. {{ .Id }} {{ if ne .Type "Tombstone" }}[Report]{{ end }} +

{{.Content}}

+ {{ if .Replies }} + {{ $replies := .Replies }} + {{ if gt $replies.TotalItems 5 }} + {{ $replies.TotalItems }} replies{{ if gt $replies.TotalImgs 0}} and {{ $replies.TotalImgs }} images{{ end }}, Click here to view all. + {{ end }} + {{ range $replies.OrderedItems }} +
+
+
>>
+
+ {{ if eq $board.ModCred $board.Domain $board.Actor }} + [Delete Post] + {{ end }} + {{ if .Attachment }} + {{ if eq $board.ModCred $board.Domain $board.Actor }} + [Delete Attachment] + {{ end }} + File {{ (index .Attachment 0).Name }} ({{ (index .Attachment 0).Size }}) +
+ + {{ end }} + {{ .Name }}{{ if .AttributedTo }} {{.AttributedTo }} {{ else }} Anonymous {{ end }}{{ .Published }} No. {{ .Id }} {{ if ne .Type "Tombstone" }}[Report]{{ end }} + {{ $parentId := .Id }} + {{ if .Replies.OrderedItems }} + {{ range .Replies.OrderedItems }} + + + {{ end }} + {{ end }} +

{{.Content}}

+
+
+
+ + {{ end }} + {{ end }} +
+
+ +{{ end }} +{{ end }} diff --git a/static/top.html b/static/top.html new file mode 100644 index 0000000..d28043f --- /dev/null +++ b/static/top.html @@ -0,0 +1,37 @@ +{{ define "top" }} +
+

/{{ .Board.Name }}/ - {{ .Board.PrefName }}

+

{{ .Board.Summary }}

+ {{ $len := len .Posts }} + {{ if .Board.InReplyTo }} +

[Post a Reply]

+ {{ else }} +

[Start a New Thread]

+ {{ end }} + +
+{{ end }} diff --git a/static/verify.html b/static/verify.html new file mode 100644 index 0000000..fb3fb3d --- /dev/null +++ b/static/verify.html @@ -0,0 +1,17 @@ + + + + + + +
+
+ +
+ +
+ +
+
+ + -- cgit v1.2.3