feat: add page titles and meta for bug pages

Amolith and Crush created

Refactor BugsData and BugData to use embedded
RepoBaseData and PaginationData structs. Set
appropriate page titles: "Bugs | {repo}" for bug
list and "{title} | Bug {id} | {repo}" for
individual bugs. Rename Title field to Subject in
BugData to match git-bug terminology.

Implements: bug-87f9da5
Co-Authored-By: Crush <crush@charm.land>

Change summary

pkg/web/templates/bug.html |  2 
pkg/web/webui_bugs.go      | 95 ++++++++++++++++++++++-----------------
2 files changed, 54 insertions(+), 43 deletions(-)

Detailed changes

pkg/web/templates/bug.html 🔗

@@ -19,7 +19,7 @@
       <path d="M5 8 l2 2 l4 -4" stroke-linecap="round" stroke-linejoin="round" />
     </svg>
     {{end}}
-    {{.Title}}
+    {{.Subject}}
   </h2>
   {{if .Labels}}
   <p>

pkg/web/webui_bugs.go 🔗

@@ -24,18 +24,11 @@ import (
 const defaultBugsPerPage = 20
 
 type BugsData struct {
-	Repo          proto.Repository
-	DefaultBranch string
-	ActiveTab     string
-	ServerName    string
-	HasGitBug     bool
-
-	Bugs        []BugListItem
-	Status      string
-	Page        int
-	TotalPages  int
-	HasPrevPage bool
-	HasNextPage bool
+	RepoBaseData
+	PaginationData
+
+	Bugs   []BugListItem
+	Status string
 }
 
 type BugListItem struct {
@@ -52,14 +45,10 @@ type BugListItem struct {
 }
 
 type BugData struct {
-	Repo          proto.Repository
-	DefaultBranch string
-	ActiveTab     string
-	ServerName    string
-	HasGitBug     bool
+	RepoBaseData
 
 	ID        string
-	Title     string
+	Subject   string
 	Status    string
 	Author    string
 	CreatedAt time.Time
@@ -376,18 +365,30 @@ func repoBugs(w http.ResponseWriter, r *http.Request) {
 	}
 	defaultBranch := getDefaultBranch(gr)
 
+	repoDisplayName := repo.ProjectName()
+	if repoDisplayName == "" {
+		repoDisplayName = repo.Name()
+	}
+
 	data := BugsData{
-		Repo:          repo,
-		DefaultBranch: defaultBranch,
-		ActiveTab:     "bugs",
-		ServerName:    cfg.Name,
-		HasGitBug:     true,
-		Bugs:          pagedBugs,
-		Status:        status,
-		Page:          page,
-		TotalPages:    totalPages,
-		HasPrevPage:   page > 1,
-		HasNextPage:   page < totalPages,
+		RepoBaseData: RepoBaseData{
+			BaseData: BaseData{
+				ServerName: cfg.Name,
+				ActiveTab:  "bugs",
+				Title:      "Bugs | " + repoDisplayName,
+			},
+			Repo:          repo,
+			DefaultBranch: defaultBranch,
+			HasGitBug:     true,
+		},
+		PaginationData: PaginationData{
+			Page:        page,
+			TotalPages:  totalPages,
+			HasPrevPage: page > 1,
+			HasNextPage: page < totalPages,
+		},
+		Bugs:   pagedBugs,
+		Status: status,
 	}
 
 	renderHTML(w, "bugs.html", data)
@@ -446,20 +447,30 @@ func repoBug(w http.ResponseWriter, r *http.Request) {
 	}
 	defaultBranch := getDefaultBranch(gr)
 
+	repoDisplayName := repo.ProjectName()
+	if repoDisplayName == "" {
+		repoDisplayName = repo.Name()
+	}
+
 	data := BugData{
-		Repo:          repo,
-		DefaultBranch: defaultBranch,
-		ActiveTab:     "bugs",
-		ServerName:    cfg.Name,
-		HasGitBug:     true,
-		ID:            snap.Id().Human(),
-		Title:         snap.Title,
-		Status:        snap.Status.String(),
-		Author:        snap.Author.DisplayName(),
-		CreatedAt:     snap.CreateTime,
-		Edited:        edited,
-		Timeline:      timeline,
-		Labels:        labels,
+		RepoBaseData: RepoBaseData{
+			BaseData: BaseData{
+				ServerName: cfg.Name,
+				ActiveTab:  "bugs",
+				Title:      snap.Title + " | Bug " + snap.Id().Human() + " | " + repoDisplayName,
+			},
+			Repo:          repo,
+			DefaultBranch: defaultBranch,
+			HasGitBug:     true,
+		},
+		ID:        snap.Id().Human(),
+		Subject:   snap.Title,
+		Status:    snap.Status.String(),
+		Author:    snap.Author.DisplayName(),
+		CreatedAt: snap.CreateTime,
+		Edited:    edited,
+		Timeline:  timeline,
+		Labels:    labels,
 	}
 
 	renderHTML(w, "bug.html", data)