From 677aaa288a3b6065316b81fc4c3d22350e06286d Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 13 Jun 2022 20:00:49 +0400 Subject: [PATCH] Unfortunately, Jade cannot extend templates. Instead you must include parts. --- web/templates/404.jade | 19 -------- web/templates/base.jade | 2 +- web/templates/base/body.footer.jade | 2 + web/templates/base/body.header.jade | 7 +++ web/templates/base/top.jade | 11 +++++ web/templates/error404.jade | 19 ++++++++ web/templates/index.jade | 70 ++++++++++++++++------------- web/templates/nospace.jade | 14 +++--- web/templates/uploaded.jade | 24 ++++++---- 9 files changed, 100 insertions(+), 68 deletions(-) delete mode 100644 web/templates/404.jade create mode 100644 web/templates/base/body.footer.jade create mode 100644 web/templates/base/body.header.jade create mode 100644 web/templates/base/top.jade create mode 100644 web/templates/error404.jade diff --git a/web/templates/404.jade b/web/templates/404.jade deleted file mode 100644 index 68a586c..0000000 --- a/web/templates/404.jade +++ /dev/null @@ -1,19 +0,0 @@ -extends base.jade - -block head - style(type="text/css"). - #error { - font-size: 3.5rem; - line-height: 5rem; - text-align: center; - margin: 6rem 0; } - - #error h1 { font-size: 8rem; } - -block header - h1 xDDDD - -block body - section#error - h1 404 - | Nod Found xD \ No newline at end of file diff --git a/web/templates/base.jade b/web/templates/base.jade index b43dcb3..f0aa2a4 100644 --- a/web/templates/base.jade +++ b/web/templates/base.jade @@ -16,7 +16,7 @@ html(lang="en") text.logo Arav's dwelling text.under(y="11") Welcome to my sacred place, wanderer nav - a(href=.MainSite title="Arav's dwelling") Back to main website + a(href=mainSite title="Arav's dwelling") Back to main website block header h1 Upload block body diff --git a/web/templates/base/body.footer.jade b/web/templates/base/body.footer.jade new file mode 100644 index 0000000..5c5136a --- /dev/null +++ b/web/templates/base/body.footer.jade @@ -0,0 +1,2 @@ +footer + | 2022 Arav <#[a(href="mailto:me@arav.top") me@arav.top]> \ No newline at end of file diff --git a/web/templates/base/body.header.jade b/web/templates/base/body.header.jade new file mode 100644 index 0000000..ee19f86 --- /dev/null +++ b/web/templates/base/body.header.jade @@ -0,0 +1,7 @@ +body + header + svg#logo(viewBox="0 -25 216 40") + text.logo Arav's dwelling + text.under(y="11") Welcome to my sacred place, wanderer + nav + a(href=mainSite title="Arav's dwelling") Back to main website \ No newline at end of file diff --git a/web/templates/base/top.jade b/web/templates/base/top.jade new file mode 100644 index 0000000..56a21fc --- /dev/null +++ b/web/templates/base/top.jade @@ -0,0 +1,11 @@ +doctype html +html(lang="en") + head + title Arav's dwelling / Upload + meta(charset="utf-8") + meta(http-equiv="X-UA-Compatible" content="IE=edge") + meta(name="viewport" content="width=device-width, initial-scale=1.0") + meta(name="theme-color" content="#cd2682") + meta(name="description" content="File upload service for ya.") + link(rel="icon" href="/assets/img/favicon.svg" sizes="any" type="image/svg+xml") + link(href="/assets/css/main.css" rel="stylesheet") \ No newline at end of file diff --git a/web/templates/error404.jade b/web/templates/error404.jade new file mode 100644 index 0000000..00e1850 --- /dev/null +++ b/web/templates/error404.jade @@ -0,0 +1,19 @@ +:go:func Error404(mainSite string) + +include base/top.jade + style(type="text/css"). + #error { + font-size: 3.5rem; + line-height: 5rem; + text-align: center; + margin: 6rem 0; } + + #error h1 { font-size: 8rem; } +include base/body.header.jade + h1 404 + +section#error + h1 404 + | Nod Found xD + +include base/body.footer.jade diff --git a/web/templates/index.jade b/web/templates/index.jade index 5798946..c27e8dc 100644 --- a/web/templates/index.jade +++ b/web/templates/index.jade @@ -1,32 +1,38 @@ -extends base.jade -block body - section#rules.center - h2 Rules - ul - li Max. file size is #{.FileMaxSz}. - li It will be kept for #{.KeepForHours} hours. - li Anything you upload should comply with Russian Federation's law. Generally speaking, anything illegal, like CP, extremist literature etc., is forbidden. - section#used-space.center - h2 Free space - div - span #{.StorageUsedStr} - progress(value=.StorageUsed max=.StorageCapacity) - span #{.StorageCapStr} - div - | #{.StorageAvailStr} - section#upload.center - h2 Upload - form(action="/" method="POST" enctype="multipart/form-data") - input(type="file" name="file" multiple=false) - button(type="submit") Upload - section - p.center You can use cURL to upload a file: #[code curl -F 'file=@somefile.ext' https://upload.arav.top] - p.center Over I2P: #[code curl --proxy 127.0.0.1:4444 -F 'file=@somefile.ext' http://upload.arav.i2p] - p.center A resulted link looks like this: #[code /f/base64rawURL(sha256)/filename.ext]. - p.center filename.ext is mandatory. It is a name the file will be retrieved with. - section - h2 Privacy statements - p I WILL cooperate with law enforcements and provide them with logs, guess I shouldn't clarify why. Abuses should be sent to #[a(href="mailto:admin@arav.top") admin@arav.top]. - p Upload logs include: access time, IP-address, name of a file it was uploaded with, a SHA-256 hash of the file, download name*, size of the file in bytes, User-Agent. - p Each download also being logged and include: access time, IP-address, name of a file it was requested with, download name*, User-Agent. - p *Download name is a salted SHA-256 hash of the file encoded using base64 raw URL encoding. The hash is being salted to make useless any attempt of bruteforcing. \ No newline at end of file +:go:func Index(mainSite string, fileMaxSize, storageCapacity, storageUsed, keepForHours int, storageUsedStr, storageCapacityStr, storageAvailableStr string) + +include base/top.jade +include base/body.header.jade + h1 Upload + +section#rules.center + h2 Rules + ul + li Max. file size is #{fileMaxSize}. + li It will be kept for #{keepForHours} hours. + li Anything you upload should comply with Russian Federation's law. Generally speaking, anything illegal, like CP, extremist literature etc., is forbidden. +section#used-space.center + h2 Free space + div + span #{storageUsedStr} + progress(value=storageUsed max=storageCapacity) + span #{storageCapacityStr} + div + | #{storageAvailableStr} +section#upload.center + h2 Upload + form(action="/" method="POST" enctype="multipart/form-data") + input(type="file" name="file" multiple=false) + button(type="submit") Upload +section + p.center You can use cURL to upload a file: #[code curl -F 'file=@somefile.ext' https://upload.arav.top] + p.center Over I2P: #[code curl --proxy 127.0.0.1:4444 -F 'file=@somefile.ext' http://upload.arav.i2p] + p.center A resulted link looks like this: #[code /f/base64rawURL(sha256)/filename.ext]. + p.center filename.ext is mandatory. It is a name the file will be retrieved with. +section + h2 Privacy statements + p I WILL cooperate with law enforcements and provide them with logs, guess I shouldn't clarify why. Abuses should be sent to #[a(href="mailto:admin@arav.top") admin@arav.top]. + p Upload logs include: access time, IP-address, name of a file it was uploaded with, a SHA-256 hash of the file, download name*, size of the file in bytes, User-Agent. + p Each download also being logged and include: access time, IP-address, name of a file it was requested with, download name*, User-Agent. + p *Download name is a salted SHA-256 hash of the file encoded using base64 raw URL encoding. The hash is being salted to make useless any attempt of bruteforcing. + +include base/body.footer.jade \ No newline at end of file diff --git a/web/templates/nospace.jade b/web/templates/nospace.jade index 7fb6748..12a0f3d 100644 --- a/web/templates/nospace.jade +++ b/web/templates/nospace.jade @@ -1,6 +1,6 @@ -extends base.jade +:go:func ErrorNoSpace(mainSite string) -block head +include base/top.jade style(type="text/css"). #error { font-size: 3.5rem; @@ -9,10 +9,10 @@ block head margin: 6rem 0; } #error h1 { font-size: 6rem; } - -block header +include base/body.header.jade h1 :( -block body - section#error - h1 Not enough space left \ No newline at end of file +section#error + h1 Not enough space left + +include base/body.footer.jade diff --git a/web/templates/uploaded.jade b/web/templates/uploaded.jade index 1908190..1c8c4cd 100644 --- a/web/templates/uploaded.jade +++ b/web/templates/uploaded.jade @@ -1,9 +1,15 @@ -extends base.jade -block body - section#file - h2 Your link - center - a(href=.DownloadURL) #{.DownloadURL} - center It will be available for next #{.KeepForHours} hours. - center - a(href="/") Back to index page \ No newline at end of file +:go:func Uploaded(mainSite, downloadLink string, keepForHours int) + +include base/top.jade +include base/body.header.jade + h1 Upload + +section#file + h2 Your link + center + a(href=downloadLink) #{downloadLink} + center It will be available for next #{keepForHours} hours. + center + a(href="/") Back to index page + +include base/body.footer.jade