From 1917e50367ad60d496e577ac1c8e40231872c50a Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sat, 20 Feb 2021 21:14:33 +0500 Subject: [PATCH] Move readers views to the views module --- http_history.go | 4 +- http_readers.go | 14 +- templates/common.qtpl | 69 +----- templates/common.qtpl.go | 287 +++++++------------------ templates/readers.qtpl.go | 326 ---------------------------- views/nav.qtpl | 78 +++++++ views/nav.qtpl.go | 314 +++++++++++++++++++++++++++ {templates => views}/readers.qtpl | 75 ++++--- views/readers.qtpl.go | 338 ++++++++++++++++++++++++++++++ 9 files changed, 858 insertions(+), 647 deletions(-) delete mode 100644 templates/readers.qtpl.go create mode 100644 views/nav.qtpl create mode 100644 views/nav.qtpl.go rename {templates => views}/readers.qtpl (75%) create mode 100644 views/readers.qtpl.go diff --git a/http_history.go b/http_history.go index 3adda8a..a952682 100644 --- a/http_history.go +++ b/http_history.go @@ -8,9 +8,9 @@ import ( "strings" "github.com/bouncepaw/mycorrhiza/history" - "github.com/bouncepaw/mycorrhiza/templates" "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" + "github.com/bouncepaw/mycorrhiza/views" ) func init() { @@ -35,7 +35,7 @@ func handlerHistory(w http.ResponseWriter, rq *http.Request) { log.Println("Found", len(revs), "revisions for", hyphaName) util.HTTP200Page(w, - base(hyphaName, templates.HistoryHTML(rq, hyphaName, list), user.FromRequest(rq))) + base(hyphaName, views.HistoryHTML(rq, hyphaName, list), user.FromRequest(rq))) } // Recent changes diff --git a/http_readers.go b/http_readers.go index 9cc1351..119704b 100644 --- a/http_readers.go +++ b/http_readers.go @@ -14,7 +14,6 @@ import ( "github.com/bouncepaw/mycorrhiza/markup" "github.com/bouncepaw/mycorrhiza/mimetype" "github.com/bouncepaw/mycorrhiza/templates" - "github.com/bouncepaw/mycorrhiza/tree" "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" "github.com/bouncepaw/mycorrhiza/views" @@ -44,13 +43,10 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) { if err == nil { contents = markup.Doc(hyphaName, textContents).AsHTML() } - treeHTML, subhyphae, _, _ := tree.Tree(hyphaName) - page := templates.RevisionHTML( + page := views.RevisionHTML( rq, h, contents, - treeHTML, - subhyphae, revHash, ) w.Header().Set("Content-Type", "text/html;charset=utf-8") @@ -102,16 +98,10 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) { contents = views.AttachmentHTML(h) + contents } } - treeHTML, subhyphaeHTML, prevHypha, nextHypha := tree.Tree(hyphaName) util.HTTP200Page(w, templates.BaseHTML( util.BeautifulName(hyphaName), - templates.PageHTML(rq, h, - contents, - treeHTML, - subhyphaeHTML, - prevHypha, nextHypha, - ), + views.HyphaHTML(rq, h, contents), u, openGraph)) } diff --git a/templates/common.qtpl b/templates/common.qtpl index 57dea92..2f225ac 100644 --- a/templates/common.qtpl +++ b/templates/common.qtpl @@ -1,78 +1,19 @@ {% import "net/http" %} -{% import "strings" %} {% import "github.com/bouncepaw/mycorrhiza/user" %} -{% import "github.com/bouncepaw/mycorrhiza/util" %} - -This is the