Experimental browser for the Atmosphere
{ "uri": "at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3llyd5jevwc22", "cid": "bafyreid2yt2akftee6jchywdsvhrzwrw4mjalcc4byubg37jmandvw25g4", "value": { "$type": "sh.tangled.repo.pull", "patch": "diff --git a/appview/pages/funcmap.go b/appview/pages/funcmap.go\nindex 04b6868..775006a 100644\n--- a/appview/pages/funcmap.go\n+++ b/appview/pages/funcmap.go\n@@ -168,6 +168,7 @@ func funcMap() template.FuncMap {\n \t\t\t}\n \t\t\treturn template.HTML(data)\n \t\t},\n+\t\t\"cssContentHash\": CssContentHash,\n \t}\n }\n \ndiff --git a/appview/pages/pages.go b/appview/pages/pages.go\nindex 1a9e3b6..8e6e2f3 100644\n--- a/appview/pages/pages.go\n+++ b/appview/pages/pages.go\n@@ -2,7 +2,9 @@ package pages\n \n import (\n \t\"bytes\"\n+\t\"crypto/sha256\"\n \t\"embed\"\n+\t\"encoding/hex\"\n \t\"fmt\"\n \t\"html/template\"\n \t\"io\"\n@@ -709,7 +711,9 @@ func (p *Pages) Static() http.Handler {\n \n func Cache(h http.Handler) http.Handler {\n \treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n-\t\tif strings.HasSuffix(r.URL.Path, \".css\") {\n+\t\tpath := strings.Split(r.URL.Path, \"?\")[0]\n+\n+\t\tif strings.HasSuffix(path, \".css\") {\n \t\t\t// on day for css files\n \t\t\tw.Header().Set(\"Cache-Control\", \"public, max-age=86400\")\n \t\t} else {\n@@ -719,6 +723,23 @@ func Cache(h http.Handler) http.Handler {\n \t})\n }\n \n+func CssContentHash() string {\n+\tcssFile, err := Files.Open(\"static/tw.css\")\n+\tif err != nil {\n+\t\tlog.Printf(\"Error opening CSS file: %v\", err)\n+\t\treturn \"\"\n+\t}\n+\tdefer cssFile.Close()\n+\n+\thasher := sha256.New()\n+\tif _, err := io.Copy(hasher, cssFile); err != nil {\n+\t\tlog.Printf(\"Error hashing CSS file: %v\", err)\n+\t\treturn \"\"\n+\t}\n+\n+\treturn hex.EncodeToString(hasher.Sum(nil))[:8] // Use first 8 chars of hash\n+}\n+\n func (p *Pages) Error500(w io.Writer) error {\n \treturn p.execute(\"errors/500\", w, nil)\n }\ndiff --git a/appview/pages/templates/layouts/base.html b/appview/pages/templates/layouts/base.html\nindex f07e4bb..d5d0651 100644\n--- a/appview/pages/templates/layouts/base.html\n+++ b/appview/pages/templates/layouts/base.html\n@@ -8,8 +8,7 @@\n content=\"width=device-width, initial-scale=1.0\"\n />\n <script src=\"/static/htmx.min.js\"></script>\n- <link href=\"/static/tw.css\" rel=\"stylesheet\" type=\"text/css\" />\n- \n+ <link rel=\"stylesheet\" href=\"/static/tw.css?{{ cssContentHash }}\" type=\"text/css\" />\n <title>{{ block \"title\" . }}{{ end }} · tangled</title>\n {{ block \"extrameta\" . }}{{ end }}\n </head>\ndiff --git a/appview/pages/templates/user/login.html b/appview/pages/templates/user/login.html\nindex 9ed5491..5c8d45c 100644\n--- a/appview/pages/templates/user/login.html\n+++ b/appview/pages/templates/user/login.html\n@@ -8,7 +8,7 @@\n content=\"width=device-width, initial-scale=1.0\"\n />\n <script src=\"/static/htmx.min.js\"></script>\n- <link rel=\"stylesheet\" href=\"/static/tw.css\" type=\"text/css\" />\n+ <link rel=\"stylesheet\" href=\"/static/tw.css?{{ cssContentHash }}\" type=\"text/css\" />\n <title>login</title>\n </head>\n <body class=\"flex items-center justify-center min-h-screen\">\n@@ -27,7 +27,13 @@\n >\n <div class=\"flex flex-col\">\n <label for=\"handle\">handle</label>\n- <input type=\"text\" id=\"handle\" name=\"handle\" required />\n+ <input \n+ type=\"text\"\n+ id=\"handle\"\n+ name=\"handle\"\n+ tabindex=\"1\"\n+ required\n+ />\n <span class=\"text-xs text-gray-500 mt-1\">\n You need to use your\n <a href=\"https://bsky.app\">Bluesky</a> handle to log\n@@ -41,6 +47,7 @@\n type=\"password\"\n id=\"app_password\"\n name=\"app_password\"\n+ tabindex=\"2\"\n required\n />\n <span class=\"text-xs text-gray-500 mt-1\">\n@@ -57,6 +64,7 @@\n class=\"btn w-full my-2 mt-6\"\n type=\"submit\"\n id=\"login-button\"\n+ tabindex=\"3\"\n >\n <span>login</span>\n </button>\ndiff --git a/appview/pages/templates/user/profile.html b/appview/pages/templates/user/profile.html\nindex 59d2485..fb9e7e6 100644\n--- a/appview/pages/templates/user/profile.html\n+++ b/appview/pages/templates/user/profile.html\n@@ -108,8 +108,11 @@\n <img class=\"w-3/4 rounded-full p-2\" src=\"{{ .AvatarUri }}\" />\n {{ end }}\n </div>\n- <p class=\"text-xl font-bold text-center dark:text-white\">\n- {{ truncateAt30 (didOrHandle .UserDid .UserHandle) }}\n+ <p \n+ title=\"{{ didOrHandle .UserDid .UserHandle }}\"\n+ class=\"text-lg font-bold text-center dark:text-white overflow-hidden text-ellipsis whitespace-nowrap max-w-full\"\n+ >\n+ {{ didOrHandle .UserDid .UserHandle }}\n </p>\n <div class=\"text-sm text-center dark:text-gray-300\">\n <span>{{ .ProfileStats.Followers }} followers</span>\n", "title": "implement cache busting for tw.css", "pullId": 25, "targetRepo": "at://did:plc:wshs7t2adsemcrrd4snkeqli/sh.tangled.repo/3liuighjy2h22", "targetBranch": "master" } }