dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 3cd39656865810ecfc850b87a93aaadc2075438f
parent a380ebd50901d5978555f53a95eb9c557500bf83
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon, 12 Jun 2023 20:40:03 -0700

move code

Diffstat:
Mpkg/web/handlers/handlers.go | 32--------------------------------
Mpkg/web/handlers/signup.go | 33+++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -110,38 +110,6 @@ func DAesB64Str(in string) (string, error) { return string(encryptedVal), err } -func MetaCss(c echo.Context) error { - return c.Blob(http.StatusOK, "text/css; charset=utf-8", metaCss("signal")) -} - -func SignupCss(c echo.Context) error { - return c.Blob(http.StatusOK, "text/css; charset=utf-8", metaCss(c.Param("signupToken"))) -} - -func metaCss(token string) []byte { - lb := "" // \n - var buf bytes.Buffer - sizes := []float64{0, 320, 350, 390, 430, 470, 520, 570, 620, 690, 750, 830, 910, 1000, 1100, 1220, 1340, 1470, 1620, 1780, 1960, 2150, 2370, 2600} - for i := 1; i < len(sizes); i++ { - prev := sizes[i-1] - size := sizes[i] - _, _ = fmt.Fprintf(&buf, "@media(min-device-width:%.0fpx) and (max-device-width:%.5fpx){.div_1{background:url('/public/img/%s/sw/%.0fx%.0f.png')}}%s", prev, size-0.00001, token, prev, size, lb) - } - _, _ = fmt.Fprintf(&buf, "@media(min-device-width:%.0fpx){.div_1{background:url('/public/img/%s/sw/%.0fx.png')}}%s", 2600.0, token, 2600.0, lb) - for i := 1; i < len(sizes); i++ { - prev := sizes[i-1] - size := sizes[i] - _, _ = fmt.Fprintf(&buf, "@media(min-device-height:%.0fpx) and (max-device-height:%.5fpx){.div_2{background:url('/public/img/%s/sh/%.0fx%.0f.png')}}%s", prev, size-0.00001, token, prev, size, lb) - } - _, _ = fmt.Fprintf(&buf, "@media(min-device-height:%.0fpx){.div_2{background:url('/public/img/%s/sh/%.0fx.png')}}%s", 2600.0, token, 2600.0, lb) - fonts := []string{"Helvatica"} - for idx, font := range fonts { - _, _ = fmt.Fprintf(&buf, `@font-face{font-family:'%s';src:local('%s'),url('/public/img/%s/%s/%s.ttf')format('truetype');}%s`, font, font, token, font, font, lb) - _, _ = fmt.Fprintf(&buf, `.div_f%d{font-family:'%s';position:absolute;top:-100px}%s`, idx, font, lb) - } - return buf.Bytes() -} - type WaitPageCookiePayload struct { Token string Count int64 diff --git a/pkg/web/handlers/signup.go b/pkg/web/handlers/signup.go @@ -1,6 +1,7 @@ package handlers import ( + "bytes" "dkforest/pkg/cache" "dkforest/pkg/captcha" "dkforest/pkg/config" @@ -231,3 +232,35 @@ func SignalCss(c echo.Context) error { signupCache.SetD(token, info) return c.NoContent(http.StatusOK) } + +func MetaCss(c echo.Context) error { + return c.Blob(http.StatusOK, "text/css; charset=utf-8", metaCss("signal")) +} + +func SignupCss(c echo.Context) error { + return c.Blob(http.StatusOK, "text/css; charset=utf-8", metaCss(c.Param("signupToken"))) +} + +func metaCss(token string) []byte { + lb := "" // \n + var buf bytes.Buffer + sizes := []float64{0, 320, 350, 390, 430, 470, 520, 570, 620, 690, 750, 830, 910, 1000, 1100, 1220, 1340, 1470, 1620, 1780, 1960, 2150, 2370, 2600} + for i := 1; i < len(sizes); i++ { + prev := sizes[i-1] + size := sizes[i] + _, _ = fmt.Fprintf(&buf, "@media(min-device-width:%.0fpx) and (max-device-width:%.5fpx){.div_1{background:url('/public/img/%s/sw/%.0fx%.0f.png')}}%s", prev, size-0.00001, token, prev, size, lb) + } + _, _ = fmt.Fprintf(&buf, "@media(min-device-width:%.0fpx){.div_1{background:url('/public/img/%s/sw/%.0fx.png')}}%s", 2600.0, token, 2600.0, lb) + for i := 1; i < len(sizes); i++ { + prev := sizes[i-1] + size := sizes[i] + _, _ = fmt.Fprintf(&buf, "@media(min-device-height:%.0fpx) and (max-device-height:%.5fpx){.div_2{background:url('/public/img/%s/sh/%.0fx%.0f.png')}}%s", prev, size-0.00001, token, prev, size, lb) + } + _, _ = fmt.Fprintf(&buf, "@media(min-device-height:%.0fpx){.div_2{background:url('/public/img/%s/sh/%.0fx.png')}}%s", 2600.0, token, 2600.0, lb) + fonts := []string{"Helvatica"} + for idx, font := range fonts { + _, _ = fmt.Fprintf(&buf, `@font-face{font-family:'%s';src:local('%s'),url('/public/img/%s/%s/%s.ttf')format('truetype');}%s`, font, font, token, font, font, lb) + _, _ = fmt.Fprintf(&buf, `.div_f%d{font-family:'%s';position:absolute;top:-100px}%s`, idx, font, lb) + } + return buf.Bytes() +}