diff --git a/.gitignore b/.gitignore index 7567e9c5f01dbc65ecd4075eb04fac010fe3bb45..b9b393a300614832c2d98778c4e40512ee478694 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ build/ node_modules/ # Configuration files, binaries etc. paste* +build.css diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000000000000000000000000000000000000..bf9a208755bb2b754213429e978e06b26304a776 --- /dev/null +++ b/css/style.css @@ -0,0 +1,14 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +select.h-full { + height: 40px; +} + +h1:before { + content: '# '; +} +h2:before { + content: '## '; +} diff --git a/handlers.go b/handlers.go index bf49a65e18ac6cd050df042d114611b8593046d3..9fefbb153a9687b51f8124a0b85fdc05244a18c0 100644 --- a/handlers.go +++ b/handlers.go @@ -25,9 +25,10 @@ func (h Handlers) GetRouter() *vestigo.Router { r.Get("/", h.HandleHome) r.Post("/", h.HandleNewPaste) + r.Get("/about", h.HandleAbout) r.Get("/s/:key", h.HandleShowPaste) r.Get("/r/:key", h.HandleShowRaw) - r.Get("/privacy.html", h.HandlePrivacyPolicy) + r.Get("/static/*", h.HandleStaticContent) return r } @@ -36,6 +37,10 @@ func (h Handlers) HandleHome(w http.ResponseWriter, req *http.Request) { _ = h.Templates.ExecuteTemplate(w, "homepage", nil) } +func (h Handlers) HandleAbout(w http.ResponseWriter, req *http.Request) { + _ = h.Templates.ExecuteTemplate(w, "about", nil) +} + func (h Handlers) HandleNewPaste(w http.ResponseWriter, req *http.Request) { err := req.ParseForm() @@ -143,6 +148,6 @@ func (h Handlers) HandleShowRaw(w http.ResponseWriter, req *http.Request) { _, _ = fmt.Fprint(w, res.Val()) } -func (h Handlers) HandlePrivacyPolicy(w http.ResponseWriter, req *http.Request) { - _ = h.Templates.ExecuteTemplate(w, "privacy", nil) +func (h Handlers) HandleStaticContent(w http.ResponseWriter, req *http.Request) { + http.ServeFile(w, req, "./static/" + vestigo.Param(req, "_name")) } diff --git a/package.json b/package.json index 334bbc12196d4ff165d4c9907a4573656e4b991a..a8b1b4cb0e8c24462457d3015a71dd1030f8f7dc 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,31 @@ { - "dependencies": { - "uglifycss": "^0.0.29" - }, - "scripts": { - "css-uglify": "uglifycss style.css > style.min.css" - } + "name": "paste-prototype", + "version": "1.0.0", + "description": "New paste design", + "main": "index.js", + "author": "Artemis ", + "license": "Apache-2.0", + "private": true, + "dependencies": { + "cssnano": "^4.1.10", + "nodemon": "^1.19.1", + "postcss-cli": "^6.1.2", + "tailwindcss": "^1.0.4" + }, + "scripts": { + "build": "postcss -o static/style.css css/style.css", + "watch": "nodemon css/style.css" + }, + "nodemonConfig": { + "ignore": [ + "build.css" + ], + "execMap": { + "css": "yarn build", + "html": "yarn build" + } + }, + "devDependencies": { + "@fullhuman/postcss-purgecss": "^1.2.0" + } } diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000000000000000000000000000000000000..0fc9fce80443003c44949fb5afcaf55cfefdfe54 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,17 @@ +module.exports = { + theme: { + extend: {} + }, + variants: {}, + plugins: [ + require('tailwindcss'), + require('autoprefixer'), + // require('@fullhuman/postcss-purgecss')({ + // content: [ + // './*.html' + // ], + // defaultExtractor: c => c.match(/[A-Za-z0-9-_:/]+/g) || [] + // }), + require('cssnano') + ] +}; diff --git a/static/.gitignore b/static/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e8c7365cf2c5776164085102b38b3dba8a39d16b --- /dev/null +++ b/static/.gitignore @@ -0,0 +1 @@ +style.css diff --git a/style.css b/style.css deleted file mode 100644 index c85ad0960b18f91e3eae4e2d620ce2dacf6921fa..0000000000000000000000000000000000000000 --- a/style.css +++ /dev/null @@ -1,45 +0,0 @@ -body { - margin: 1em; - background-color: #F7F7F7; - color: #1E1E1E; - font-size: 1.2rem; - font-family: Sans-Serif; -} - -p { - text-align: justify; - line-height: 1.4; -} - -a { - color: #0677D3; -} - -a:hover { - color: #9606D3; -} - -footer { - text-align: center; -} - -@media screen and (min-width: 1200px) { - body { - margin: 1em auto; - width: 1200px; - } -} -form fieldset { - padding: 0; - border: 0; - line-height: 2.8; -} -form fieldset label, form fieldset input, form fieldset textarea { - display: block; - width: 100%; -} -form fieldset textarea { - resize: vertical; -} - -/*# sourceMappingURL=style.css.map */ diff --git a/templates.go b/templates.go index 489e75b118558687f519bdfd7722c9f27e805d9c..1f90f308bc0f430ca630a9b5123c3ec8969649fa 100644 --- a/templates.go +++ b/templates.go @@ -1,7 +1,38 @@ package main -import "html/template" +import ( + "fmt" + "html/template" +) + +func lineCount(input string) uint { + var output uint = 0 + + for _, char := range input { + if char == '\n' { + output += 1 + } + } + + return output + 1 // final line, there's no line return +} + +// Takes an input string, counts the number of lines, +// and generates an output with the same number of lines, +// each containing the line number. +func Lineno(input string) string { + count := lineCount(input) + output := "" + + for i := uint(1); i < count; i++ { + output += fmt.Sprintf("%d\n", i) + } + + return output[:len(output) - 1] +} func InitTemplates() *template.Template { - return template.Must(template.ParseGlob("templates/*")) + return template.Must(template.New("").Funcs(template.FuncMap{ + "lineno": Lineno, + }).ParseGlob("templates/*")) } diff --git a/templates/about.html b/templates/about.html new file mode 100644 index 0000000000000000000000000000000000000000..9efbc16fe9b339b57f06440d8433135ae6e39bc0 --- /dev/null +++ b/templates/about.html @@ -0,0 +1,99 @@ +{{define "about"}} + + + + {{template "header"}} + + +
+ {{template "nav"}} +
+ +
+

About paste

+ +

+ Paste is a FOSS ephemeral pastebin tool, made to be simple, + lightweight, and without any tracker or javascript. +

+ +

+ Ephemeral means it does not store anything on a form of + persistent storage (like a HDD or a SSD), but instead only keeps + it in RAM for the selected duration (between 1 and 24 hours as of now). +

+ +

+ FOSS means that the source-code is available for free for anyone + who might want to self-host it, or extend it + (Source-code). +

+ +

Privacy Policy

+ +

+ As general logging, we only collect your IP. + This is solely for cases where someone tries to abuse our services, + to be able to block them out. +

+ +

Paste storing

+ +

+ Every paste is stored in ephemeral memory (RAM, through Redis configured + to not persist anything), with an auto-expiry set to, at maximum, 24 hours. +

+ +

+ Following that, we don't persist anything, and once the expiry time + is passed, or the server (/ redis instance) rebooted, everything is + forgotten. +

+ +

Analytics

+ +

+ Except for the possible exception above, we don't collect anything. + No, really. The person behind this is very privacy-conscious, so + they'll always try to only keep the necessary data, and nothing more. + No ad, no tracker in any form, period. +

+ +

Security

+ +

+ We employ good methods to keep data secure. Not digging into details, + but the usual stuff, like a good firewall, monitoring system, and no + apparent openflow. +

+ +

+ There's only one person who's technically authorized to be on the + hosting servers, so only one person should be able to have access. +

+ +

+ Note that we're not saying that our servers and services are unbreakable + and perfect, but that we try to do our very best to prevent any + possibility for such incidents to occur. +

+ +

Incident or vulnerability disclosure

+ +

+ If you managed to encounter an incident or a vulnerability in our + infrastructure, we'd gladly receive your feedback and alerts by + e-mail at alert[at]artemix[dot]org. +

+ +

+ Responsible disclosure will allow us to recover and fix those + incidents without much risk, allowing us to provide you our services + with as much quality as we can manage to. +

+ +

Plus, you may receive a special mention or some small token of appreciation!

+
+ + +{{end}} diff --git a/templates/footer.html b/templates/footer.html deleted file mode 100644 index 8fae43e997ea9405ff2639b3db49a706c49ee0d5..0000000000000000000000000000000000000000 --- a/templates/footer.html +++ /dev/null @@ -1,8 +0,0 @@ -{{define "footer"}} -
- - -{{end}} diff --git a/templates/header.html b/templates/header.html deleted file mode 100644 index 64cad04d9bcadd62867ea04a9955f09bae30ea25..0000000000000000000000000000000000000000 --- a/templates/header.html +++ /dev/null @@ -1,5 +0,0 @@ -{{define "header"}} - - Paste - -{{end}} diff --git a/templates/homepage.html b/templates/homepage.html index 827b6d3e687ca54b36e64b2f322327797eeee3f0..0f6b89ceb51a6ea7169c8d8d7e9ed28ce133cec4 100644 --- a/templates/homepage.html +++ b/templates/homepage.html @@ -1,44 +1,37 @@ {{define "homepage"}} - - - - {{template "header"}} - - -

Paste

- - {{if .Error}} -
-

{{.Error}}

-
- {{end}} - -
-

Enter your document below (approximate maximum of 1MB)

- -
-
- - -
-
- - -
-
- -
-
- -

Pastes are stored for the selected duration (maximum of 24h) or until next server restart, whichever comes first.

-
- - {{template "footer"}} - - + + + + {{template "header"}} + + +
+
+ {{template "nav"}} +
+ +
+
+
+ +
+
+ + {{end}} diff --git a/templates/partials.html b/templates/partials.html new file mode 100644 index 0000000000000000000000000000000000000000..c25a8ddede386389ad3d27f61077855f0ac761c9 --- /dev/null +++ b/templates/partials.html @@ -0,0 +1,13 @@ +{{define "header"}} + + Paste + + + +{{end}} +{{define "nav"}} + +{{end}} diff --git a/templates/privacy.html b/templates/privacy.html deleted file mode 100644 index 8826e4f9bbd105b3d4dda0f0916df2df5b3486c9..0000000000000000000000000000000000000000 --- a/templates/privacy.html +++ /dev/null @@ -1,19 +0,0 @@ -{{define "privacy"}} - - - - - Privacy policy and incident report guidelines - - -

Privacy Notice

- -

Note that this Privacy Notice is a project-specific specialisation of the privacy policy linked here.

- -

Paste storing

- -

Every paste is stored in RAM (through Redis, configured to not persist anything), with an auto-expiry set to either 1, 6, 12, or 24 hours.

-

In that sense, we don't persist anything, and once the expiry time is passed, or the server rebooted, everything is forgotten.

- - -{{end}} diff --git a/templates/show.html b/templates/show.html index 549a1e81de7cff4d39c6ea6bf159dd81181d418f..6debf21c7d9c6e0ed109273e29d3ed393d44a2fd 100644 --- a/templates/show.html +++ b/templates/show.html @@ -1,28 +1,30 @@ {{define "show"}} - - - - {{template "header"}} - - - -

Paste

+ + + + {{template "header"}} + + + +
+ {{template "nav"}} +
+ View raw +
+
- +
+
+			{{.Value|lineno}}
+			{{.Value}}
+		
+
-
- -

Your paste

-
{{.Value}}
-
- - {{template "footer"}} - - - - + + + + {{end}} diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index 0cfcb786d968268976ee3b8dd30d4c727604d716..0000000000000000000000000000000000000000 --- a/yarn.lock +++ /dev/null @@ -1,7 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -uglifycss@^0.0.29: - version "0.0.29" - resolved "https://registry.yarnpkg.com/uglifycss/-/uglifycss-0.0.29.tgz#abe49531155d146e75dd2fdf933d371bc1180054"