nandi/gleanpublic⑂ Fork 0
⑂ 8f27e39
Commits
⬇ Clone ▾
git clone https://git.rickub.com/nandi/glean.git
git clone ssh://git@rickub.com/nandi/glean.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Refactor like button styling and update trending card annotationsUnverified

Julien Robert committed 2026-04-21T21:37:43+02:00 Browse files
8f27e39 parent: 112adee
modified internal/server/articles_handler.go +8 -3
@@ -15,7 +15,7 @@ import (
1515 "pkg.rbrt.fr/glean/internal/sanitize"
1616 )
1717
18-func writeLikeButton(w http.ResponseWriter, articleID int64, liked bool, count int) {
18+func writeLikeButton(w http.ResponseWriter, articleID int64, liked bool, count int, bordered bool) {
1919 fill := "none"
2020 colorCls := "text-spot-muted"
2121 if liked {
@@ -23,7 +23,11 @@ func writeLikeButton(w http.ResponseWriter, articleID int64, liked bool, count i
2323 colorCls = "text-spot-red"
2424 }
2525 w.Header().Set("Content-Type", "text/html")
26- _, _ = fmt.Fprintf(w, `<button hx-post="/articles/%d/like" hx-target="this" hx-swap="outerHTML" class="border border-spot-outline text-spot-text rounded-pill px-4 py-1.5 text-xs font-bold uppercase tracking-button hover:border-spot-text transition inline-flex items-center gap-1.5"><svg class="w-3.5 h-3.5 %s" fill="%s" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z"/></svg><span>%d</span></button>`, articleID, colorCls, fill, count)
26+ cls := "text-spot-text rounded-pill px-3 py-1 text-xs font-bold transition inline-flex items-center gap-1.5 hover:text-spot-green"
27+ if bordered {
28+ cls = "border border-spot-outline text-spot-text rounded-pill px-4 py-1.5 text-xs font-bold uppercase tracking-button hover:border-spot-text transition inline-flex items-center gap-1.5"
29+ }
30+ _, _ = fmt.Fprintf(w, `<button hx-post="/articles/%d/like?bordered=%t" hx-target="this" hx-swap="outerHTML" class="%s"><svg class="w-3.5 h-3.5 %s" fill="%s" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z"/></svg><span>%d</span></button>`, articleID, bordered, cls, colorCls, fill, count)
2731 }
2832
2933 func (s *Server) handleArticles(w http.ResponseWriter, r *http.Request) {
@@ -272,7 +276,8 @@ func (s *Server) handleLikeArticle(w http.ResponseWriter, r *http.Request) {
272276 }
273277
274278 likeCount, _ := s.db.GetLikeCount(r.Context(), article.FeedURL, article.URL.String)
275- writeLikeButton(w, id, !liked, likeCount)
279+ bordered := r.URL.Query().Get("bordered") == "true"
280+ writeLikeButton(w, id, !liked, likeCount, bordered)
276281 }
277282
278283 func (s *Server) handleMarkAllRead(w http.ResponseWriter, r *http.Request) {
@@ -15,7 +15,7 @@ import (
15 "pkg.rbrt.fr/glean/internal/sanitize"15 "pkg.rbrt.fr/glean/internal/sanitize"
16 )16 )
17 17
18-func writeLikeButton(w http.ResponseWriter, articleID int64, liked bool, count int) {18+func writeLikeButton(w http.ResponseWriter, articleID int64, liked bool, count int, bordered bool) {
19 fill := "none"19 fill := "none"
20 colorCls := "text-spot-muted"20 colorCls := "text-spot-muted"
21 if liked {21 if liked {
@@ -23,7 +23,11 @@ func writeLikeButton(w http.ResponseWriter, articleID int64, liked bool, count i
23 colorCls = "text-spot-red"23 colorCls = "text-spot-red"
24 }24 }
25 w.Header().Set("Content-Type", "text/html")25 w.Header().Set("Content-Type", "text/html")
26- _, _ = fmt.Fprintf(w, `<button hx-post="/articles/%d/like" hx-target="this" hx-swap="outerHTML" class="border border-spot-outline text-spot-text rounded-pill px-4 py-1.5 text-xs font-bold uppercase tracking-button hover:border-spot-text transition inline-flex items-center gap-1.5"><svg class="w-3.5 h-3.5 %s" fill="%s" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z"/></svg><span>%d</span></button>`, articleID, colorCls, fill, count)26+ cls := "text-spot-text rounded-pill px-3 py-1 text-xs font-bold transition inline-flex items-center gap-1.5 hover:text-spot-green"
27+ if bordered {
28+ cls = "border border-spot-outline text-spot-text rounded-pill px-4 py-1.5 text-xs font-bold uppercase tracking-button hover:border-spot-text transition inline-flex items-center gap-1.5"
29+ }
30+ _, _ = fmt.Fprintf(w, `<button hx-post="/articles/%d/like?bordered=%t" hx-target="this" hx-swap="outerHTML" class="%s"><svg class="w-3.5 h-3.5 %s" fill="%s" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z"/></svg><span>%d</span></button>`, articleID, bordered, cls, colorCls, fill, count)
27 }31 }
28 32
29 func (s *Server) handleArticles(w http.ResponseWriter, r *http.Request) {33 func (s *Server) handleArticles(w http.ResponseWriter, r *http.Request) {
@@ -272,7 +276,8 @@ func (s *Server) handleLikeArticle(w http.ResponseWriter, r *http.Request) {
272 }276 }
273 277
274 likeCount, _ := s.db.GetLikeCount(r.Context(), article.FeedURL, article.URL.String)278 likeCount, _ := s.db.GetLikeCount(r.Context(), article.FeedURL, article.URL.String)
275- writeLikeButton(w, id, !liked, likeCount)279+ bordered := r.URL.Query().Get("bordered") == "true"
280+ writeLikeButton(w, id, !liked, likeCount, bordered)
276 }281 }
277 282
278 func (s *Server) handleMarkAllRead(w http.ResponseWriter, r *http.Request) {283 func (s *Server) handleMarkAllRead(w http.ResponseWriter, r *http.Request) {
modified internal/tmpl/article_detail.html +1 -1
@@ -23,7 +23,7 @@
2323 </div>
2424
2525 <div class="flex items-center gap-2 mt-6">
26- <button hx-post="/articles/{{.Article.ID}}/like" hx-target="this" hx-swap="outerHTML"
26+ <button hx-post="/articles/{{.Article.ID}}/like?bordered=true" hx-target="this" hx-swap="outerHTML"
2727 class="border border-spot-outline text-spot-text rounded-pill px-4 py-1.5 text-xs font-bold uppercase tracking-button hover:border-spot-text transition inline-flex items-center gap-1.5">
2828 <svg class="w-3.5 h-3.5 {{if .HasLiked}}text-spot-red{{else}}text-spot-muted{{end}}" fill="{{if .HasLiked}}currentColor{{else}}none{{end}}" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">{{template "icon-heart"}}</svg>
2929 <span>{{.LikeCount}}</span>
@@ -23,7 +23,7 @@
23 </div>23 </div>
24 24
25 <div class="flex items-center gap-2 mt-6">25 <div class="flex items-center gap-2 mt-6">
26- <button hx-post="/articles/{{.Article.ID}}/like" hx-target="this" hx-swap="outerHTML"26+ <button hx-post="/articles/{{.Article.ID}}/like?bordered=true" hx-target="this" hx-swap="outerHTML"
27 class="border border-spot-outline text-spot-text rounded-pill px-4 py-1.5 text-xs font-bold uppercase tracking-button hover:border-spot-text transition inline-flex items-center gap-1.5">27 class="border border-spot-outline text-spot-text rounded-pill px-4 py-1.5 text-xs font-bold uppercase tracking-button hover:border-spot-text transition inline-flex items-center gap-1.5">
28 <svg class="w-3.5 h-3.5 {{if .HasLiked}}text-spot-red{{else}}text-spot-muted{{end}}" fill="{{if .HasLiked}}currentColor{{else}}none{{end}}" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">{{template "icon-heart"}}</svg>28 <svg class="w-3.5 h-3.5 {{if .HasLiked}}text-spot-red{{else}}text-spot-muted{{end}}" fill="{{if .HasLiked}}currentColor{{else}}none{{end}}" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">{{template "icon-heart"}}</svg>
29 <span>{{.LikeCount}}</span>29 <span>{{.LikeCount}}</span>
modified internal/tmpl/partials/like-button.html +2 -2
@@ -1,7 +1,7 @@
11 {{define "like-button.html"}}
22 <button hx-post="/articles/{{.ID}}/like" hx-target="this" hx-swap="outerHTML"
3- class="border border-spot-outline text-spot-text rounded-pill px-4 py-1.5 text-xs font-bold uppercase tracking-button hover:border-spot-text transition inline-flex items-center gap-1.5">
4- <svg class="w-3.5 h-3.5 {{if .HasLiked}}text-spot-red{{else}}text-spot-muted{{end}}" fill="{{if .HasLiked}}currentColor{{else}}none{{end}}" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">{{template "icon-heart"}}</svg>
3+ class="text-spot-text rounded-pill px-2 py-1 text-xs font-bold transition inline-flex items-center gap-1 hover:text-spot-green">
4+ <svg class="w-4 h-4 {{if .HasLiked}}text-spot-red{{else}}text-spot-muted{{end}}" fill="{{if .HasLiked}}currentColor{{else}}none{{end}}" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">{{template "icon-heart"}}</svg>
55 <span>{{.LikeCount}}</span>
66 </button>
77 {{end}}
@@ -1,7 +1,7 @@
1 {{define "like-button.html"}}1 {{define "like-button.html"}}
2 <button hx-post="/articles/{{.ID}}/like" hx-target="this" hx-swap="outerHTML"2 <button hx-post="/articles/{{.ID}}/like" hx-target="this" hx-swap="outerHTML"
3- class="border border-spot-outline text-spot-text rounded-pill px-4 py-1.5 text-xs font-bold uppercase tracking-button hover:border-spot-text transition inline-flex items-center gap-1.5">3+ class="text-spot-text rounded-pill px-2 py-1 text-xs font-bold transition inline-flex items-center gap-1 hover:text-spot-green">
4- <svg class="w-3.5 h-3.5 {{if .HasLiked}}text-spot-red{{else}}text-spot-muted{{end}}" fill="{{if .HasLiked}}currentColor{{else}}none{{end}}" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">{{template "icon-heart"}}</svg>4+ <svg class="w-4 h-4 {{if .HasLiked}}text-spot-red{{else}}text-spot-muted{{end}}" fill="{{if .HasLiked}}currentColor{{else}}none{{end}}" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">{{template "icon-heart"}}</svg>
5 <span>{{.LikeCount}}</span>5 <span>{{.LikeCount}}</span>
6 </button>6 </button>
7 {{end}}7 {{end}}