From f5eadac93e73ee483da7cc114a9fd12e713b2862 Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 6 Mar 2025 00:01:41 +0000 Subject: [PATCH] improve markdown styles; cache all static --- appview/db/registration.go | 2 +- appview/pages/pages.go | 4 +- appview/pages/templates/repo/index.html | 2 +- .../pages/templates/repo/issues/issue.html | 4 +- appview/state/state.go | 6 +-- flake.nix | 2 +- tailwind.config.js | 50 +++++++++++-------- 7 files changed, 39 insertions(+), 31 deletions(-) diff --git a/appview/db/registration.go b/appview/db/registration.go index b354f59d..1e8e0e60 100644 --- a/appview/db/registration.go +++ b/appview/db/registration.go @@ -130,7 +130,7 @@ func GenerateRegistrationKey(e Execer, domain, did string) (string, error) { _, err = e.Exec(` insert into registrations (domain, did, secret) values (?, ?, ?) - on conflict(domain) do update set did = excluded.did, secret = excluded.secret + on conflict(domain) do update set did = excluded.did, secret = excluded.secret, created = excluded.created `, domain, did, secret) if err != nil { diff --git a/appview/pages/pages.go b/appview/pages/pages.go index 239ea3e6..eb194507 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -421,9 +421,7 @@ func (p *Pages) Static() http.Handler { func Cache(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if strings.HasPrefix(r.URL.Path, "/static/fonts") { - w.Header().Set("Cache-Control", "public, max-age=31536000, immutable") - } + w.Header().Set("Cache-Control", "public, max-age=31536000, immutable") h.ServeHTTP(w, r) }) } diff --git a/appview/pages/templates/repo/index.html b/appview/pages/templates/repo/index.html index 5523e1ab..b977f330 100644 --- a/appview/pages/templates/repo/index.html +++ b/appview/pages/templates/repo/index.html @@ -192,7 +192,7 @@ {{ define "repoAfter" }} {{- if .Readme }} -
+
{{- .Readme -}}
diff --git a/appview/pages/templates/repo/issues/issue.html b/appview/pages/templates/repo/issues/issue.html index a315f5ea..7ac6a909 100644 --- a/appview/pages/templates/repo/issues/issue.html +++ b/appview/pages/templates/repo/issues/issue.html @@ -41,7 +41,7 @@ {{ if .Issue.Body }} -
+
{{ .Issue.Body | markdown }}
{{ end }} @@ -82,7 +82,7 @@ {{ .Created | timeFmt }} -
+
{{ .Body | markdown }}
diff --git a/appview/state/state.go b/appview/state/state.go index 3843c1ae..581eab64 100644 --- a/appview/state/state.go +++ b/appview/state/state.go @@ -508,7 +508,7 @@ func (s *State) AddMember(w http.ResponseWriter, r *http.Request) { func (s *State) RemoveMember(w http.ResponseWriter, r *http.Request) { } -func (s *State) AddRepo(w http.ResponseWriter, r *http.Request) { +func (s *State) NewRepo(w http.ResponseWriter, r *http.Request) { switch r.Method { case http.MethodGet: user := s.auth.GetUser(r) @@ -885,8 +885,8 @@ func (s *State) StandardRouter() http.Handler { r.Route("/repo", func(r chi.Router) { r.Route("/new", func(r chi.Router) { r.Use(AuthMiddleware(s)) - r.Get("/", s.AddRepo) - r.Post("/", s.AddRepo) + r.Get("/", s.NewRepo) + r.Post("/", s.NewRepo) }) // r.Post("/import", s.ImportRepo) }) diff --git a/flake.nix b/flake.nix index 76fe4250..42ae9d1f 100644 --- a/flake.nix +++ b/flake.nix @@ -363,7 +363,7 @@ services.tangled-knotserver = { enable = true; server = { - secret = "21c9c8b2a405bcfb14694481e32bab09d842c2f4cc0437906b68015d32f15b97"; + secret = "61120605bf85e8b036c922221ae0d740efb1e93a1ebe5cd71e4aca552d7d8a86"; hostname = "localhost:6000"; listenAddr = "0.0.0.0:6000"; }; diff --git a/tailwind.config.js b/tailwind.config.js index 2ee36e5a..93af9041 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,23 +1,33 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: ["./appview/pages/templates/**/*.html"], - theme: { - container: { - padding: "2rem", - center: true, - screens: { - sm: "540px", - md: "650px", - lg: "900px", - xl: "1100px", - "2xl": "1300px" - }, - }, - extend: { - fontFamily: { - sans: ["iA Writer Quattro S", "Inter", "system-ui", "sans-serif", "ui-sans-serif"], - mono: ["iA Writer Mono S", "ui-monospace", "SFMono-Regular", "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", "monospace"], - }, - }, - }, + content: ["./appview/pages/templates/**/*.html"], + theme: { + container: { + padding: "2rem", + center: true, + screens: { + sm: "540px", + md: "650px", + lg: "900px", + xl: "1100px", + "2xl": "1300px" + }, + }, + extend: { + fontFamily: { + sans: ["iA Writer Quattro S", "Inter", "system-ui", "sans-serif", "ui-sans-serif"], + mono: ["iA Writer Mono S", "ui-monospace", "SFMono-Regular", "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", "monospace"], + }, + typography: { + DEFAULT: { + css: { + maxWidth: 'none', + } + }, + }, + }, + }, + plugins: [ + require('@tailwindcss/typography'), + ] }; -- 2.51.2