From b299d10d42f221d2e621569a414c3a8fdf1250df Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Wed, 22 Sep 2021 22:08:17 +0300 Subject: [PATCH 1/3] Migrate to Mycomarkup v2.1.0 The bug related to image descriptions has been resolved!! --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 00311a3..3d9a9bc 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/bouncepaw/mycorrhiza go 1.16 require ( - github.com/bouncepaw/mycomarkup/v2 v2.0.2 + github.com/bouncepaw/mycomarkup/v2 v2.1.0 github.com/go-ini/ini v1.62.0 github.com/gorilla/feeds v1.1.1 github.com/gorilla/mux v1.8.0 @@ -17,7 +17,7 @@ require ( ) // Use this trick to test mycomarkup: -// replace github.com/bouncepaw/mycomarkup/v2 v2.0.0 => "/Users/bouncepaw/GolandProjects/mycomarkup" +// replace github.com/bouncepaw/mycomarkup/v2 v2.1.0 => "/Users/bouncepaw/GolandProjects/mycomarkup" // Use this utility every time Mycomarkup gets broken: // https://github.com/marwan-at-work/mod diff --git a/go.sum b/go.sum index f5e8b57..975f8ad 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= -github.com/bouncepaw/mycomarkup/v2 v2.0.2 h1:BT7waogdo7KH7PVqksfmj60j8MFCcmu998oKaPnTfh0= -github.com/bouncepaw/mycomarkup/v2 v2.0.2/go.mod h1:sIvtvJFGG61ZeSUC+fNBrFmrQ2xBpTMZezk/QtxiQbk= +github.com/bouncepaw/mycomarkup/v2 v2.1.0 h1:9ZtgiovBaL9xXLGLoXQG8Jgb1VtZ3mlyU5qPn3BGx+4= +github.com/bouncepaw/mycomarkup/v2 v2.1.0/go.mod h1:sIvtvJFGG61ZeSUC+fNBrFmrQ2xBpTMZezk/QtxiQbk= github.com/go-ini/ini v1.62.0 h1:7VJT/ZXjzqSrvtraFp4ONq80hTcRQth1c9ZnQ3uNQvU= github.com/go-ini/ini v1.62.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= From 71b404c4f07e7460bd99831108789bc57e899e57 Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Thu, 23 Sep 2021 12:17:50 +0300 Subject: [PATCH 2/3] Write docs for prevnext --- help/en/prevnext.myco | 19 +++ views/readers.qtpl | 2 + views/readers.qtpl.go | 216 +++++++++++++------------- views/stuff.qtpl | 1 + views/stuff.qtpl.go | 343 +++++++++++++++++++++--------------------- 5 files changed, 303 insertions(+), 278 deletions(-) create mode 100644 help/en/prevnext.myco diff --git a/help/en/prevnext.myco b/help/en/prevnext.myco new file mode 100644 index 0000000..c943d17 --- /dev/null +++ b/help/en/prevnext.myco @@ -0,0 +1,19 @@ +# Previous/next +Under every hypha there is a **previous/next** section with quick links to previous and next hyphae alphabetically. + +This design encourages you to name your hyphae in such a way that clicking through these links would make sense. For example, if you are storing pages of a book, you should name them //p01//, //p02//, //p03//, etc. + +It is impossible to change what hyphae are linked in this section. If you want to provide a different means of sequential navigation, just place some links by yourself. + +## Hotkeys +Press `n` to go to the **n**ext page, press `p` to go to the **p**revious page. + +## For administrators: how to remove these links +For some wikis, these links make little or no sense. In this case, it is better to hide them. + +In file `your-wiki/static/custom.css` write this: +```css +.prevnext { display: none; } +``` + +The section would still be there, but no one will see it. The hotkeys will still work. \ No newline at end of file diff --git a/views/readers.qtpl b/views/readers.qtpl index 935ab3b..3b597f6 100644 --- a/views/readers.qtpl +++ b/views/readers.qtpl @@ -74,6 +74,8 @@ {% endfunc %} If `contents` == "", a helpful message is shown instead. + +If you rename .prevnext, change the docs too. {% func HyphaHTML(rq *http.Request, h *hyphae.Hypha, contents string) %} {% code siblings, subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.Name) diff --git a/views/readers.qtpl.go b/views/readers.qtpl.go index 283b972..02a66b7 100644 --- a/views/readers.qtpl.go +++ b/views/readers.qtpl.go @@ -222,17 +222,19 @@ func AttachmentMenuHTML(rq *http.Request, h *hyphae.Hypha, u *user.User) string } // If `contents` == "", a helpful message is shown instead. +// +// If you rename .prevnext, change the docs too. -//line views/readers.qtpl:77 +//line views/readers.qtpl:79 func StreamHyphaHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, contents string) { -//line views/readers.qtpl:77 +//line views/readers.qtpl:79 qw422016.N().S(` `) -//line views/readers.qtpl:79 +//line views/readers.qtpl:81 siblings, subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.Name) u := user.FromRequest(rq) -//line views/readers.qtpl:81 +//line views/readers.qtpl:83 qw422016.N().S(`
@@ -241,265 +243,265 @@ func StreamHyphaHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hyph
`) -//line views/readers.qtpl:88 +//line views/readers.qtpl:90 if u.CanProceed("edit") { -//line views/readers.qtpl:88 +//line views/readers.qtpl:90 qw422016.N().S(``) -//line views/readers.qtpl:90 +//line views/readers.qtpl:92 } -//line views/readers.qtpl:90 +//line views/readers.qtpl:92 qw422016.N().S(` `) -//line views/readers.qtpl:91 +//line views/readers.qtpl:93 qw422016.N().S(NaviTitleHTML(h)) -//line views/readers.qtpl:91 +//line views/readers.qtpl:93 qw422016.N().S(` `) -//line views/readers.qtpl:92 +//line views/readers.qtpl:94 if h.Exists { -//line views/readers.qtpl:92 +//line views/readers.qtpl:94 qw422016.N().S(` `) -//line views/readers.qtpl:93 +//line views/readers.qtpl:95 qw422016.N().S(contents) -//line views/readers.qtpl:93 +//line views/readers.qtpl:95 qw422016.N().S(` `) -//line views/readers.qtpl:94 +//line views/readers.qtpl:96 } else { -//line views/readers.qtpl:94 +//line views/readers.qtpl:96 qw422016.N().S(` `) -//line views/readers.qtpl:95 +//line views/readers.qtpl:97 streamnonExistentHyphaNotice(qw422016, h, u) -//line views/readers.qtpl:95 +//line views/readers.qtpl:97 qw422016.N().S(` `) -//line views/readers.qtpl:96 +//line views/readers.qtpl:98 } -//line views/readers.qtpl:96 +//line views/readers.qtpl:98 qw422016.N().S(`
`) -//line views/readers.qtpl:99 +//line views/readers.qtpl:101 if prevHyphaName != "" { -//line views/readers.qtpl:99 +//line views/readers.qtpl:101 qw422016.N().S(` `) -//line views/readers.qtpl:101 +//line views/readers.qtpl:103 } -//line views/readers.qtpl:101 +//line views/readers.qtpl:103 qw422016.N().S(` `) -//line views/readers.qtpl:102 +//line views/readers.qtpl:104 if nextHyphaName != "" { -//line views/readers.qtpl:102 +//line views/readers.qtpl:104 qw422016.N().S(` `) -//line views/readers.qtpl:104 +//line views/readers.qtpl:106 } -//line views/readers.qtpl:104 +//line views/readers.qtpl:106 qw422016.N().S(`
`) -//line views/readers.qtpl:106 +//line views/readers.qtpl:108 StreamSubhyphaeHTML(qw422016, subhyphae) -//line views/readers.qtpl:106 +//line views/readers.qtpl:108 qw422016.N().S(`
`) -//line views/readers.qtpl:111 +//line views/readers.qtpl:113 streamhyphaInfo(qw422016, rq, h) -//line views/readers.qtpl:111 +//line views/readers.qtpl:113 qw422016.N().S(`
`) -//line views/readers.qtpl:114 +//line views/readers.qtpl:116 streamsiblingHyphaeHTML(qw422016, siblings) -//line views/readers.qtpl:114 +//line views/readers.qtpl:116 qw422016.N().S(` `) -//line views/readers.qtpl:116 +//line views/readers.qtpl:118 streamviewScripts(qw422016) -//line views/readers.qtpl:116 +//line views/readers.qtpl:118 qw422016.N().S(` `) -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 } -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 func WriteHyphaHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha, contents string) { -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 StreamHyphaHTML(qw422016, rq, h, contents) -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 qt422016.ReleaseWriter(qw422016) -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 } -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 func HyphaHTML(rq *http.Request, h *hyphae.Hypha, contents string) string { -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 qb422016 := qt422016.AcquireByteBuffer() -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 WriteHyphaHTML(qb422016, rq, h, contents) -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 qs422016 := string(qb422016.B) -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 qt422016.ReleaseByteBuffer(qb422016) -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 return qs422016 -//line views/readers.qtpl:117 +//line views/readers.qtpl:119 } -//line views/readers.qtpl:119 +//line views/readers.qtpl:121 func StreamRevisionHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha, contents, revHash string) { -//line views/readers.qtpl:119 +//line views/readers.qtpl:121 qw422016.N().S(` `) -//line views/readers.qtpl:121 +//line views/readers.qtpl:123 siblings, subhyphae, _, _ := tree.Tree(h.Name) -//line views/readers.qtpl:122 +//line views/readers.qtpl:124 qw422016.N().S(`

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

`) -//line views/readers.qtpl:127 +//line views/readers.qtpl:129 qw422016.N().S(NaviTitleHTML(h)) -//line views/readers.qtpl:127 +//line views/readers.qtpl:129 qw422016.N().S(` `) -//line views/readers.qtpl:128 +//line views/readers.qtpl:130 qw422016.N().S(contents) -//line views/readers.qtpl:128 +//line views/readers.qtpl:130 qw422016.N().S(`
`) -//line views/readers.qtpl:130 +//line views/readers.qtpl:132 StreamSubhyphaeHTML(qw422016, subhyphae) -//line views/readers.qtpl:130 +//line views/readers.qtpl:132 qw422016.N().S(`
`) -//line views/readers.qtpl:132 +//line views/readers.qtpl:134 streamsiblingHyphaeHTML(qw422016, siblings) -//line views/readers.qtpl:132 +//line views/readers.qtpl:134 qw422016.N().S(`
`) -//line views/readers.qtpl:134 +//line views/readers.qtpl:136 streamviewScripts(qw422016) -//line views/readers.qtpl:134 +//line views/readers.qtpl:136 qw422016.N().S(` `) -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 } -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 func WriteRevisionHTML(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha, contents, revHash string) { -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 StreamRevisionHTML(qw422016, rq, h, contents, revHash) -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 qt422016.ReleaseWriter(qw422016) -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 } -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 func RevisionHTML(rq *http.Request, h *hyphae.Hypha, contents, revHash string) string { -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 qb422016 := qt422016.AcquireByteBuffer() -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 WriteRevisionHTML(qb422016, rq, h, contents, revHash) -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 qs422016 := string(qb422016.B) -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 qt422016.ReleaseByteBuffer(qb422016) -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 return qs422016 -//line views/readers.qtpl:135 +//line views/readers.qtpl:137 } -//line views/readers.qtpl:137 +//line views/readers.qtpl:139 func streamviewScripts(qw422016 *qt422016.Writer) { -//line views/readers.qtpl:137 +//line views/readers.qtpl:139 qw422016.N().S(` `) -//line views/readers.qtpl:138 +//line views/readers.qtpl:140 for _, scriptPath := range cfg.ViewScripts { -//line views/readers.qtpl:138 +//line views/readers.qtpl:140 qw422016.N().S(` `) -//line views/readers.qtpl:140 +//line views/readers.qtpl:142 } -//line views/readers.qtpl:140 +//line views/readers.qtpl:142 qw422016.N().S(` `) -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 } -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 func writeviewScripts(qq422016 qtio422016.Writer) { -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 streamviewScripts(qw422016) -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 qt422016.ReleaseWriter(qw422016) -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 } -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 func viewScripts() string { -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 qb422016 := qt422016.AcquireByteBuffer() -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 writeviewScripts(qb422016) -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 qs422016 := string(qb422016.B) -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 qt422016.ReleaseByteBuffer(qb422016) -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 return qs422016 -//line views/readers.qtpl:141 +//line views/readers.qtpl:143 } diff --git a/views/stuff.qtpl b/views/stuff.qtpl index 644484b..6ced8c9 100644 --- a/views/stuff.qtpl +++ b/views/stuff.qtpl @@ -165,6 +165,7 @@ It outputs a poorly formatted JSON, but it works and is valid.
  • Mycomarkup
  • Interface
      +
    • Previous/next
    • Top bar
    • Sibling hyphae
    • ...
    • diff --git a/views/stuff.qtpl.go b/views/stuff.qtpl.go index c24c69b..3dec1e1 100644 --- a/views/stuff.qtpl.go +++ b/views/stuff.qtpl.go @@ -565,6 +565,7 @@ func streamhelpTopicsHTML(qw422016 *qt422016.Writer) {
    • Mycomarkup
    • Interface `) -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 } -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 func writehelpTopicsHTML(qq422016 qtio422016.Writer) { -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 streamhelpTopicsHTML(qw422016) -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 } -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 func helpTopicsHTML() string { -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 writehelpTopicsHTML(qb422016) -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 return qs422016 -//line views/stuff.qtpl:188 +//line views/stuff.qtpl:189 } -//line views/stuff.qtpl:190 +//line views/stuff.qtpl:191 func streamhelpTopicBadgeHTML(qw422016 *qt422016.Writer, lang, topic string) { -//line views/stuff.qtpl:190 +//line views/stuff.qtpl:191 qw422016.N().S(` ? `) -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 } -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 func writehelpTopicBadgeHTML(qq422016 qtio422016.Writer, lang, topic string) { -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 streamhelpTopicBadgeHTML(qw422016, lang, topic) -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 } -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 func helpTopicBadgeHTML(lang, topic string) string { -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 writehelpTopicBadgeHTML(qb422016, lang, topic) -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 return qs422016 -//line views/stuff.qtpl:192 +//line views/stuff.qtpl:193 } -//line views/stuff.qtpl:194 +//line views/stuff.qtpl:195 func StreamUserListHTML(qw422016 *qt422016.Writer) { -//line views/stuff.qtpl:194 +//line views/stuff.qtpl:195 qw422016.N().S(`

      List of users

      `) -//line views/stuff.qtpl:199 +//line views/stuff.qtpl:200 var ( admins = make([]string, 0) moderators = make([]string, 0) @@ -683,345 +684,345 @@ func StreamUserListHTML(qw422016 *qt422016.Writer) { } } -//line views/stuff.qtpl:214 +//line views/stuff.qtpl:215 qw422016.N().S(`

      Admins

        `) -//line views/stuff.qtpl:217 +//line views/stuff.qtpl:218 for _, name := range admins { -//line views/stuff.qtpl:217 +//line views/stuff.qtpl:218 qw422016.N().S(`
      1. `) -//line views/stuff.qtpl:218 +//line views/stuff.qtpl:219 qw422016.E().S(name) -//line views/stuff.qtpl:218 +//line views/stuff.qtpl:219 qw422016.N().S(`
      2. `) -//line views/stuff.qtpl:219 +//line views/stuff.qtpl:220 } -//line views/stuff.qtpl:219 +//line views/stuff.qtpl:220 qw422016.N().S(`

      Moderators

        `) -//line views/stuff.qtpl:223 +//line views/stuff.qtpl:224 for _, name := range moderators { -//line views/stuff.qtpl:223 +//line views/stuff.qtpl:224 qw422016.N().S(`
      1. `) -//line views/stuff.qtpl:224 +//line views/stuff.qtpl:225 qw422016.E().S(name) -//line views/stuff.qtpl:224 +//line views/stuff.qtpl:225 qw422016.N().S(`
      2. `) -//line views/stuff.qtpl:225 +//line views/stuff.qtpl:226 } -//line views/stuff.qtpl:225 +//line views/stuff.qtpl:226 qw422016.N().S(`

      Editors

        `) -//line views/stuff.qtpl:229 +//line views/stuff.qtpl:230 for _, name := range editors { -//line views/stuff.qtpl:229 +//line views/stuff.qtpl:230 qw422016.N().S(`
      1. `) -//line views/stuff.qtpl:230 +//line views/stuff.qtpl:231 qw422016.E().S(name) -//line views/stuff.qtpl:230 +//line views/stuff.qtpl:231 qw422016.N().S(`
      2. `) -//line views/stuff.qtpl:231 +//line views/stuff.qtpl:232 } -//line views/stuff.qtpl:231 +//line views/stuff.qtpl:232 qw422016.N().S(`
      `) -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 } -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 func WriteUserListHTML(qq422016 qtio422016.Writer) { -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 StreamUserListHTML(qw422016) -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 } -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 func UserListHTML() string { -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 WriteUserListHTML(qb422016) -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 return qs422016 -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:236 } -//line views/stuff.qtpl:237 +//line views/stuff.qtpl:238 func StreamHyphaListHTML(qw422016 *qt422016.Writer) { -//line views/stuff.qtpl:237 +//line views/stuff.qtpl:238 qw422016.N().S(`

      List of hyphae

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

        `) -//line views/stuff.qtpl:243 +//line views/stuff.qtpl:244 for h := range hyphae.YieldExistingHyphae() { -//line views/stuff.qtpl:243 +//line views/stuff.qtpl:244 qw422016.N().S(`
      • `) -//line views/stuff.qtpl:245 +//line views/stuff.qtpl:246 qw422016.E().S(util.BeautifulName(h.Name)) -//line views/stuff.qtpl:245 +//line views/stuff.qtpl:246 qw422016.N().S(` `) -//line views/stuff.qtpl:246 +//line views/stuff.qtpl:247 if h.BinaryPath != "" { -//line views/stuff.qtpl:246 +//line views/stuff.qtpl:247 qw422016.N().S(` `) -//line views/stuff.qtpl:247 +//line views/stuff.qtpl:248 qw422016.E().S(filepath.Ext(h.BinaryPath)[1:]) -//line views/stuff.qtpl:247 +//line views/stuff.qtpl:248 qw422016.N().S(` `) -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:249 } -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:249 qw422016.N().S(`
      • `) -//line views/stuff.qtpl:250 +//line views/stuff.qtpl:251 } -//line views/stuff.qtpl:250 +//line views/stuff.qtpl:251 qw422016.N().S(`
      `) -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 } -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 func WriteHyphaListHTML(qq422016 qtio422016.Writer) { -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 StreamHyphaListHTML(qw422016) -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 } -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 func HyphaListHTML() string { -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 WriteHyphaListHTML(qb422016) -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 return qs422016 -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:255 } -//line views/stuff.qtpl:256 +//line views/stuff.qtpl:257 func StreamAboutHTML(qw422016 *qt422016.Writer) { -//line views/stuff.qtpl:256 +//line views/stuff.qtpl:257 qw422016.N().S(`

      About `) -//line views/stuff.qtpl:260 +//line views/stuff.qtpl:261 qw422016.E().S(cfg.WikiName) -//line views/stuff.qtpl:260 +//line views/stuff.qtpl:261 qw422016.N().S(`

      See /list for information about hyphae on this wiki.

      `) -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 } -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 func WriteAboutHTML(qq422016 qtio422016.Writer) { -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 StreamAboutHTML(qw422016) -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 } -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 func AboutHTML() string { -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 WriteAboutHTML(qb422016) -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 return qs422016 -//line views/stuff.qtpl:278 +//line views/stuff.qtpl:279 } -//line views/stuff.qtpl:280 +//line views/stuff.qtpl:281 func StreamCommonScripts(qw422016 *qt422016.Writer) { -//line views/stuff.qtpl:280 +//line views/stuff.qtpl:281 qw422016.N().S(` `) -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:282 for _, scriptPath := range cfg.CommonScripts { -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:282 qw422016.N().S(` `) -//line views/stuff.qtpl:283 +//line views/stuff.qtpl:284 } -//line views/stuff.qtpl:283 +//line views/stuff.qtpl:284 qw422016.N().S(` `) -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 } -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 func WriteCommonScripts(qq422016 qtio422016.Writer) { -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 StreamCommonScripts(qw422016) -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 } -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 func CommonScripts() string { -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 WriteCommonScripts(qb422016) -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 return qs422016 -//line views/stuff.qtpl:284 +//line views/stuff.qtpl:285 } From 51704b72cde70c0988be6b71ffccb03abb014e5b Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Thu, 23 Sep 2021 12:36:54 +0300 Subject: [PATCH 3/3] Add /rev-text/ --- hyphae/iterators.go | 18 +++++++++++++----- views/readers.qtpl | 2 +- views/readers.qtpl.go | 10 +++++++++- web/readers.go | 29 ++++++++++++++++++++++++++++- 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/hyphae/iterators.go b/hyphae/iterators.go index 4c06216..9fb494e 100644 --- a/hyphae/iterators.go +++ b/hyphae/iterators.go @@ -2,8 +2,8 @@ package hyphae import ( - "strings" "sort" + "strings" ) // YieldExistingHyphae iterates over all hyphae and yields all existing ones. @@ -48,14 +48,22 @@ func PathographicSort(src chan string) <-chan string { // Classic lexicographical sort with a twist c := 0 for { - if c == len(raw[i]) { return true } - if c == len(raw[j]) { return false } + if c == len(raw[i]) { + return true + } + if c == len(raw[j]) { + return false + } if raw[i][c] == raw[j][c] { c++ } else { // The twist: subhyphae-awareness is about pushing slash upwards - if raw[i][c] == slash { return true } - if raw[j][c] == slash { return false } + if raw[i][c] == slash { + return true + } + if raw[j][c] == slash { + return false + } return raw[i][c] < raw[j][c] } } diff --git a/views/readers.qtpl b/views/readers.qtpl index 3b597f6..c07ebd3 100644 --- a/views/readers.qtpl +++ b/views/readers.qtpl @@ -125,7 +125,7 @@ If you rename .prevnext, change the docs too.
      -

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

      +

      Please note that viewing attachments of hyphae is not supported in history for now. Get Mycomarkup source of this revision

      {%s= NaviTitleHTML(h) %} {%s= contents %}
      diff --git a/views/readers.qtpl.go b/views/readers.qtpl.go index 02a66b7..56b4ef6 100644 --- a/views/readers.qtpl.go +++ b/views/readers.qtpl.go @@ -398,7 +398,15 @@ func StreamRevisionHTML(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.H
      -

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

      +

      Please note that viewing attachments of hyphae is not supported in history for now. Get Mycomarkup source of this revision

      `) //line views/readers.qtpl:129 qw422016.N().S(NaviTitleHTML(h)) diff --git a/web/readers.go b/web/readers.go index 8c0289d..f2d0efe 100644 --- a/web/readers.go +++ b/web/readers.go @@ -2,6 +2,7 @@ package web import ( "fmt" + "io" "log" "net/http" "os" @@ -29,6 +30,7 @@ func initReaders(r *mux.Router) { r.PathPrefix("/text/").HandlerFunc(handlerText) r.PathPrefix("/binary/").HandlerFunc(handlerBinary) r.PathPrefix("/rev/").HandlerFunc(handlerRevision) + r.PathPrefix("/rev-text/").HandlerFunc(handlerRevisionText) r.PathPrefix("/primitive-diff/").HandlerFunc(handlerPrimitiveDiff) r.PathPrefix("/attachment/").HandlerFunc(handlerAttachment) } @@ -64,7 +66,32 @@ func handlerPrimitiveDiff(w http.ResponseWriter, rq *http.Request) { u)) } -// handlerRevision displays a specific revision of text part a page +// handlerRevisionText sends Mycomarkup text of the hypha at the given revision. See also: handlerRevision, handlerText. +// +// /rev-text// +func handlerRevisionText(w http.ResponseWriter, rq *http.Request) { + util.PrepareRq(rq) + var ( + shorterUrl = strings.TrimPrefix(rq.URL.Path, "/rev-text/") + firstSlashIndex = strings.IndexRune(shorterUrl, '/') + revHash = shorterUrl[:firstSlashIndex] + hyphaName = util.CanonicalName(shorterUrl[firstSlashIndex+1:]) + h = hyphae.ByName(hyphaName) + textContents, err = history.FileAtRevision(h.TextPartPath(), revHash) + ) + w.Header().Set("Content-Type", "text/plain; charset=utf-8") + if err != nil { + w.WriteHeader(http.StatusNotFound) + log.Printf("While serving text of ‘%s’ at revision ‘%s’: %s\n", hyphaName, revHash, err.Error()) + _, _ = io.WriteString(w, "Error: "+err.Error()) + return + } + log.Printf("Serving text of ‘%s’ from ‘%s’ at revision ‘%s’\n", hyphaName, h.TextPartPath(), revHash) + w.WriteHeader(http.StatusOK) + _, _ = io.WriteString(w, textContents) +} + +// handlerRevision displays a specific revision of the text part the hypha func handlerRevision(w http.ResponseWriter, rq *http.Request) { util.PrepareRq(rq) var (