diff --git a/http_auth.go b/http_auth.go index 2e1039b..cfe0799 100644 --- a/http_auth.go +++ b/http_auth.go @@ -28,7 +28,7 @@ func handlerLogout(w http.ResponseWriter, rq *http.Request) { log.Println("Unknown user tries to log out") w.WriteHeader(http.StatusForbidden) } - w.Write([]byte(base("Logout?", templates.LogoutHTML(can)))) + w.Write([]byte(base("Logout?", templates.LogoutHTML(can), u))) } func handlerLogoutConfirm(w http.ResponseWriter, rq *http.Request) { @@ -44,7 +44,7 @@ func handlerLoginData(w http.ResponseWriter, rq *http.Request) { err = user.LoginDataHTTP(w, rq, username, password) ) if err != "" { - w.Write([]byte(base(err, templates.LoginErrorHTML(err)))) + w.Write([]byte(base(err, templates.LoginErrorHTML(err), user.EmptyUser()))) } else { http.Redirect(w, rq, "/", http.StatusSeeOther) } @@ -58,5 +58,5 @@ func handlerLogin(w http.ResponseWriter, rq *http.Request) { } else { w.WriteHeader(http.StatusForbidden) } - w.Write([]byte(base("Login", templates.LoginHTML()))) + w.Write([]byte(base("Login", templates.LoginHTML(), user.EmptyUser()))) } diff --git a/http_history.go b/http_history.go index de010d5..3adda8a 100644 --- a/http_history.go +++ b/http_history.go @@ -9,6 +9,7 @@ import ( "github.com/bouncepaw/mycorrhiza/history" "github.com/bouncepaw/mycorrhiza/templates" + "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" ) @@ -34,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))) + base(hyphaName, templates.HistoryHTML(rq, hyphaName, list), user.FromRequest(rq))) } // Recent changes @@ -45,7 +46,7 @@ func handlerRecentChanges(w http.ResponseWriter, rq *http.Request) { n, err = strconv.Atoi(noPrefix) ) if err == nil && n < 101 { - util.HTTP200Page(w, base(strconv.Itoa(n)+" recent changes", history.RecentChanges(n))) + util.HTTP200Page(w, base(strconv.Itoa(n)+" recent changes", history.RecentChanges(n), user.FromRequest(rq))) } else { http.Redirect(w, rq, "/recent-changes/20", http.StatusSeeOther) } diff --git a/http_mutators.go b/http_mutators.go index 61d1da9..ca48d07 100644 --- a/http_mutators.go +++ b/http_mutators.go @@ -41,7 +41,7 @@ func handlerUnattachAsk(w http.ResponseWriter, rq *http.Request) { log.Println("Rejected (no rights):", rq.URL) return } - util.HTTP200Page(w, base("Unattach "+hyphaName+"?", templates.UnattachAskHTML(rq, hyphaName, isOld))) + util.HTTP200Page(w, base("Unattach "+hyphaName+"?", templates.UnattachAskHTML(rq, hyphaName, isOld), user.FromRequest(rq))) } func handlerUnattachConfirm(w http.ResponseWriter, rq *http.Request) { @@ -82,13 +82,14 @@ func handlerRenameAsk(w http.ResponseWriter, rq *http.Request) { var ( hyphaName = HyphaNameFromRq(rq, "rename-ask") _, isOld = HyphaStorage[hyphaName] + u = user.FromRequest(rq) ) - if ok := user.CanProceed(rq, "rename-confirm"); !ok { + if !u.CanProceed("rename-confirm") { HttpErr(w, http.StatusForbidden, hyphaName, "Not enough rights", "You must be a trusted editor to rename pages.") log.Println("Rejected", rq.URL) return } - util.HTTP200Page(w, base("Rename "+hyphaName+"?", templates.RenameAskHTML(rq, hyphaName, isOld))) + util.HTTP200Page(w, base("Rename "+hyphaName+"?", templates.RenameAskHTML(rq, hyphaName, isOld), u)) } func handlerRenameConfirm(w http.ResponseWriter, rq *http.Request) { @@ -134,13 +135,14 @@ func handlerDeleteAsk(w http.ResponseWriter, rq *http.Request) { var ( hyphaName = HyphaNameFromRq(rq, "delete-ask") _, isOld = HyphaStorage[hyphaName] + u = user.FromRequest(rq) ) - if ok := user.CanProceed(rq, "delete-ask"); !ok { + if !u.CanProceed("delete-ask") { HttpErr(w, http.StatusForbidden, hyphaName, "Not enough rights", "You must be a moderator to delete pages.") log.Println("Rejected", rq.URL) return } - util.HTTP200Page(w, base("Delete "+hyphaName+"?", templates.DeleteAskHTML(rq, hyphaName, isOld))) + util.HTTP200Page(w, base("Delete "+hyphaName+"?", templates.DeleteAskHTML(rq, hyphaName, isOld), u)) } // handlerDeleteConfirm deletes a hypha for sure @@ -151,7 +153,7 @@ func handlerDeleteConfirm(w http.ResponseWriter, rq *http.Request) { hyphaData, isOld = HyphaStorage[hyphaName] u = user.FromRequest(rq) ) - if !user.CanProceed(rq, "delete-confirm") { + if !u.CanProceed("delete-confirm") { HttpErr(w, http.StatusForbidden, hyphaName, "Not enough rights", "You must be a moderator to delete pages.") log.Println("Rejected", rq.URL) return @@ -181,8 +183,9 @@ func handlerEdit(w http.ResponseWriter, rq *http.Request) { warning string textAreaFill string err error + u = user.FromRequest(rq) ) - if ok := user.CanProceed(rq, "edit"); !ok { + if !u.CanProceed("edit") { HttpErr(w, http.StatusForbidden, hyphaName, "Not enough rights", "You must be an editor to edit pages.") log.Println("Rejected", rq.URL) return @@ -197,7 +200,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(rq, hyphaName, textAreaFill, warning))) + util.HTTP200Page(w, base("Edit "+hyphaName, templates.EditHTML(rq, hyphaName, textAreaFill, warning), u)) } // handlerUploadText uploads a new text part for the hypha. @@ -209,7 +212,7 @@ func handlerUploadText(w http.ResponseWriter, rq *http.Request) { action = rq.PostFormValue("action") u = user.FromRequest(rq) ) - if ok := user.CanProceed(rq, "upload-text"); !ok { + if !u.CanProceed("upload-text") { HttpErr(w, http.StatusForbidden, hyphaName, "Not enough rights", "You must be an editor to edit pages.") log.Println("Rejected", rq.URL) return @@ -219,7 +222,7 @@ func handlerUploadText(w http.ResponseWriter, rq *http.Request) { return } if action == "Preview" { - util.HTTP200Page(w, base("Preview "+hyphaName, templates.PreviewHTML(rq, hyphaName, textData, "", markup.Doc(hyphaName, textData).AsHTML()))) + util.HTTP200Page(w, base("Preview "+hyphaName, templates.PreviewHTML(rq, hyphaName, textData, "", markup.Doc(hyphaName, textData).AsHTML()), u)) } else if hop := UploadText(hyphaName, textData, u); len(hop.Errs) != 0 { HttpErr(w, http.StatusInternalServerError, hyphaName, "Error", hop.Errs[0].Error()) } else { diff --git a/http_readers.go b/http_readers.go index 939aef1..970200d 100644 --- a/http_readers.go +++ b/http_readers.go @@ -13,6 +13,7 @@ import ( "github.com/bouncepaw/mycorrhiza/markup" "github.com/bouncepaw/mycorrhiza/templates" "github.com/bouncepaw/mycorrhiza/tree" + "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" ) @@ -34,6 +35,7 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) { contents = fmt.Sprintf(`

This hypha had no text at this revision.

`) textPath = hyphaName + ".myco" textContents, err = history.FileAtRevision(textPath, revHash) + u = user.FromRequest(rq) ) if err == nil { contents = markup.Doc(hyphaName, textContents).AsHTML() @@ -49,7 +51,7 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) { ) w.Header().Set("Content-Type", "text/html;charset=utf-8") w.WriteHeader(http.StatusOK) - w.Write([]byte(base(hyphaName, page))) + w.Write([]byte(base(hyphaName, page, u))) } // handlerText serves raw source text of the hypha. @@ -83,6 +85,7 @@ func handlerPage(w http.ResponseWriter, rq *http.Request) { hasAmnt = hyphaExists && data.binaryPath != "" contents string openGraph string + u = user.FromRequest(rq) ) if hyphaExists { fileContentsT, errT := ioutil.ReadFile(data.textPath) @@ -105,5 +108,6 @@ func handlerPage(w http.ResponseWriter, rq *http.Request) { contents, treeHTML, prevHypha, nextHypha, hasAmnt), + u, openGraph)) } diff --git a/main.go b/main.go index cf79b9f..c87c96e 100644 --- a/main.go +++ b/main.go @@ -41,9 +41,18 @@ func HttpErr(w http.ResponseWriter, status int, name, title, errMsg string) { log.Println(errMsg, "for", name) w.Header().Set("Content-Type", "text/html;charset=utf-8") w.WriteHeader(status) - fmt.Fprint(w, base(title, fmt.Sprintf( - `

%s. Go back to the hypha.

`, - errMsg, name))) + fmt.Fprint( + w, + base( + title, + fmt.Sprintf( + `

%s. Go back to the hypha.

`, + errMsg, + name, + ), + user.EmptyUser(), + ), + ) } // Show all hyphae @@ -52,11 +61,12 @@ func handlerList(w http.ResponseWriter, rq *http.Request) { var ( tbody string pageCount = hyphae.Count() + u = user.FromRequest(rq) ) for hyphaName, data := range HyphaStorage { tbody += templates.HyphaListRowHTML(hyphaName, ExtensionToMime(filepath.Ext(data.binaryPath)), data.binaryPath != "") } - util.HTTP200Page(w, base("List of pages", templates.HyphaListHTML(tbody, pageCount))) + util.HTTP200Page(w, base("List of pages", templates.HyphaListHTML(tbody, pageCount), u)) } // This part is present in all html documents. @@ -146,7 +156,7 @@ func handlerIcon(w http.ResponseWriter, rq *http.Request) { func handlerAbout(w http.ResponseWriter, rq *http.Request) { w.Header().Set("Content-Type", "text/html;charset=utf-8") w.WriteHeader(http.StatusOK) - w.Write([]byte(base("About "+util.SiteName, templates.AboutHTML()))) + w.Write([]byte(base("About "+util.SiteName, templates.AboutHTML(), user.FromRequest(rq)))) } func handlerRobotsTxt(w http.ResponseWriter, rq *http.Request) { diff --git a/templates/asset.qtpl.go b/templates/asset.qtpl.go index 7f405cb..c13cf38 100644 --- a/templates/asset.qtpl.go +++ b/templates/asset.qtpl.go @@ -29,6 +29,7 @@ func StreamDefaultCSS(qw422016 *qt422016.Writer) { .hypha-tabs { padding: 1rem 2rem; margin: 0 auto; width: 800px; } header { margin: 0 auto; width: 800px; } .header-links__entry { margin-right: 1.5rem; } + .header-links__entry_user { margin: 0 2rem 0 auto; } .header-links__entry:nth-of-type(1), .hypha-tabs__tab:nth-of-type(1) { margin-left: 2rem; } .hypha-tabs__tab { margin-right: 1.5rem; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.2); border-bottom: 2px #ddd solid; padding: 0 .5rem; } @@ -94,13 +95,13 @@ figcaption { padding-bottom: .5rem; } #new-name {width:100%;} header { margin-bottom: .5rem; } +.header-links__entry_user { font-style:italic; } .header-links__link { text-decoration: none; display: block; width: 100%; height: 100%; padding: .25rem; } .hypha-tabs { padding: 0; } .header-links__list, .hypha-tabs__flex { margin: 0; padding: 0; display: flex; flex-wrap: wrap; } .header-links__entry, .hypha-tabs__tab { list-style-type: none; } .hypha-tabs__tab a { text-decoration: none; } .hypha-tabs__tab_active { font-weight: bold; } -.hypha-tabs__user { font-style:italic; } .rc-entry { display: grid; list-style-type: none; padding: .25rem; grid-template-columns: 1fr 1fr; } .rc-entry__time { font-style: italic; } diff --git a/templates/common.qtpl b/templates/common.qtpl index 08fa7d2..b5e06a1 100644 --- a/templates/common.qtpl +++ b/templates/common.qtpl @@ -41,20 +41,19 @@ var navEntries = []navEntry{ {%- endif -%} {%- endfor -%} - {%s= userMenuHTML(u) %} {% endfunc %} {% func userMenuHTML(u *user.User) %} - {% if user.AuthUsed %} -
  • - {% if u.Group == "anon" %} - Login - {% else %} - {%s u.Name %} - {% endif %} -
  • +{% if user.AuthUsed %} +
  • + {% if u.Group == "anon" %} + Login + {% else %} + {%s u.Name %} {% endif %} +
  • +{% endif %} {% endfunc %} diff --git a/templates/common.qtpl.go b/templates/common.qtpl.go index 5895b1e..590cc02 100644 --- a/templates/common.qtpl.go +++ b/templates/common.qtpl.go @@ -106,114 +106,109 @@ func streamnavHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, navTy //line templates/common.qtpl:43 } //line templates/common.qtpl:43 - qw422016.N().S(` `) -//line templates/common.qtpl:44 - qw422016.N().S(userMenuHTML(u)) -//line templates/common.qtpl:44 - qw422016.N().S(` - + qw422016.N().S(` `) -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 } -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 func writenavHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, navType string, revisionHash ...string) { -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 streamnavHTML(qw422016, rq, hyphaName, navType, revisionHash...) -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 qt422016.ReleaseWriter(qw422016) -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 } -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 func navHTML(rq *http.Request, hyphaName, navType string, revisionHash ...string) string { -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 qb422016 := qt422016.AcquireByteBuffer() -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 writenavHTML(qb422016, rq, hyphaName, navType, revisionHash...) -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 qs422016 := string(qb422016.B) -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 qt422016.ReleaseByteBuffer(qb422016) -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 return qs422016 -//line templates/common.qtpl:47 +//line templates/common.qtpl:46 } -//line templates/common.qtpl:49 +//line templates/common.qtpl:48 func streamuserMenuHTML(qw422016 *qt422016.Writer, u *user.User) { -//line templates/common.qtpl:49 - qw422016.N().S(` - `) -//line templates/common.qtpl:50 - if user.AuthUsed { -//line templates/common.qtpl:50 - qw422016.N().S(` -
  • - `) -//line templates/common.qtpl:52 - if u.Group == "anon" { -//line templates/common.qtpl:52 - qw422016.N().S(` - Login - `) -//line templates/common.qtpl:54 - } else { -//line templates/common.qtpl:54 - qw422016.N().S(` - `) -//line templates/common.qtpl:55 - qw422016.E().S(u.Name) -//line templates/common.qtpl:55 - qw422016.N().S(` - `) -//line templates/common.qtpl:56 - } -//line templates/common.qtpl:56 - qw422016.N().S(` -
  • - `) -//line templates/common.qtpl:58 - } -//line templates/common.qtpl:58 +//line templates/common.qtpl:48 qw422016.N().S(` `) -//line templates/common.qtpl:59 +//line templates/common.qtpl:49 + if user.AuthUsed { +//line templates/common.qtpl:49 + qw422016.N().S(` +
  • + `) +//line templates/common.qtpl:51 + if u.Group == "anon" { +//line templates/common.qtpl:51 + qw422016.N().S(` + Login + `) +//line templates/common.qtpl:53 + } else { +//line templates/common.qtpl:53 + qw422016.N().S(` + `) +//line templates/common.qtpl:54 + qw422016.E().S(u.Name) +//line templates/common.qtpl:54 + qw422016.N().S(` + `) +//line templates/common.qtpl:55 + } +//line templates/common.qtpl:55 + qw422016.N().S(` +
  • +`) +//line templates/common.qtpl:57 + } +//line templates/common.qtpl:57 + qw422016.N().S(` +`) +//line templates/common.qtpl:58 } -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 func writeuserMenuHTML(qq422016 qtio422016.Writer, u *user.User) { -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 streamuserMenuHTML(qw422016, u) -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 qt422016.ReleaseWriter(qw422016) -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 } -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 func userMenuHTML(u *user.User) string { -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 qb422016 := qt422016.AcquireByteBuffer() -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 writeuserMenuHTML(qb422016, u) -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 qs422016 := string(qb422016.B) -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 qt422016.ReleaseByteBuffer(qb422016) -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 return qs422016 -//line templates/common.qtpl:59 +//line templates/common.qtpl:58 } diff --git a/templates/default.css b/templates/default.css index ffbcc82..a669a87 100644 --- a/templates/default.css +++ b/templates/default.css @@ -4,6 +4,7 @@ .hypha-tabs { padding: 1rem 2rem; margin: 0 auto; width: 800px; } header { margin: 0 auto; width: 800px; } .header-links__entry { margin-right: 1.5rem; } + .header-links__entry_user { margin: 0 2rem 0 auto; } .header-links__entry:nth-of-type(1), .hypha-tabs__tab:nth-of-type(1) { margin-left: 2rem; } .hypha-tabs__tab { margin-right: 1.5rem; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.2); border-bottom: 2px #ddd solid; padding: 0 .5rem; } @@ -69,13 +70,13 @@ figcaption { padding-bottom: .5rem; } #new-name {width:100%;} header { margin-bottom: .5rem; } +.header-links__entry_user { font-style:italic; } .header-links__link { text-decoration: none; display: block; width: 100%; height: 100%; padding: .25rem; } .hypha-tabs { padding: 0; } .header-links__list, .hypha-tabs__flex { margin: 0; padding: 0; display: flex; flex-wrap: wrap; } .header-links__entry, .hypha-tabs__tab { list-style-type: none; } .hypha-tabs__tab a { text-decoration: none; } .hypha-tabs__tab_active { font-weight: bold; } -.hypha-tabs__user { font-style:italic; } .rc-entry { display: grid; list-style-type: none; padding: .25rem; grid-template-columns: 1fr 1fr; } .rc-entry__time { font-style: italic; } diff --git a/templates/http_stuff.qtpl b/templates/http_stuff.qtpl index c65c0f9..8723860 100644 --- a/templates/http_stuff.qtpl +++ b/templates/http_stuff.qtpl @@ -1,7 +1,7 @@ {% import "github.com/bouncepaw/mycorrhiza/util" %} {% import "github.com/bouncepaw/mycorrhiza/user" %} -{% func BaseHTML(title, body string, headElements ...string) %} +{% func BaseHTML(title, body string, u *user.User, headElements ...string) %} @@ -17,6 +17,7 @@ {%- for _, link := range util.HeaderLinks -%}
  • {%s link.Display %}
  • {%- endfor -%} + {%s= userMenuHTML(u) %} diff --git a/templates/http_stuff.qtpl.go b/templates/http_stuff.qtpl.go index 667627a..2de5906 100644 --- a/templates/http_stuff.qtpl.go +++ b/templates/http_stuff.qtpl.go @@ -24,7 +24,7 @@ var ( ) //line templates/http_stuff.qtpl:4 -func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, headElements ...string) { +func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, u *user.User, headElements ...string) { //line templates/http_stuff.qtpl:4 qw422016.N().S(` @@ -68,56 +68,61 @@ func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, headElements //line templates/http_stuff.qtpl:19 } //line templates/http_stuff.qtpl:19 - qw422016.N().S(` + qw422016.N().S(` `) +//line templates/http_stuff.qtpl:20 + qw422016.N().S(userMenuHTML(u)) +//line templates/http_stuff.qtpl:20 + qw422016.N().S(` + `) -//line templates/http_stuff.qtpl:23 +//line templates/http_stuff.qtpl:24 qw422016.N().S(body) -//line templates/http_stuff.qtpl:23 +//line templates/http_stuff.qtpl:24 qw422016.N().S(` `) -//line templates/http_stuff.qtpl:26 +//line templates/http_stuff.qtpl:27 } -//line templates/http_stuff.qtpl:26 -func WriteBaseHTML(qq422016 qtio422016.Writer, title, body string, headElements ...string) { -//line templates/http_stuff.qtpl:26 +//line templates/http_stuff.qtpl:27 +func WriteBaseHTML(qq422016 qtio422016.Writer, title, body string, u *user.User, headElements ...string) { +//line templates/http_stuff.qtpl:27 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/http_stuff.qtpl:26 - StreamBaseHTML(qw422016, title, body, headElements...) -//line templates/http_stuff.qtpl:26 +//line templates/http_stuff.qtpl:27 + StreamBaseHTML(qw422016, title, body, u, headElements...) +//line templates/http_stuff.qtpl:27 qt422016.ReleaseWriter(qw422016) -//line templates/http_stuff.qtpl:26 +//line templates/http_stuff.qtpl:27 } -//line templates/http_stuff.qtpl:26 -func BaseHTML(title, body string, headElements ...string) string { -//line templates/http_stuff.qtpl:26 +//line templates/http_stuff.qtpl:27 +func BaseHTML(title, body string, u *user.User, headElements ...string) string { +//line templates/http_stuff.qtpl:27 qb422016 := qt422016.AcquireByteBuffer() -//line templates/http_stuff.qtpl:26 - WriteBaseHTML(qb422016, title, body, headElements...) -//line templates/http_stuff.qtpl:26 +//line templates/http_stuff.qtpl:27 + WriteBaseHTML(qb422016, title, body, u, headElements...) +//line templates/http_stuff.qtpl:27 qs422016 := string(qb422016.B) -//line templates/http_stuff.qtpl:26 +//line templates/http_stuff.qtpl:27 qt422016.ReleaseByteBuffer(qb422016) -//line templates/http_stuff.qtpl:26 +//line templates/http_stuff.qtpl:27 return qs422016 -//line templates/http_stuff.qtpl:26 +//line templates/http_stuff.qtpl:27 } -//line templates/http_stuff.qtpl:28 +//line templates/http_stuff.qtpl:29 func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) { -//line templates/http_stuff.qtpl:28 +//line templates/http_stuff.qtpl:29 qw422016.N().S(`

    List of hyphae

    This wiki has `) -//line templates/http_stuff.qtpl:31 +//line templates/http_stuff.qtpl:32 qw422016.N().D(pageCount) -//line templates/http_stuff.qtpl:31 +//line templates/http_stuff.qtpl:32 qw422016.N().S(` hyphae.

    @@ -128,203 +133,203 @@ func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) `) -//line templates/http_stuff.qtpl:40 +//line templates/http_stuff.qtpl:41 qw422016.N().S(tbody) -//line templates/http_stuff.qtpl:40 +//line templates/http_stuff.qtpl:41 qw422016.N().S(`
    `) -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 } -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 func WriteHyphaListHTML(qq422016 qtio422016.Writer, tbody string, pageCount int) { -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 StreamHyphaListHTML(qw422016, tbody, pageCount) -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 qt422016.ReleaseWriter(qw422016) -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 } -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 func HyphaListHTML(tbody string, pageCount int) string { -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 qb422016 := qt422016.AcquireByteBuffer() -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 WriteHyphaListHTML(qb422016, tbody, pageCount) -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 qs422016 := string(qb422016.B) -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 qt422016.ReleaseByteBuffer(qb422016) -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 return qs422016 -//line templates/http_stuff.qtpl:44 +//line templates/http_stuff.qtpl:45 } -//line templates/http_stuff.qtpl:46 +//line templates/http_stuff.qtpl:47 func StreamHyphaListRowHTML(qw422016 *qt422016.Writer, hyphaName, binaryMime string, binaryPresent bool) { -//line templates/http_stuff.qtpl:46 +//line templates/http_stuff.qtpl:47 qw422016.N().S(` `) -//line templates/http_stuff.qtpl:48 +//line templates/http_stuff.qtpl:49 qw422016.E().S(hyphaName) -//line templates/http_stuff.qtpl:48 +//line templates/http_stuff.qtpl:49 qw422016.N().S(` `) -//line templates/http_stuff.qtpl:49 +//line templates/http_stuff.qtpl:50 if binaryPresent { -//line templates/http_stuff.qtpl:49 +//line templates/http_stuff.qtpl:50 qw422016.N().S(` `) -//line templates/http_stuff.qtpl:50 +//line templates/http_stuff.qtpl:51 qw422016.E().S(binaryMime) -//line templates/http_stuff.qtpl:50 +//line templates/http_stuff.qtpl:51 qw422016.N().S(` `) -//line templates/http_stuff.qtpl:51 +//line templates/http_stuff.qtpl:52 } else { -//line templates/http_stuff.qtpl:51 +//line templates/http_stuff.qtpl:52 qw422016.N().S(` `) -//line templates/http_stuff.qtpl:53 +//line templates/http_stuff.qtpl:54 } -//line templates/http_stuff.qtpl:53 +//line templates/http_stuff.qtpl:54 qw422016.N().S(` `) -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 } -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 func WriteHyphaListRowHTML(qq422016 qtio422016.Writer, hyphaName, binaryMime string, binaryPresent bool) { -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 StreamHyphaListRowHTML(qw422016, hyphaName, binaryMime, binaryPresent) -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 qt422016.ReleaseWriter(qw422016) -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 } -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 func HyphaListRowHTML(hyphaName, binaryMime string, binaryPresent bool) string { -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 qb422016 := qt422016.AcquireByteBuffer() -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 WriteHyphaListRowHTML(qb422016, hyphaName, binaryMime, binaryPresent) -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 qs422016 := string(qb422016.B) -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 qt422016.ReleaseByteBuffer(qb422016) -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 return qs422016 -//line templates/http_stuff.qtpl:55 +//line templates/http_stuff.qtpl:56 } -//line templates/http_stuff.qtpl:57 +//line templates/http_stuff.qtpl:58 func StreamAboutHTML(qw422016 *qt422016.Writer) { -//line templates/http_stuff.qtpl:57 +//line templates/http_stuff.qtpl:58 qw422016.N().S(`

    About `) -//line templates/http_stuff.qtpl:60 +//line templates/http_stuff.qtpl:61 qw422016.E().S(util.SiteName) -//line templates/http_stuff.qtpl:60 +//line templates/http_stuff.qtpl:61 qw422016.N().S(`

    See /list for information about hyphae on this wiki.

    `) -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 } -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 func WriteAboutHTML(qq422016 qtio422016.Writer) { -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 StreamAboutHTML(qw422016) -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 qt422016.ReleaseWriter(qw422016) -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 } -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 func AboutHTML() string { -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 qb422016 := qt422016.AcquireByteBuffer() -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 WriteAboutHTML(qb422016) -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 qs422016 := string(qb422016.B) -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 qt422016.ReleaseByteBuffer(qb422016) -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 return qs422016 -//line templates/http_stuff.qtpl:77 +//line templates/http_stuff.qtpl:78 } diff --git a/user/net.go b/user/net.go index 55b08e1..caec383 100644 --- a/user/net.go +++ b/user/net.go @@ -17,7 +17,7 @@ func CanProceed(rq *http.Request, route string) bool { func FromRequest(rq *http.Request) *User { cookie, err := rq.Cookie("mycorrhiza_token") if err != nil { - return emptyUser() + return EmptyUser() } return userByToken(cookie.Value) } diff --git a/user/user.go b/user/user.go index b45e2c5..efc0028 100644 --- a/user/user.go +++ b/user/user.go @@ -37,7 +37,7 @@ var groupRight = map[string]int{ "admin": 4, } -func emptyUser() *User { +func EmptyUser() *User { return &User{ Name: "anon", Group: "anon", diff --git a/user/users.go b/user/users.go index 397ecf0..aa5bb4b 100644 --- a/user/users.go +++ b/user/users.go @@ -44,7 +44,7 @@ func userByToken(token string) *User { username := usernameUntyped.(string) return userByName(username) } - return emptyUser() + return EmptyUser() } func userByName(username string) *User { @@ -52,7 +52,7 @@ func userByName(username string) *User { user := userUntyped.(*User) return user } - return emptyUser() + return EmptyUser() } func commenceSession(username, token string) {