From b662eb5219d6bd44eb4b9939c57bd2e26cacabdd Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sun, 24 Jan 2021 17:52:40 +0500 Subject: [PATCH 01/53] Move some files around --- README.md | 2 +- .../{http_mutators.qtpl => mutators.qtpl} | 0 ...http_mutators.qtpl.go => mutators.qtpl.go} | 122 ++++----- templates/{http_readers.qtpl => readers.qtpl} | 0 .../{http_readers.qtpl.go => readers.qtpl.go} | 220 +++++++-------- templates/{http_stuff.qtpl => stuff.qtpl} | 2 +- .../{http_stuff.qtpl.go => stuff.qtpl.go} | 252 +++++++++--------- 7 files changed, 299 insertions(+), 299 deletions(-) rename templates/{http_mutators.qtpl => mutators.qtpl} (100%) rename templates/{http_mutators.qtpl.go => mutators.qtpl.go} (57%) rename templates/{http_readers.qtpl => readers.qtpl} (100%) rename templates/{http_readers.qtpl.go => readers.qtpl.go} (54%) rename templates/{http_stuff.qtpl => stuff.qtpl} (98%) rename templates/{http_stuff.qtpl.go => stuff.qtpl.go} (52%) diff --git a/README.md b/README.md index db4db81..d092c4c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 🍄 MycorrhizaWiki 0.12 +# 🍄 MycorrhizaWiki 0.13 A wiki engine. [Main wiki](https://mycorrhiza.lesarbr.es) diff --git a/templates/http_mutators.qtpl b/templates/mutators.qtpl similarity index 100% rename from templates/http_mutators.qtpl rename to templates/mutators.qtpl diff --git a/templates/http_mutators.qtpl.go b/templates/mutators.qtpl.go similarity index 57% rename from templates/http_mutators.qtpl.go rename to templates/mutators.qtpl.go index 8f25c90..7a4ec80 100644 --- a/templates/http_mutators.qtpl.go +++ b/templates/mutators.qtpl.go @@ -1,169 +1,169 @@ -// Code generated by qtc from "http_mutators.qtpl". DO NOT EDIT. +// Code generated by qtc from "mutators.qtpl". DO NOT EDIT. // See https://github.com/valyala/quicktemplate for details. -//line templates/http_mutators.qtpl:1 +//line templates/mutators.qtpl:1 package templates -//line templates/http_mutators.qtpl:1 +//line templates/mutators.qtpl:1 import "net/http" -//line templates/http_mutators.qtpl:3 +//line templates/mutators.qtpl:3 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/http_mutators.qtpl:3 +//line templates/mutators.qtpl:3 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/http_mutators.qtpl:3 +//line templates/mutators.qtpl:3 func StreamEditHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string) { -//line templates/http_mutators.qtpl:3 +//line templates/mutators.qtpl:3 qw422016.N().S(` `) -//line templates/http_mutators.qtpl:4 +//line templates/mutators.qtpl:4 qw422016.N().S(navHTML(rq, hyphaName, "edit")) -//line templates/http_mutators.qtpl:4 +//line templates/mutators.qtpl:4 qw422016.N().S(`

Edit `) -//line templates/http_mutators.qtpl:6 +//line templates/mutators.qtpl:6 qw422016.E().S(hyphaName) -//line templates/http_mutators.qtpl:6 +//line templates/mutators.qtpl:6 qw422016.N().S(`

`) -//line templates/http_mutators.qtpl:7 +//line templates/mutators.qtpl:7 qw422016.N().S(warning) -//line templates/http_mutators.qtpl:7 +//line templates/mutators.qtpl:7 qw422016.N().S(`

Cancel
`) -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 } -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 func WriteEditHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string) { -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 StreamEditHTML(qw422016, rq, hyphaName, textAreaFill, warning) -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 qt422016.ReleaseWriter(qw422016) -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 } -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 func EditHTML(rq *http.Request, hyphaName, textAreaFill, warning string) string { -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 qb422016 := qt422016.AcquireByteBuffer() -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 WriteEditHTML(qb422016, rq, hyphaName, textAreaFill, warning) -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 qs422016 := string(qb422016.B) -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 qt422016.ReleaseByteBuffer(qb422016) -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 return qs422016 -//line templates/http_mutators.qtpl:17 +//line templates/mutators.qtpl:17 } -//line templates/http_mutators.qtpl:19 +//line templates/mutators.qtpl:19 func StreamPreviewHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) { -//line templates/http_mutators.qtpl:19 +//line templates/mutators.qtpl:19 qw422016.N().S(` `) -//line templates/http_mutators.qtpl:20 +//line templates/mutators.qtpl:20 qw422016.N().S(navHTML(rq, hyphaName, "edit")) -//line templates/http_mutators.qtpl:20 +//line templates/mutators.qtpl:20 qw422016.N().S(`

Edit `) -//line templates/http_mutators.qtpl:22 +//line templates/mutators.qtpl:22 qw422016.E().S(hyphaName) -//line templates/http_mutators.qtpl:22 +//line templates/mutators.qtpl:22 qw422016.N().S(` (preview)

`) -//line templates/http_mutators.qtpl:23 +//line templates/mutators.qtpl:23 qw422016.N().S(warning) -//line templates/http_mutators.qtpl:23 +//line templates/mutators.qtpl:23 qw422016.N().S(`

Cancel

Note that the hypha is not saved yet. You can preview the changes ↓

`) -//line templates/http_mutators.qtpl:33 +//line templates/mutators.qtpl:33 qw422016.N().S(renderedPage) -//line templates/http_mutators.qtpl:33 +//line templates/mutators.qtpl:33 qw422016.N().S(`
`) -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 } -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 func WritePreviewHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) { -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 StreamPreviewHTML(qw422016, rq, hyphaName, textAreaFill, warning, renderedPage) -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 qt422016.ReleaseWriter(qw422016) -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 } -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 func PreviewHTML(rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) string { -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 qb422016 := qt422016.AcquireByteBuffer() -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 WritePreviewHTML(qb422016, rq, hyphaName, textAreaFill, warning, renderedPage) -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 qs422016 := string(qb422016.B) -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 qt422016.ReleaseByteBuffer(qb422016) -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 return qs422016 -//line templates/http_mutators.qtpl:35 +//line templates/mutators.qtpl:35 } diff --git a/templates/http_readers.qtpl b/templates/readers.qtpl similarity index 100% rename from templates/http_readers.qtpl rename to templates/readers.qtpl diff --git a/templates/http_readers.qtpl.go b/templates/readers.qtpl.go similarity index 54% rename from templates/http_readers.qtpl.go rename to templates/readers.qtpl.go index d9000da..e93927b 100644 --- a/templates/http_readers.qtpl.go +++ b/templates/readers.qtpl.go @@ -1,256 +1,256 @@ -// Code generated by qtc from "http_readers.qtpl". DO NOT EDIT. +// Code generated by qtc from "readers.qtpl". DO NOT EDIT. // See https://github.com/valyala/quicktemplate for details. -//line templates/http_readers.qtpl:1 +//line templates/readers.qtpl:1 package templates -//line templates/http_readers.qtpl:1 +//line templates/readers.qtpl:1 import "net/http" -//line templates/http_readers.qtpl:2 +//line templates/readers.qtpl:2 import "path" -//line templates/http_readers.qtpl:3 +//line templates/readers.qtpl:3 import "github.com/bouncepaw/mycorrhiza/user" -//line templates/http_readers.qtpl:5 +//line templates/readers.qtpl:5 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/http_readers.qtpl:5 +//line templates/readers.qtpl:5 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/http_readers.qtpl:5 +//line templates/readers.qtpl:5 func StreamHistoryHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, list string) { -//line templates/http_readers.qtpl:5 +//line templates/readers.qtpl:5 qw422016.N().S(` `) -//line templates/http_readers.qtpl:6 +//line templates/readers.qtpl:6 streamnavHTML(qw422016, rq, hyphaName, "history") -//line templates/http_readers.qtpl:6 +//line templates/readers.qtpl:6 qw422016.N().S(`

History of `) -//line templates/http_readers.qtpl:9 +//line templates/readers.qtpl:9 qw422016.E().S(hyphaName) -//line templates/http_readers.qtpl:9 +//line templates/readers.qtpl:9 qw422016.N().S(`

`) -//line templates/http_readers.qtpl:10 +//line templates/readers.qtpl:10 qw422016.N().S(list) -//line templates/http_readers.qtpl:10 +//line templates/readers.qtpl:10 qw422016.N().S(`
`) -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 } -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 func WriteHistoryHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, list string) { -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 StreamHistoryHTML(qw422016, rq, hyphaName, list) -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 qt422016.ReleaseWriter(qw422016) -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 } -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 func HistoryHTML(rq *http.Request, hyphaName, list string) string { -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 qb422016 := qt422016.AcquireByteBuffer() -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 WriteHistoryHTML(qb422016, rq, hyphaName, list) -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 qs422016 := string(qb422016.B) -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 qt422016.ReleaseByteBuffer(qb422016) -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 return qs422016 -//line templates/http_readers.qtpl:13 +//line templates/readers.qtpl:13 } -//line templates/http_readers.qtpl:15 +//line templates/readers.qtpl:15 func StreamRevisionHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, naviTitle, contents, tree, revHash string) { -//line templates/http_readers.qtpl:15 +//line templates/readers.qtpl:15 qw422016.N().S(` `) -//line templates/http_readers.qtpl:16 +//line templates/readers.qtpl:16 streamnavHTML(qw422016, rq, hyphaName, "revision", revHash) -//line templates/http_readers.qtpl:16 +//line templates/readers.qtpl:16 qw422016.N().S(`

Please note that viewing binary parts of hyphae is not supported in history for now.

`) -//line templates/http_readers.qtpl:20 +//line templates/readers.qtpl:20 qw422016.N().S(naviTitle) -//line templates/http_readers.qtpl:20 +//line templates/readers.qtpl:20 qw422016.N().S(` `) -//line templates/http_readers.qtpl:21 +//line templates/readers.qtpl:21 qw422016.N().S(contents) -//line templates/http_readers.qtpl:21 +//line templates/readers.qtpl:21 qw422016.N().S(`

`) -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 } -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 func WriteRevisionHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, naviTitle, contents, tree, revHash string) { -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 StreamRevisionHTML(qw422016, rq, hyphaName, naviTitle, contents, tree, revHash) -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 qt422016.ReleaseWriter(qw422016) -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 } -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 func RevisionHTML(rq *http.Request, hyphaName, naviTitle, contents, tree, revHash string) string { -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 qb422016 := qt422016.AcquireByteBuffer() -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 WriteRevisionHTML(qb422016, rq, hyphaName, naviTitle, contents, tree, revHash) -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 qs422016 := string(qb422016.B) -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 qt422016.ReleaseByteBuffer(qb422016) -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 return qs422016 -//line templates/http_readers.qtpl:28 +//line templates/readers.qtpl:28 } // If `contents` == "", a helpful message is shown instead. -//line templates/http_readers.qtpl:31 +//line templates/readers.qtpl:31 func StreamPageHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, naviTitle, contents, tree, prevHyphaName, nextHyphaName string, hasAmnt bool) { -//line templates/http_readers.qtpl:31 +//line templates/readers.qtpl:31 qw422016.N().S(` `) -//line templates/http_readers.qtpl:32 +//line templates/readers.qtpl:32 streamnavHTML(qw422016, rq, hyphaName, "page") -//line templates/http_readers.qtpl:32 +//line templates/readers.qtpl:32 qw422016.N().S(`
`) -//line templates/http_readers.qtpl:35 +//line templates/readers.qtpl:35 qw422016.N().S(naviTitle) -//line templates/http_readers.qtpl:35 +//line templates/readers.qtpl:35 qw422016.N().S(` `) -//line templates/http_readers.qtpl:36 +//line templates/readers.qtpl:36 if contents == "" { -//line templates/http_readers.qtpl:36 +//line templates/readers.qtpl:36 qw422016.N().S(`

This hypha has no text. Why not create it?

`) -//line templates/http_readers.qtpl:38 +//line templates/readers.qtpl:38 } else { -//line templates/http_readers.qtpl:38 +//line templates/readers.qtpl:38 qw422016.N().S(` `) -//line templates/http_readers.qtpl:39 +//line templates/readers.qtpl:39 qw422016.N().S(contents) -//line templates/http_readers.qtpl:39 +//line templates/readers.qtpl:39 qw422016.N().S(` `) -//line templates/http_readers.qtpl:40 +//line templates/readers.qtpl:40 } -//line templates/http_readers.qtpl:40 +//line templates/readers.qtpl:40 qw422016.N().S(`
`) -//line templates/http_readers.qtpl:43 +//line templates/readers.qtpl:43 if prevHyphaName != "" { -//line templates/http_readers.qtpl:43 +//line templates/readers.qtpl:43 qw422016.N().S(` `) -//line templates/http_readers.qtpl:45 +//line templates/readers.qtpl:45 } -//line templates/http_readers.qtpl:45 +//line templates/readers.qtpl:45 qw422016.N().S(` `) -//line templates/http_readers.qtpl:46 +//line templates/readers.qtpl:46 if nextHyphaName != "" { -//line templates/http_readers.qtpl:46 +//line templates/readers.qtpl:46 qw422016.N().S(` `) -//line templates/http_readers.qtpl:48 +//line templates/readers.qtpl:48 } -//line templates/http_readers.qtpl:48 +//line templates/readers.qtpl:48 qw422016.N().S(`
`) -//line templates/http_readers.qtpl:50 +//line templates/readers.qtpl:50 if u := user.FromRequest(rq); !user.AuthUsed || u.Group != "anon" { -//line templates/http_readers.qtpl:50 +//line templates/readers.qtpl:50 qw422016.N().S(`
`) -//line templates/http_readers.qtpl:54 +//line templates/readers.qtpl:54 if hasAmnt { -//line templates/http_readers.qtpl:54 +//line templates/readers.qtpl:54 qw422016.N().S(` Unattach current attachment? `) -//line templates/http_readers.qtpl:56 +//line templates/readers.qtpl:56 } -//line templates/http_readers.qtpl:56 +//line templates/readers.qtpl:56 qw422016.N().S(`
@@ -258,44 +258,44 @@ func StreamPageHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, navi
`) -//line templates/http_readers.qtpl:62 +//line templates/readers.qtpl:62 } -//line templates/http_readers.qtpl:62 +//line templates/readers.qtpl:62 qw422016.N().S(`
`) -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 } -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 func WritePageHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, naviTitle, contents, tree, prevHyphaName, nextHyphaName string, hasAmnt bool) { -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 StreamPageHTML(qw422016, rq, hyphaName, naviTitle, contents, tree, prevHyphaName, nextHyphaName, hasAmnt) -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 qt422016.ReleaseWriter(qw422016) -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 } -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 func PageHTML(rq *http.Request, hyphaName, naviTitle, contents, tree, prevHyphaName, nextHyphaName string, hasAmnt bool) string { -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 qb422016 := qt422016.AcquireByteBuffer() -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 WritePageHTML(qb422016, rq, hyphaName, naviTitle, contents, tree, prevHyphaName, nextHyphaName, hasAmnt) -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 qs422016 := string(qb422016.B) -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 qt422016.ReleaseByteBuffer(qb422016) -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 return qs422016 -//line templates/http_readers.qtpl:67 +//line templates/readers.qtpl:67 } diff --git a/templates/http_stuff.qtpl b/templates/stuff.qtpl similarity index 98% rename from templates/http_stuff.qtpl rename to templates/stuff.qtpl index 8723860..adf7958 100644 --- a/templates/http_stuff.qtpl +++ b/templates/stuff.qtpl @@ -60,7 +60,7 @@

About {%s util.SiteName %}

+ {% endfunc %} diff --git a/templates/recent_changes.qtpl.go b/templates/recent_changes.qtpl.go index 329ccc5..e3cc346 100644 --- a/templates/recent_changes.qtpl.go +++ b/templates/recent_changes.qtpl.go @@ -21,58 +21,59 @@ var ( func StreamRecentChangesHTML(qw422016 *qt422016.Writer, changes []string, n int) { //line templates/recent_changes.qtpl:1 qw422016.N().S(` -
+
+

Recent Changes

← Back

@@ -80,80 +81,81 @@ func StreamRecentChangesHTML(qw422016 *qt422016.Writer, changes []string, n int)

Subscribe via RSS, Atom or JSON feed.

`) -//line templates/recent_changes.qtpl:28 +//line templates/recent_changes.qtpl:29 qw422016.N().S(`
`) -//line templates/recent_changes.qtpl:31 +//line templates/recent_changes.qtpl:32 if len(changes) == 0 { -//line templates/recent_changes.qtpl:31 +//line templates/recent_changes.qtpl:32 qw422016.N().S(`

Could not find any recent changes.

`) -//line templates/recent_changes.qtpl:33 +//line templates/recent_changes.qtpl:34 } else { -//line templates/recent_changes.qtpl:33 +//line templates/recent_changes.qtpl:34 qw422016.N().S(` `) -//line templates/recent_changes.qtpl:34 +//line templates/recent_changes.qtpl:35 for i, entry := range changes { -//line templates/recent_changes.qtpl:34 +//line templates/recent_changes.qtpl:35 qw422016.N().S(`
    `) -//line templates/recent_changes.qtpl:37 +//line templates/recent_changes.qtpl:38 qw422016.N().S(entry) -//line templates/recent_changes.qtpl:37 +//line templates/recent_changes.qtpl:38 qw422016.N().S(`
`) -//line templates/recent_changes.qtpl:39 +//line templates/recent_changes.qtpl:40 } -//line templates/recent_changes.qtpl:39 +//line templates/recent_changes.qtpl:40 qw422016.N().S(` `) -//line templates/recent_changes.qtpl:40 +//line templates/recent_changes.qtpl:41 } -//line templates/recent_changes.qtpl:40 +//line templates/recent_changes.qtpl:41 qw422016.N().S(`
+
`) -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 } -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 func WriteRecentChangesHTML(qq422016 qtio422016.Writer, changes []string, n int) { -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 StreamRecentChangesHTML(qw422016, changes, n) -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 qt422016.ReleaseWriter(qw422016) -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 } -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 func RecentChangesHTML(changes []string, n int) string { -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 qb422016 := qt422016.AcquireByteBuffer() -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 WriteRecentChangesHTML(qb422016, changes, n) -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 qs422016 := string(qb422016.B) -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 qt422016.ReleaseByteBuffer(qb422016) -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 return qs422016 -//line templates/recent_changes.qtpl:43 +//line templates/recent_changes.qtpl:45 } diff --git a/templates/rename.qtpl b/templates/rename.qtpl index aee28ce..8f35d55 100644 --- a/templates/rename.qtpl +++ b/templates/rename.qtpl @@ -2,7 +2,8 @@ This dialog is to be shown to a user when they try to rename a hypha. {% func RenameAskHTML(rq *http.Request, hyphaName string, isOld bool) %} {%= navHTML(rq, hyphaName, "rename-ask") %} -
+
+
{%- if isOld -%}

Rename {%s hyphaName %}

@@ -26,6 +27,7 @@ This dialog is to be shown to a user when they try to rename a hypha. {%= cannotRenameDueToNonExistence(hyphaName) %} {%- endif -%}
+
{% endfunc %} {% func cannotRenameDueToNonExistence(hyphaName string) %} diff --git a/templates/rename.qtpl.go b/templates/rename.qtpl.go index 2347bcd..973c5f7 100644 --- a/templates/rename.qtpl.go +++ b/templates/rename.qtpl.go @@ -31,28 +31,29 @@ func StreamRenameAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName streamnavHTML(qw422016, rq, hyphaName, "rename-ask") //line templates/rename.qtpl:4 qw422016.N().S(` -
+
+
`) -//line templates/rename.qtpl:6 +//line templates/rename.qtpl:7 if isOld { -//line templates/rename.qtpl:6 +//line templates/rename.qtpl:7 qw422016.N().S(`

Rename `) -//line templates/rename.qtpl:8 +//line templates/rename.qtpl:9 qw422016.E().S(hyphaName) -//line templates/rename.qtpl:8 +//line templates/rename.qtpl:9 qw422016.N().S(`

New name
@@ -67,92 +68,93 @@ func StreamRenameAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName
`) -//line templates/rename.qtpl:25 +//line templates/rename.qtpl:26 } else { -//line templates/rename.qtpl:25 +//line templates/rename.qtpl:26 qw422016.N().S(` `) -//line templates/rename.qtpl:26 +//line templates/rename.qtpl:27 streamcannotRenameDueToNonExistence(qw422016, hyphaName) -//line templates/rename.qtpl:26 +//line templates/rename.qtpl:27 qw422016.N().S(` `) -//line templates/rename.qtpl:27 +//line templates/rename.qtpl:28 } -//line templates/rename.qtpl:27 +//line templates/rename.qtpl:28 qw422016.N().S(`
+
`) -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 } -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 func WriteRenameAskHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string, isOld bool) { -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 StreamRenameAskHTML(qw422016, rq, hyphaName, isOld) -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 qt422016.ReleaseWriter(qw422016) -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 } -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 func RenameAskHTML(rq *http.Request, hyphaName string, isOld bool) string { -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 qb422016 := qt422016.AcquireByteBuffer() -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 WriteRenameAskHTML(qb422016, rq, hyphaName, isOld) -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 qs422016 := string(qb422016.B) -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 qt422016.ReleaseByteBuffer(qb422016) -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 return qs422016 -//line templates/rename.qtpl:29 +//line templates/rename.qtpl:31 } -//line templates/rename.qtpl:31 +//line templates/rename.qtpl:33 func streamcannotRenameDueToNonExistence(qw422016 *qt422016.Writer, hyphaName string) { -//line templates/rename.qtpl:31 +//line templates/rename.qtpl:33 qw422016.N().S(`

Cannot rename `) -//line templates/rename.qtpl:33 +//line templates/rename.qtpl:35 qw422016.E().S(hyphaName) -//line templates/rename.qtpl:33 +//line templates/rename.qtpl:35 qw422016.N().S(`

This hypha does not exist.

Go back

`) -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 } -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 func writecannotRenameDueToNonExistence(qq422016 qtio422016.Writer, hyphaName string) { -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 streamcannotRenameDueToNonExistence(qw422016, hyphaName) -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 qt422016.ReleaseWriter(qw422016) -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 } -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 func cannotRenameDueToNonExistence(hyphaName string) string { -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 qb422016 := qt422016.AcquireByteBuffer() -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 writecannotRenameDueToNonExistence(qb422016, hyphaName) -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 qs422016 := string(qb422016.B) -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 qt422016.ReleaseByteBuffer(qb422016) -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 return qs422016 -//line templates/rename.qtpl:37 +//line templates/rename.qtpl:39 } diff --git a/templates/stuff.qtpl b/templates/stuff.qtpl index 724a925..fce9908 100644 --- a/templates/stuff.qtpl +++ b/templates/stuff.qtpl @@ -27,7 +27,8 @@ {% endfunc %} {% func HyphaListHTML(tbody string, pageCount int) %} -
+
+

List of hyphae

This wiki has {%d pageCount %} hyphae.

@@ -42,6 +43,7 @@
+
{% endfunc %} {% func HyphaListRowHTML(hyphaName, binaryMime string, binaryPresent bool) %} @@ -56,7 +58,8 @@ {% endfunc %} {% func AboutHTML() %} -
+
+

About {%s util.SiteName %}

    @@ -75,4 +78,5 @@

    See /list for information about hyphae on this wiki.

+
{% endfunc %} diff --git a/templates/stuff.qtpl.go b/templates/stuff.qtpl.go index a42f972..0bf3bf1 100644 --- a/templates/stuff.qtpl.go +++ b/templates/stuff.qtpl.go @@ -117,12 +117,13 @@ func BaseHTML(title, body string, u *user.User, headElements ...string) string { func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) { //line templates/stuff.qtpl:29 qw422016.N().S(` -
+
+

List of hyphae

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

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

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

See /list for information about hyphae on this wiki.

+
`) -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 } -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 func WriteAboutHTML(qq422016 qtio422016.Writer) { -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 StreamAboutHTML(qw422016) -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 qt422016.ReleaseWriter(qw422016) -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 } -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 func AboutHTML() string { -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 qb422016 := qt422016.AcquireByteBuffer() -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 WriteAboutHTML(qb422016) -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 qs422016 := string(qb422016.B) -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 qt422016.ReleaseByteBuffer(qb422016) -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 return qs422016 -//line templates/stuff.qtpl:78 +//line templates/stuff.qtpl:82 } diff --git a/templates/unattach.qtpl b/templates/unattach.qtpl index e4f0ae2..8f7fe60 100644 --- a/templates/unattach.qtpl +++ b/templates/unattach.qtpl @@ -1,7 +1,8 @@ {% import "net/http" %} {% func UnattachAskHTML(rq *http.Request, hyphaName string, isOld bool) %} -
{%= navHTML(rq, hyphaName, "unattach-ask") %} +
+
{%- if isOld -%}

Unattach {%s hyphaName %}?

@@ -13,6 +14,7 @@ {%= cannotUnattachDueToNonExistence(hyphaName) %} {%- endif -%}
+
{% endfunc %} {% func cannotUnattachDueToNonExistence(hyphaName string) %} diff --git a/templates/unattach.qtpl.go b/templates/unattach.qtpl.go index c00bc80..e5bc0d2 100644 --- a/templates/unattach.qtpl.go +++ b/templates/unattach.qtpl.go @@ -24,125 +24,127 @@ var ( func StreamUnattachAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string, isOld bool) { //line templates/unattach.qtpl:2 qw422016.N().S(` -
`) -//line templates/unattach.qtpl:4 +//line templates/unattach.qtpl:3 streamnavHTML(qw422016, rq, hyphaName, "unattach-ask") -//line templates/unattach.qtpl:4 +//line templates/unattach.qtpl:3 qw422016.N().S(` +
+
`) -//line templates/unattach.qtpl:5 +//line templates/unattach.qtpl:6 if isOld { -//line templates/unattach.qtpl:5 +//line templates/unattach.qtpl:6 qw422016.N().S(`

Unattach `) -//line templates/unattach.qtpl:7 +//line templates/unattach.qtpl:8 qw422016.E().S(hyphaName) -//line templates/unattach.qtpl:7 +//line templates/unattach.qtpl:8 qw422016.N().S(`?

Do you really want to unattach hypha `) -//line templates/unattach.qtpl:8 +//line templates/unattach.qtpl:9 qw422016.E().S(hyphaName) -//line templates/unattach.qtpl:8 +//line templates/unattach.qtpl:9 qw422016.N().S(`?

Confirm

Cancel

`) -//line templates/unattach.qtpl:12 +//line templates/unattach.qtpl:13 } else { -//line templates/unattach.qtpl:12 +//line templates/unattach.qtpl:13 qw422016.N().S(` `) -//line templates/unattach.qtpl:13 +//line templates/unattach.qtpl:14 streamcannotUnattachDueToNonExistence(qw422016, hyphaName) -//line templates/unattach.qtpl:13 +//line templates/unattach.qtpl:14 qw422016.N().S(` `) -//line templates/unattach.qtpl:14 +//line templates/unattach.qtpl:15 } -//line templates/unattach.qtpl:14 +//line templates/unattach.qtpl:15 qw422016.N().S(`
+
`) -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 } -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 func WriteUnattachAskHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string, isOld bool) { -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 StreamUnattachAskHTML(qw422016, rq, hyphaName, isOld) -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 qt422016.ReleaseWriter(qw422016) -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 } -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 func UnattachAskHTML(rq *http.Request, hyphaName string, isOld bool) string { -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 qb422016 := qt422016.AcquireByteBuffer() -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 WriteUnattachAskHTML(qb422016, rq, hyphaName, isOld) -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 qs422016 := string(qb422016.B) -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 qt422016.ReleaseByteBuffer(qb422016) -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 return qs422016 -//line templates/unattach.qtpl:16 +//line templates/unattach.qtpl:18 } -//line templates/unattach.qtpl:18 +//line templates/unattach.qtpl:20 func streamcannotUnattachDueToNonExistence(qw422016 *qt422016.Writer, hyphaName string) { -//line templates/unattach.qtpl:18 +//line templates/unattach.qtpl:20 qw422016.N().S(`

Cannot unattach `) -//line templates/unattach.qtpl:20 +//line templates/unattach.qtpl:22 qw422016.E().S(hyphaName) -//line templates/unattach.qtpl:20 +//line templates/unattach.qtpl:22 qw422016.N().S(`

This hypha does not exist.

Go back

`) -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 } -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 func writecannotUnattachDueToNonExistence(qq422016 qtio422016.Writer, hyphaName string) { -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 streamcannotUnattachDueToNonExistence(qw422016, hyphaName) -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 qt422016.ReleaseWriter(qw422016) -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 } -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 func cannotUnattachDueToNonExistence(hyphaName string) string { -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 qb422016 := qt422016.AcquireByteBuffer() -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 writecannotUnattachDueToNonExistence(qb422016, hyphaName) -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 qs422016 := string(qb422016.B) -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 qt422016.ReleaseByteBuffer(qb422016) -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 return qs422016 -//line templates/unattach.qtpl:24 +//line templates/unattach.qtpl:26 } From ae1c5db3b3b69f5cefbc10bf2a7e416b44e46eaa Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Fri, 29 Jan 2021 00:07:21 +0500 Subject: [PATCH 07/53] Move mimetype stuff to a separate module --- .gitignore | 1 + http_readers.go | 3 +- hypha.go | 87 ++++++++++++++++++++++++------------------------ hyphae/hypha.go | 21 ------------ main.go | 3 +- mime.go | 62 ---------------------------------- mimetype/mime.go | 68 +++++++++++++++++++++++++++++++++++++ util/util.go | 14 ++++++++ 8 files changed, 131 insertions(+), 128 deletions(-) delete mode 100644 hyphae/hypha.go delete mode 100644 mime.go create mode 100644 mimetype/mime.go diff --git a/.gitignore b/.gitignore index c450f48..9632b28 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ mycorrhiza +hyphae/*.gog diff --git a/http_readers.go b/http_readers.go index 7978e69..9cd4c69 100644 --- a/http_readers.go +++ b/http_readers.go @@ -11,6 +11,7 @@ import ( "github.com/bouncepaw/mycorrhiza/history" "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" @@ -71,7 +72,7 @@ func handlerBinary(w http.ResponseWriter, rq *http.Request) { hyphaName := HyphaNameFromRq(rq, "binary") if data, ok := HyphaStorage[hyphaName]; ok { log.Println("Serving", data.binaryPath) - w.Header().Set("Content-Type", ExtensionToMime(filepath.Ext(data.binaryPath))) + w.Header().Set("Content-Type", mimetype.FromExtension(filepath.Ext(data.binaryPath))) http.ServeFile(w, rq, data.binaryPath) } } diff --git a/hypha.go b/hypha.go index be7fef4..82fe103 100644 --- a/hypha.go +++ b/hypha.go @@ -13,6 +13,7 @@ import ( "github.com/bouncepaw/mycorrhiza/history" "github.com/bouncepaw/mycorrhiza/hyphae" "github.com/bouncepaw/mycorrhiza/markup" + "github.com/bouncepaw/mycorrhiza/mimetype" "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" ) @@ -114,7 +115,7 @@ func UploadBinary(hyphaName, mime string, file multipart.File, u *user.User) *hi if err != nil { return hop.WithError(err).Apply() } - return uploadHelp(hop, hyphaName, MimeToExtension(mime), data, u) + return uploadHelp(hop, hyphaName, mimetype.ToExtension(mime), data, u) } // DeleteHypha deletes hypha and makes a history record about that. @@ -254,48 +255,6 @@ func binaryHtmlBlock(hyphaName string, hd *HyphaData) string { } } -// Index finds all hypha files in the full `path` and saves them to HyphaStorage. This function is recursive. -func Index(path string) { - nodes, err := ioutil.ReadDir(path) - if err != nil { - log.Fatal(err) - } - - for _, node := range nodes { - // If this hypha looks like it can be a hypha path, go deeper. Do not touch the .git and static folders for they have an admnistrative importance! - if node.IsDir() && isCanonicalName(node.Name()) && node.Name() != ".git" && node.Name() != "static" { - Index(filepath.Join(path, node.Name())) - continue - } - - var ( - hyphaPartPath = filepath.Join(path, node.Name()) - hyphaName, isText, skip = DataFromFilename(hyphaPartPath) - hyphaData *HyphaData - ) - if !skip { - // Reuse the entry for existing hyphae, create a new one for those that do not exist yet. - if hd, ok := HyphaStorage[hyphaName]; ok { - hyphaData = hd - } else { - hyphaData = &HyphaData{} - HyphaStorage[hyphaName] = hyphaData - hyphae.IncrementCount() - } - if isText { - hyphaData.textPath = hyphaPartPath - } else { - // Notify the user about binary part collisions. It's a design decision to just use any of them, it's the user's fault that they have screwed up the folder structure, but the engine should at least let them know, right? - if hyphaData.binaryPath != "" { - log.Println("There is a file collision for binary part of a hypha:", hyphaData.binaryPath, "and", hyphaPartPath, "-- going on with the latter") - } - hyphaData.binaryPath = hyphaPartPath - } - } - - } -} - // FetchTextPart tries to read text file in the `d`. If there is no file, empty string is returned. func FetchTextPart(d *HyphaData) (string, error) { if d.textPath == "" { @@ -327,3 +286,45 @@ func setHeaderLinks() { } } } + +// Index finds all hypha files in the full `path` and saves them to HyphaStorage. This function is recursive. +func Index(path string) { + nodes, err := ioutil.ReadDir(path) + if err != nil { + log.Fatal(err) + } + + for _, node := range nodes { + // If this hypha looks like it can be a hypha path, go deeper. Do not touch the .git and static folders for they have an admnistrative importance! + if node.IsDir() && isCanonicalName(node.Name()) && node.Name() != ".git" && node.Name() != "static" { + Index(filepath.Join(path, node.Name())) + continue + } + + var ( + hyphaPartPath = filepath.Join(path, node.Name()) + hyphaName, isText, skip = mimetype.DataFromFilename(hyphaPartPath) + hyphaData *HyphaData + ) + if !skip { + // Reuse the entry for existing hyphae, create a new one for those that do not exist yet. + if hd, ok := HyphaStorage[hyphaName]; ok { + hyphaData = hd + } else { + hyphaData = &HyphaData{} + HyphaStorage[hyphaName] = hyphaData + hyphae.IncrementCount() + } + if isText { + hyphaData.textPath = hyphaPartPath + } else { + // Notify the user about binary part collisions. It's a design decision to just use any of them, it's the user's fault that they have screwed up the folder structure, but the engine should at least let them know, right? + if hyphaData.binaryPath != "" { + log.Println("There is a file collision for binary part of a hypha:", hyphaData.binaryPath, "and", hyphaPartPath, "-- going on with the latter") + } + hyphaData.binaryPath = hyphaPartPath + } + } + + } +} diff --git a/hyphae/hypha.go b/hyphae/hypha.go deleted file mode 100644 index d70cd1e..0000000 --- a/hyphae/hypha.go +++ /dev/null @@ -1,21 +0,0 @@ -package hyphae - -// TODO: do -import () - -type Hypha struct { - Name string - Exists bool - TextPath string - BinaryPath string - OutLinks []string - BackLinks []string -} - -// AddHypha adds a hypha named `name` with such `textPath` and `binaryPath`. Both paths can be empty. Does //not// check for hypha's existence beforehand. Count is handled. -func AddHypha(name, textPath, binaryPath string) { -} - -// DeleteHypha clears both paths and all out-links from the named hypha and marks it as non-existent. It does not actually delete it from the memdb. Count is handled. -func DeleteHypha(name string) { -} diff --git a/main.go b/main.go index c87c96e..f16eaa3 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( "github.com/bouncepaw/mycorrhiza/history" "github.com/bouncepaw/mycorrhiza/hyphae" + "github.com/bouncepaw/mycorrhiza/mimetype" "github.com/bouncepaw/mycorrhiza/templates" "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" @@ -64,7 +65,7 @@ func handlerList(w http.ResponseWriter, rq *http.Request) { u = user.FromRequest(rq) ) for hyphaName, data := range HyphaStorage { - tbody += templates.HyphaListRowHTML(hyphaName, ExtensionToMime(filepath.Ext(data.binaryPath)), data.binaryPath != "") + tbody += templates.HyphaListRowHTML(hyphaName, mimetype.FromExtension(filepath.Ext(data.binaryPath)), data.binaryPath != "") } util.HTTP200Page(w, base("List of pages", templates.HyphaListHTML(tbody, pageCount), u)) } diff --git a/mime.go b/mime.go deleted file mode 100644 index c16eebe..0000000 --- a/mime.go +++ /dev/null @@ -1,62 +0,0 @@ -package main - -import ( - "path/filepath" - "strings" -) - -func MimeToExtension(mime string) string { - mm := map[string]string{ - "application/octet-stream": "bin", - "image/jpeg": "jpg", - "image/gif": "gif", - "image/png": "png", - "image/webp": "webp", - "image/svg+xml": "svg", - "image/x-icon": "ico", - "application/ogg": "ogg", - "video/webm": "webm", - "audio/mp3": "mp3", - "video/mp4": "mp4", - } - if ext, ok := mm[mime]; ok { - return "." + ext - } - return ".bin" -} - -func ExtensionToMime(ext string) string { - mm := map[string]string{ - ".bin": "application/octet-stream", - ".jpg": "image/jpeg", - ".jpeg": "image/jpeg", - ".gif": "image/gif", - ".png": "image/png", - ".webp": "image/webp", - ".svg": "image/svg+xml", - ".ico": "image/x-icon", - ".ogg": "application/ogg", - ".webm": "video/webm", - ".mp3": "audio/mp3", - ".mp4": "video/mp4", - } - if mime, ok := mm[ext]; ok { - return mime - } - return "application/octet-stream" -} - -// DataFromFilename fetches all meta information from hypha content file with path `fullPath`. If it is not a content file, `skip` is true, and you are expected to ignore this file when indexing hyphae. `name` is name of the hypha to which this file relates. `isText` is true when the content file is text, false when is binary. `mimeId` is an integer representation of content type. Cast it to TextType if `isText == true`, cast it to BinaryType if `isText == false`. -func DataFromFilename(fullPath string) (name string, isText bool, skip bool) { - shortPath := strings.TrimPrefix(fullPath, WikiDir)[1:] - ext := filepath.Ext(shortPath) - name = CanonicalName(strings.TrimSuffix(shortPath, ext)) - switch ext { - case ".myco": - isText = true - case "", shortPath: - skip = true - } - - return -} diff --git a/mimetype/mime.go b/mimetype/mime.go new file mode 100644 index 0000000..7e18ca7 --- /dev/null +++ b/mimetype/mime.go @@ -0,0 +1,68 @@ +package mimetype + +import ( + "path/filepath" + "strings" + + "github.com/bouncepaw/mycorrhiza/util" +) + +// ToExtension returns dotted extension for given mime-type. +func ToExtension(mime string) string { + if ext, ok := mapMime2Ext[mime]; ok { + return "." + ext + } + return ".bin" +} + +// FromExtension returns mime-type for given extension. The extension must start with a dot. +func FromExtension(ext string) string { + if mime, ok := mapExt2Mime[ext]; ok { + return mime + } + return "application/octet-stream" +} + +// DataFromFilename fetches all meta information from hypha content file with path `fullPath`. If it is not a content file, `skip` is true, and you are expected to ignore this file when indexing hyphae. `name` is name of the hypha to which this file relates. `isText` is true when the content file is text, false when is binary. +func DataFromFilename(fullPath string) (name string, isText bool, skip bool) { + shortPath := util.ShorterPath(fullPath) + ext := filepath.Ext(shortPath) + name = util.CanonicalName(strings.TrimSuffix(shortPath, ext)) + switch ext { + case ".myco": + isText = true + case "", shortPath: + skip = true + } + + return +} + +var mapMime2Ext = map[string]string{ + "application/octet-stream": "bin", + "image/jpeg": "jpg", + "image/gif": "gif", + "image/png": "png", + "image/webp": "webp", + "image/svg+xml": "svg", + "image/x-icon": "ico", + "application/ogg": "ogg", + "video/webm": "webm", + "audio/mp3": "mp3", + "video/mp4": "mp4", +} + +var mapExt2Mime = map[string]string{ + ".bin": "application/octet-stream", + ".jpg": "image/jpeg", + ".jpeg": "image/jpeg", + ".gif": "image/gif", + ".png": "image/png", + ".webp": "image/webp", + ".svg": "image/svg+xml", + ".ico": "image/x-icon", + ".ogg": "application/ogg", + ".webm": "video/webm", + ".mp3": "audio/mp3", + ".mp4": "video/mp4", +} diff --git a/util/util.go b/util/util.go index c977992..acf0eec 100644 --- a/util/util.go +++ b/util/util.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "encoding/hex" "net/http" + "regexp" "strings" ) @@ -65,3 +66,16 @@ func BeautifulName(uglyName string) string { } return strings.Title(strings.ReplaceAll(uglyName, "_", " ")) } + +// CanonicalName makes sure the `name` is canonical. A name is canonical if it is lowercase and all spaces are replaced with underscores. +func CanonicalName(name string) string { + return strings.ToLower(strings.ReplaceAll(name, " ", "_")) +} + +// HyphaPattern is a pattern which all hyphae must match. +var HyphaPattern = regexp.MustCompile(`[^?!:#@><*|"\'&%{}]+`) + +// IsCanonicalName checks if the `name` is canonical. +func IsCanonicalName(name string) bool { + return HyphaPattern.MatchString(name) +} From e3b4c75f799fed49d29d8149ce3720753b88d2c5 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sat, 30 Jan 2021 23:21:50 +0500 Subject: [PATCH 08/53] Add /user-list page --- main.go | 7 + markup/paragraph.go | 12 ++ templates/stuff.qtpl | 43 ++++++ templates/stuff.qtpl.go | 307 +++++++++++++++++++++++++++++----------- user/users.go | 23 ++- 5 files changed, 300 insertions(+), 92 deletions(-) diff --git a/main.go b/main.go index f16eaa3..97ce3c3 100644 --- a/main.go +++ b/main.go @@ -160,6 +160,12 @@ func handlerAbout(w http.ResponseWriter, rq *http.Request) { w.Write([]byte(base("About "+util.SiteName, templates.AboutHTML(), user.FromRequest(rq)))) } +func handlerUserList(w http.ResponseWriter, rq *http.Request) { + w.Header().Set("Content-Type", "text/html;charset=utf-8") + w.WriteHeader(http.StatusOK) + w.Write([]byte(base("User list", templates.UserListHTML(), user.FromRequest(rq)))) +} + func handlerRobotsTxt(w http.ResponseWriter, rq *http.Request) { w.Header().Set("Content-Type", "text/plain") w.WriteHeader(http.StatusOK) @@ -193,6 +199,7 @@ func main() { http.HandleFunc("/update-header-links", handlerUpdateHeaderLinks) http.HandleFunc("/random", handlerRandom) http.HandleFunc("/about", handlerAbout) + http.HandleFunc("/user-list", handlerUserList) http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(WikiDir+"/static")))) http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, rq *http.Request) { http.ServeFile(w, rq, WikiDir+"/static/favicon.ico") diff --git a/markup/paragraph.go b/markup/paragraph.go index f506bb6..4bef250 100644 --- a/markup/paragraph.go +++ b/markup/paragraph.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "html" + "regexp" "strings" "unicode" ) @@ -103,6 +104,17 @@ func getTextNode(input *bytes.Buffer) string { return textNodeBuffer.String() } +var ( + dangerousSymbols = "<>{}|\\^[]`,()" + reLink = regexp.MustCompile(fmt.Sprintf(`[^[]{0,2}((https|http|gemini|gopher)://[^%[1]s]+)|(mailto:[^%[1]s]+)[^]]{0,2}`, dangerousSymbols)) +) + +// TODO: +func doRegexpStuff(input string) string { + reLink.ReplaceAllString(input, "[[$1]]") + return "" +} + func ParagraphToHtml(hyphaName, input string) string { var ( p = bytes.NewBufferString(input) diff --git a/templates/stuff.qtpl b/templates/stuff.qtpl index fce9908..f6f95b8 100644 --- a/templates/stuff.qtpl +++ b/templates/stuff.qtpl @@ -26,6 +26,49 @@ {% endfunc %} +{% func UserListHTML() %} +
+
+

List of users

+{% code +var ( + admins = make([]string, 0) + moderators = make([]string, 0) + editors = make([]string, 0) +) +for u := range user.YieldUsers() { + switch u.Group { + case "admin": + admins = append(admins, u.Name) + case "moderator": + moderators = append(moderators, u.Name) + case "editor", "trusted": + editors = append(editors, u.Name) + } +} +%} +
+

Admins

+
    {% for _, name := range admins %} +
  1. {%s name %}
  2. + {% endfor %}
+
+
+

Moderators

+
    {% for _, name := range moderators %} +
  1. {%s name %}
  2. + {% endfor %}
+
+
+

Editors

+
    {% for _, name := range editors %} +
  1. {%s name %}
  2. + {% endfor %}
+
+
+
+{% endfunc %} + {% func HyphaListHTML(tbody string, pageCount int) %}
diff --git a/templates/stuff.qtpl.go b/templates/stuff.qtpl.go index 0bf3bf1..d6efabd 100644 --- a/templates/stuff.qtpl.go +++ b/templates/stuff.qtpl.go @@ -114,16 +114,153 @@ func BaseHTML(title, body string, u *user.User, headElements ...string) string { } //line templates/stuff.qtpl:29 -func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) { +func StreamUserListHTML(qw422016 *qt422016.Writer) { //line templates/stuff.qtpl:29 qw422016.N().S(`
+
+

List of users

+`) +//line templates/stuff.qtpl:34 + var ( + admins = make([]string, 0) + moderators = make([]string, 0) + editors = make([]string, 0) + ) + for u := range user.YieldUsers() { + switch u.Group { + case "admin": + admins = append(admins, u.Name) + case "moderator": + moderators = append(moderators, u.Name) + case "editor", "trusted": + editors = append(editors, u.Name) + } + } + +//line templates/stuff.qtpl:49 + qw422016.N().S(` +
+

Admins

+
    `) +//line templates/stuff.qtpl:52 + for _, name := range admins { +//line templates/stuff.qtpl:52 + qw422016.N().S(` +
  1. `) +//line templates/stuff.qtpl:53 + qw422016.E().S(name) +//line templates/stuff.qtpl:53 + qw422016.N().S(`
  2. + `) +//line templates/stuff.qtpl:54 + } +//line templates/stuff.qtpl:54 + qw422016.N().S(`
+
+
+

Moderators

+
    `) +//line templates/stuff.qtpl:58 + for _, name := range moderators { +//line templates/stuff.qtpl:58 + qw422016.N().S(` +
  1. `) +//line templates/stuff.qtpl:59 + qw422016.E().S(name) +//line templates/stuff.qtpl:59 + qw422016.N().S(`
  2. + `) +//line templates/stuff.qtpl:60 + } +//line templates/stuff.qtpl:60 + qw422016.N().S(`
+
+
+

Editors

+
    `) +//line templates/stuff.qtpl:64 + for _, name := range editors { +//line templates/stuff.qtpl:64 + qw422016.N().S(` +
  1. `) +//line templates/stuff.qtpl:65 + qw422016.E().S(name) +//line templates/stuff.qtpl:65 + qw422016.N().S(`
  2. + `) +//line templates/stuff.qtpl:66 + } +//line templates/stuff.qtpl:66 + qw422016.N().S(`
+
+
+
+`) +//line templates/stuff.qtpl:70 +} + +//line templates/stuff.qtpl:70 +func WriteUserListHTML(qq422016 qtio422016.Writer) { +//line templates/stuff.qtpl:70 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/stuff.qtpl:70 + StreamUserListHTML(qw422016) +//line templates/stuff.qtpl:70 + qt422016.ReleaseWriter(qw422016) +//line templates/stuff.qtpl:70 +} + +//line templates/stuff.qtpl:70 +func UserListHTML() string { +//line templates/stuff.qtpl:70 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/stuff.qtpl:70 + WriteUserListHTML(qb422016) +//line templates/stuff.qtpl:70 + qs422016 := string(qb422016.B) +//line templates/stuff.qtpl:70 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/stuff.qtpl:70 + return qs422016 +//line templates/stuff.qtpl:70 +} + +//line templates/stuff.qtpl:72 +func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) { +//line templates/stuff.qtpl:72 + qw422016.N().S(` +

List of hyphae

This wiki has `) -//line templates/stuff.qtpl:33 +//line templates/stuff.qtpl:76 qw422016.N().D(pageCount) -//line templates/stuff.qtpl:33 +//line templates/stuff.qtpl:76 qw422016.N().S(` hyphae.

@@ -134,206 +271,206 @@ func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) `) -//line templates/stuff.qtpl:42 +//line templates/stuff.qtpl:85 qw422016.N().S(tbody) -//line templates/stuff.qtpl:42 +//line templates/stuff.qtpl:85 qw422016.N().S(`
`) -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 } -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 func WriteHyphaListHTML(qq422016 qtio422016.Writer, tbody string, pageCount int) { -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 StreamHyphaListHTML(qw422016, tbody, pageCount) -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 qt422016.ReleaseWriter(qw422016) -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 } -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 func HyphaListHTML(tbody string, pageCount int) string { -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 qb422016 := qt422016.AcquireByteBuffer() -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 WriteHyphaListHTML(qb422016, tbody, pageCount) -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 qs422016 := string(qb422016.B) -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 qt422016.ReleaseByteBuffer(qb422016) -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 return qs422016 -//line templates/stuff.qtpl:47 +//line templates/stuff.qtpl:90 } -//line templates/stuff.qtpl:49 +//line templates/stuff.qtpl:92 func StreamHyphaListRowHTML(qw422016 *qt422016.Writer, hyphaName, binaryMime string, binaryPresent bool) { -//line templates/stuff.qtpl:49 +//line templates/stuff.qtpl:92 qw422016.N().S(` `) -//line templates/stuff.qtpl:51 +//line templates/stuff.qtpl:94 qw422016.E().S(hyphaName) -//line templates/stuff.qtpl:51 +//line templates/stuff.qtpl:94 qw422016.N().S(` `) -//line templates/stuff.qtpl:52 +//line templates/stuff.qtpl:95 if binaryPresent { -//line templates/stuff.qtpl:52 +//line templates/stuff.qtpl:95 qw422016.N().S(` `) -//line templates/stuff.qtpl:53 +//line templates/stuff.qtpl:96 qw422016.E().S(binaryMime) -//line templates/stuff.qtpl:53 +//line templates/stuff.qtpl:96 qw422016.N().S(` `) -//line templates/stuff.qtpl:54 +//line templates/stuff.qtpl:97 } else { -//line templates/stuff.qtpl:54 +//line templates/stuff.qtpl:97 qw422016.N().S(` `) -//line templates/stuff.qtpl:56 +//line templates/stuff.qtpl:99 } -//line templates/stuff.qtpl:56 +//line templates/stuff.qtpl:99 qw422016.N().S(` `) -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 } -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 func WriteHyphaListRowHTML(qq422016 qtio422016.Writer, hyphaName, binaryMime string, binaryPresent bool) { -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 StreamHyphaListRowHTML(qw422016, hyphaName, binaryMime, binaryPresent) -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 qt422016.ReleaseWriter(qw422016) -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 } -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 func HyphaListRowHTML(hyphaName, binaryMime string, binaryPresent bool) string { -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 qb422016 := qt422016.AcquireByteBuffer() -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 WriteHyphaListRowHTML(qb422016, hyphaName, binaryMime, binaryPresent) -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 qs422016 := string(qb422016.B) -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 qt422016.ReleaseByteBuffer(qb422016) -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 return qs422016 -//line templates/stuff.qtpl:58 +//line templates/stuff.qtpl:101 } -//line templates/stuff.qtpl:60 +//line templates/stuff.qtpl:103 func StreamAboutHTML(qw422016 *qt422016.Writer) { -//line templates/stuff.qtpl:60 +//line templates/stuff.qtpl:103 qw422016.N().S(`

About `) -//line templates/stuff.qtpl:64 +//line templates/stuff.qtpl:107 qw422016.E().S(util.SiteName) -//line templates/stuff.qtpl:64 +//line templates/stuff.qtpl:107 qw422016.N().S(`

See /list for information about hyphae on this wiki.

`) -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 } -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 func WriteAboutHTML(qq422016 qtio422016.Writer) { -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 StreamAboutHTML(qw422016) -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 qt422016.ReleaseWriter(qw422016) -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 } -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 func AboutHTML() string { -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 qb422016 := qt422016.AcquireByteBuffer() -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 WriteAboutHTML(qb422016) -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 qs422016 := string(qb422016.B) -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 qt422016.ReleaseByteBuffer(qb422016) -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 return qs422016 -//line templates/stuff.qtpl:82 +//line templates/stuff.qtpl:125 } diff --git a/user/users.go b/user/users.go index aa5bb4b..847d130 100644 --- a/user/users.go +++ b/user/users.go @@ -8,16 +8,25 @@ var AuthUsed bool var users sync.Map var tokens sync.Map +func YieldUsers() chan *User { + ch := make(chan *User) + go func(ch chan *User) { + users.Range(func(_, v interface{}) bool { + ch <- v.(*User) + return true + }) + close(ch) + }(ch) + return ch +} + func ListUsersWithGroup(group string) []string { usersWithTheGroup := []string{} - users.Range(func(_, v interface{}) bool { - userobj := v.(*User) - - if userobj.Group == group { - usersWithTheGroup = append(usersWithTheGroup, userobj.Name) + for u := range YieldUsers() { + if u.Group == group { + usersWithTheGroup = append(usersWithTheGroup, u.Name) } - return true - }) + } return usersWithTheGroup } From 92dd19316cb98e865c95995fe15a447157a839d4 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sat, 30 Jan 2021 23:29:56 +0500 Subject: [PATCH 09/53] Make /hypha/ a synonym for /page/ --- http_readers.go | 9 +++++---- main.go | 2 +- name.go | 14 +++++++++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/http_readers.go b/http_readers.go index 9cd4c69..10676a8 100644 --- a/http_readers.go +++ b/http_readers.go @@ -19,7 +19,8 @@ import ( ) func init() { - http.HandleFunc("/page/", handlerPage) + http.HandleFunc("/page/", handlerHypha) + http.HandleFunc("/hypha/", handlerHypha) http.HandleFunc("/text/", handlerText) http.HandleFunc("/binary/", handlerBinary) http.HandleFunc("/rev/", handlerRevision) @@ -77,11 +78,11 @@ func handlerBinary(w http.ResponseWriter, rq *http.Request) { } } -// handlerPage is the main hypha action that displays the hypha and the binary upload form along with some navigation. -func handlerPage(w http.ResponseWriter, rq *http.Request) { +// handlerHypha is the main hypha action that displays the hypha and the binary upload form along with some navigation. +func handlerHypha(w http.ResponseWriter, rq *http.Request) { log.Println(rq.URL) var ( - hyphaName = HyphaNameFromRq(rq, "page") + hyphaName = HyphaNameFromRq(rq, "page", "hypha") data, hyphaExists = HyphaStorage[hyphaName] hasAmnt = hyphaExists && data.binaryPath != "" contents string diff --git a/main.go b/main.go index 97ce3c3..068f706 100644 --- a/main.go +++ b/main.go @@ -190,7 +190,7 @@ func main() { history.Start(WikiDir) setHeaderLinks() - // See http_readers.go for /page/, /text/, /binary/ + // See http_readers.go for /page/, /hypha/, /text/, /binary/ // See http_mutators.go for /upload-binary/, /upload-text/, /edit/, /delete-ask/, /delete-confirm/, /rename-ask/, /rename-confirm/, /unattach-ask/, /unattach-confirm/ // See http_auth.go for /login, /login-data, /logout, /logout-confirm // See http_history.go for /history/, /recent-changes diff --git a/name.go b/name.go index 2a859d8..57c860a 100644 --- a/name.go +++ b/name.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "log" "net/http" "strings" @@ -46,7 +47,14 @@ func naviTitle(canonicalName string) string { return html + "" } -// HyphaNameFromRq extracts hypha name from http request. You have to also pass the action which is embedded in the url. For url /page/hypha, the action would be "page". -func HyphaNameFromRq(rq *http.Request, action string) string { - return CanonicalName(strings.TrimPrefix(rq.URL.Path, "/"+action+"/")) +// HyphaNameFromRq extracts hypha name from http request. You have to also pass the action which is embedded in the url or several actions. For url /hypha/hypha, the action would be "hypha". +func HyphaNameFromRq(rq *http.Request, actions ...string) string { + p := rq.URL.Path + for _, action := range actions { + if strings.HasPrefix(p, "/"+action+"/") { + return util.CanonicalName(strings.TrimPrefix(p, "/"+action+"/")) + } + } + log.Fatal("HyphaNameFromRq: no matching action passed") + return "" } From dd98ae492bfd7701c8a87356c39ff29539dfadcc Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sun, 31 Jan 2021 00:25:18 +0500 Subject: [PATCH 10/53] Start moving universal link-related stuff to a separate module --- link/link.go | 107 +++++++++++++++++++++++++++++++++++++++++++++++++ markup/link.go | 39 ++++-------------- 2 files changed, 114 insertions(+), 32 deletions(-) create mode 100644 link/link.go diff --git a/link/link.go b/link/link.go new file mode 100644 index 0000000..3f9b9c4 --- /dev/null +++ b/link/link.go @@ -0,0 +1,107 @@ +package link + +import ( + "fmt" + "path" + "strings" + + "github.com/bouncepaw/mycorrhiza/util" +) + +// LinkType tells what type the given link is. +type LinkType int + +const ( + LinkInavild LinkType = iota + // LinkLocalRoot is a link like "/list", "/user-list", etc. + LinkLocalRoot + // LinkLocalHypha is a link like "test", "../test", etc. + LinkLocalHypha + // LinkExternal is an external link with specified protocol. + LinkExternal + // LinkInterwiki is currently unused. + LinkInterwiki +) + +// Link is an abstraction for universal representation of links, be they links in mycomarkup links or whatever. +type Link struct { + // Address is what the link points to. + Address string + // Display is what gets nested into the tag. + Display string + Kind LinkType + DestinationUnknown bool + + Protocol string + // How the link address looked originally in source text. + SrcAddress string + // How the link display text looked originally in source text. May be empty. + SrcDisplay string + // RelativeTo is hypha name to which the link is relative to. + RelativeTo string +} + +// Classes returns CSS class string for given link. +func (l *Link) Classes() string { + if l.Kind == LinkExternal { + return fmt.Sprintf("wikilink wikilink_external wikilink_%s", l.Protocol) + } + classes := "wikilink wikilink_internal" + if l.DestinationUnknown { + classes += " wikilink_new" + } + return classes +} + +// Href returns content for the href attrubite. You should always use it. +func (l *Link) Href() string { + switch l.Kind { + case LinkExternal, LinkLocalRoot: + return l.Address + default: + return "/hypha/" + l.Address + } +} + +// From returns a Link object given these `address` and `display` on relative to given `hyphaName`. +func From(address, display, hyphaName string) *Link { + link := Link{ + SrcAddress: address, + SrcDisplay: display, + RelativeTo: hyphaName, + } + + if display == "" { + link.Display = address + } else { + link.Display = strings.TrimSpace(display) + } + + switch { + case strings.ContainsRune(address, ':'): + pos := strings.IndexRune(address, ':') + link.Protocol = address[:pos] + link.Kind = LinkExternal + + if display == "" { + link.Display = address[pos+1:] + if strings.HasPrefix(link.Display, "//") && len(link.Display) > 2 { + link.Display = link.Display[2:] + } + } + link.Address = address + case strings.HasPrefix(address, "/"): + link.Address = address + link.Kind = LinkLocalRoot + case strings.HasPrefix(address, "./"): + link.Kind = LinkLocalHypha + link.Address = util.CanonicalName(path.Join(hyphaName, address[2:])) + case strings.HasPrefix(address, "../"): + link.Kind = LinkLocalHypha + link.Address = util.CanonicalName(path.Join(path.Dir(hyphaName), address[3:])) + default: + link.Address = util.CanonicalName(address) + } + + return &link +} diff --git a/markup/link.go b/markup/link.go index af3e51c..9243fca 100644 --- a/markup/link.go +++ b/markup/link.go @@ -1,47 +1,22 @@ package markup import ( - "fmt" - "path" "strings" + + "github.com/bouncepaw/mycorrhiza/link" ) // LinkParts determines what href, text and class should resulting have based on mycomarkup's addr, display and hypha name. // // => addr display // [[addr|display]] +// TODO: deprecate func LinkParts(addr, display, hyphaName string) (href, text, class string) { - if display == "" { - text = addr - } else { - text = strings.TrimSpace(display) + l := link.From(addr, display, hyphaName) + if l.Kind == link.LinkLocalHypha && !HyphaExists(l.Address) { + l.DestinationUnknown = true } - class = "wikilink wikilink_internal" - - switch { - case strings.ContainsRune(addr, ':'): - pos := strings.IndexRune(addr, ':') - destination := addr[:pos] - if display == "" { - text = addr[pos+1:] - if strings.HasPrefix(text, "//") && len(text) > 2 { - text = text[2:] - } - } - return addr, text, fmt.Sprintf("wikilink wikilink_external wikilink_%s", destination) - case strings.HasPrefix(addr, "/"): - return addr, text, class - case strings.HasPrefix(addr, "./"): - hyphaName = canonicalName(path.Join(hyphaName, addr[2:])) - case strings.HasPrefix(addr, "../"): - hyphaName = canonicalName(path.Join(path.Dir(hyphaName), addr[3:])) - default: - hyphaName = canonicalName(addr) - } - if !HyphaExists(hyphaName) { - class += " wikilink_new" - } - return "/page/" + hyphaName, text, class + return l.Href(), l.Display, l.Classes() } // Parse markup line starting with "=>" according to wikilink rules. From b4e866446e961dbfaf996026966b44ff65c3696d Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sun, 31 Jan 2021 21:39:08 +0500 Subject: [PATCH 11/53] Make img galleries use the new link abstraction --- link/link.go | 20 ++++++++- markup/img.go | 99 +++++++++----------------------------------- markup/img_entry.go | 45 ++++++++++++++++++++ markup/mycomarkup.go | 15 +++++-- 4 files changed, 94 insertions(+), 85 deletions(-) create mode 100644 markup/img_entry.go diff --git a/link/link.go b/link/link.go index 3f9b9c4..6c7e7b8 100644 --- a/link/link.go +++ b/link/link.go @@ -41,6 +41,13 @@ type Link struct { RelativeTo string } +// DoubtExistence sets DestinationUnknown to true if the link is local hypha link. +func (l *Link) DoubtExistence() { + if l.Kind == LinkLocalHypha { + l.DestinationUnknown = true + } +} + // Classes returns CSS class string for given link. func (l *Link) Classes() string { if l.Kind == LinkExternal { @@ -53,7 +60,7 @@ func (l *Link) Classes() string { return classes } -// Href returns content for the href attrubite. You should always use it. +// Href returns content for the href attrubite for hyperlink. You should always use it. func (l *Link) Href() string { switch l.Kind { case LinkExternal, LinkLocalRoot: @@ -63,6 +70,16 @@ func (l *Link) Href() string { } } +// ImgSrc returns content for src attribute of img tag. Used with `img{}`. +func (l *Link) ImgSrc() string { + switch l.Kind { + case LinkExternal, LinkLocalRoot: + return l.Address + default: + return "/binary/" + l.Address + } +} + // From returns a Link object given these `address` and `display` on relative to given `hyphaName`. func From(address, display, hyphaName string) *Link { link := Link{ @@ -100,6 +117,7 @@ func From(address, display, hyphaName string) *Link { link.Kind = LinkLocalHypha link.Address = util.CanonicalName(path.Join(path.Dir(hyphaName), address[3:])) default: + link.Kind = LinkLocalHypha link.Address = util.CanonicalName(address) } diff --git a/markup/img.go b/markup/img.go index 99c919b..b1a59c1 100644 --- a/markup/img.go +++ b/markup/img.go @@ -5,7 +5,7 @@ import ( "regexp" "strings" - "github.com/bouncepaw/mycorrhiza/util" + "github.com/bouncepaw/mycorrhiza/link" ) var imgRe = regexp.MustCompile(`^img\s+{`) @@ -14,44 +14,6 @@ func MatchesImg(line string) bool { return imgRe.MatchString(line) } -type imgEntry struct { - trimmedPath string - path strings.Builder - sizeW strings.Builder - sizeH strings.Builder - desc strings.Builder -} - -func (entry *imgEntry) descriptionAsHtml(hyphaName string) (html string) { - if entry.desc.Len() == 0 { - return "" - } - lines := strings.Split(entry.desc.String(), "\n") - for _, line := range lines { - if line = strings.TrimSpace(line); line != "" { - if html != "" { - html += `
` - } - html += ParagraphToHtml(hyphaName, line) - } - } - return `
` + html + `
` -} - -func (entry *imgEntry) sizeWAsAttr() string { - if entry.sizeW.Len() == 0 { - return "" - } - return ` width="` + entry.sizeW.String() + `"` -} - -func (entry *imgEntry) sizeHAsAttr() string { - if entry.sizeH.Len() == 0 { - return "" - } - return ` height="` + entry.sizeH.String() + `"` -} - type imgState int const ( @@ -71,6 +33,8 @@ type Img struct { func (img *Img) pushEntry() { if strings.TrimSpace(img.currEntry.path.String()) != "" { + img.currEntry.srclink = link.From(img.currEntry.path.String(), "", img.hyphaName) + img.currEntry.srclink.DoubtExistence() img.entries = append(img.entries, img.currEntry) img.currEntry = imgEntry{} img.currEntry.path.Reset() @@ -177,23 +141,6 @@ func ImgFromFirstLine(line, hyphaName string) (img *Img, shouldGoBackToNormal bo return img, img.Process(line) } -func (img *Img) binaryPathFor(path string) string { - path = strings.TrimSpace(path) - if strings.IndexRune(path, ':') != -1 || strings.IndexRune(path, '/') == 0 { - return path - } else { - return "/binary/" + xclCanonicalName(img.hyphaName, path) - } -} - -func (img *Img) ogBinaryPathFor(path string) string { - path = img.binaryPathFor(path) - if strings.HasPrefix(path, "/binary/") { - return util.URL + path - } - return path -} - func (img *Img) pagePathFor(path string) string { path = strings.TrimSpace(path) if strings.IndexRune(path, ':') != -1 || strings.IndexRune(path, '/') == 0 { @@ -214,30 +161,18 @@ func parseDimensions(dimensions string) (sizeW, sizeH string) { return } -func (img *Img) checkLinks() map[string]bool { - m := make(map[string]bool) - for i, entry := range img.entries { - // Also trim them for later use - entry.trimmedPath = strings.TrimSpace(entry.path.String()) - isAbsoluteUrl := strings.ContainsRune(entry.trimmedPath, ':') - if !isAbsoluteUrl { - entry.trimmedPath = canonicalName(entry.trimmedPath) - } - img.entries[i] = entry - m[entry.trimmedPath] = isAbsoluteUrl - } - HyphaIterate(func(hyphaName string) { +func (img *Img) markExistenceOfSrcLinks() { + HyphaIterate(func(hn string) { for _, entry := range img.entries { - if hyphaName == xclCanonicalName(img.hyphaName, entry.trimmedPath) { - m[entry.trimmedPath] = true + if hn == entry.srclink.Address { + entry.srclink.DestinationUnknown = false } } }) - return m } func (img *Img) ToHtml() (html string) { - linkAvailabilityMap := img.checkLinks() + img.markExistenceOfSrcLinks() isOneImageOnly := len(img.entries) == 1 && img.entries[0].desc.Len() == 0 if isOneImageOnly { html += `
{% endfunc %} + +{% func AdminPanelHTML() %} +
+
+

Admininstrative functions

+
+

Safe things

+ +
+
+

Dangerous things

+
+
+ Shutdown wiki + +
+
+
+
+ Reindex hyphae + +
+
+
+
+
+{% endfunc %} diff --git a/templates/stuff.qtpl.go b/views/stuff.qtpl.go similarity index 52% rename from templates/stuff.qtpl.go rename to views/stuff.qtpl.go index d6efabd..7c63324 100644 --- a/templates/stuff.qtpl.go +++ b/views/stuff.qtpl.go @@ -1,50 +1,51 @@ // Code generated by qtc from "stuff.qtpl". DO NOT EDIT. // See https://github.com/valyala/quicktemplate for details. -//line templates/stuff.qtpl:1 -package templates +//line views/stuff.qtpl:1 +package views -//line templates/stuff.qtpl:1 +//line views/stuff.qtpl:1 import "github.com/bouncepaw/mycorrhiza/util" -//line templates/stuff.qtpl:2 +//line views/stuff.qtpl:2 import "github.com/bouncepaw/mycorrhiza/user" -//line templates/stuff.qtpl:4 +//line views/stuff.qtpl:4 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/stuff.qtpl:4 +//line views/stuff.qtpl:4 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/stuff.qtpl:4 +//line views/stuff.qtpl:4 func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, u *user.User, headElements ...string) { -//line templates/stuff.qtpl:4 +//line views/stuff.qtpl:4 qw422016.N().S(` + `) -//line templates/stuff.qtpl:10 +//line views/stuff.qtpl:11 qw422016.E().S(title) -//line templates/stuff.qtpl:10 +//line views/stuff.qtpl:11 qw422016.N().S(` `) -//line templates/stuff.qtpl:11 +//line views/stuff.qtpl:12 for _, el := range headElements { -//line templates/stuff.qtpl:11 +//line views/stuff.qtpl:12 qw422016.N().S(el) -//line templates/stuff.qtpl:11 +//line views/stuff.qtpl:12 } -//line templates/stuff.qtpl:11 +//line views/stuff.qtpl:12 qw422016.N().S(` @@ -52,76 +53,76 @@ func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, u *user.User, `) -//line templates/stuff.qtpl:24 +//line views/stuff.qtpl:25 qw422016.N().S(body) -//line templates/stuff.qtpl:24 +//line views/stuff.qtpl:25 qw422016.N().S(` `) -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 } -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 func WriteBaseHTML(qq422016 qtio422016.Writer, title, body string, u *user.User, headElements ...string) { -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 StreamBaseHTML(qw422016, title, body, u, headElements...) -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 qt422016.ReleaseWriter(qw422016) -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 } -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 func BaseHTML(title, body string, u *user.User, headElements ...string) string { -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 qb422016 := qt422016.AcquireByteBuffer() -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 WriteBaseHTML(qb422016, title, body, u, headElements...) -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 qs422016 := string(qb422016.B) -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 qt422016.ReleaseByteBuffer(qb422016) -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 return qs422016 -//line templates/stuff.qtpl:27 +//line views/stuff.qtpl:28 } -//line templates/stuff.qtpl:29 +//line views/stuff.qtpl:30 func StreamUserListHTML(qw422016 *qt422016.Writer) { -//line templates/stuff.qtpl:29 +//line views/stuff.qtpl:30 qw422016.N().S(`

List of users

`) -//line templates/stuff.qtpl:34 +//line views/stuff.qtpl:35 var ( admins = make([]string, 0) moderators = make([]string, 0) @@ -138,129 +139,129 @@ func StreamUserListHTML(qw422016 *qt422016.Writer) { } } -//line templates/stuff.qtpl:49 +//line views/stuff.qtpl:50 qw422016.N().S(`

Admins

    `) -//line templates/stuff.qtpl:52 +//line views/stuff.qtpl:53 for _, name := range admins { -//line templates/stuff.qtpl:52 +//line views/stuff.qtpl:53 qw422016.N().S(`
  1. `) -//line templates/stuff.qtpl:53 +//line views/stuff.qtpl:54 qw422016.E().S(name) -//line templates/stuff.qtpl:53 +//line views/stuff.qtpl:54 qw422016.N().S(`
  2. `) -//line templates/stuff.qtpl:54 +//line views/stuff.qtpl:55 } -//line templates/stuff.qtpl:54 +//line views/stuff.qtpl:55 qw422016.N().S(`

Moderators

    `) -//line templates/stuff.qtpl:58 +//line views/stuff.qtpl:59 for _, name := range moderators { -//line templates/stuff.qtpl:58 +//line views/stuff.qtpl:59 qw422016.N().S(`
  1. `) -//line templates/stuff.qtpl:59 +//line views/stuff.qtpl:60 qw422016.E().S(name) -//line templates/stuff.qtpl:59 +//line views/stuff.qtpl:60 qw422016.N().S(`
  2. `) -//line templates/stuff.qtpl:60 +//line views/stuff.qtpl:61 } -//line templates/stuff.qtpl:60 +//line views/stuff.qtpl:61 qw422016.N().S(`

Editors

    `) -//line templates/stuff.qtpl:64 +//line views/stuff.qtpl:65 for _, name := range editors { -//line templates/stuff.qtpl:64 +//line views/stuff.qtpl:65 qw422016.N().S(`
  1. `) -//line templates/stuff.qtpl:65 +//line views/stuff.qtpl:66 qw422016.E().S(name) -//line templates/stuff.qtpl:65 +//line views/stuff.qtpl:66 qw422016.N().S(`
  2. `) -//line templates/stuff.qtpl:66 +//line views/stuff.qtpl:67 } -//line templates/stuff.qtpl:66 +//line views/stuff.qtpl:67 qw422016.N().S(`
`) -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 } -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 func WriteUserListHTML(qq422016 qtio422016.Writer) { -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 StreamUserListHTML(qw422016) -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 qt422016.ReleaseWriter(qw422016) -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 } -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 func UserListHTML() string { -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 qb422016 := qt422016.AcquireByteBuffer() -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 WriteUserListHTML(qb422016) -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 qs422016 := string(qb422016.B) -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 qt422016.ReleaseByteBuffer(qb422016) -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 return qs422016 -//line templates/stuff.qtpl:70 +//line views/stuff.qtpl:71 } -//line templates/stuff.qtpl:72 +//line views/stuff.qtpl:73 func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) { -//line templates/stuff.qtpl:72 +//line views/stuff.qtpl:73 qw422016.N().S(`

List of hyphae

This wiki has `) -//line templates/stuff.qtpl:76 +//line views/stuff.qtpl:77 qw422016.N().D(pageCount) -//line templates/stuff.qtpl:76 +//line views/stuff.qtpl:77 qw422016.N().S(` hyphae.

@@ -271,206 +272,268 @@ func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) `) -//line templates/stuff.qtpl:85 +//line views/stuff.qtpl:86 qw422016.N().S(tbody) -//line templates/stuff.qtpl:85 +//line views/stuff.qtpl:86 qw422016.N().S(`
`) -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 } -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 func WriteHyphaListHTML(qq422016 qtio422016.Writer, tbody string, pageCount int) { -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 StreamHyphaListHTML(qw422016, tbody, pageCount) -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 qt422016.ReleaseWriter(qw422016) -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 } -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 func HyphaListHTML(tbody string, pageCount int) string { -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 qb422016 := qt422016.AcquireByteBuffer() -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 WriteHyphaListHTML(qb422016, tbody, pageCount) -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 qs422016 := string(qb422016.B) -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 qt422016.ReleaseByteBuffer(qb422016) -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 return qs422016 -//line templates/stuff.qtpl:90 +//line views/stuff.qtpl:91 } -//line templates/stuff.qtpl:92 +//line views/stuff.qtpl:93 func StreamHyphaListRowHTML(qw422016 *qt422016.Writer, hyphaName, binaryMime string, binaryPresent bool) { -//line templates/stuff.qtpl:92 +//line views/stuff.qtpl:93 qw422016.N().S(` `) -//line templates/stuff.qtpl:94 +//line views/stuff.qtpl:95 qw422016.E().S(hyphaName) -//line templates/stuff.qtpl:94 +//line views/stuff.qtpl:95 qw422016.N().S(` `) -//line templates/stuff.qtpl:95 +//line views/stuff.qtpl:96 if binaryPresent { -//line templates/stuff.qtpl:95 +//line views/stuff.qtpl:96 qw422016.N().S(` `) -//line templates/stuff.qtpl:96 +//line views/stuff.qtpl:97 qw422016.E().S(binaryMime) -//line templates/stuff.qtpl:96 +//line views/stuff.qtpl:97 qw422016.N().S(` `) -//line templates/stuff.qtpl:97 +//line views/stuff.qtpl:98 } else { -//line templates/stuff.qtpl:97 +//line views/stuff.qtpl:98 qw422016.N().S(` `) -//line templates/stuff.qtpl:99 +//line views/stuff.qtpl:100 } -//line templates/stuff.qtpl:99 +//line views/stuff.qtpl:100 qw422016.N().S(` `) -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 } -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 func WriteHyphaListRowHTML(qq422016 qtio422016.Writer, hyphaName, binaryMime string, binaryPresent bool) { -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 StreamHyphaListRowHTML(qw422016, hyphaName, binaryMime, binaryPresent) -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 qt422016.ReleaseWriter(qw422016) -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 } -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 func HyphaListRowHTML(hyphaName, binaryMime string, binaryPresent bool) string { -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 qb422016 := qt422016.AcquireByteBuffer() -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 WriteHyphaListRowHTML(qb422016, hyphaName, binaryMime, binaryPresent) -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 qs422016 := string(qb422016.B) -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 qt422016.ReleaseByteBuffer(qb422016) -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 return qs422016 -//line templates/stuff.qtpl:101 +//line views/stuff.qtpl:102 } -//line templates/stuff.qtpl:103 +//line views/stuff.qtpl:104 func StreamAboutHTML(qw422016 *qt422016.Writer) { -//line templates/stuff.qtpl:103 +//line views/stuff.qtpl:104 qw422016.N().S(`

About `) -//line templates/stuff.qtpl:107 +//line views/stuff.qtpl:108 qw422016.E().S(util.SiteName) -//line templates/stuff.qtpl:107 +//line views/stuff.qtpl:108 qw422016.N().S(`

See /list for information about hyphae on this wiki.

`) -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 } -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 func WriteAboutHTML(qq422016 qtio422016.Writer) { -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 StreamAboutHTML(qw422016) -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 qt422016.ReleaseWriter(qw422016) -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 } -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 func AboutHTML() string { -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 qb422016 := qt422016.AcquireByteBuffer() -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 WriteAboutHTML(qb422016) -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 qs422016 := string(qb422016.B) -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 qt422016.ReleaseByteBuffer(qb422016) -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 return qs422016 -//line templates/stuff.qtpl:125 +//line views/stuff.qtpl:126 +} + +//line views/stuff.qtpl:128 +func StreamAdminPanelHTML(qw422016 *qt422016.Writer) { +//line views/stuff.qtpl:128 + qw422016.N().S(` +
+
+

Admininstrative functions

+
+

Safe things

+ +
+
+

Dangerous things

+
+
+ Shutdown wiki + +
+
+
+
+ Reindex hyphae + +
+
+
+
+
+`) +//line views/stuff.qtpl:157 +} + +//line views/stuff.qtpl:157 +func WriteAdminPanelHTML(qq422016 qtio422016.Writer) { +//line views/stuff.qtpl:157 + qw422016 := qt422016.AcquireWriter(qq422016) +//line views/stuff.qtpl:157 + StreamAdminPanelHTML(qw422016) +//line views/stuff.qtpl:157 + qt422016.ReleaseWriter(qw422016) +//line views/stuff.qtpl:157 +} + +//line views/stuff.qtpl:157 +func AdminPanelHTML() string { +//line views/stuff.qtpl:157 + qb422016 := qt422016.AcquireByteBuffer() +//line views/stuff.qtpl:157 + WriteAdminPanelHTML(qb422016) +//line views/stuff.qtpl:157 + qs422016 := string(qb422016.B) +//line views/stuff.qtpl:157 + qt422016.ReleaseByteBuffer(qb422016) +//line views/stuff.qtpl:157 + return qs422016 +//line views/stuff.qtpl:157 } From d2cc1e70744fb9ab3c917bf804ca58195ff54cd9 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Mon, 22 Feb 2021 23:37:23 +0500 Subject: [PATCH 40/53] Redesign /list --- main.go | 12 +- templates/asset.qtpl.go | 11 +- templates/default.css | 9 +- views/stuff.qtpl | 40 ++-- views/stuff.qtpl.go | 437 ++++++++++++++++++---------------------- 5 files changed, 233 insertions(+), 276 deletions(-) diff --git a/main.go b/main.go index 88c9d1a..288ff7f 100644 --- a/main.go +++ b/main.go @@ -10,12 +10,10 @@ import ( "math/rand" "net/http" "os" - "path/filepath" "strings" "github.com/bouncepaw/mycorrhiza/history" "github.com/bouncepaw/mycorrhiza/hyphae" - "github.com/bouncepaw/mycorrhiza/mimetype" "github.com/bouncepaw/mycorrhiza/shroom" "github.com/bouncepaw/mycorrhiza/templates" "github.com/bouncepaw/mycorrhiza/user" @@ -48,15 +46,7 @@ func HttpErr(w http.ResponseWriter, status int, name, title, errMsg string) { // Show all hyphae func handlerList(w http.ResponseWriter, rq *http.Request) { log.Println(rq.URL) - var ( - tbody string - pageCount = hyphae.Count() - u = user.FromRequest(rq) - ) - for h := range hyphae.YieldExistingHyphae() { - tbody += views.HyphaListRowHTML(h.Name, mimetype.FromExtension(filepath.Ext(h.BinaryPath)), h.BinaryPath != "") - } - util.HTTP200Page(w, base("List of pages", views.HyphaListHTML(tbody, pageCount), u)) + util.HTTP200Page(w, base("List of pages", views.HyphaListHTML(), user.FromRequest(rq))) } // This part is present in all html documents. diff --git a/templates/asset.qtpl.go b/templates/asset.qtpl.go index 7125101..7e951aa 100644 --- a/templates/asset.qtpl.go +++ b/templates/asset.qtpl.go @@ -23,12 +23,19 @@ func StreamDefaultCSS(qw422016 *qt422016.Writer) { qw422016.N().S(` `) //line templates/asset.qtpl:2 - qw422016.N().S(`/* General element positions, from small to big */ -.modal__title { font-size: 2rem; } + qw422016.N().S(`.modal__title { font-size: 2rem; } .modal__confirmation-msg { margin: 0 0 .5rem 0; } .modal__action { display: inline-block; font-size: 1rem; padding: .25rem; border-radius: .25rem; } .modal__submit { border: 1px #999 solid; } .modal__cancel { border: 1px #999 dashed; text-decoration: none; } + +.hypha-list { padding-left: 0; } +.hypha-list__entry { list-style-type: none; } +.hypha-list__link { text-decoration: none; display: inline-block; padding: .25rem; } +.hypha-list__link:hover { text-decoration: underline; } +.hypha-list__amnt-type { font-size: smaller; color: #999; } + +/* General element positions, from small to big */ /* Phones and whatnot */ .layout { display: grid; row-gap: 1rem; } header { width: 100%; margin-bottom: 1rem; } diff --git a/templates/default.css b/templates/default.css index c5d3001..31c7313 100644 --- a/templates/default.css +++ b/templates/default.css @@ -1,9 +1,16 @@ -/* General element positions, from small to big */ .modal__title { font-size: 2rem; } .modal__confirmation-msg { margin: 0 0 .5rem 0; } .modal__action { display: inline-block; font-size: 1rem; padding: .25rem; border-radius: .25rem; } .modal__submit { border: 1px #999 solid; } .modal__cancel { border: 1px #999 dashed; text-decoration: none; } + +.hypha-list { padding-left: 0; } +.hypha-list__entry { list-style-type: none; } +.hypha-list__link { text-decoration: none; display: inline-block; padding: .25rem; } +.hypha-list__link:hover { text-decoration: underline; } +.hypha-list__amnt-type { font-size: smaller; color: #999; } + +/* General element positions, from small to big */ /* Phones and whatnot */ .layout { display: grid; row-gap: 1rem; } header { width: 100%; margin-bottom: 1rem; } diff --git a/views/stuff.qtpl b/views/stuff.qtpl index fed2faa..5fbdc25 100644 --- a/views/stuff.qtpl +++ b/views/stuff.qtpl @@ -1,5 +1,7 @@ -{% import "github.com/bouncepaw/mycorrhiza/util" %} +{% import "path/filepath" %} +{% import "github.com/bouncepaw/mycorrhiza/hyphae" %} {% import "github.com/bouncepaw/mycorrhiza/user" %} +{% import "github.com/bouncepaw/mycorrhiza/util" %} {% func BaseHTML(title, body string, u *user.User, headElements ...string) %} @@ -70,37 +72,25 @@ for u := range user.YieldUsers() { {% endfunc %} -{% func HyphaListHTML(tbody string, pageCount int) %} +{% func HyphaListHTML() %}

List of hyphae

-

This wiki has {%d pageCount %} hyphae.

- - - - - - - - - {%s= tbody %} - -
Full nameBinary part type
+

This wiki has {%d hyphae.Count() %} hyphae.

+
    + {% for h := range hyphae.YieldExistingHyphae() %} +
  • + {%s util.BeautifulName(h.Name) %} + {% if h.BinaryPath != "" %} + {%s filepath.Ext(h.BinaryPath)[1:] %} + {% endif %} +
  • + {% endfor %} +
{% endfunc %} -{% func HyphaListRowHTML(hyphaName, binaryMime string, binaryPresent bool) %} - - {%s hyphaName %} - {% if binaryPresent %} - {%s binaryMime %} - {% else %} - - {% endif %} - -{% endfunc %} - {% func AboutHTML() %}
diff --git a/views/stuff.qtpl.go b/views/stuff.qtpl.go index 7c63324..7780726 100644 --- a/views/stuff.qtpl.go +++ b/views/stuff.qtpl.go @@ -5,27 +5,33 @@ package views //line views/stuff.qtpl:1 -import "github.com/bouncepaw/mycorrhiza/util" +import "path/filepath" //line views/stuff.qtpl:2 +import "github.com/bouncepaw/mycorrhiza/hyphae" + +//line views/stuff.qtpl:3 import "github.com/bouncepaw/mycorrhiza/user" //line views/stuff.qtpl:4 +import "github.com/bouncepaw/mycorrhiza/util" + +//line views/stuff.qtpl:6 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line views/stuff.qtpl:4 +//line views/stuff.qtpl:6 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line views/stuff.qtpl:4 +//line views/stuff.qtpl:6 func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, u *user.User, headElements ...string) { -//line views/stuff.qtpl:4 +//line views/stuff.qtpl:6 qw422016.N().S(` @@ -34,18 +40,18 @@ func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, u *user.User, `) -//line views/stuff.qtpl:11 +//line views/stuff.qtpl:13 qw422016.E().S(title) -//line views/stuff.qtpl:11 +//line views/stuff.qtpl:13 qw422016.N().S(` `) -//line views/stuff.qtpl:12 +//line views/stuff.qtpl:14 for _, el := range headElements { -//line views/stuff.qtpl:12 +//line views/stuff.qtpl:14 qw422016.N().S(el) -//line views/stuff.qtpl:12 +//line views/stuff.qtpl:14 } -//line views/stuff.qtpl:12 +//line views/stuff.qtpl:14 qw422016.N().S(` @@ -53,76 +59,76 @@ func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, u *user.User, `) -//line views/stuff.qtpl:25 +//line views/stuff.qtpl:27 qw422016.N().S(body) -//line views/stuff.qtpl:25 +//line views/stuff.qtpl:27 qw422016.N().S(` `) -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 } -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 func WriteBaseHTML(qq422016 qtio422016.Writer, title, body string, u *user.User, headElements ...string) { -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 StreamBaseHTML(qw422016, title, body, u, headElements...) -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 } -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 func BaseHTML(title, body string, u *user.User, headElements ...string) string { -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 WriteBaseHTML(qb422016, title, body, u, headElements...) -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 return qs422016 -//line views/stuff.qtpl:28 +//line views/stuff.qtpl:30 } -//line views/stuff.qtpl:30 +//line views/stuff.qtpl:32 func StreamUserListHTML(qw422016 *qt422016.Writer) { -//line views/stuff.qtpl:30 +//line views/stuff.qtpl:32 qw422016.N().S(`

List of users

`) -//line views/stuff.qtpl:35 +//line views/stuff.qtpl:37 var ( admins = make([]string, 0) moderators = make([]string, 0) @@ -139,346 +145,303 @@ func StreamUserListHTML(qw422016 *qt422016.Writer) { } } -//line views/stuff.qtpl:50 +//line views/stuff.qtpl:52 qw422016.N().S(`

Admins

    `) -//line views/stuff.qtpl:53 +//line views/stuff.qtpl:55 for _, name := range admins { -//line views/stuff.qtpl:53 +//line views/stuff.qtpl:55 qw422016.N().S(`
  1. `) -//line views/stuff.qtpl:54 +//line views/stuff.qtpl:56 qw422016.E().S(name) -//line views/stuff.qtpl:54 +//line views/stuff.qtpl:56 qw422016.N().S(`
  2. `) -//line views/stuff.qtpl:55 +//line views/stuff.qtpl:57 } -//line views/stuff.qtpl:55 +//line views/stuff.qtpl:57 qw422016.N().S(`

Moderators

    `) -//line views/stuff.qtpl:59 +//line views/stuff.qtpl:61 for _, name := range moderators { -//line views/stuff.qtpl:59 +//line views/stuff.qtpl:61 qw422016.N().S(`
  1. `) -//line views/stuff.qtpl:60 +//line views/stuff.qtpl:62 qw422016.E().S(name) -//line views/stuff.qtpl:60 +//line views/stuff.qtpl:62 qw422016.N().S(`
  2. `) -//line views/stuff.qtpl:61 +//line views/stuff.qtpl:63 } -//line views/stuff.qtpl:61 +//line views/stuff.qtpl:63 qw422016.N().S(`

Editors

    `) -//line views/stuff.qtpl:65 +//line views/stuff.qtpl:67 for _, name := range editors { -//line views/stuff.qtpl:65 +//line views/stuff.qtpl:67 qw422016.N().S(`
  1. `) -//line views/stuff.qtpl:66 +//line views/stuff.qtpl:68 qw422016.E().S(name) -//line views/stuff.qtpl:66 +//line views/stuff.qtpl:68 qw422016.N().S(`
  2. `) -//line views/stuff.qtpl:67 +//line views/stuff.qtpl:69 } -//line views/stuff.qtpl:67 +//line views/stuff.qtpl:69 qw422016.N().S(`
`) -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 } -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 func WriteUserListHTML(qq422016 qtio422016.Writer) { -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 StreamUserListHTML(qw422016) -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 } -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 func UserListHTML() string { -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 WriteUserListHTML(qb422016) -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 return qs422016 -//line views/stuff.qtpl:71 +//line views/stuff.qtpl:73 } -//line views/stuff.qtpl:73 -func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) { -//line views/stuff.qtpl:73 +//line views/stuff.qtpl:75 +func StreamHyphaListHTML(qw422016 *qt422016.Writer) { +//line views/stuff.qtpl:75 qw422016.N().S(`

List of hyphae

This wiki has `) -//line views/stuff.qtpl:77 - qw422016.N().D(pageCount) -//line views/stuff.qtpl:77 +//line views/stuff.qtpl:79 + qw422016.N().D(hyphae.Count()) +//line views/stuff.qtpl:79 qw422016.N().S(` hyphae.

- - - - - - - - +
    + `) +//line views/stuff.qtpl:81 + for h := range hyphae.YieldExistingHyphae() { +//line views/stuff.qtpl:81 + qw422016.N().S(` +
  • + `) +//line views/stuff.qtpl:83 + qw422016.E().S(util.BeautifulName(h.Name)) +//line views/stuff.qtpl:83 + qw422016.N().S(` + `) +//line views/stuff.qtpl:84 + if h.BinaryPath != "" { +//line views/stuff.qtpl:84 + qw422016.N().S(` + `) +//line views/stuff.qtpl:85 + qw422016.E().S(filepath.Ext(h.BinaryPath)[1:]) +//line views/stuff.qtpl:85 + qw422016.N().S(` `) //line views/stuff.qtpl:86 - qw422016.N().S(tbody) + } //line views/stuff.qtpl:86 + qw422016.N().S(` +
  • + `) +//line views/stuff.qtpl:88 + } +//line views/stuff.qtpl:88 qw422016.N().S(` -
-
Full nameBinary part type
+
`) -//line views/stuff.qtpl:91 +//line views/stuff.qtpl:92 } -//line views/stuff.qtpl:91 -func WriteHyphaListHTML(qq422016 qtio422016.Writer, tbody string, pageCount int) { -//line views/stuff.qtpl:91 +//line views/stuff.qtpl:92 +func WriteHyphaListHTML(qq422016 qtio422016.Writer) { +//line views/stuff.qtpl:92 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:91 - StreamHyphaListHTML(qw422016, tbody, pageCount) -//line views/stuff.qtpl:91 +//line views/stuff.qtpl:92 + StreamHyphaListHTML(qw422016) +//line views/stuff.qtpl:92 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:91 +//line views/stuff.qtpl:92 } -//line views/stuff.qtpl:91 -func HyphaListHTML(tbody string, pageCount int) string { -//line views/stuff.qtpl:91 +//line views/stuff.qtpl:92 +func HyphaListHTML() string { +//line views/stuff.qtpl:92 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:91 - WriteHyphaListHTML(qb422016, tbody, pageCount) -//line views/stuff.qtpl:91 +//line views/stuff.qtpl:92 + WriteHyphaListHTML(qb422016) +//line views/stuff.qtpl:92 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:91 +//line views/stuff.qtpl:92 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:91 +//line views/stuff.qtpl:92 return qs422016 -//line views/stuff.qtpl:91 +//line views/stuff.qtpl:92 } -//line views/stuff.qtpl:93 -func StreamHyphaListRowHTML(qw422016 *qt422016.Writer, hyphaName, binaryMime string, binaryPresent bool) { -//line views/stuff.qtpl:93 - qw422016.N().S(` - - `) -//line views/stuff.qtpl:95 - qw422016.E().S(hyphaName) -//line views/stuff.qtpl:95 - qw422016.N().S(` - `) -//line views/stuff.qtpl:96 - if binaryPresent { -//line views/stuff.qtpl:96 - qw422016.N().S(` - `) -//line views/stuff.qtpl:97 - qw422016.E().S(binaryMime) -//line views/stuff.qtpl:97 - qw422016.N().S(` - `) -//line views/stuff.qtpl:98 - } else { -//line views/stuff.qtpl:98 - qw422016.N().S(` - - `) -//line views/stuff.qtpl:100 - } -//line views/stuff.qtpl:100 - qw422016.N().S(` - -`) -//line views/stuff.qtpl:102 -} - -//line views/stuff.qtpl:102 -func WriteHyphaListRowHTML(qq422016 qtio422016.Writer, hyphaName, binaryMime string, binaryPresent bool) { -//line views/stuff.qtpl:102 - qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:102 - StreamHyphaListRowHTML(qw422016, hyphaName, binaryMime, binaryPresent) -//line views/stuff.qtpl:102 - qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:102 -} - -//line views/stuff.qtpl:102 -func HyphaListRowHTML(hyphaName, binaryMime string, binaryPresent bool) string { -//line views/stuff.qtpl:102 - qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:102 - WriteHyphaListRowHTML(qb422016, hyphaName, binaryMime, binaryPresent) -//line views/stuff.qtpl:102 - qs422016 := string(qb422016.B) -//line views/stuff.qtpl:102 - qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:102 - return qs422016 -//line views/stuff.qtpl:102 -} - -//line views/stuff.qtpl:104 +//line views/stuff.qtpl:94 func StreamAboutHTML(qw422016 *qt422016.Writer) { -//line views/stuff.qtpl:104 +//line views/stuff.qtpl:94 qw422016.N().S(`

About `) -//line views/stuff.qtpl:108 +//line views/stuff.qtpl:98 qw422016.E().S(util.SiteName) -//line views/stuff.qtpl:108 +//line views/stuff.qtpl:98 qw422016.N().S(`

See /list for information about hyphae on this wiki.

`) -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 } -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 func WriteAboutHTML(qq422016 qtio422016.Writer) { -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 StreamAboutHTML(qw422016) -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 } -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 func AboutHTML() string { -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 WriteAboutHTML(qb422016) -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 return qs422016 -//line views/stuff.qtpl:126 +//line views/stuff.qtpl:116 } -//line views/stuff.qtpl:128 +//line views/stuff.qtpl:118 func StreamAdminPanelHTML(qw422016 *qt422016.Writer) { -//line views/stuff.qtpl:128 +//line views/stuff.qtpl:118 qw422016.N().S(`
@@ -509,31 +472,31 @@ func StreamAdminPanelHTML(qw422016 *qt422016.Writer) {
`) -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 } -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 func WriteAdminPanelHTML(qq422016 qtio422016.Writer) { -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 StreamAdminPanelHTML(qw422016) -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 } -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 func AdminPanelHTML() string { -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 WriteAdminPanelHTML(qb422016) -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 return qs422016 -//line views/stuff.qtpl:157 +//line views/stuff.qtpl:147 } From f992f0a098620b3346fc418f2a8e3c66b02399f0 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Tue, 23 Feb 2021 14:15:25 +0500 Subject: [PATCH 41/53] Add clear: both to the subhyphae block --- templates/asset.qtpl.go | 2 +- templates/default.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/asset.qtpl.go b/templates/asset.qtpl.go index 7e951aa..cfecdf5 100644 --- a/templates/asset.qtpl.go +++ b/templates/asset.qtpl.go @@ -146,7 +146,7 @@ article pre.codeblock { padding:.5rem; white-space: pre-wrap; border-radius: .25 .binary-container_with-video video, .binary-container_with-audio audio {width: 100%} -.subhyphae__title { padding-bottom: .5rem; } +.subhyphae__title { padding-bottom: .5rem; clear: both; } .navi-title { padding-bottom: .5rem; margin: .25rem 0; } .navi-title a {text-decoration:none; } .navi-title__separator { margin: 0 .25rem; } diff --git a/templates/default.css b/templates/default.css index 31c7313..bc4f3e1 100644 --- a/templates/default.css +++ b/templates/default.css @@ -121,7 +121,7 @@ article pre.codeblock { padding:.5rem; white-space: pre-wrap; border-radius: .25 .binary-container_with-video video, .binary-container_with-audio audio {width: 100%} -.subhyphae__title { padding-bottom: .5rem; } +.subhyphae__title { padding-bottom: .5rem; clear: both; } .navi-title { padding-bottom: .5rem; margin: .25rem 0; } .navi-title a {text-decoration:none; } .navi-title__separator { margin: 0 .25rem; } From c83710f155077e328cf1ba6707c31058fd3a7566 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Tue, 23 Feb 2021 19:25:07 +0500 Subject: [PATCH 42/53] Move mutators.qtpl and auth.qtpl to the views --- http_auth.go | 8 +- http_mutators.go | 5 +- templates/common.qtpl | 19 --- templates/common.qtpl.go | 183 -------------------------- {templates => views}/auth.qtpl | 0 {templates => views}/auth.qtpl.go | 146 ++++++++++---------- {templates => views}/mutators.qtpl | 6 +- {templates => views}/mutators.qtpl.go | 130 +++++++++--------- 8 files changed, 147 insertions(+), 350 deletions(-) delete mode 100644 templates/common.qtpl delete mode 100644 templates/common.qtpl.go rename {templates => views}/auth.qtpl (100%) rename {templates => views}/auth.qtpl.go (62%) rename {templates => views}/mutators.qtpl (91%) rename {templates => views}/mutators.qtpl.go (60%) diff --git a/http_auth.go b/http_auth.go index a9ba5de..9981520 100644 --- a/http_auth.go +++ b/http_auth.go @@ -4,9 +4,9 @@ import ( "log" "net/http" - "github.com/bouncepaw/mycorrhiza/templates" "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" + "github.com/bouncepaw/mycorrhiza/views" ) func init() { @@ -29,7 +29,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), u))) + w.Write([]byte(base("Logout?", views.LogoutHTML(can), u))) } func handlerLogoutConfirm(w http.ResponseWriter, rq *http.Request) { @@ -45,7 +45,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), user.EmptyUser()))) + w.Write([]byte(base(err, views.LoginErrorHTML(err), user.EmptyUser()))) } else { http.Redirect(w, rq, "/", http.StatusSeeOther) } @@ -59,5 +59,5 @@ func handlerLogin(w http.ResponseWriter, rq *http.Request) { } else { w.WriteHeader(http.StatusForbidden) } - w.Write([]byte(base("Login", templates.LoginHTML(), user.EmptyUser()))) + w.Write([]byte(base("Login", views.LoginHTML(), user.EmptyUser()))) } diff --git a/http_mutators.go b/http_mutators.go index 0cc3f56..5835420 100644 --- a/http_mutators.go +++ b/http_mutators.go @@ -9,7 +9,6 @@ import ( "github.com/bouncepaw/mycorrhiza/hyphae" "github.com/bouncepaw/mycorrhiza/markup" "github.com/bouncepaw/mycorrhiza/shroom" - "github.com/bouncepaw/mycorrhiza/templates" "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" "github.com/bouncepaw/mycorrhiza/views" @@ -161,7 +160,7 @@ func handlerEdit(w http.ResponseWriter, rq *http.Request) { w, base( "Edit "+hyphaName, - templates.EditHTML(rq, hyphaName, textAreaFill, warning), + views.EditHTML(rq, hyphaName, textAreaFill, warning), u)) } @@ -193,7 +192,7 @@ func handlerUploadText(w http.ResponseWriter, rq *http.Request) { w, base( "Preview "+hyphaName, - templates.PreviewHTML( + views.PreviewHTML( rq, hyphaName, textData, diff --git a/templates/common.qtpl b/templates/common.qtpl deleted file mode 100644 index 2f225ac..0000000 --- a/templates/common.qtpl +++ /dev/null @@ -1,19 +0,0 @@ -{% import "net/http" %} -{% import "github.com/bouncepaw/mycorrhiza/user" %} -{% import "github.com/bouncepaw/mycorrhiza/views" %} - -{% func navHTML(rq *http.Request, hyphaName, navType string, revisionHash ...string) %} -{%s= views.NavHTML(rq, hyphaName, navType, revisionHash...) %} -{% endfunc %} - -{% func userMenuHTML(u *user.User) %} -{%s= views.UserMenuHTML(u) %} -{% endfunc %} - -{% func relativeHyphae(relatives string) %} -{%s= views.RelativeHyphaeHTML(relatives) %} -{% endfunc %} - -{% func subhyphaeMatrix(subhyphae string) %} -{%s= views.SubhyphaeHTML(subhyphae) %} -{% endfunc %} diff --git a/templates/common.qtpl.go b/templates/common.qtpl.go deleted file mode 100644 index 40293c8..0000000 --- a/templates/common.qtpl.go +++ /dev/null @@ -1,183 +0,0 @@ -// Code generated by qtc from "common.qtpl". DO NOT EDIT. -// See https://github.com/valyala/quicktemplate for details. - -//line templates/common.qtpl:1 -package templates - -//line templates/common.qtpl:1 -import "net/http" - -//line templates/common.qtpl:2 -import "github.com/bouncepaw/mycorrhiza/user" - -//line templates/common.qtpl:3 -import "github.com/bouncepaw/mycorrhiza/views" - -//line templates/common.qtpl:5 -import ( - qtio422016 "io" - - qt422016 "github.com/valyala/quicktemplate" -) - -//line templates/common.qtpl:5 -var ( - _ = qtio422016.Copy - _ = qt422016.AcquireByteBuffer -) - -//line templates/common.qtpl:5 -func streamnavHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, navType string, revisionHash ...string) { -//line templates/common.qtpl:5 - qw422016.N().S(` -`) -//line templates/common.qtpl:6 - qw422016.N().S(views.NavHTML(rq, hyphaName, navType, revisionHash...)) -//line templates/common.qtpl:6 - qw422016.N().S(` -`) -//line templates/common.qtpl:7 -} - -//line templates/common.qtpl:7 -func writenavHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, navType string, revisionHash ...string) { -//line templates/common.qtpl:7 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/common.qtpl:7 - streamnavHTML(qw422016, rq, hyphaName, navType, revisionHash...) -//line templates/common.qtpl:7 - qt422016.ReleaseWriter(qw422016) -//line templates/common.qtpl:7 -} - -//line templates/common.qtpl:7 -func navHTML(rq *http.Request, hyphaName, navType string, revisionHash ...string) string { -//line templates/common.qtpl:7 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/common.qtpl:7 - writenavHTML(qb422016, rq, hyphaName, navType, revisionHash...) -//line templates/common.qtpl:7 - qs422016 := string(qb422016.B) -//line templates/common.qtpl:7 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/common.qtpl:7 - return qs422016 -//line templates/common.qtpl:7 -} - -//line templates/common.qtpl:9 -func streamuserMenuHTML(qw422016 *qt422016.Writer, u *user.User) { -//line templates/common.qtpl:9 - qw422016.N().S(` -`) -//line templates/common.qtpl:10 - qw422016.N().S(views.UserMenuHTML(u)) -//line templates/common.qtpl:10 - qw422016.N().S(` -`) -//line templates/common.qtpl:11 -} - -//line templates/common.qtpl:11 -func writeuserMenuHTML(qq422016 qtio422016.Writer, u *user.User) { -//line templates/common.qtpl:11 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/common.qtpl:11 - streamuserMenuHTML(qw422016, u) -//line templates/common.qtpl:11 - qt422016.ReleaseWriter(qw422016) -//line templates/common.qtpl:11 -} - -//line templates/common.qtpl:11 -func userMenuHTML(u *user.User) string { -//line templates/common.qtpl:11 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/common.qtpl:11 - writeuserMenuHTML(qb422016, u) -//line templates/common.qtpl:11 - qs422016 := string(qb422016.B) -//line templates/common.qtpl:11 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/common.qtpl:11 - return qs422016 -//line templates/common.qtpl:11 -} - -//line templates/common.qtpl:13 -func streamrelativeHyphae(qw422016 *qt422016.Writer, relatives string) { -//line templates/common.qtpl:13 - qw422016.N().S(` -`) -//line templates/common.qtpl:14 - qw422016.N().S(views.RelativeHyphaeHTML(relatives)) -//line templates/common.qtpl:14 - qw422016.N().S(` -`) -//line templates/common.qtpl:15 -} - -//line templates/common.qtpl:15 -func writerelativeHyphae(qq422016 qtio422016.Writer, relatives string) { -//line templates/common.qtpl:15 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/common.qtpl:15 - streamrelativeHyphae(qw422016, relatives) -//line templates/common.qtpl:15 - qt422016.ReleaseWriter(qw422016) -//line templates/common.qtpl:15 -} - -//line templates/common.qtpl:15 -func relativeHyphae(relatives string) string { -//line templates/common.qtpl:15 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/common.qtpl:15 - writerelativeHyphae(qb422016, relatives) -//line templates/common.qtpl:15 - qs422016 := string(qb422016.B) -//line templates/common.qtpl:15 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/common.qtpl:15 - return qs422016 -//line templates/common.qtpl:15 -} - -//line templates/common.qtpl:17 -func streamsubhyphaeMatrix(qw422016 *qt422016.Writer, subhyphae string) { -//line templates/common.qtpl:17 - qw422016.N().S(` -`) -//line templates/common.qtpl:18 - qw422016.N().S(views.SubhyphaeHTML(subhyphae)) -//line templates/common.qtpl:18 - qw422016.N().S(` -`) -//line templates/common.qtpl:19 -} - -//line templates/common.qtpl:19 -func writesubhyphaeMatrix(qq422016 qtio422016.Writer, subhyphae string) { -//line templates/common.qtpl:19 - qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/common.qtpl:19 - streamsubhyphaeMatrix(qw422016, subhyphae) -//line templates/common.qtpl:19 - qt422016.ReleaseWriter(qw422016) -//line templates/common.qtpl:19 -} - -//line templates/common.qtpl:19 -func subhyphaeMatrix(subhyphae string) string { -//line templates/common.qtpl:19 - qb422016 := qt422016.AcquireByteBuffer() -//line templates/common.qtpl:19 - writesubhyphaeMatrix(qb422016, subhyphae) -//line templates/common.qtpl:19 - qs422016 := string(qb422016.B) -//line templates/common.qtpl:19 - qt422016.ReleaseByteBuffer(qb422016) -//line templates/common.qtpl:19 - return qs422016 -//line templates/common.qtpl:19 -} diff --git a/templates/auth.qtpl b/views/auth.qtpl similarity index 100% rename from templates/auth.qtpl rename to views/auth.qtpl diff --git a/templates/auth.qtpl.go b/views/auth.qtpl.go similarity index 62% rename from templates/auth.qtpl.go rename to views/auth.qtpl.go index 25bb21a..fec28c1 100644 --- a/templates/auth.qtpl.go +++ b/views/auth.qtpl.go @@ -1,36 +1,36 @@ // Code generated by qtc from "auth.qtpl". DO NOT EDIT. // See https://github.com/valyala/quicktemplate for details. -//line templates/auth.qtpl:1 -package templates +//line views/auth.qtpl:1 +package views -//line templates/auth.qtpl:1 +//line views/auth.qtpl:1 import "github.com/bouncepaw/mycorrhiza/user" -//line templates/auth.qtpl:3 +//line views/auth.qtpl:3 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/auth.qtpl:3 +//line views/auth.qtpl:3 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/auth.qtpl:3 +//line views/auth.qtpl:3 func StreamLoginHTML(qw422016 *qt422016.Writer) { -//line templates/auth.qtpl:3 +//line views/auth.qtpl:3 qw422016.N().S(`
`) -//line templates/auth.qtpl:7 +//line views/auth.qtpl:7 if user.AuthUsed { -//line templates/auth.qtpl:7 +//line views/auth.qtpl:7 qw422016.N().S(`

Login

@@ -48,177 +48,177 @@ func StreamLoginHTML(qw422016 *qt422016.Writer) { Cancel
`) -//line templates/auth.qtpl:23 +//line views/auth.qtpl:23 } else { -//line templates/auth.qtpl:23 +//line views/auth.qtpl:23 qw422016.N().S(`

Administrator of this wiki have not configured any authorization method. You can make edits anonymously.

← Go home

`) -//line templates/auth.qtpl:26 +//line views/auth.qtpl:26 } -//line templates/auth.qtpl:26 +//line views/auth.qtpl:26 qw422016.N().S(`
`) -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 } -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 func WriteLoginHTML(qq422016 qtio422016.Writer) { -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 StreamLoginHTML(qw422016) -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 qt422016.ReleaseWriter(qw422016) -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 } -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 func LoginHTML() string { -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 qb422016 := qt422016.AcquireByteBuffer() -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 WriteLoginHTML(qb422016) -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 qs422016 := string(qb422016.B) -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 qt422016.ReleaseByteBuffer(qb422016) -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 return qs422016 -//line templates/auth.qtpl:30 +//line views/auth.qtpl:30 } -//line templates/auth.qtpl:32 +//line views/auth.qtpl:32 func StreamLoginErrorHTML(qw422016 *qt422016.Writer, err string) { -//line templates/auth.qtpl:32 +//line views/auth.qtpl:32 qw422016.N().S(`
`) -//line templates/auth.qtpl:36 +//line views/auth.qtpl:36 switch err { -//line templates/auth.qtpl:37 +//line views/auth.qtpl:37 case "unknown username": -//line templates/auth.qtpl:37 +//line views/auth.qtpl:37 qw422016.N().S(`

Unknown username.

`) -//line templates/auth.qtpl:39 +//line views/auth.qtpl:39 case "wrong password": -//line templates/auth.qtpl:39 +//line views/auth.qtpl:39 qw422016.N().S(`

Wrong password.

`) -//line templates/auth.qtpl:41 +//line views/auth.qtpl:41 default: -//line templates/auth.qtpl:41 +//line views/auth.qtpl:41 qw422016.N().S(`

`) -//line templates/auth.qtpl:42 +//line views/auth.qtpl:42 qw422016.E().S(err) -//line templates/auth.qtpl:42 +//line views/auth.qtpl:42 qw422016.N().S(`

`) -//line templates/auth.qtpl:43 +//line views/auth.qtpl:43 } -//line templates/auth.qtpl:43 +//line views/auth.qtpl:43 qw422016.N().S(`

← Try again

`) -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 } -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 func WriteLoginErrorHTML(qq422016 qtio422016.Writer, err string) { -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 StreamLoginErrorHTML(qw422016, err) -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 qt422016.ReleaseWriter(qw422016) -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 } -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 func LoginErrorHTML(err string) string { -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 qb422016 := qt422016.AcquireByteBuffer() -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 WriteLoginErrorHTML(qb422016, err) -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 qs422016 := string(qb422016.B) -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 qt422016.ReleaseByteBuffer(qb422016) -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 return qs422016 -//line templates/auth.qtpl:48 +//line views/auth.qtpl:48 } -//line templates/auth.qtpl:50 +//line views/auth.qtpl:50 func StreamLogoutHTML(qw422016 *qt422016.Writer, can bool) { -//line templates/auth.qtpl:50 +//line views/auth.qtpl:50 qw422016.N().S(`
`) -//line templates/auth.qtpl:54 +//line views/auth.qtpl:54 if can { -//line templates/auth.qtpl:54 +//line views/auth.qtpl:54 qw422016.N().S(`

Log out?

Confirm

Cancel

`) -//line templates/auth.qtpl:58 +//line views/auth.qtpl:58 } else { -//line templates/auth.qtpl:58 +//line views/auth.qtpl:58 qw422016.N().S(`

You cannot log out because you are not logged in.

Login

← Home

`) -//line templates/auth.qtpl:62 +//line views/auth.qtpl:62 } -//line templates/auth.qtpl:62 +//line views/auth.qtpl:62 qw422016.N().S(`
`) -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 } -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 func WriteLogoutHTML(qq422016 qtio422016.Writer, can bool) { -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 StreamLogoutHTML(qw422016, can) -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 qt422016.ReleaseWriter(qw422016) -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 } -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 func LogoutHTML(can bool) string { -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 qb422016 := qt422016.AcquireByteBuffer() -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 WriteLogoutHTML(qb422016, can) -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 qs422016 := string(qb422016.B) -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 qt422016.ReleaseByteBuffer(qb422016) -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 return qs422016 -//line templates/auth.qtpl:66 +//line views/auth.qtpl:66 } diff --git a/templates/mutators.qtpl b/views/mutators.qtpl similarity index 91% rename from templates/mutators.qtpl rename to views/mutators.qtpl index a90b767..233c3d5 100644 --- a/templates/mutators.qtpl +++ b/views/mutators.qtpl @@ -2,7 +2,7 @@ {% import "github.com/bouncepaw/mycorrhiza/util" %} {% func EditHTML(rq *http.Request, hyphaName, textAreaFill, warning string) %} -{%s= navHTML(rq, hyphaName, "edit") %} +{%s= NavHTML(rq, hyphaName, "edit") %}

Edit {%s util.BeautifulName(hyphaName) %}

@@ -20,10 +20,10 @@ {% endfunc %} {% func PreviewHTML(rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) %} -{%s= navHTML(rq, hyphaName, "edit") %} +{%s= NavHTML(rq, hyphaName, "edit") %}
-

Edit {%s hyphaName %} (preview)

+

Edit {%s util.BeautifulName(hyphaName) %} (preview)

{%s= warning %}
diff --git a/templates/mutators.qtpl.go b/views/mutators.qtpl.go similarity index 60% rename from templates/mutators.qtpl.go rename to views/mutators.qtpl.go index b1642cf..5510ceb 100644 --- a/templates/mutators.qtpl.go +++ b/views/mutators.qtpl.go @@ -1,176 +1,176 @@ // Code generated by qtc from "mutators.qtpl". DO NOT EDIT. // See https://github.com/valyala/quicktemplate for details. -//line templates/mutators.qtpl:1 -package templates +//line views/mutators.qtpl:1 +package views -//line templates/mutators.qtpl:1 +//line views/mutators.qtpl:1 import "net/http" -//line templates/mutators.qtpl:2 +//line views/mutators.qtpl:2 import "github.com/bouncepaw/mycorrhiza/util" -//line templates/mutators.qtpl:4 +//line views/mutators.qtpl:4 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/mutators.qtpl:4 +//line views/mutators.qtpl:4 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/mutators.qtpl:4 +//line views/mutators.qtpl:4 func StreamEditHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string) { -//line templates/mutators.qtpl:4 +//line views/mutators.qtpl:4 qw422016.N().S(` `) -//line templates/mutators.qtpl:5 - qw422016.N().S(navHTML(rq, hyphaName, "edit")) -//line templates/mutators.qtpl:5 +//line views/mutators.qtpl:5 + qw422016.N().S(NavHTML(rq, hyphaName, "edit")) +//line views/mutators.qtpl:5 qw422016.N().S(`

Edit `) -//line templates/mutators.qtpl:8 +//line views/mutators.qtpl:8 qw422016.E().S(util.BeautifulName(hyphaName)) -//line templates/mutators.qtpl:8 +//line views/mutators.qtpl:8 qw422016.N().S(`

`) -//line templates/mutators.qtpl:9 +//line views/mutators.qtpl:9 qw422016.N().S(warning) -//line templates/mutators.qtpl:9 +//line views/mutators.qtpl:9 qw422016.N().S(`
Cancel
`) -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 } -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 func WriteEditHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string) { -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 StreamEditHTML(qw422016, rq, hyphaName, textAreaFill, warning) -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 qt422016.ReleaseWriter(qw422016) -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 } -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 func EditHTML(rq *http.Request, hyphaName, textAreaFill, warning string) string { -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 qb422016 := qt422016.AcquireByteBuffer() -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 WriteEditHTML(qb422016, rq, hyphaName, textAreaFill, warning) -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 qs422016 := string(qb422016.B) -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 qt422016.ReleaseByteBuffer(qb422016) -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 return qs422016 -//line templates/mutators.qtpl:20 +//line views/mutators.qtpl:20 } -//line templates/mutators.qtpl:22 +//line views/mutators.qtpl:22 func StreamPreviewHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) { -//line templates/mutators.qtpl:22 +//line views/mutators.qtpl:22 qw422016.N().S(` `) -//line templates/mutators.qtpl:23 - qw422016.N().S(navHTML(rq, hyphaName, "edit")) -//line templates/mutators.qtpl:23 +//line views/mutators.qtpl:23 + qw422016.N().S(NavHTML(rq, hyphaName, "edit")) +//line views/mutators.qtpl:23 qw422016.N().S(`

Edit `) -//line templates/mutators.qtpl:26 - qw422016.E().S(hyphaName) -//line templates/mutators.qtpl:26 +//line views/mutators.qtpl:26 + qw422016.E().S(util.BeautifulName(hyphaName)) +//line views/mutators.qtpl:26 qw422016.N().S(` (preview)

`) -//line templates/mutators.qtpl:27 +//line views/mutators.qtpl:27 qw422016.N().S(warning) -//line templates/mutators.qtpl:27 +//line views/mutators.qtpl:27 qw422016.N().S(`

Cancel

Note that the hypha is not saved yet. You can preview the changes ↓

`) -//line templates/mutators.qtpl:37 +//line views/mutators.qtpl:37 qw422016.N().S(renderedPage) -//line templates/mutators.qtpl:37 +//line views/mutators.qtpl:37 qw422016.N().S(`
`) -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 } -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 func WritePreviewHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) { -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 StreamPreviewHTML(qw422016, rq, hyphaName, textAreaFill, warning, renderedPage) -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 qt422016.ReleaseWriter(qw422016) -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 } -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 func PreviewHTML(rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) string { -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 qb422016 := qt422016.AcquireByteBuffer() -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 WritePreviewHTML(qb422016, rq, hyphaName, textAreaFill, warning, renderedPage) -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 qs422016 := string(qb422016.B) -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 qt422016.ReleaseByteBuffer(qb422016) -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 return qs422016 -//line templates/mutators.qtpl:40 +//line views/mutators.qtpl:40 } From 170240177eff1fbf8d66e693f442ab0aa7989f07 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Tue, 23 Feb 2021 19:36:12 +0500 Subject: [PATCH 43/53] Slight redesign of the login form --- views/auth.qtpl | 32 ++++---- views/auth.qtpl.go | 178 +++++++++++++++++++++++---------------------- 2 files changed, 110 insertions(+), 100 deletions(-) diff --git a/views/auth.qtpl b/views/auth.qtpl index d51e588..f3f257a 100644 --- a/views/auth.qtpl +++ b/views/auth.qtpl @@ -1,28 +1,30 @@ {% import "github.com/bouncepaw/mycorrhiza/user" %} +{% import "github.com/bouncepaw/mycorrhiza/util" %} {% func LoginHTML() %}
{% if user.AuthUsed %} -

Login

-
-

Use the data you were given by an administrator.

-
- Username - + + -
- Password - -
-

By submitting this form you give this wiki a permission to store cookies in your browser. It lets the engine associate your edits with you. You will stay logged in until you log out.

- - Cancel {% else %} -

Administrator of this wiki have not configured any authorization method. You can make edits anonymously.

-

← Go home

+

Administrators of this wiki have not configured any authorization method. You can make edits anonymously.

+

← Go home

{% endif %}
diff --git a/views/auth.qtpl.go b/views/auth.qtpl.go index fec28c1..74d83b1 100644 --- a/views/auth.qtpl.go +++ b/views/auth.qtpl.go @@ -7,218 +7,226 @@ package views //line views/auth.qtpl:1 import "github.com/bouncepaw/mycorrhiza/user" -//line views/auth.qtpl:3 +//line views/auth.qtpl:2 +import "github.com/bouncepaw/mycorrhiza/util" + +//line views/auth.qtpl:4 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line views/auth.qtpl:3 +//line views/auth.qtpl:4 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line views/auth.qtpl:3 +//line views/auth.qtpl:4 func StreamLoginHTML(qw422016 *qt422016.Writer) { -//line views/auth.qtpl:3 +//line views/auth.qtpl:4 qw422016.N().S(`
`) -//line views/auth.qtpl:7 +//line views/auth.qtpl:8 if user.AuthUsed { -//line views/auth.qtpl:7 +//line views/auth.qtpl:8 qw422016.N().S(` -

Login

-
-

Use the data you were given by an administrator.

-
- Username - + + -
- Password - -
-

By submitting this form you give this wiki a permission to store cookies in your browser. It lets the engine associate your edits with you. You will stay logged in until you log out.

- - Cancel `) -//line views/auth.qtpl:23 +//line views/auth.qtpl:25 } else { -//line views/auth.qtpl:23 +//line views/auth.qtpl:25 qw422016.N().S(` -

Administrator of this wiki have not configured any authorization method. You can make edits anonymously.

-

← Go home

+

Administrators of this wiki have not configured any authorization method. You can make edits anonymously.

+

← Go home

`) -//line views/auth.qtpl:26 +//line views/auth.qtpl:28 } -//line views/auth.qtpl:26 +//line views/auth.qtpl:28 qw422016.N().S(`
`) -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 } -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 func WriteLoginHTML(qq422016 qtio422016.Writer) { -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 StreamLoginHTML(qw422016) -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 qt422016.ReleaseWriter(qw422016) -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 } -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 func LoginHTML() string { -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 qb422016 := qt422016.AcquireByteBuffer() -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 WriteLoginHTML(qb422016) -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 qs422016 := string(qb422016.B) -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 qt422016.ReleaseByteBuffer(qb422016) -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 return qs422016 -//line views/auth.qtpl:30 +//line views/auth.qtpl:32 } -//line views/auth.qtpl:32 +//line views/auth.qtpl:34 func StreamLoginErrorHTML(qw422016 *qt422016.Writer, err string) { -//line views/auth.qtpl:32 +//line views/auth.qtpl:34 qw422016.N().S(`
`) -//line views/auth.qtpl:36 +//line views/auth.qtpl:38 switch err { -//line views/auth.qtpl:37 +//line views/auth.qtpl:39 case "unknown username": -//line views/auth.qtpl:37 +//line views/auth.qtpl:39 qw422016.N().S(`

Unknown username.

`) -//line views/auth.qtpl:39 +//line views/auth.qtpl:41 case "wrong password": -//line views/auth.qtpl:39 +//line views/auth.qtpl:41 qw422016.N().S(`

Wrong password.

`) -//line views/auth.qtpl:41 +//line views/auth.qtpl:43 default: -//line views/auth.qtpl:41 +//line views/auth.qtpl:43 qw422016.N().S(`

`) -//line views/auth.qtpl:42 +//line views/auth.qtpl:44 qw422016.E().S(err) -//line views/auth.qtpl:42 +//line views/auth.qtpl:44 qw422016.N().S(`

`) -//line views/auth.qtpl:43 +//line views/auth.qtpl:45 } -//line views/auth.qtpl:43 +//line views/auth.qtpl:45 qw422016.N().S(`

← Try again

`) -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 } -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 func WriteLoginErrorHTML(qq422016 qtio422016.Writer, err string) { -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 StreamLoginErrorHTML(qw422016, err) -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 qt422016.ReleaseWriter(qw422016) -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 } -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 func LoginErrorHTML(err string) string { -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 qb422016 := qt422016.AcquireByteBuffer() -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 WriteLoginErrorHTML(qb422016, err) -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 qs422016 := string(qb422016.B) -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 qt422016.ReleaseByteBuffer(qb422016) -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 return qs422016 -//line views/auth.qtpl:48 +//line views/auth.qtpl:50 } -//line views/auth.qtpl:50 +//line views/auth.qtpl:52 func StreamLogoutHTML(qw422016 *qt422016.Writer, can bool) { -//line views/auth.qtpl:50 +//line views/auth.qtpl:52 qw422016.N().S(`
`) -//line views/auth.qtpl:54 +//line views/auth.qtpl:56 if can { -//line views/auth.qtpl:54 +//line views/auth.qtpl:56 qw422016.N().S(`

Log out?

Confirm

Cancel

`) -//line views/auth.qtpl:58 +//line views/auth.qtpl:60 } else { -//line views/auth.qtpl:58 +//line views/auth.qtpl:60 qw422016.N().S(`

You cannot log out because you are not logged in.

Login

← Home

`) -//line views/auth.qtpl:62 +//line views/auth.qtpl:64 } -//line views/auth.qtpl:62 +//line views/auth.qtpl:64 qw422016.N().S(`
`) -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 } -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 func WriteLogoutHTML(qq422016 qtio422016.Writer, can bool) { -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 StreamLogoutHTML(qw422016, can) -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 qt422016.ReleaseWriter(qw422016) -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 } -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 func LogoutHTML(can bool) string { -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 qb422016 := qt422016.AcquireByteBuffer() -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 WriteLogoutHTML(qb422016, can) -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 qs422016 := string(qb422016.B) -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 qt422016.ReleaseByteBuffer(qb422016) -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 return qs422016 -//line views/auth.qtpl:66 +//line views/auth.qtpl:68 } From 22420bf690804bde1d679fc22f3d39b696b9520f Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Tue, 23 Feb 2021 19:41:22 +0500 Subject: [PATCH 44/53] Move assets from templates to the assets module --- templates/asset.qtpl => assets/assets.qtpl | 0 .../asset.qtpl.go => assets/assets.qtpl.go | 180 +++++++++--------- {templates => assets}/default.css | 0 .../icon/gemini-protocol-icon.svg | 0 .../icon/gopher-protocol-icon.svg | 0 .../icon/http-protocol-icon.svg | 0 .../icon/mailto-protocol-icon.svg | 0 main.go | 14 +- 8 files changed, 97 insertions(+), 97 deletions(-) rename templates/asset.qtpl => assets/assets.qtpl (100%) rename templates/asset.qtpl.go => assets/assets.qtpl.go (86%) rename {templates => assets}/default.css (100%) rename {templates => assets}/icon/gemini-protocol-icon.svg (100%) rename {templates => assets}/icon/gopher-protocol-icon.svg (100%) rename {templates => assets}/icon/http-protocol-icon.svg (100%) rename {templates => assets}/icon/mailto-protocol-icon.svg (100%) diff --git a/templates/asset.qtpl b/assets/assets.qtpl similarity index 100% rename from templates/asset.qtpl rename to assets/assets.qtpl diff --git a/templates/asset.qtpl.go b/assets/assets.qtpl.go similarity index 86% rename from templates/asset.qtpl.go rename to assets/assets.qtpl.go index cfecdf5..83a3131 100644 --- a/templates/asset.qtpl.go +++ b/assets/assets.qtpl.go @@ -1,28 +1,28 @@ -// Code generated by qtc from "asset.qtpl". DO NOT EDIT. +// Code generated by qtc from "assets.qtpl". DO NOT EDIT. // See https://github.com/valyala/quicktemplate for details. -//line templates/asset.qtpl:1 -package templates +//line assets/assets.qtpl:1 +package assets -//line templates/asset.qtpl:1 +//line assets/assets.qtpl:1 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line templates/asset.qtpl:1 +//line assets/assets.qtpl:1 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line templates/asset.qtpl:1 +//line assets/assets.qtpl:1 func StreamDefaultCSS(qw422016 *qt422016.Writer) { -//line templates/asset.qtpl:1 +//line assets/assets.qtpl:1 qw422016.N().S(` `) -//line templates/asset.qtpl:2 +//line assets/assets.qtpl:2 qw422016.N().S(`.modal__title { font-size: 2rem; } .modal__confirmation-msg { margin: 0 0 .5rem 0; } .modal__action { display: inline-block; font-size: 1rem; padding: .25rem; border-radius: .25rem; } @@ -295,168 +295,168 @@ mark { background: rgba(130, 80, 30, 5); color: inherit; } .backlinks { display: none; } `) -//line templates/asset.qtpl:2 +//line assets/assets.qtpl:2 qw422016.N().S(` `) -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 } -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 func WriteDefaultCSS(qq422016 qtio422016.Writer) { -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 StreamDefaultCSS(qw422016) -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 qt422016.ReleaseWriter(qw422016) -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 } -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 func DefaultCSS() string { -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 qb422016 := qt422016.AcquireByteBuffer() -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 WriteDefaultCSS(qb422016) -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 qs422016 := string(qb422016.B) -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 qt422016.ReleaseByteBuffer(qb422016) -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 return qs422016 -//line templates/asset.qtpl:3 +//line assets/assets.qtpl:3 } // Next three are from https://remixicon.com/ -//line templates/asset.qtpl:6 +//line assets/assets.qtpl:6 func StreamIconHTTP(qw422016 *qt422016.Writer) { -//line templates/asset.qtpl:6 +//line assets/assets.qtpl:6 qw422016.N().S(` `) -//line templates/asset.qtpl:7 +//line assets/assets.qtpl:7 qw422016.N().S(` `) -//line templates/asset.qtpl:7 +//line assets/assets.qtpl:7 qw422016.N().S(` `) -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 } -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 func WriteIconHTTP(qq422016 qtio422016.Writer) { -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 StreamIconHTTP(qw422016) -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 qt422016.ReleaseWriter(qw422016) -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 } -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 func IconHTTP() string { -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 qb422016 := qt422016.AcquireByteBuffer() -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 WriteIconHTTP(qb422016) -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 qs422016 := string(qb422016.B) -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 qt422016.ReleaseByteBuffer(qb422016) -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 return qs422016 -//line templates/asset.qtpl:8 +//line assets/assets.qtpl:8 } -//line templates/asset.qtpl:10 +//line assets/assets.qtpl:10 func StreamIconGemini(qw422016 *qt422016.Writer) { -//line templates/asset.qtpl:10 +//line assets/assets.qtpl:10 qw422016.N().S(` `) -//line templates/asset.qtpl:11 +//line assets/assets.qtpl:11 qw422016.N().S(` `) -//line templates/asset.qtpl:11 +//line assets/assets.qtpl:11 qw422016.N().S(` `) -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 } -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 func WriteIconGemini(qq422016 qtio422016.Writer) { -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 StreamIconGemini(qw422016) -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 qt422016.ReleaseWriter(qw422016) -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 } -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 func IconGemini() string { -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 qb422016 := qt422016.AcquireByteBuffer() -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 WriteIconGemini(qb422016) -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 qs422016 := string(qb422016.B) -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 qt422016.ReleaseByteBuffer(qb422016) -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 return qs422016 -//line templates/asset.qtpl:12 +//line assets/assets.qtpl:12 } -//line templates/asset.qtpl:14 +//line assets/assets.qtpl:14 func StreamIconMailto(qw422016 *qt422016.Writer) { -//line templates/asset.qtpl:14 +//line assets/assets.qtpl:14 qw422016.N().S(` `) -//line templates/asset.qtpl:15 +//line assets/assets.qtpl:15 qw422016.N().S(` `) -//line templates/asset.qtpl:15 +//line assets/assets.qtpl:15 qw422016.N().S(` `) -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 } -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 func WriteIconMailto(qq422016 qtio422016.Writer) { -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 StreamIconMailto(qw422016) -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 qt422016.ReleaseWriter(qw422016) -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 } -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 func IconMailto() string { -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 qb422016 := qt422016.AcquireByteBuffer() -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 WriteIconMailto(qb422016) -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 qs422016 := string(qb422016.B) -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 qt422016.ReleaseByteBuffer(qb422016) -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 return qs422016 -//line templates/asset.qtpl:16 +//line assets/assets.qtpl:16 } // This is a modified version of https://www.svgrepo.com/svg/232085/rat -//line templates/asset.qtpl:19 +//line assets/assets.qtpl:19 func StreamIconGopher(qw422016 *qt422016.Writer) { -//line templates/asset.qtpl:19 +//line assets/assets.qtpl:19 qw422016.N().S(` `) -//line templates/asset.qtpl:20 +//line assets/assets.qtpl:20 qw422016.N().S(` `) -//line templates/asset.qtpl:20 +//line assets/assets.qtpl:20 qw422016.N().S(` `) -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 } -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 func WriteIconGopher(qq422016 qtio422016.Writer) { -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 qw422016 := qt422016.AcquireWriter(qq422016) -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 StreamIconGopher(qw422016) -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 qt422016.ReleaseWriter(qw422016) -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 } -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 func IconGopher() string { -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 qb422016 := qt422016.AcquireByteBuffer() -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 WriteIconGopher(qb422016) -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 qs422016 := string(qb422016.B) -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 qt422016.ReleaseByteBuffer(qb422016) -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 return qs422016 -//line templates/asset.qtpl:21 +//line assets/assets.qtpl:21 } diff --git a/templates/default.css b/assets/default.css similarity index 100% rename from templates/default.css rename to assets/default.css diff --git a/templates/icon/gemini-protocol-icon.svg b/assets/icon/gemini-protocol-icon.svg similarity index 100% rename from templates/icon/gemini-protocol-icon.svg rename to assets/icon/gemini-protocol-icon.svg diff --git a/templates/icon/gopher-protocol-icon.svg b/assets/icon/gopher-protocol-icon.svg similarity index 100% rename from templates/icon/gopher-protocol-icon.svg rename to assets/icon/gopher-protocol-icon.svg diff --git a/templates/icon/http-protocol-icon.svg b/assets/icon/http-protocol-icon.svg similarity index 100% rename from templates/icon/http-protocol-icon.svg rename to assets/icon/http-protocol-icon.svg diff --git a/templates/icon/mailto-protocol-icon.svg b/assets/icon/mailto-protocol-icon.svg similarity index 100% rename from templates/icon/mailto-protocol-icon.svg rename to assets/icon/mailto-protocol-icon.svg diff --git a/main.go b/main.go index 288ff7f..ba4ce5b 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,5 @@ //go:generate go get -u github.com/valyala/quicktemplate/qtc -//go:generate qtc -dir=templates +//go:generate qtc -dir=assets //go:generate qtc -dir=views package main @@ -12,10 +12,10 @@ import ( "os" "strings" + "github.com/bouncepaw/mycorrhiza/assets" "github.com/bouncepaw/mycorrhiza/history" "github.com/bouncepaw/mycorrhiza/hyphae" "github.com/bouncepaw/mycorrhiza/shroom" - "github.com/bouncepaw/mycorrhiza/templates" "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" "github.com/bouncepaw/mycorrhiza/views" @@ -102,7 +102,7 @@ func handlerStyle(w http.ResponseWriter, rq *http.Request) { http.ServeFile(w, rq, util.WikiDir+"/static/common.css") } else { w.Header().Set("Content-Type", "text/css;charset=utf-8") - w.Write([]byte(templates.DefaultCSS())) + w.Write([]byte(assets.DefaultCSS())) } if bytes, err := ioutil.ReadFile(util.WikiDir + "/static/custom.css"); err == nil { w.Write(bytes) @@ -126,13 +126,13 @@ func handlerIcon(w http.ResponseWriter, rq *http.Request) { w.Header().Set("Content-Type", "image/svg+xml") switch iconName { case "gemini": - w.Write([]byte(templates.IconGemini())) + w.Write([]byte(assets.IconGemini())) case "mailto": - w.Write([]byte(templates.IconMailto())) + w.Write([]byte(assets.IconMailto())) case "gopher": - w.Write([]byte(templates.IconGopher())) + w.Write([]byte(assets.IconGopher())) default: - w.Write([]byte(templates.IconHTTP())) + w.Write([]byte(assets.IconHTTP())) } } From a8a2735363ce19e39eec92152fb7effd95fa0a53 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Wed, 24 Feb 2021 22:34:42 +0500 Subject: [PATCH 45/53] Add the attachment tab --- assets/assets.qtpl.go | 7 +- assets/default.css | 5 + http_readers.go | 15 ++ main.go | 2 +- views/modal.qtpl | 2 +- views/modal.qtpl.go | 2 +- views/nav.qtpl | 1 + views/nav.qtpl.go | 213 ++++++++++----------- views/readers.qtpl | 90 +++++++-- views/readers.qtpl.go | 431 +++++++++++++++++++++++++++++------------- 10 files changed, 514 insertions(+), 254 deletions(-) diff --git a/assets/assets.qtpl.go b/assets/assets.qtpl.go index 83a3131..1b8fd71 100644 --- a/assets/assets.qtpl.go +++ b/assets/assets.qtpl.go @@ -23,7 +23,11 @@ func StreamDefaultCSS(qw422016 *qt422016.Writer) { qw422016.N().S(` `) //line assets/assets.qtpl:2 - qw422016.N().S(`.modal__title { font-size: 2rem; } + qw422016.N().S(`.amnt-grid { display: grid; grid-template-columns: 1fr 1fr; } +.upload-binary__input { display: block; margin: .25rem 0; } + +.modal__title { font-size: 2rem; } +.modal__title_small { font-size: 1.5rem; } .modal__confirmation-msg { margin: 0 0 .5rem 0; } .modal__action { display: inline-block; font-size: 1rem; padding: .25rem; border-radius: .25rem; } .modal__submit { border: 1px #999 solid; } @@ -56,6 +60,7 @@ header { width: 100%; margin-bottom: 1rem; } .backlinks__link { text-decoration: none; display: block; padding: .25rem; padding-left: 1.25rem; } @media screen and (max-width: 800px) { + .amnt-grid { grid-template-columns: 1fr; } .layout { grid-template-column: auto; grid-template-row: auto auto auto; } .main-width { width: 100%; } main { padding: 1rem; margin: 0; } diff --git a/assets/default.css b/assets/default.css index bc4f3e1..d785cfc 100644 --- a/assets/default.css +++ b/assets/default.css @@ -1,4 +1,8 @@ +.amnt-grid { display: grid; grid-template-columns: 1fr 1fr; } +.upload-binary__input { display: block; margin: .25rem 0; } + .modal__title { font-size: 2rem; } +.modal__title_small { font-size: 1.5rem; } .modal__confirmation-msg { margin: 0 0 .5rem 0; } .modal__action { display: inline-block; font-size: 1rem; padding: .25rem; border-radius: .25rem; } .modal__submit { border: 1px #999 solid; } @@ -31,6 +35,7 @@ header { width: 100%; margin-bottom: 1rem; } .backlinks__link { text-decoration: none; display: block; padding: .25rem; padding-left: 1.25rem; } @media screen and (max-width: 800px) { + .amnt-grid { grid-template-columns: 1fr; } .layout { grid-template-column: auto; grid-template-row: auto auto auto; } .main-width { width: 100%; } main { padding: 1rem; margin: 0; } diff --git a/http_readers.go b/http_readers.go index b7711c6..a75b682 100644 --- a/http_readers.go +++ b/http_readers.go @@ -24,6 +24,21 @@ func init() { http.HandleFunc("/text/", handlerText) http.HandleFunc("/binary/", handlerBinary) http.HandleFunc("/rev/", handlerRevision) + http.HandleFunc("/attachment/", handlerAttachment) +} + +func handlerAttachment(w http.ResponseWriter, rq *http.Request) { + log.Println(rq.URL) + var ( + hyphaName = HyphaNameFromRq(rq, "attachment") + h = hyphae.ByName(hyphaName) + u = user.FromRequest(rq) + ) + util.HTTP200Page(w, + views.BaseHTML( + fmt.Sprintf("Attachment of %s", util.BeautifulName(hyphaName)), + views.AttachmentMenuHTML(rq, h, u), + u)) } // handlerRevision displays a specific revision of text part a page diff --git a/main.go b/main.go index ba4ce5b..f8780b1 100644 --- a/main.go +++ b/main.go @@ -178,7 +178,7 @@ func main() { // See http_admin.go for /admin, /admin/* initAdmin() - // See http_readers.go for /page/, /hypha/, /text/, /binary/ + // See http_readers.go for /page/, /hypha/, /text/, /binary/, /attachment/ // See http_mutators.go for /upload-binary/, /upload-text/, /edit/, /delete-ask/, /delete-confirm/, /rename-ask/, /rename-confirm/, /unattach-ask/, /unattach-confirm/ // See http_auth.go for /login, /login-data, /logout, /logout-confirm // See http_history.go for /history/, /recent-changes diff --git a/views/modal.qtpl b/views/modal.qtpl index 8ca4ec6..bb1a559 100644 --- a/views/modal.qtpl +++ b/views/modal.qtpl @@ -16,7 +16,7 @@ {% func UnattachAskHTML(rq *http.Request, hyphaName string, isOld bool) %} {%= NavHTML(rq, hyphaName, "unattach-ask") %} {%= modalBegin( - "unattach-confirm", + "unattach", hyphaName, "", "Unattach "+util.BeautifulName(hyphaName)+"?") %} diff --git a/views/modal.qtpl.go b/views/modal.qtpl.go index 9e81e54..3efb837 100644 --- a/views/modal.qtpl.go +++ b/views/modal.qtpl.go @@ -94,7 +94,7 @@ func StreamUnattachAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaNam `) //line views/modal.qtpl:18 streammodalBegin(qw422016, - "unattach-confirm", + "unattach", hyphaName, "", "Unattach "+util.BeautifulName(hyphaName)+"?") diff --git a/views/nav.qtpl b/views/nav.qtpl index 900b8e1..cecdc63 100644 --- a/views/nav.qtpl +++ b/views/nav.qtpl @@ -12,6 +12,7 @@ type navEntry struct { var navEntries = []navEntry{ {"page", "Hypha"}, {"edit", "Edit"}, + {"attachment", "Attachment"}, {"history", "History"}, {"revision", "NOT REACHED"}, {"rename-ask", "Rename"}, diff --git a/views/nav.qtpl.go b/views/nav.qtpl.go index 82c062d..b1cabdb 100644 --- a/views/nav.qtpl.go +++ b/views/nav.qtpl.go @@ -40,6 +40,7 @@ type navEntry struct { var navEntries = []navEntry{ {"page", "Hypha"}, {"edit", "Edit"}, + {"attachment", "Attachment"}, {"history", "History"}, {"revision", "NOT REACHED"}, {"rename-ask", "Rename"}, @@ -47,268 +48,268 @@ var navEntries = []navEntry{ {"text", "Raw text"}, } -//line views/nav.qtpl:23 +//line views/nav.qtpl:24 func StreamNavHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, navType string, revisionHash ...string) { -//line views/nav.qtpl:23 +//line views/nav.qtpl:24 qw422016.N().S(` `) -//line views/nav.qtpl:25 +//line views/nav.qtpl:26 u := user.FromRequest(rq) -//line views/nav.qtpl:26 +//line views/nav.qtpl:27 qw422016.N().S(` `) -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 } -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 func WriteNavHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, navType string, revisionHash ...string) { -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 StreamNavHTML(qw422016, rq, hyphaName, navType, revisionHash...) -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 qt422016.ReleaseWriter(qw422016) -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 } -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 func NavHTML(rq *http.Request, hyphaName, navType string, revisionHash ...string) string { -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 qb422016 := qt422016.AcquireByteBuffer() -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 WriteNavHTML(qb422016, rq, hyphaName, navType, revisionHash...) -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 qs422016 := string(qb422016.B) -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 qt422016.ReleaseByteBuffer(qb422016) -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 return qs422016 -//line views/nav.qtpl:46 +//line views/nav.qtpl:47 } -//line views/nav.qtpl:48 +//line views/nav.qtpl:49 func StreamUserMenuHTML(qw422016 *qt422016.Writer, u *user.User) { -//line views/nav.qtpl:48 +//line views/nav.qtpl:49 qw422016.N().S(` `) -//line views/nav.qtpl:49 +//line views/nav.qtpl:50 if user.AuthUsed { -//line views/nav.qtpl:49 +//line views/nav.qtpl:50 qw422016.N().S(`
  • `) -//line views/nav.qtpl:51 +//line views/nav.qtpl:52 if u.Group == "anon" { -//line views/nav.qtpl:51 +//line views/nav.qtpl:52 qw422016.N().S(` Login `) -//line views/nav.qtpl:53 +//line views/nav.qtpl:54 } else { -//line views/nav.qtpl:53 +//line views/nav.qtpl:54 qw422016.N().S(` `) -//line views/nav.qtpl:54 +//line views/nav.qtpl:55 qw422016.E().S(u.Name) -//line views/nav.qtpl:54 +//line views/nav.qtpl:55 qw422016.N().S(` `) -//line views/nav.qtpl:55 +//line views/nav.qtpl:56 } -//line views/nav.qtpl:55 +//line views/nav.qtpl:56 qw422016.N().S(`
  • `) -//line views/nav.qtpl:57 +//line views/nav.qtpl:58 } -//line views/nav.qtpl:57 +//line views/nav.qtpl:58 qw422016.N().S(` `) -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 } -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 func WriteUserMenuHTML(qq422016 qtio422016.Writer, u *user.User) { -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 StreamUserMenuHTML(qw422016, u) -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 qt422016.ReleaseWriter(qw422016) -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 } -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 func UserMenuHTML(u *user.User) string { -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 qb422016 := qt422016.AcquireByteBuffer() -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 WriteUserMenuHTML(qb422016, u) -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 qs422016 := string(qb422016.B) -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 qt422016.ReleaseByteBuffer(qb422016) -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 return qs422016 -//line views/nav.qtpl:58 +//line views/nav.qtpl:59 } -//line views/nav.qtpl:60 +//line views/nav.qtpl:61 func StreamRelativeHyphaeHTML(qw422016 *qt422016.Writer, relatives string) { -//line views/nav.qtpl:60 +//line views/nav.qtpl:61 qw422016.N().S(` `) -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 } -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 func WriteRelativeHyphaeHTML(qq422016 qtio422016.Writer, relatives string) { -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 StreamRelativeHyphaeHTML(qw422016, relatives) -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 qt422016.ReleaseWriter(qw422016) -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 } -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 func RelativeHyphaeHTML(relatives string) string { -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 qb422016 := qt422016.AcquireByteBuffer() -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 WriteRelativeHyphaeHTML(qb422016, relatives) -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 qs422016 := string(qb422016.B) -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 qt422016.ReleaseByteBuffer(qb422016) -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 return qs422016 -//line views/nav.qtpl:65 +//line views/nav.qtpl:66 } -//line views/nav.qtpl:67 +//line views/nav.qtpl:68 func StreamSubhyphaeHTML(qw422016 *qt422016.Writer, subhyphae string) { -//line views/nav.qtpl:67 +//line views/nav.qtpl:68 qw422016.N().S(` `) -//line views/nav.qtpl:68 +//line views/nav.qtpl:69 if strings.TrimSpace(subhyphae) != "" { -//line views/nav.qtpl:68 +//line views/nav.qtpl:69 qw422016.N().S(`

    Subhyphae

    `) -//line views/nav.qtpl:77 +//line views/nav.qtpl:78 } -//line views/nav.qtpl:77 +//line views/nav.qtpl:78 qw422016.N().S(` `) -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 } -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 func WriteSubhyphaeHTML(qq422016 qtio422016.Writer, subhyphae string) { -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 StreamSubhyphaeHTML(qw422016, subhyphae) -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 qt422016.ReleaseWriter(qw422016) -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 } -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 func SubhyphaeHTML(subhyphae string) string { -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 qb422016 := qt422016.AcquireByteBuffer() -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 WriteSubhyphaeHTML(qb422016, subhyphae) -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 qs422016 := string(qb422016.B) -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 qt422016.ReleaseByteBuffer(qb422016) -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 return qs422016 -//line views/nav.qtpl:78 +//line views/nav.qtpl:79 } diff --git a/views/readers.qtpl b/views/readers.qtpl index 9bbdb9e..2a80c4f 100644 --- a/views/readers.qtpl +++ b/views/readers.qtpl @@ -1,10 +1,75 @@ {% import "net/http" %} +{% import "strings" %} {% import "path" %} +{% import "os" %} {% import "github.com/bouncepaw/mycorrhiza/hyphae" %} +{% import "github.com/bouncepaw/mycorrhiza/mimetype" %} +{% import "github.com/bouncepaw/mycorrhiza/tree" %} {% import "github.com/bouncepaw/mycorrhiza/user" %} {% import "github.com/bouncepaw/mycorrhiza/util" %} -{% import "github.com/bouncepaw/mycorrhiza/tree" %} + +{% func AttachmentMenuHTML(rq *http.Request, h *hyphae.Hypha, u *user.User) %} +{%= NavHTML(rq, h.Name, "attachment") %} +
    +
    +

    Attachment of {%s util.BeautifulName(h.Name) %}

    + {% if h.BinaryPath == "" %} +

    This hypha has no attachment, you can upload it here.

    + {% else %} +

    You can manage the hypha's attachment on this page.

    + {% endif %} + +
    + + {% if h.BinaryPath != "" %} + {% code + mime := mimetype.FromExtension(path.Ext(h.BinaryPath)) + fileinfo, err := os.Stat(h.BinaryPath) %} + {% if err == nil %} +
    + Stat + +

    MIME type: {%s mime %}

    +
    + {% endif %} + + {% if strings.HasPrefix(mime, "image/") %} +
    + Include + +
    img { {%s h.Name %} }
    +
    + {% endif %} + {% endif %} + + {% if u.CanProceed("upload-binary") %} + + {% endif %} + + {% if h.BinaryPath != "" && u.CanProceed("unattach-confirm") %} + + {% endif %} + +
    +
    +
    +{% endfunc %} If `contents` == "", a helpful message is shown instead. {% func HyphaHTML(rq *http.Request, h *hyphae.Hypha, contents string) %} @@ -18,6 +83,16 @@ If `contents` == "", a helpful message is shown instead. {%s= NaviTitleHTML(h) %} {% if contents == "" %}

    This hypha has no text. Why not create it?

    + {% if u := user.FromRequest(rq); (!user.AuthUsed || u.Group != "anon") && !h.Exists %} +
    + + + +
    +
    + {% endif %} {% else %} {%s= contents %} {% endif %} @@ -30,19 +105,6 @@ If `contents` == "", a helpful message is shown instead. {% endif %} -{% if u := user.FromRequest(rq); !user.AuthUsed || u.Group != "anon" %} -
    - {% if h.Exists && h.BinaryPath != "" %} - Unattach current attachment? - {% endif %} - -
    - - -
    -{% endif %} {%= SubhyphaeHTML(subhyphae) %}
    {%= RelativeHyphaeHTML(relatives) %} diff --git a/views/readers.qtpl.go b/views/readers.qtpl.go index fc358ff..4244b5c 100644 --- a/views/readers.qtpl.go +++ b/views/readers.qtpl.go @@ -8,276 +8,447 @@ package views import "net/http" //line views/readers.qtpl:2 +import "strings" + +//line views/readers.qtpl:3 import "path" //line views/readers.qtpl:4 -import "github.com/bouncepaw/mycorrhiza/hyphae" - -//line views/readers.qtpl:5 -import "github.com/bouncepaw/mycorrhiza/user" +import "os" //line views/readers.qtpl:6 -import "github.com/bouncepaw/mycorrhiza/util" +import "github.com/bouncepaw/mycorrhiza/hyphae" //line views/readers.qtpl:7 +import "github.com/bouncepaw/mycorrhiza/mimetype" + +//line views/readers.qtpl:8 import "github.com/bouncepaw/mycorrhiza/tree" -// If `contents` == "", a helpful message is shown instead. +//line views/readers.qtpl:9 +import "github.com/bouncepaw/mycorrhiza/user" //line views/readers.qtpl:10 +import "github.com/bouncepaw/mycorrhiza/util" + +//line views/readers.qtpl:12 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line views/readers.qtpl:10 +//line views/readers.qtpl:12 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line views/readers.qtpl:10 -func StreamHyphaHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, contents string) { -//line views/readers.qtpl:10 +//line views/readers.qtpl:12 +func StreamAttachmentMenuHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, u *user.User) { +//line views/readers.qtpl:12 qw422016.N().S(` `) -//line views/readers.qtpl:12 - relatives, subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.Name) - +//line views/readers.qtpl:13 + StreamNavHTML(qw422016, rq, h.Name, "attachment") //line views/readers.qtpl:13 qw422016.N().S(` +
    +
    +

    Attachment of `) +//line views/readers.qtpl:16 + qw422016.E().S(util.BeautifulName(h.Name)) +//line views/readers.qtpl:16 + qw422016.N().S(`

    + `) +//line views/readers.qtpl:17 + if h.BinaryPath == "" { +//line views/readers.qtpl:17 + qw422016.N().S(` +

    This hypha has no attachment, you can upload it here.

    + `) +//line views/readers.qtpl:19 + } else { +//line views/readers.qtpl:19 + qw422016.N().S(` +

    You can manage the hypha's attachment on this page.

    + `) +//line views/readers.qtpl:21 + } +//line views/readers.qtpl:21 + qw422016.N().S(` + +
    + + `) +//line views/readers.qtpl:25 + if h.BinaryPath != "" { +//line views/readers.qtpl:25 + qw422016.N().S(` + `) +//line views/readers.qtpl:27 + mime := mimetype.FromExtension(path.Ext(h.BinaryPath)) + fileinfo, err := os.Stat(h.BinaryPath) + +//line views/readers.qtpl:28 + qw422016.N().S(` + `) +//line views/readers.qtpl:29 + if err == nil { +//line views/readers.qtpl:29 + qw422016.N().S(` +
    + Stat + +

    MIME type: `) +//line views/readers.qtpl:33 + qw422016.E().S(mime) +//line views/readers.qtpl:33 + qw422016.N().S(`

    +
    + `) +//line views/readers.qtpl:35 + } +//line views/readers.qtpl:35 + qw422016.N().S(` + + `) +//line views/readers.qtpl:37 + if strings.HasPrefix(mime, "image/") { +//line views/readers.qtpl:37 + qw422016.N().S(` +
    + Include + +
    img { `)
    +//line views/readers.qtpl:41
    +			qw422016.E().S(h.Name)
    +//line views/readers.qtpl:41
    +			qw422016.N().S(` }
    +
    + `) +//line views/readers.qtpl:43 + } +//line views/readers.qtpl:43 + qw422016.N().S(` + `) +//line views/readers.qtpl:44 + } +//line views/readers.qtpl:44 + qw422016.N().S(` + + `) +//line views/readers.qtpl:46 + if u.CanProceed("upload-binary") { +//line views/readers.qtpl:46 + qw422016.N().S(` + + `) +//line views/readers.qtpl:57 + } +//line views/readers.qtpl:57 + qw422016.N().S(` + + `) +//line views/readers.qtpl:59 + if h.BinaryPath != "" && u.CanProceed("unattach-confirm") { +//line views/readers.qtpl:59 + qw422016.N().S(` + + `) +//line views/readers.qtpl:67 + } +//line views/readers.qtpl:67 + qw422016.N().S(` + +
    +
    +
    `) -//line views/readers.qtpl:14 +//line views/readers.qtpl:72 +} + +//line views/readers.qtpl:72 +func WriteAttachmentMenuHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha, u *user.User) { +//line views/readers.qtpl:72 + qw422016 := qt422016.AcquireWriter(qq422016) +//line views/readers.qtpl:72 + StreamAttachmentMenuHTML(qw422016, rq, h, u) +//line views/readers.qtpl:72 + qt422016.ReleaseWriter(qw422016) +//line views/readers.qtpl:72 +} + +//line views/readers.qtpl:72 +func AttachmentMenuHTML(rq *http.Request, h *hyphae.Hypha, u *user.User) string { +//line views/readers.qtpl:72 + qb422016 := qt422016.AcquireByteBuffer() +//line views/readers.qtpl:72 + WriteAttachmentMenuHTML(qb422016, rq, h, u) +//line views/readers.qtpl:72 + qs422016 := string(qb422016.B) +//line views/readers.qtpl:72 + qt422016.ReleaseByteBuffer(qb422016) +//line views/readers.qtpl:72 + return qs422016 +//line views/readers.qtpl:72 +} + +// If `contents` == "", a helpful message is shown instead. + +//line views/readers.qtpl:75 +func StreamHyphaHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, contents string) { +//line views/readers.qtpl:75 + qw422016.N().S(` +`) +//line views/readers.qtpl:77 + relatives, subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.Name) + +//line views/readers.qtpl:78 + qw422016.N().S(` +`) +//line views/readers.qtpl:79 StreamNavHTML(qw422016, rq, h.Name, "page") -//line views/readers.qtpl:14 +//line views/readers.qtpl:79 qw422016.N().S(`
    `) -//line views/readers.qtpl:18 +//line views/readers.qtpl:83 qw422016.N().S(NaviTitleHTML(h)) -//line views/readers.qtpl:18 +//line views/readers.qtpl:83 qw422016.N().S(` `) -//line views/readers.qtpl:19 +//line views/readers.qtpl:84 if contents == "" { -//line views/readers.qtpl:19 +//line views/readers.qtpl:84 qw422016.N().S(`

    This hypha has no text. Why not create it?

    `) -//line views/readers.qtpl:21 - } else { -//line views/readers.qtpl:21 - qw422016.N().S(` - `) -//line views/readers.qtpl:22 - qw422016.N().S(contents) -//line views/readers.qtpl:22 +//line views/readers.qtpl:86 + if u := user.FromRequest(rq); (!user.AuthUsed || u.Group != "anon") && !h.Exists { +//line views/readers.qtpl:86 + qw422016.N().S(` +
    + + + +
    +
    + `) +//line views/readers.qtpl:95 + } +//line views/readers.qtpl:95 qw422016.N().S(` `) -//line views/readers.qtpl:23 +//line views/readers.qtpl:96 + } else { +//line views/readers.qtpl:96 + qw422016.N().S(` + `) +//line views/readers.qtpl:97 + qw422016.N().S(contents) +//line views/readers.qtpl:97 + qw422016.N().S(` + `) +//line views/readers.qtpl:98 } -//line views/readers.qtpl:23 +//line views/readers.qtpl:98 qw422016.N().S(`
    `) -//line views/readers.qtpl:26 +//line views/readers.qtpl:101 if prevHyphaName != "" { -//line views/readers.qtpl:26 +//line views/readers.qtpl:101 qw422016.N().S(` `) -//line views/readers.qtpl:28 +//line views/readers.qtpl:103 } -//line views/readers.qtpl:28 +//line views/readers.qtpl:103 qw422016.N().S(` `) -//line views/readers.qtpl:29 +//line views/readers.qtpl:104 if nextHyphaName != "" { -//line views/readers.qtpl:29 +//line views/readers.qtpl:104 qw422016.N().S(` `) -//line views/readers.qtpl:31 +//line views/readers.qtpl:106 } -//line views/readers.qtpl:31 +//line views/readers.qtpl:106 qw422016.N().S(`
    `) -//line views/readers.qtpl:33 - if u := user.FromRequest(rq); !user.AuthUsed || u.Group != "anon" { -//line views/readers.qtpl:33 - qw422016.N().S(` -
    - `) -//line views/readers.qtpl:37 - if h.Exists && h.BinaryPath != "" { -//line views/readers.qtpl:37 - qw422016.N().S(` - Unattach current attachment? - `) -//line views/readers.qtpl:39 - } -//line views/readers.qtpl:39 - qw422016.N().S(` - -
    - - -
    -`) -//line views/readers.qtpl:45 - } -//line views/readers.qtpl:45 - qw422016.N().S(` -`) -//line views/readers.qtpl:46 +//line views/readers.qtpl:108 StreamSubhyphaeHTML(qw422016, subhyphae) -//line views/readers.qtpl:46 +//line views/readers.qtpl:108 qw422016.N().S(`
    `) -//line views/readers.qtpl:48 +//line views/readers.qtpl:110 StreamRelativeHyphaeHTML(qw422016, relatives) -//line views/readers.qtpl:48 +//line views/readers.qtpl:110 qw422016.N().S(` `) -//line views/readers.qtpl:49 +//line views/readers.qtpl:111 StreamBackLinksHTML(qw422016, h) -//line views/readers.qtpl:49 +//line views/readers.qtpl:111 qw422016.N().S(`
    `) -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 } -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 func WriteHyphaHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha, contents string) { -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 StreamHyphaHTML(qw422016, rq, h, contents) -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 qt422016.ReleaseWriter(qw422016) -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 } -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 func HyphaHTML(rq *http.Request, h *hyphae.Hypha, contents string) string { -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 qb422016 := qt422016.AcquireByteBuffer() -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 WriteHyphaHTML(qb422016, rq, h, contents) -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 qs422016 := string(qb422016.B) -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 qt422016.ReleaseByteBuffer(qb422016) -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 return qs422016 -//line views/readers.qtpl:51 +//line views/readers.qtpl:113 } -//line views/readers.qtpl:53 +//line views/readers.qtpl:115 func StreamRevisionHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, contents, revHash string) { -//line views/readers.qtpl:53 +//line views/readers.qtpl:115 qw422016.N().S(` `) -//line views/readers.qtpl:55 +//line views/readers.qtpl:117 relatives, subhyphae, _, _ := tree.Tree(h.Name) -//line views/readers.qtpl:56 +//line views/readers.qtpl:118 qw422016.N().S(` `) -//line views/readers.qtpl:57 +//line views/readers.qtpl:119 StreamNavHTML(qw422016, rq, h.Name, "revision", revHash) -//line views/readers.qtpl:57 +//line views/readers.qtpl:119 qw422016.N().S(`

    Please note that viewing binary parts of hyphae is not supported in history for now.

    `) -//line views/readers.qtpl:62 +//line views/readers.qtpl:124 qw422016.N().S(NaviTitleHTML(h)) -//line views/readers.qtpl:62 +//line views/readers.qtpl:124 qw422016.N().S(` `) -//line views/readers.qtpl:63 +//line views/readers.qtpl:125 qw422016.N().S(contents) -//line views/readers.qtpl:63 +//line views/readers.qtpl:125 qw422016.N().S(`
    `) -//line views/readers.qtpl:65 +//line views/readers.qtpl:127 StreamSubhyphaeHTML(qw422016, subhyphae) -//line views/readers.qtpl:65 +//line views/readers.qtpl:127 qw422016.N().S(`
    `) -//line views/readers.qtpl:67 +//line views/readers.qtpl:129 StreamRelativeHyphaeHTML(qw422016, relatives) -//line views/readers.qtpl:67 +//line views/readers.qtpl:129 qw422016.N().S(`
    `) -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 } -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 func WriteRevisionHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha, contents, revHash string) { -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 StreamRevisionHTML(qw422016, rq, h, contents, revHash) -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 qt422016.ReleaseWriter(qw422016) -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 } -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 func RevisionHTML(rq *http.Request, h *hyphae.Hypha, contents, revHash string) string { -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 qb422016 := qt422016.AcquireByteBuffer() -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 WriteRevisionHTML(qb422016, rq, h, contents, revHash) -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 qs422016 := string(qb422016.B) -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 qt422016.ReleaseByteBuffer(qb422016) -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 return qs422016 -//line views/readers.qtpl:69 +//line views/readers.qtpl:131 } From f33eefe5027a34484dbe6c42f9367449ee590f10 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Wed, 24 Feb 2021 22:37:34 +0500 Subject: [PATCH 46/53] Change the wording slightly --- views/readers.qtpl | 4 ++-- views/readers.qtpl.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/views/readers.qtpl b/views/readers.qtpl index 2a80c4f..08e6eb9 100644 --- a/views/readers.qtpl +++ b/views/readers.qtpl @@ -37,7 +37,7 @@ {% if strings.HasPrefix(mime, "image/") %}
    Include - +
    img { {%s h.Name %} }
    {% endif %} @@ -49,7 +49,7 @@ class="modal amnt-menu-block"> diff --git a/views/readers.qtpl.go b/views/readers.qtpl.go index 4244b5c..f9921e4 100644 --- a/views/readers.qtpl.go +++ b/views/readers.qtpl.go @@ -123,7 +123,7 @@ func StreamAttachmentMenuHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hy qw422016.N().S(`
    Include - +
    img { `)
     //line views/readers.qtpl:41
     			qw422016.E().S(h.Name)
    @@ -155,7 +155,7 @@ func StreamAttachmentMenuHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hy
     			class="modal amnt-menu-block">
     		
    
    From 9052f31e1faedccfdb98808588beea55c4a18560 Mon Sep 17 00:00:00 2001
    From: bouncepaw 
    Date: Fri, 26 Feb 2021 21:43:45 +0500
    Subject: [PATCH 47/53] Fix the bug with git locking
    
    ---
     history/operations.go |  8 ++++++--
     shroom/delete.go      |  2 +-
     shroom/rename.go      |  4 ++--
     shroom/unattach.go    |  5 +++--
     shroom/upload.go      | 16 ++++++++--------
     5 files changed, 20 insertions(+), 15 deletions(-)
    
    diff --git a/history/operations.go b/history/operations.go
    index b815c28..97e7aa7 100644
    --- a/history/operations.go
    +++ b/history/operations.go
    @@ -59,12 +59,16 @@ func (hop *HistoryOp) gitop(args ...string) *HistoryOp {
     	return hop
     }
     
    -// WithError appends the `err` to the list of errors.
    -func (hop *HistoryOp) WithError(err error) *HistoryOp {
    +// WithErr appends the `err` to the list of errors.
    +func (hop *HistoryOp) WithErr(err error) *HistoryOp {
     	hop.Errs = append(hop.Errs, err)
     	return hop
     }
     
    +func (hop *HistoryOp) WithErrAbort(err error) *HistoryOp {
    +	return hop.WithErr(err).Abort()
    +}
    +
     // WithFilesRemoved git-rm-s all passed `paths`. Paths can be rooted or not. Paths that are empty strings are ignored.
     func (hop *HistoryOp) WithFilesRemoved(paths ...string) *HistoryOp {
     	args := []string{"rm", "--quiet", "--"}
    diff --git a/shroom/delete.go b/shroom/delete.go
    index f88f017..2341351 100644
    --- a/shroom/delete.go
    +++ b/shroom/delete.go
    @@ -13,7 +13,7 @@ func DeleteHypha(u *user.User, h *hyphae.Hypha) (hop *history.HistoryOp, errtitl
     	hop = history.Operation(history.TypeDeleteHypha)
     
     	if err, errtitle := CanDelete(u, h); errtitle != "" {
    -		hop.WithError(err).Abort()
    +		hop.WithErrAbort(err)
     		return hop, errtitle
     	}
     
    diff --git a/shroom/rename.go b/shroom/rename.go
    index 7689538..1f861b2 100644
    --- a/shroom/rename.go
    +++ b/shroom/rename.go
    @@ -37,11 +37,11 @@ func RenameHypha(h *hyphae.Hypha, newHypha *hyphae.Hypha, recursive bool, u *use
     	hop = history.Operation(history.TypeRenameHypha)
     
     	if err, errtitle := CanRename(u, h); errtitle != "" {
    -		hop.WithError(err)
    +		hop.WithErrAbort(err)
     		return hop, errtitle
     	}
     	if err, errtitle := canRenameThisToThat(h, newHypha, u); errtitle != "" {
    -		hop.WithError(err)
    +		hop.WithErrAbort(err)
     		return hop, errtitle
     	}
     
    diff --git a/shroom/unattach.go b/shroom/unattach.go
    index 5ed5b0f..60f31e6 100644
    --- a/shroom/unattach.go
    +++ b/shroom/unattach.go
    @@ -14,7 +14,7 @@ func UnattachHypha(u *user.User, h *hyphae.Hypha) (hop *history.HistoryOp, errti
     	hop = history.Operation(history.TypeUnattachHypha)
     
     	if err, errtitle := CanUnattach(u, h); errtitle != "" {
    -		hop.WithError(err).Abort()
    +		hop.WithErrAbort(err)
     		return hop, errtitle
     	}
     
    @@ -26,7 +26,8 @@ func UnattachHypha(u *user.User, h *hyphae.Hypha) (hop *history.HistoryOp, errti
     
     	if len(hop.Errs) > 0 {
     		rejectUnattachLog(h, u, "fail")
    -		return hop.WithError(errors.New(fmt.Sprintf("Could not unattach this hypha due to internal server errors: %v", hop.Errs))), "Error"
    +		// FIXME: something may be wrong here
    +		return hop.WithErrAbort(errors.New(fmt.Sprintf("Could not unattach this hypha due to internal server errors: %v", hop.Errs))), "Error"
     	}
     
     	if h.BinaryPath != "" {
    diff --git a/shroom/upload.go b/shroom/upload.go
    index 08634b2..c72ec9a 100644
    --- a/shroom/upload.go
    +++ b/shroom/upload.go
    @@ -25,10 +25,10 @@ func UploadText(h *hyphae.Hypha, data []byte, u *user.User) (hop *history.Histor
     	}
     
     	if err, errtitle := CanEdit(u, h); err != nil {
    -		return hop.WithError(err), errtitle
    +		return hop.WithErrAbort(err), errtitle
     	}
     	if len(data) == 0 {
    -		return hop.WithError(errors.New("No data passed")), "Empty"
    +		return hop.WithErrAbort(errors.New("No data passed")), "Empty"
     	}
     
     	return uploadHelp(h, hop, ".myco", data, u)
    @@ -41,13 +41,13 @@ func UploadBinary(h *hyphae.Hypha, mime string, file multipart.File, u *user.Use
     	)
     
     	if err != nil {
    -		return hop.WithError(err), err.Error()
    +		return hop.WithErrAbort(err), err.Error()
     	}
     	if err, errtitle := CanAttach(u, h); err != nil {
    -		return hop.WithError(err), errtitle
    +		return hop.WithErrAbort(err), errtitle
     	}
     	if len(data) == 0 {
    -		return hop.WithError(errors.New("No data passed")), "Empty"
    +		return hop.WithErrAbort(errors.New("No data passed")), "Empty"
     	}
     
     	return uploadHelp(h, hop, mimetype.ToExtension(mime), data, u)
    @@ -64,16 +64,16 @@ func uploadHelp(h *hyphae.Hypha, hop *history.HistoryOp, ext string, data []byte
     	}
     
     	if err := os.MkdirAll(filepath.Dir(fullPath), 0777); err != nil {
    -		return hop.WithError(err), err.Error()
    +		return hop.WithErrAbort(err), err.Error()
     	}
     
     	if err := ioutil.WriteFile(fullPath, data, 0644); err != nil {
    -		return hop.WithError(err), err.Error()
    +		return hop.WithErrAbort(err), err.Error()
     	}
     
     	if h.Exists && *originalFullPath != fullPath && *originalFullPath != "" {
     		if err := history.Rename(*originalFullPath, fullPath); err != nil {
    -			return hop.WithError(err), err.Error()
    +			return hop.WithErrAbort(err), err.Error()
     		}
     		log.Println("Move", *originalFullPath, "to", fullPath)
     	}
    
    From 2d14d3060328ba3d1b3d7ee046d405516b7e7a45 Mon Sep 17 00:00:00 2001
    From: bouncepaw 
    Date: Fri, 26 Feb 2021 21:45:52 +0500
    Subject: [PATCH 48/53] Rename Makefile targets
    
    ---
     Makefile | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/Makefile b/Makefile
    index f1d598f..0b9db7e 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -1,10 +1,10 @@
     run: build
     	./mycorrhiza metarrhiza
     
    -run_with_fixed_auth: build
    +auth_run: build
     	./mycorrhiza -auth-method fixed metarrhiza
     
    -run_with_gemini: build
    +gemini_run: build
     	./mycorrhiza -gemini-cert-path "." metarrhiza
     
     build:
    
    From f45758cb0eb8f7678298202b0ade80446f345085 Mon Sep 17 00:00:00 2001
    From: bouncepaw 
    Date: Sat, 27 Feb 2021 13:42:32 +0500
    Subject: [PATCH 49/53] Show only stems of names in the relative hyphae block
    
    ---
     tree/tree.go | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/tree/tree.go b/tree/tree.go
    index ab56d5f..dc3cf38 100644
    --- a/tree/tree.go
    +++ b/tree/tree.go
    @@ -112,7 +112,7 @@ func Tree(hyphaName string) (relatives, subhyphae, prev, next string) {
     	for i, s := range siblings {
     		if s.name == hyphaName {
     			I = i
    -			relatives += fmt.Sprintf(`
  • %s
  • `, util.BeautifulName(hyphaName)) + relatives += fmt.Sprintf(`
  • %s
  • `, util.BeautifulName(path.Base(hyphaName))) } else { relatives += s.asHTML() } From fbf94975aabd7e922ba7a2aa6066e112ebb307f6 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Tue, 2 Mar 2021 21:36:57 +0500 Subject: [PATCH 50/53] Add anchor links --- assets/assets.qtpl.go | 8 +++----- assets/default.css | 8 +++----- hyphae/hyphae.go | 35 ++++++++++++++++++++++++++++++++++- link/link.go | 8 +++++++- markup/lexer.go | 5 ++++- shroom/rename.go | 4 ++-- util/util.go | 19 +++++++++++++++++++ 7 files changed, 72 insertions(+), 15 deletions(-) diff --git a/assets/assets.qtpl.go b/assets/assets.qtpl.go index 1b8fd71..160549b 100644 --- a/assets/assets.qtpl.go +++ b/assets/assets.qtpl.go @@ -134,6 +134,9 @@ blockquote { margin-left: 0; padding-left: 1rem; } article { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; line-height: 150%; } main h1, main h2, main h3, main h4, main h5, main h6 { margin: 1.5rem 0 0 0; } +.heading__link { text-decoration: none; display: inline-block; } +.heading__link::after { width: 1rem; content: "§"; color: transparent; } +.heading__link:hover::after, .heading__link:active::after { color: #999; } article p { margin: .5rem 0; } article ul, ol { padding-left: 1.5rem; margin: .5rem 0; } article code { padding: .1rem .3rem; border-radius: .25rem; font-size: 90%; } @@ -291,12 +294,7 @@ mark { background: rgba(130, 80, 30, 5); color: inherit; } @media screen and (max-width: 800px) { .hypha-tabs { background-color: #232323; } } -@media screen and (min-width: 801px) { - /* .hypha-tabs__tab { border: 1px #ddd solid; } */ - /* .hypha-tabs__tab_active { border-bottom: 1px white solid; } */ } -} - .backlinks { display: none; } `) diff --git a/assets/default.css b/assets/default.css index d785cfc..9c93b48 100644 --- a/assets/default.css +++ b/assets/default.css @@ -109,6 +109,9 @@ blockquote { margin-left: 0; padding-left: 1rem; } article { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; line-height: 150%; } main h1, main h2, main h3, main h4, main h5, main h6 { margin: 1.5rem 0 0 0; } +.heading__link { text-decoration: none; display: inline-block; } +.heading__link::after { width: 1rem; content: "§"; color: transparent; } +.heading__link:hover::after, .heading__link:active::after { color: #999; } article p { margin: .5rem 0; } article ul, ol { padding-left: 1.5rem; margin: .5rem 0; } article code { padding: .1rem .3rem; border-radius: .25rem; font-size: 90%; } @@ -266,11 +269,6 @@ mark { background: rgba(130, 80, 30, 5); color: inherit; } @media screen and (max-width: 800px) { .hypha-tabs { background-color: #232323; } } -@media screen and (min-width: 801px) { - /* .hypha-tabs__tab { border: 1px #ddd solid; } */ - /* .hypha-tabs__tab_active { border-bottom: 1px white solid; } */ } -} - .backlinks { display: none; } diff --git a/hyphae/hyphae.go b/hyphae/hyphae.go index ce2a3d9..59e2763 100644 --- a/hyphae/hyphae.go +++ b/hyphae/hyphae.go @@ -88,6 +88,10 @@ func (h *Hypha) Delete() { DecrementCount() byNamesMutex.Unlock() h.Unlock() + + for _, outlinkHypha := range h.OutLinks { + outlinkHypha.DropBackLink(h) + } } func (h *Hypha) RenameTo(newName string) { @@ -113,7 +117,16 @@ func (h *Hypha) MergeIn(oh *Hypha) { } } -// Link related stuff: +// ## Link related stuff +// Notes in pseudocode and whatnot: +// * (Reader h) does not mutate h => safe +// * (Rename h) reuses the same hypha object => safe +// * (Unattach h) and (Attach h) do not change (Backlinks h) => safe + +// * (Delete h) does not change (Backlinks h), but changes (Outlinks h), removing h from them => make it safe +// * (Unattach h) and (Attach h) => h may start or stop existing => may change (Outlinks h) => make it safe +// * (Edit h) => h may start existing => may change (Backlinks h) => make it safe +// * (Edit h) may add or remove h to or from (Outlinks h) => make it safe func (h *Hypha) AddOutLink(oh *Hypha) (added bool) { h.Lock() @@ -140,3 +153,23 @@ func (h *Hypha) AddBackLink(bh *Hypha) (added bool) { h.BackLinks = append(h.BackLinks, bh) return true } + +func (h *Hypha) DropBackLink(bh *Hypha) { + h.Lock() + defer h.Unlock() + + if len(h.BackLinks) <= 1 { + h.BackLinks = make([]*Hypha, 0) + return + } + lastBackLinkIndex := len(h.BackLinks) + for i, backlink := range h.BackLinks { + if backlink == bh { + if i != lastBackLinkIndex { + h.BackLinks[i] = h.BackLinks[lastBackLinkIndex] + } + h.BackLinks = h.BackLinks[:lastBackLinkIndex] + return + } + } +} diff --git a/link/link.go b/link/link.go index 8771ca9..6fe3323 100644 --- a/link/link.go +++ b/link/link.go @@ -32,6 +32,8 @@ type Link struct { Kind LinkType DestinationUnknown bool + // #... + Anchor string Protocol string // How the link address looked originally in source text. SrcAddress string @@ -66,7 +68,7 @@ func (l *Link) Href() string { case LinkExternal, LinkLocalRoot: return l.Address default: - return "/hypha/" + l.Address + return "/hypha/" + l.Address + l.Anchor } } @@ -117,6 +119,10 @@ func From(address, display, hyphaName string) *Link { case strings.HasPrefix(address, "../"): link.Kind = LinkLocalHypha link.Address = util.CanonicalName(path.Join(path.Dir(hyphaName), address[3:])) + case strings.HasPrefix(address, "#"): + link.Kind = LinkLocalHypha + link.Address = util.CanonicalName(hyphaName) + link.Anchor = address default: link.Kind = LinkLocalHypha link.Address = util.CanonicalName(address) diff --git a/markup/lexer.go b/markup/lexer.go index 607393f..ef178b0 100644 --- a/markup/lexer.go +++ b/markup/lexer.go @@ -4,6 +4,8 @@ import ( "fmt" "html" "strings" + + "github.com/bouncepaw/mycorrhiza/util" ) // HyphaExists holds function that checks that a hypha is present. @@ -83,7 +85,8 @@ func lineToAST(line string, state *GemLexerState, ast *[]Line) { return strings.HasPrefix(line, token) } addHeading := func(i int) { - addLine(fmt.Sprintf("%s", i, state.id, ParagraphToHtml(state.name, line[i+1:]), i)) + id := util.LettersNumbersOnly(line[i+1:]) + addLine(fmt.Sprintf(`%s`, i, state.id, ParagraphToHtml(state.name, line[i+1:]), id, id, i)) } // Beware! Usage of goto. Some may say it is considered evil but in this case it helped to make a better-structured code. diff --git a/shroom/rename.go b/shroom/rename.go index 1f861b2..a2d44da 100644 --- a/shroom/rename.go +++ b/shroom/rename.go @@ -89,7 +89,7 @@ func renamingPairs(hyphaeToRename []*hyphae.Hypha, replaceName func(string) stri renameMap := make(map[string]string) newNames := make([]string, len(hyphaeToRename)) for _, h := range hyphaeToRename { - h.RLock() + h.Lock() newNames = append(newNames, replaceName(h.Name)) if h.TextPath != "" { renameMap[h.TextPath] = replaceName(h.TextPath) @@ -97,7 +97,7 @@ func renamingPairs(hyphaeToRename []*hyphae.Hypha, replaceName func(string) stri if h.BinaryPath != "" { renameMap[h.BinaryPath] = replaceName(h.BinaryPath) } - h.RUnlock() + h.Unlock() } if firstFailure, ok := hyphae.AreFreeNames(newNames...); !ok { return nil, errors.New("Hypha " + firstFailure + " already exists") diff --git a/util/util.go b/util/util.go index d7b90a4..6b7590f 100644 --- a/util/util.go +++ b/util/util.go @@ -6,6 +6,7 @@ import ( "net/http" "regexp" "strings" + "unicode" ) var ( @@ -22,6 +23,24 @@ var ( GeminiCertPath string ) +// LettersNumbersOnly keeps letters and numbers only in the given string. +func LettersNumbersOnly(s string) string { + var ( + ret strings.Builder + usedUnderscore bool + ) + for _, r := range s { + if unicode.IsLetter(r) || unicode.IsNumber(r) { + ret.WriteRune(r) + usedUnderscore = false + } else if !usedUnderscore { + ret.WriteRune('_') + usedUnderscore = true + } + } + return strings.Trim(ret.String(), "_") +} + // ShorterPath is used by handlerList to display shorter path to the files. It simply strips WikiDir. func ShorterPath(path string) string { if strings.HasPrefix(path, WikiDir) { From 8dfd2fcf9bdfe9957106d4ded4cec39b864ce8af Mon Sep 17 00:00:00 2001 From: hugmouse Date: Fri, 5 Mar 2021 14:34:56 +0800 Subject: [PATCH 51/53] Fix lexer for "----" (
    ) case The point is that there may be another character in the string. For example, a space or a line break. Because we check the whole string, not the first 4 characters - we can ignore the variant where it can be "----\s" or "----\r\n" and make the wrong markup. Alternatively: use `startsWith("----")`, but this is a bit more expensive operation. --- markup/lexer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markup/lexer.go b/markup/lexer.go index 607393f..fbd87fc 100644 --- a/markup/lexer.go +++ b/markup/lexer.go @@ -235,7 +235,7 @@ normalState: case startsWith("<="): addParagraphIfNeeded() addLine(parseTransclusion(line, state.name)) - case line == "----": + case line[:4] == "----": addParagraphIfNeeded() *ast = append(*ast, Line{id: -1, contents: "
    "}) case MatchesImg(line): From 62c616985d8bb70898fc13093d2bccb454ea82bd Mon Sep 17 00:00:00 2001 From: hugmouse Date: Fri, 5 Mar 2021 16:29:39 +0800 Subject: [PATCH 52/53] Replace old method with new that is a little overcomplicated --- markup/hr.go | 34 ++++++++++++++++++++++++++++++++++ markup/lexer.go | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 markup/hr.go diff --git a/markup/hr.go b/markup/hr.go new file mode 100644 index 0000000..278138a --- /dev/null +++ b/markup/hr.go @@ -0,0 +1,34 @@ +package markup + +import ( + "unicode" +) + +// MatchesHorizontalLine checks if the string can be interpreted as suitable for rendering as
    . +// +// The rule is: if there are more than 4 characters "-" in the string, then make it a horizontal line. +// Otherwise it is a paragraph (

    ). +func MatchesHorizontalLine(line string) bool { + counter := 0 + + // Check initially that the symbol is "-". If it is not a "-", it is most likely a space or another character. + // With unicode.IsLetter() we can separate spaces and characters. + for _, ch := range line { + if ch == '-' { + counter++ + continue + } + // If we bump into any other character (letter) in the line, it is immediately an incorrect horizontal line. + // There is no point in counting further, we end the loop. + if unicode.IsLetter(ch) { + counter = 0 + break + } + } + + if counter >= 4 { + return true + } + + return false +} diff --git a/markup/lexer.go b/markup/lexer.go index fbd87fc..bf077e7 100644 --- a/markup/lexer.go +++ b/markup/lexer.go @@ -235,7 +235,7 @@ normalState: case startsWith("<="): addParagraphIfNeeded() addLine(parseTransclusion(line, state.name)) - case line[:4] == "----": + case MatchesHorizontalLine(line): addParagraphIfNeeded() *ast = append(*ast, Line{id: -1, contents: "


    "}) case MatchesImg(line): From f6a41b4818d854543f851aca8d423d9e7103d941 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Fri, 5 Mar 2021 14:39:33 +0500 Subject: [PATCH 53/53] Some adjusting before merging --- README.md | 3 +++ views/stuff.qtpl | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d092c4c..d7269e6 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ Options: What auth method to use. Variants: "none", "fixed" (default "none") -fixed-credentials-path string Used when -auth-method=fixed. Path to file with user credentials. (default "mycocredentials.json") + -gemini-cert-path string + Directory where you store Gemini certificates. Leave empty if you don't want to use Gemini. -header-links-hypha string Optional hypha that overrides the header links -home string @@ -57,6 +59,7 @@ Options: * Hyphae can be renamed (recursive renaming of subhyphae is also supported) * Light on resources * Authorization with pre-set credentials +* Basic Gemini protocol support ## Contributing Help is always needed. We have a [tg chat](https://t.me/mycorrhizadev) where some development is coordinated. You can also sponsor on [boosty](https://boosty.to/bouncepaw). Feel free to open an issue or contact directly. diff --git a/views/stuff.qtpl b/views/stuff.qtpl index 5fbdc25..4359734 100644 --- a/views/stuff.qtpl +++ b/views/stuff.qtpl @@ -97,7 +97,7 @@ for u := range user.YieldUsers() {

    About {%s util.SiteName %}