From f8d8b5b63b9ba9a5dbf2c269b72a94c89f589cb1 Mon Sep 17 00:00:00 2001 From: prettysunflower Date: Fri, 23 May 2025 20:34:25 +0200 Subject: [PATCH] Added public keys page --- baseTemplates/templates/keys/keys.tmpl | 57 ++++++++++++++++++++++++++ keys/init.go | 16 ++++++++ static/static/css/layout.scss | 55 +++++++++++++++++++++++++ static/static/css/style.css | 44 ++++++++++++++++++++ static/static/css/style.css.map | 2 +- static/static/svg/copy.svg | 1 + 6 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 baseTemplates/templates/keys/keys.tmpl create mode 100644 static/static/svg/copy.svg diff --git a/baseTemplates/templates/keys/keys.tmpl b/baseTemplates/templates/keys/keys.tmpl new file mode 100644 index 0000000..8a95add --- /dev/null +++ b/baseTemplates/templates/keys/keys.tmpl @@ -0,0 +1,57 @@ +{{ define "bodyClass" }}page-keys{{ end }} + +{{ define "content" }} +
+

Public keys

+ +

SSH

+

+ text/plain: https://prettysunflower.moe/ssh +

+ +
+ + +
+ +

age

+

+ text/plain: https://prettysunflower.moe/age +

+ +
+ + +
+ +

GPG

+

+ text/plain: https://prettysunflower.moe/gpg +

+ +
+ + +
+
+ + +{{ end }} \ No newline at end of file diff --git a/keys/init.go b/keys/init.go index 2894291..28e6db4 100644 --- a/keys/init.go +++ b/keys/init.go @@ -3,15 +3,31 @@ package keys import ( "io" "net/http" + "prettysunflower-website/baseTemplates" ) func InitHttpHandlers() { + http.HandleFunc("/keys/", keysPage) http.HandleFunc("/ssh/", sshKey) http.HandleFunc("/age/", ageKey) http.HandleFunc("/gpg/", gpgKey) http.HandleFunc("/gpg/koumbit/", gpgKey) } +type TemplateData struct { + Ssh string + Age string + Gpg string +} + +func keysPage(w http.ResponseWriter, r *http.Request) { + baseTemplates.WithBase(w, TemplateData{ + Ssh: SSH_KEY, + Age: AGE_KEY, + Gpg: GPG_KEY, + }, "templates/keys/keys.tmpl") +} + func sshKey(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") _, _ = io.WriteString(w, SSH_KEY) diff --git a/static/static/css/layout.scss b/static/static/css/layout.scss index 9d9e4d8..0c78173 100644 --- a/static/static/css/layout.scss +++ b/static/static/css/layout.scss @@ -92,4 +92,59 @@ nav { } margin-bottom: 2rem; +} + +.page-keys { + main { + margin-bottom: 2rem; + } + + h2:has(+ p) { + margin-bottom: 0; + } + + h2 + p { + margin-top: 0.25rem; + } + + .key { + width: 100%; + display: flex; + justify-content: center; + align-items: stretch; + + input, textarea { + background-color: oklch(from colors.$background-color calc(l - 0.1) c h); + border: none; + padding: 1rem; + width: 100%; + line-height: 2em; + line-break: anywhere; + resize: none; + + &:focus-visible, &:focus { + outline: none; + } + } + + button { + background-color: oklch(from colors.$background-color calc(l - 0.2) c h); + border: 0; + padding: 1rem; + width: auto; + cursor: pointer; + + &:hover { + background-color: oklch(from colors.$background-color calc(l - 0.25) c h); + } + + &:active { + background-color: oklch(from colors.$background-color calc(l - 0.3) c h); + } + + img { + height: 1.5em; + } + } + } } \ No newline at end of file diff --git a/static/static/css/style.css b/static/static/css/style.css index a2bfa61..85fc74f 100644 --- a/static/static/css/style.css +++ b/static/static/css/style.css @@ -78,6 +78,50 @@ nav > div > div:last-child { max-width: 100%; } +.page-keys main { + margin-bottom: 2rem; +} +.page-keys h2:has(+ p) { + margin-bottom: 0; +} +.page-keys h2 + p { + margin-top: 0.25rem; +} +.page-keys .key { + width: 100%; + display: flex; + justify-content: center; + align-items: stretch; +} +.page-keys .key input, .page-keys .key textarea { + background-color: oklch(from oklch(97% 0.0261 90.1deg) calc(l - 0.1) c h); + border: none; + padding: 1rem; + width: 100%; + line-height: 2em; + line-break: anywhere; + resize: none; +} +.page-keys .key input:focus-visible, .page-keys .key input:focus, .page-keys .key textarea:focus-visible, .page-keys .key textarea:focus { + outline: none; +} +.page-keys .key button { + background-color: oklch(from oklch(97% 0.0261 90.1deg) calc(l - 0.2) c h); + border: 0; + padding: 1rem; + width: auto; + cursor: pointer; +} +.page-keys .key button:hover { + background-color: oklch(from oklch(97% 0.0261 90.1deg) calc(l - 0.25) c h); +} +.page-keys .key button:active { + background-color: oklch(from oklch(97% 0.0261 90.1deg) calc(l - 0.3) c h); +} +.page-keys .key button img { + height: 1.5em; +} + body { font-family: "Open Sans", apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; background-color: oklch(97% 0.0261 90.1deg); diff --git a/static/static/css/style.css.map b/static/static/css/style.css.map index ff4e8ba..d351317 100644 --- a/static/static/css/style.css.map +++ b/static/static/css/style.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["fonts.scss","layout.scss","body.scss","colors.scss","index.scss","radio.scss"],"names":[],"mappings":"AAAQ;ACER;EACI;EACA;EACA;EACA;;AAEA;EACI;;;AAIR;EACI;EACA;EACA;;;AAOJ;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EARJ;IASQ;IACA;;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;;AAEA;EACI;;AAGJ;EACI;;AAIR;EACI;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;;;AAKZ;EAOI;;AALI;EACI;;;ACtFZ;EACI,aFFS;EEGT,kBCLe;EDMf;;;AEHA;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EAOA;EACA;;AANA;EANJ;IAOQ;IACA;;;AAMJ;EACI;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;;AAMhB;EACI;EACA;;AAEA;EAkBI;;AAjBA;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;;AAIR;EAdJ;IAeQ;;;AAOJ;EACI;;AAGJ;EACI;EACA;;AAKJ;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA;;AAGJ;EACI;;AAGJ;EAfJ;IAgBQ;IACA;;;AAMhB;EHxGA;;;AIjBA;EACI;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;;AAIR;EACI;EACA;;AAGJ;EACI;EACA;EACA;EACA;;AAGI;EACI;;AAGJ;EACI;;AAGJ;EACI;;AAEA;EACI;EACA;;AAKZ;EAzBJ;IA0BQ;;;AAGJ;EA7BJ;IA8BQ;;;AAGJ;EAjCJ;IAkCQ","file":"style.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["fonts.scss","layout.scss","body.scss","colors.scss","index.scss","radio.scss"],"names":[],"mappings":"AAAQ;ACER;EACI;EACA;EACA;EACA;;AAEA;EACI;;;AAIR;EACI;EACA;EACA;;;AAOJ;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EARJ;IASQ;IACA;;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;;AAEA;EACI;;AAGJ;EACI;;AAIR;EACI;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;;;AAKZ;EAOI;;AALI;EACI;;;AAQR;EACI;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAIR;EACI;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAGJ;EACI;;AAGJ;EACI;;;AC9IhB;EACI,aFFS;EEGT,kBCLe;EDMf;;;AEHA;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EAOA;EACA;;AANA;EANJ;IAOQ;IACA;;;AAMJ;EACI;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;;AAMhB;EACI;EACA;;AAEA;EAkBI;;AAjBA;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;;AAIR;EAdJ;IAeQ;;;AAOJ;EACI;;AAGJ;EACI;EACA;;AAKJ;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA;;AAGJ;EACI;;AAGJ;EAfJ;IAgBQ;IACA;;;AAMhB;EHxGA;;;AIjBA;EACI;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;;AAIR;EACI;EACA;;AAGJ;EACI;EACA;EACA;EACA;;AAGI;EACI;;AAGJ;EACI;;AAGJ;EACI;;AAEA;EACI;EACA;;AAKZ;EAzBJ;IA0BQ;;;AAGJ;EA7BJ;IA8BQ;;;AAGJ;EAjCJ;IAkCQ","file":"style.css"} \ No newline at end of file diff --git a/static/static/svg/copy.svg b/static/static/svg/copy.svg new file mode 100644 index 0000000..1059752 --- /dev/null +++ b/static/static/svg/copy.svg @@ -0,0 +1 @@ + \ No newline at end of file