From 57751d03f4ab43abbdefd92bff97d2d23f475e90 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Mon, 16 Nov 2020 20:26:03 +0500 Subject: [PATCH] Change navigation links depending on who the user is --- http_mutators.go | 6 +- http_readers.go | 5 +- templates/common.qtpl | 27 ++++- templates/common.qtpl.go | 183 ++++++++++++++++++++-------- templates/css.qtpl | 1 + templates/css.qtpl.go | 27 +++-- templates/delete.qtpl | 6 +- templates/delete.qtpl.go | 129 ++++++++++---------- templates/http_mutators.qtpl | 27 +++-- templates/http_mutators.qtpl.go | 106 ++++++++-------- templates/http_readers.qtpl | 17 ++- templates/http_readers.qtpl.go | 208 +++++++++++++++++--------------- templates/rename.qtpl | 5 +- templates/rename.qtpl.go | 125 +++++++++---------- user/user.go | 7 ++ 15 files changed, 517 insertions(+), 362 deletions(-) diff --git a/http_mutators.go b/http_mutators.go index 8deaaac..59f464b 100644 --- a/http_mutators.go +++ b/http_mutators.go @@ -31,7 +31,7 @@ func handlerRenameAsk(w http.ResponseWriter, rq *http.Request) { log.Println("Rejected", rq.URL) return } - util.HTTP200Page(w, base("Rename "+hyphaName+"?", templates.RenameAskHTML(hyphaName, isOld))) + util.HTTP200Page(w, base("Rename "+hyphaName+"?", templates.RenameAskHTML(rq, hyphaName, isOld))) } func handlerRenameConfirm(w http.ResponseWriter, rq *http.Request) { @@ -87,7 +87,7 @@ func handlerDeleteAsk(w http.ResponseWriter, rq *http.Request) { log.Println("Rejected", rq.URL) return } - util.HTTP200Page(w, base("Delete "+hyphaName+"?", templates.DeleteAskHTML(hyphaName, isOld))) + util.HTTP200Page(w, base("Delete "+hyphaName+"?", templates.DeleteAskHTML(rq, hyphaName, isOld))) } // handlerDeleteConfirm deletes a hypha for sure @@ -144,7 +144,7 @@ func handlerEdit(w http.ResponseWriter, rq *http.Request) { } else { warning = `

You are creating a new hypha.

` } - util.HTTP200Page(w, base("Edit "+hyphaName, templates.EditHTML(hyphaName, textAreaFill, warning))) + util.HTTP200Page(w, base("Edit "+hyphaName, templates.EditHTML(rq, hyphaName, textAreaFill, warning))) } // handlerUploadText uploads a new text part for the hypha. diff --git a/http_readers.go b/http_readers.go index 7870d3e..b8887e9 100644 --- a/http_readers.go +++ b/http_readers.go @@ -40,6 +40,7 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) { contents = markup.ToHtml(hyphaName, textContents) } page := templates.RevisionHTML( + rq, hyphaName, naviTitle(hyphaName), contents, @@ -67,7 +68,7 @@ func handlerHistory(w http.ResponseWriter, rq *http.Request) { log.Println("Found", len(revs), "revisions for", hyphaName) util.HTTP200Page(w, - base(hyphaName, templates.HistoryHTML(hyphaName, tbody))) + base(hyphaName, templates.HistoryHTML(rq, hyphaName, tbody))) } // handlerText serves raw source text of the hypha. @@ -110,7 +111,7 @@ func handlerPage(w http.ResponseWriter, rq *http.Request) { contents = binaryHtmlBlock(hyphaName, data) + contents } } - util.HTTP200Page(w, base(hyphaName, templates.PageHTML(hyphaName, + util.HTTP200Page(w, base(hyphaName, templates.PageHTML(rq, hyphaName, naviTitle(hyphaName), contents, tree.TreeAsHtml(hyphaName, IterateHyphaNamesWith)))) diff --git a/templates/common.qtpl b/templates/common.qtpl index c199fa2..321da84 100644 --- a/templates/common.qtpl +++ b/templates/common.qtpl @@ -1,3 +1,7 @@ +{% import "net/http" %} +{% import "github.com/bouncepaw/mycorrhiza/user" %} +{% import "github.com/bouncepaw/mycorrhiza/util" %} + This is the