From 6c08f284b9e5f79644126c8d64a879b620537e84 Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Thu, 28 Jan 2016 18:13:26 -0500 Subject: [PATCH] Use diferent titles per page * Related: #7 --- admin.go | 2 ++ news.go | 2 ++ reader.go | 1 + search.go | 1 + stats.go | 1 + template.go | 4 +++- templates/header.html | 4 ++-- templates/index.opds | 2 +- templates/news.rss | 2 +- templates/search.opds | 2 +- templates/search.rss | 2 +- trantor.go | 4 ++++ upload.go | 1 + user.go | 3 +++ 14 files changed, 24 insertions(+), 7 deletions(-) diff --git a/admin.go b/admin.go index 1ca0a33..e2e08a1 100644 --- a/admin.go +++ b/admin.go @@ -63,6 +63,7 @@ func editHandler(h handler) { var data bookData data.Book = book data.S = GetStatus(h) + data.S.Title = book.Title + " by " + book.Author[0] + " -- Edit -- " + data.S.Title loadTemplate(h, "edit", data) } @@ -149,6 +150,7 @@ func newHandler(h handler) { var data newData data.S = GetStatus(h) + data.S.Title = "New books -- " + data.S.Title data.Found = num if num-NEW_ITEMS_PAGE*page < NEW_ITEMS_PAGE { data.Books = make([]newBook, num-NEW_ITEMS_PAGE*page) diff --git a/news.go b/news.go index 773b43e..ad07310 100644 --- a/news.go +++ b/news.go @@ -25,6 +25,7 @@ func newsHandler(h handler) { var data newsData data.S = GetStatus(h) + data.S.Title = "News -- " + data.S.Title data.S.News = true data.News = getNews(NUM_NEWS, 0, h.db) @@ -39,6 +40,7 @@ func editNewsHandler(h handler) { var data statusData data.S = GetStatus(h) + data.S.Title = "Edit news -- " + data.S.Title data.S.News = true loadTemplate(h, "edit_news", data) } diff --git a/reader.go b/reader.go index adddee5..87528bd 100644 --- a/reader.go +++ b/reader.go @@ -157,6 +157,7 @@ func readHandler(h handler) { var data readData data.S = GetStatus(h) + data.S.Title = book.Title + " by " + book.Author[0] + " -- Read -- " + data.S.Title data.Book = book if !book.Active { data.Back = "/new/" diff --git a/search.go b/search.go index 26a54bd..57065a6 100644 --- a/search.go +++ b/search.go @@ -37,6 +37,7 @@ func searchHandler(h handler) { var data searchData data.S = GetStatus(h) + data.S.Title = req + " -- Search -- " + data.S.Title data.S.Search = req data.Books = res data.ItemsPage = items_page diff --git a/stats.go b/stats.go index 25b3d8e..26c96ab 100644 --- a/stats.go +++ b/stats.go @@ -87,6 +87,7 @@ func (sg StatsGatherer) worker() { func statsHandler(h handler) { var data statsData data.S = GetStatus(h) + data.S.Title = "Stats -- " + data.S.Title data.S.Stats = true data.HVisits = getVisits(hourlyLabel, h.db, database.Hourly_visits) data.DVisits = getVisits(dailyLabel, h.db, database.Daily_visits) diff --git a/template.go b/template.go index 5634e66..e255b22 100644 --- a/template.go +++ b/template.go @@ -17,6 +17,7 @@ import ( type Status struct { BaseURL string FullURL string + Title string Search string User string IsAdmin bool @@ -35,6 +36,7 @@ func GetStatus(h handler) Status { var s Status s.BaseURL = "http://" + h.r.Host s.FullURL = s.BaseURL + h.r.RequestURI + s.Title = "Imperial Library of Trantor" s.User = h.sess.User s.IsAdmin = h.sess.IsAdmin() s.Notif = h.sess.GetNotif() @@ -126,7 +128,7 @@ func indexJson(data interface{}) ([]byte, error) { news := newsJsonRaw(index.News) return json.Marshal(map[string]interface{}{ - "title": "Imperial Library of Trantor", + "title": index.S.Title, "url": index.S.BaseURL, "count": index.Count, "news": news, diff --git a/templates/header.html b/templates/header.html index deb69e5..3be6a56 100644 --- a/templates/header.html +++ b/templates/header.html @@ -6,8 +6,8 @@ - - Imperial Library of Trantor + + {{.Title}} diff --git a/templates/index.opds b/templates/index.opds index 85c57cb..90e259a 100644 --- a/templates/index.opds +++ b/templates/index.opds @@ -19,7 +19,7 @@ href="/opensearch.xml" type="application/opensearchdescription+xml"/> - The Imperial Libary of Trantor + {{.S.Title}} The Imperial Library of Trantor {{.S.BaseURL}} diff --git a/templates/news.rss b/templates/news.rss index 50318b1..228c4a9 100644 --- a/templates/news.rss +++ b/templates/news.rss @@ -2,7 +2,7 @@ {{with .S}} - Imperial Library of Trantor - News + {{.Title}} News of the library {{.BaseURL}}/news/ {{end}} diff --git a/templates/search.opds b/templates/search.opds index 4c00ef6..b73ce1f 100644 --- a/templates/search.opds +++ b/templates/search.opds @@ -44,7 +44,7 @@ {{.Found}} {{.ItemsPage}} - search {{.S.Search}} + {{.S.Title}} The Imperial Library of Trantor {{.S.BaseURL}} diff --git a/templates/search.rss b/templates/search.rss index 94255fa..035ff03 100644 --- a/templates/search.rss +++ b/templates/search.rss @@ -2,7 +2,7 @@ {{with .S}} - Imperial Library of Trantor + {{.Title}} {{if .Search}} Book search: {{.Search}} {{else}} diff --git a/trantor.go b/trantor.go index 195204b..5253fb9 100644 --- a/trantor.go +++ b/trantor.go @@ -21,6 +21,7 @@ type statusData struct { func aboutHandler(h handler) { var data statusData data.S = GetStatus(h) + data.S.Title = "About -- " + data.S.Title data.S.About = true loadTemplate(h, "about", data) } @@ -28,6 +29,7 @@ func aboutHandler(h handler) { func helpHandler(h handler) { var data statusData data.S = GetStatus(h) + data.S.Title = "Help -- " + data.S.Title data.S.Help = true loadTemplate(h, "help", data) } @@ -57,6 +59,7 @@ func bookHandler(h handler) { return } data.Book = book + data.S.Title = book.Title + " by " + book.Author[0] + " -- " + data.S.Title data.Description = strings.Split(data.Book.Description, "\n") data.FlaggedBadQuality = false for _, reporter := range book.BadQualityReporters { @@ -139,6 +142,7 @@ func notFound(h handler) { var data statusData data.S = GetStatus(h) + data.S.Title = "Not found --" + data.S.Title h.w.WriteHeader(http.StatusNotFound) loadTemplate(h, "404", data) } diff --git a/upload.go b/upload.go index 32e1239..030e4b3 100644 --- a/upload.go +++ b/upload.go @@ -96,6 +96,7 @@ func uploadPostHandler(h handler) { func uploadHandler(h handler) { var data uploadData data.S = GetStatus(h) + data.S.Title = "Upload -- " + data.S.Title data.S.Upload = true loadTemplate(h, "upload", data) } diff --git a/user.go b/user.go index 97e6868..c00d22b 100644 --- a/user.go +++ b/user.go @@ -14,6 +14,7 @@ func loginHandler(h handler) { var data statusData data.S = GetStatus(h) + data.S.Title = "Login -- " + data.S.Title loadTemplate(h, "login", data) } @@ -58,6 +59,7 @@ func dashboardHandler(h handler) { var data statusData data.S = GetStatus(h) + data.S.Title = "Dashboard -- " + data.S.Title data.S.Dasboard = true loadTemplate(h, "dashboard", data) } @@ -85,5 +87,6 @@ func settingsHandler(h handler) { var data statusData data.S = GetStatus(h) + data.S.Title = "Settings -- " + data.S.Title loadTemplate(h, "settings", data) }