From 9713c18b6bf4ae698e06f370d20c31c3e79b49b9 Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Fri, 10 Jun 2022 18:45:27 +0300 Subject: [PATCH] Backlinks: Fix the bug --- backlinks/hooks.go | 4 +- help/web.go | 4 +- main.go | 1 + mycoopts/mycoopts.go | 54 ++++++ views/hypha.qtpl => mycoopts/view.qtpl | 5 +- mycoopts/view.qtpl.go | 190 ++++++++++++++++++++ shroom/header_links.go | 3 +- shroom/mycomarkup_options.go | 54 ------ views/hypha.qtpl.go | 234 ------------------------- views/nav.qtpl | 7 +- views/nav.qtpl.go | 214 +++++++++++++--------- web/mutators.go | 3 +- web/readers.go | 8 +- 13 files changed, 392 insertions(+), 389 deletions(-) create mode 100644 mycoopts/mycoopts.go rename views/hypha.qtpl => mycoopts/view.qtpl (84%) create mode 100644 mycoopts/view.qtpl.go delete mode 100644 views/hypha.qtpl.go diff --git a/backlinks/hooks.go b/backlinks/hooks.go index 9a5ec85..1585475 100644 --- a/backlinks/hooks.go +++ b/backlinks/hooks.go @@ -4,9 +4,9 @@ import ( "github.com/bouncepaw/mycomarkup/v5" "github.com/bouncepaw/mycomarkup/v5/links" "github.com/bouncepaw/mycomarkup/v5/mycocontext" - "github.com/bouncepaw/mycomarkup/v5/options" "github.com/bouncepaw/mycomarkup/v5/tools" "github.com/bouncepaw/mycorrhiza/hyphae" + "github.com/bouncepaw/mycorrhiza/mycoopts" ) // UpdateBacklinksAfterEdit is a creation/editing hook for backlinks index @@ -35,7 +35,7 @@ func extractHyphaLinks(h hyphae.Hypha) []string { // extractHyphaLinksFromContent extracts local hypha links from the provided text. func extractHyphaLinksFromContent(hyphaName string, contents string) []string { - ctx, _ := mycocontext.ContextFromStringInput(contents, options.Options{HyphaName: hyphaName}.FillTheRest()) + ctx, _ := mycocontext.ContextFromStringInput(contents, mycoopts.MarkupOptions(hyphaName)) linkVisitor, getLinks := tools.LinkVisitor(ctx) // Ignore the result of BlockTree because we call it for linkVisitor. _ = mycomarkup.BlockTree(ctx, linkVisitor) diff --git a/help/web.go b/help/web.go index 70cec7d..31ec697 100644 --- a/help/web.go +++ b/help/web.go @@ -3,7 +3,7 @@ package help // stuff.go is used for meta stuff about the wiki or all hyphae at once. import ( "github.com/bouncepaw/mycomarkup/v5" - "github.com/bouncepaw/mycorrhiza/shroom" + "github.com/bouncepaw/mycorrhiza/mycoopts" "github.com/bouncepaw/mycorrhiza/viewutil" "github.com/gorilla/mux" "io" @@ -78,7 +78,7 @@ func handlerHelp(w http.ResponseWriter, rq *http.Request) { } // TODO: change for the function that uses byte array when there is such function in mycomarkup. - ctx, _ := mycocontext.ContextFromStringInput(string(content), shroom.MarkupOptions(articlePath)) + ctx, _ := mycocontext.ContextFromStringInput(string(content), mycoopts.MarkupOptions(articlePath)) ast := mycomarkup.BlockTree(ctx) result := mycomarkup.BlocksToHTML(ctx, ast) w.WriteHeader(http.StatusOK) diff --git a/main.go b/main.go index fb09898..b7dc89e 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ //go:generate go run github.com/valyala/quicktemplate/qtc -dir=views //go:generate go run github.com/valyala/quicktemplate/qtc -dir=tree //go:generate go run github.com/valyala/quicktemplate/qtc -dir=history +//go:generate go run github.com/valyala/quicktemplate/qtc -dir=mycoopts // Command mycorrhiza is a program that runs a mycorrhiza wiki. package main diff --git a/mycoopts/mycoopts.go b/mycoopts/mycoopts.go new file mode 100644 index 0000000..a160320 --- /dev/null +++ b/mycoopts/mycoopts.go @@ -0,0 +1,54 @@ +package mycoopts + +import ( + "errors" + "github.com/bouncepaw/mycomarkup/v5/options" + "github.com/bouncepaw/mycorrhiza/cfg" + "github.com/bouncepaw/mycorrhiza/hyphae" + "github.com/bouncepaw/mycorrhiza/interwiki" + "github.com/bouncepaw/mycorrhiza/util" +) + +func MarkupOptions(hyphaName string) options.Options { + return options.Options{ + HyphaName: hyphaName, + WebSiteURL: cfg.URL, + TransclusionSupported: true, + RedLinksSupported: true, + InterwikiSupported: true, + HyphaExists: func(hyphaName string) bool { + switch hyphae.ByName(hyphaName).(type) { + case *hyphae.EmptyHypha: + return false + default: + return true + } + }, + IterateHyphaNamesWith: func(λ func(string)) { + for h := range hyphae.YieldExistingHyphae() { + λ(h.CanonicalName()) + } + }, + HyphaHTMLData: func(hyphaName string) (rawText, binaryBlock string, err error) { + switch h := hyphae.ByName(hyphaName).(type) { + case *hyphae.EmptyHypha: + err = errors.New("Hypha " + hyphaName + " does not exist") + case *hyphae.TextualHypha: + rawText, err = hyphae.FetchMycomarkupFile(h) + case *hyphae.MediaHypha: + rawText, err = hyphae.FetchMycomarkupFile(h) + binaryBlock = mediaRaw(h) + } + return + }, + LocalTargetCanonicalName: util.CanonicalName, + LocalLinkHref: func(hyphaName string) string { + return "/hypha/" + util.CanonicalName(hyphaName) + }, + LocalImgSrc: func(hyphaName string) string { + return "/binary/" + util.CanonicalName(hyphaName) + }, + LinkHrefFormatForInterwikiPrefix: interwiki.HrefLinkFormatFor, + ImgSrcFormatForInterwikiPrefix: interwiki.ImgSrcFormatFor, + }.FillTheRest() +} diff --git a/views/hypha.qtpl b/mycoopts/view.qtpl similarity index 84% rename from views/hypha.qtpl rename to mycoopts/view.qtpl index a3d2bfc..935e4de 100644 --- a/views/hypha.qtpl +++ b/mycoopts/view.qtpl @@ -2,11 +2,8 @@ {% import "github.com/bouncepaw/mycorrhiza/hyphae" %} {% import "github.com/bouncepaw/mycorrhiza/l18n" %} -{% import "github.com/bouncepaw/mycorrhiza/util" %} -{% func beautifulLink(hyphaName string) %}{%s util.BeautifulName(hyphaName) %}{% endfunc %} - -{% func MediaRaw(h *hyphae.MediaHypha) %}{%= Media(h, l18n.New("en", "en")) %}{% endfunc %} +{% func mediaRaw(h *hyphae.MediaHypha) %}{%= Media(h, l18n.New("en", "en")) %}{% endfunc %} {% func Media(h *hyphae.MediaHypha, lc *l18n.Localizer) %} {% switch filepath.Ext(h.MediaFilePath()) %} diff --git a/mycoopts/view.qtpl.go b/mycoopts/view.qtpl.go new file mode 100644 index 0000000..ddb1450 --- /dev/null +++ b/mycoopts/view.qtpl.go @@ -0,0 +1,190 @@ +// Code generated by qtc from "view.qtpl". DO NOT EDIT. +// See https://github.com/valyala/quicktemplate for details. + +//line mycoopts/view.qtpl:1 +package mycoopts + +//line mycoopts/view.qtpl:1 +import "path/filepath" + +//line mycoopts/view.qtpl:3 +import "github.com/bouncepaw/mycorrhiza/hyphae" + +//line mycoopts/view.qtpl:4 +import "github.com/bouncepaw/mycorrhiza/l18n" + +//line mycoopts/view.qtpl:6 +import ( + qtio422016 "io" + + qt422016 "github.com/valyala/quicktemplate" +) + +//line mycoopts/view.qtpl:6 +var ( + _ = qtio422016.Copy + _ = qt422016.AcquireByteBuffer +) + +//line mycoopts/view.qtpl:6 +func streammediaRaw(qw422016 *qt422016.Writer, h *hyphae.MediaHypha) { +//line mycoopts/view.qtpl:6 + StreamMedia(qw422016, h, l18n.New("en", "en")) +//line mycoopts/view.qtpl:6 +} + +//line mycoopts/view.qtpl:6 +func writemediaRaw(qq422016 qtio422016.Writer, h *hyphae.MediaHypha) { +//line mycoopts/view.qtpl:6 + qw422016 := qt422016.AcquireWriter(qq422016) +//line mycoopts/view.qtpl:6 + streammediaRaw(qw422016, h) +//line mycoopts/view.qtpl:6 + qt422016.ReleaseWriter(qw422016) +//line mycoopts/view.qtpl:6 +} + +//line mycoopts/view.qtpl:6 +func mediaRaw(h *hyphae.MediaHypha) string { +//line mycoopts/view.qtpl:6 + qb422016 := qt422016.AcquireByteBuffer() +//line mycoopts/view.qtpl:6 + writemediaRaw(qb422016, h) +//line mycoopts/view.qtpl:6 + qs422016 := string(qb422016.B) +//line mycoopts/view.qtpl:6 + qt422016.ReleaseByteBuffer(qb422016) +//line mycoopts/view.qtpl:6 + return qs422016 +//line mycoopts/view.qtpl:6 +} + +//line mycoopts/view.qtpl:8 +func StreamMedia(qw422016 *qt422016.Writer, h *hyphae.MediaHypha, lc *l18n.Localizer) { +//line mycoopts/view.qtpl:8 + qw422016.N().S(` + `) +//line mycoopts/view.qtpl:9 + switch filepath.Ext(h.MediaFilePath()) { +//line mycoopts/view.qtpl:11 + case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico": +//line mycoopts/view.qtpl:11 + qw422016.N().S(` +
+ +
+ + `) +//line mycoopts/view.qtpl:16 + case ".ogg", ".webm", ".mp4": +//line mycoopts/view.qtpl:16 + qw422016.N().S(` +
+ +
+ + `) +//line mycoopts/view.qtpl:24 + case ".mp3": +//line mycoopts/view.qtpl:24 + qw422016.N().S(` +
+ +
+ + `) +//line mycoopts/view.qtpl:32 + default: +//line mycoopts/view.qtpl:32 + qw422016.N().S(` +
+

`) +//line mycoopts/view.qtpl:34 + qw422016.E().S(lc.Get("ui.media_download")) +//line mycoopts/view.qtpl:34 + qw422016.N().S(`

+
+`) +//line mycoopts/view.qtpl:36 + } +//line mycoopts/view.qtpl:36 + qw422016.N().S(` +`) +//line mycoopts/view.qtpl:37 +} + +//line mycoopts/view.qtpl:37 +func WriteMedia(qq422016 qtio422016.Writer, h *hyphae.MediaHypha, lc *l18n.Localizer) { +//line mycoopts/view.qtpl:37 + qw422016 := qt422016.AcquireWriter(qq422016) +//line mycoopts/view.qtpl:37 + StreamMedia(qw422016, h, lc) +//line mycoopts/view.qtpl:37 + qt422016.ReleaseWriter(qw422016) +//line mycoopts/view.qtpl:37 +} + +//line mycoopts/view.qtpl:37 +func Media(h *hyphae.MediaHypha, lc *l18n.Localizer) string { +//line mycoopts/view.qtpl:37 + qb422016 := qt422016.AcquireByteBuffer() +//line mycoopts/view.qtpl:37 + WriteMedia(qb422016, h, lc) +//line mycoopts/view.qtpl:37 + qs422016 := string(qb422016.B) +//line mycoopts/view.qtpl:37 + qt422016.ReleaseByteBuffer(qb422016) +//line mycoopts/view.qtpl:37 + return qs422016 +//line mycoopts/view.qtpl:37 +} diff --git a/shroom/header_links.go b/shroom/header_links.go index c4e18c7..9ec03a5 100644 --- a/shroom/header_links.go +++ b/shroom/header_links.go @@ -6,6 +6,7 @@ import ( "github.com/bouncepaw/mycomarkup/v5/mycocontext" "github.com/bouncepaw/mycorrhiza/cfg" "github.com/bouncepaw/mycorrhiza/hyphae" + "github.com/bouncepaw/mycorrhiza/mycoopts" "github.com/bouncepaw/mycorrhiza/viewutil" "os" ) @@ -40,7 +41,7 @@ func setDefaultHeaderLinks() { // parseHeaderLinks extracts all rocketlinks from the given text and saves them as header links. func parseHeaderLinks(text string) { viewutil.HeaderLinks = []viewutil.HeaderLink{} - ctx, _ := mycocontext.ContextFromStringInput(text, MarkupOptions("")) + ctx, _ := mycocontext.ContextFromStringInput(text, mycoopts.MarkupOptions("")) // We call for side-effects _ = mycomarkup.BlockTree(ctx, func(block blocks.Block) { switch launchpad := block.(type) { diff --git a/shroom/mycomarkup_options.go b/shroom/mycomarkup_options.go index 4acfa50..4bc19b2 100644 --- a/shroom/mycomarkup_options.go +++ b/shroom/mycomarkup_options.go @@ -1,55 +1 @@ package shroom - -import ( - "errors" - "github.com/bouncepaw/mycomarkup/v5/options" - "github.com/bouncepaw/mycorrhiza/cfg" - "github.com/bouncepaw/mycorrhiza/hyphae" - "github.com/bouncepaw/mycorrhiza/interwiki" - "github.com/bouncepaw/mycorrhiza/util" - "github.com/bouncepaw/mycorrhiza/views" -) - -func MarkupOptions(hyphaName string) options.Options { - return options.Options{ - HyphaName: hyphaName, - WebSiteURL: cfg.URL, - TransclusionSupported: true, - RedLinksSupported: true, - InterwikiSupported: true, - HyphaExists: func(hyphaName string) bool { - switch hyphae.ByName(hyphaName).(type) { - case *hyphae.EmptyHypha: - return false - default: - return true - } - }, - IterateHyphaNamesWith: func(λ func(string)) { - for h := range hyphae.YieldExistingHyphae() { - λ(h.CanonicalName()) - } - }, - HyphaHTMLData: func(hyphaName string) (rawText, binaryBlock string, err error) { - switch h := hyphae.ByName(hyphaName).(type) { - case *hyphae.EmptyHypha: - err = errors.New("Hypha " + hyphaName + " does not exist") - case *hyphae.TextualHypha: - rawText, err = hyphae.FetchMycomarkupFile(h) - case *hyphae.MediaHypha: - rawText, err = hyphae.FetchMycomarkupFile(h) - binaryBlock = views.MediaRaw(h) - } - return - }, - LocalTargetCanonicalName: util.CanonicalName, - LocalLinkHref: func(hyphaName string) string { - return "/hypha/" + util.CanonicalName(hyphaName) - }, - LocalImgSrc: func(hyphaName string) string { - return "/binary/" + util.CanonicalName(hyphaName) - }, - LinkHrefFormatForInterwikiPrefix: interwiki.HrefLinkFormatFor, - ImgSrcFormatForInterwikiPrefix: interwiki.ImgSrcFormatFor, - }.FillTheRest() -} diff --git a/views/hypha.qtpl.go b/views/hypha.qtpl.go deleted file mode 100644 index 40ac44a..0000000 --- a/views/hypha.qtpl.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by qtc from "hypha.qtpl". DO NOT EDIT. -// See https://github.com/valyala/quicktemplate for details. - -//line views/hypha.qtpl:1 -package views - -//line views/hypha.qtpl:1 -import "path/filepath" - -//line views/hypha.qtpl:3 -import "github.com/bouncepaw/mycorrhiza/hyphae" - -//line views/hypha.qtpl:4 -import "github.com/bouncepaw/mycorrhiza/l18n" - -//line views/hypha.qtpl:5 -import "github.com/bouncepaw/mycorrhiza/util" - -//line views/hypha.qtpl:7 -import ( - qtio422016 "io" - - qt422016 "github.com/valyala/quicktemplate" -) - -//line views/hypha.qtpl:7 -var ( - _ = qtio422016.Copy - _ = qt422016.AcquireByteBuffer -) - -//line views/hypha.qtpl:7 -func streambeautifulLink(qw422016 *qt422016.Writer, hyphaName string) { -//line views/hypha.qtpl:7 - qw422016.N().S(``) -//line views/hypha.qtpl:7 - qw422016.E().S(util.BeautifulName(hyphaName)) -//line views/hypha.qtpl:7 - qw422016.N().S(``) -//line views/hypha.qtpl:7 -} - -//line views/hypha.qtpl:7 -func writebeautifulLink(qq422016 qtio422016.Writer, hyphaName string) { -//line views/hypha.qtpl:7 - qw422016 := qt422016.AcquireWriter(qq422016) -//line views/hypha.qtpl:7 - streambeautifulLink(qw422016, hyphaName) -//line views/hypha.qtpl:7 - qt422016.ReleaseWriter(qw422016) -//line views/hypha.qtpl:7 -} - -//line views/hypha.qtpl:7 -func beautifulLink(hyphaName string) string { -//line views/hypha.qtpl:7 - qb422016 := qt422016.AcquireByteBuffer() -//line views/hypha.qtpl:7 - writebeautifulLink(qb422016, hyphaName) -//line views/hypha.qtpl:7 - qs422016 := string(qb422016.B) -//line views/hypha.qtpl:7 - qt422016.ReleaseByteBuffer(qb422016) -//line views/hypha.qtpl:7 - return qs422016 -//line views/hypha.qtpl:7 -} - -//line views/hypha.qtpl:9 -func StreamMediaRaw(qw422016 *qt422016.Writer, h *hyphae.MediaHypha) { -//line views/hypha.qtpl:9 - StreamMedia(qw422016, h, l18n.New("en", "en")) -//line views/hypha.qtpl:9 -} - -//line views/hypha.qtpl:9 -func WriteMediaRaw(qq422016 qtio422016.Writer, h *hyphae.MediaHypha) { -//line views/hypha.qtpl:9 - qw422016 := qt422016.AcquireWriter(qq422016) -//line views/hypha.qtpl:9 - StreamMediaRaw(qw422016, h) -//line views/hypha.qtpl:9 - qt422016.ReleaseWriter(qw422016) -//line views/hypha.qtpl:9 -} - -//line views/hypha.qtpl:9 -func MediaRaw(h *hyphae.MediaHypha) string { -//line views/hypha.qtpl:9 - qb422016 := qt422016.AcquireByteBuffer() -//line views/hypha.qtpl:9 - WriteMediaRaw(qb422016, h) -//line views/hypha.qtpl:9 - qs422016 := string(qb422016.B) -//line views/hypha.qtpl:9 - qt422016.ReleaseByteBuffer(qb422016) -//line views/hypha.qtpl:9 - return qs422016 -//line views/hypha.qtpl:9 -} - -//line views/hypha.qtpl:11 -func StreamMedia(qw422016 *qt422016.Writer, h *hyphae.MediaHypha, lc *l18n.Localizer) { -//line views/hypha.qtpl:11 - qw422016.N().S(` - `) -//line views/hypha.qtpl:12 - switch filepath.Ext(h.MediaFilePath()) { -//line views/hypha.qtpl:14 - case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico": -//line views/hypha.qtpl:14 - qw422016.N().S(` -
- -
- - `) -//line views/hypha.qtpl:19 - case ".ogg", ".webm", ".mp4": -//line views/hypha.qtpl:19 - qw422016.N().S(` -
- -
- - `) -//line views/hypha.qtpl:27 - case ".mp3": -//line views/hypha.qtpl:27 - qw422016.N().S(` -
- -
- - `) -//line views/hypha.qtpl:35 - default: -//line views/hypha.qtpl:35 - qw422016.N().S(` -
-

`) -//line views/hypha.qtpl:37 - qw422016.E().S(lc.Get("ui.media_download")) -//line views/hypha.qtpl:37 - qw422016.N().S(`

-
-`) -//line views/hypha.qtpl:39 - } -//line views/hypha.qtpl:39 - qw422016.N().S(` -`) -//line views/hypha.qtpl:40 -} - -//line views/hypha.qtpl:40 -func WriteMedia(qq422016 qtio422016.Writer, h *hyphae.MediaHypha, lc *l18n.Localizer) { -//line views/hypha.qtpl:40 - qw422016 := qt422016.AcquireWriter(qq422016) -//line views/hypha.qtpl:40 - StreamMedia(qw422016, h, lc) -//line views/hypha.qtpl:40 - qt422016.ReleaseWriter(qw422016) -//line views/hypha.qtpl:40 -} - -//line views/hypha.qtpl:40 -func Media(h *hyphae.MediaHypha, lc *l18n.Localizer) string { -//line views/hypha.qtpl:40 - qb422016 := qt422016.AcquireByteBuffer() -//line views/hypha.qtpl:40 - WriteMedia(qb422016, h, lc) -//line views/hypha.qtpl:40 - qs422016 := string(qb422016.B) -//line views/hypha.qtpl:40 - qt422016.ReleaseByteBuffer(qb422016) -//line views/hypha.qtpl:40 - return qs422016 -//line views/hypha.qtpl:40 -} diff --git a/views/nav.qtpl b/views/nav.qtpl index 876d6a0..1885dd2 100644 --- a/views/nav.qtpl +++ b/views/nav.qtpl @@ -1,7 +1,8 @@ -{% import "github.com/bouncepaw/mycorrhiza/cfg" %} {% import "github.com/bouncepaw/mycorrhiza/backlinks" %} -{% import "github.com/bouncepaw/mycorrhiza/user" %} +{% import "github.com/bouncepaw/mycorrhiza/cfg" %} {% import "github.com/bouncepaw/mycorrhiza/hyphae" %} +{% import "github.com/bouncepaw/mycorrhiza/user" %} +{% import "github.com/bouncepaw/mycorrhiza/util" %} {% import "github.com/bouncepaw/mycorrhiza/viewutil" %} {% func hyphaInfoEntry(h hyphae.Hypha, u *user.User, action, displayText string) %} @@ -35,3 +36,5 @@ {% endfor %} {% endfunc %} + +{% func beautifulLink(hyphaName string) %}{%s util.BeautifulName(hyphaName) %}{% endfunc %} diff --git a/views/nav.qtpl.go b/views/nav.qtpl.go index b342d47..5c14894 100644 --- a/views/nav.qtpl.go +++ b/views/nav.qtpl.go @@ -5,217 +5,261 @@ package views //line views/nav.qtpl:1 -import "github.com/bouncepaw/mycorrhiza/cfg" - -//line views/nav.qtpl:2 import "github.com/bouncepaw/mycorrhiza/backlinks" -//line views/nav.qtpl:3 -import "github.com/bouncepaw/mycorrhiza/user" +//line views/nav.qtpl:2 +import "github.com/bouncepaw/mycorrhiza/cfg" -//line views/nav.qtpl:4 +//line views/nav.qtpl:3 import "github.com/bouncepaw/mycorrhiza/hyphae" +//line views/nav.qtpl:4 +import "github.com/bouncepaw/mycorrhiza/user" + //line views/nav.qtpl:5 +import "github.com/bouncepaw/mycorrhiza/util" + +//line views/nav.qtpl:6 import "github.com/bouncepaw/mycorrhiza/viewutil" -//line views/nav.qtpl:7 +//line views/nav.qtpl:8 import ( qtio422016 "io" qt422016 "github.com/valyala/quicktemplate" ) -//line views/nav.qtpl:7 +//line views/nav.qtpl:8 var ( _ = qtio422016.Copy _ = qt422016.AcquireByteBuffer ) -//line views/nav.qtpl:7 +//line views/nav.qtpl:8 func streamhyphaInfoEntry(qw422016 *qt422016.Writer, h hyphae.Hypha, u *user.User, action, displayText string) { -//line views/nav.qtpl:7 +//line views/nav.qtpl:8 qw422016.N().S(` `) -//line views/nav.qtpl:8 +//line views/nav.qtpl:9 if u.CanProceed(action) { -//line views/nav.qtpl:8 +//line views/nav.qtpl:9 qw422016.N().S(`
  • `) -//line views/nav.qtpl:10 +//line views/nav.qtpl:11 qw422016.E().S(displayText) -//line views/nav.qtpl:10 +//line views/nav.qtpl:11 qw422016.N().S(`
  • `) -//line views/nav.qtpl:12 +//line views/nav.qtpl:13 } -//line views/nav.qtpl:12 +//line views/nav.qtpl:13 qw422016.N().S(` `) -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 } -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 func writehyphaInfoEntry(qq422016 qtio422016.Writer, h hyphae.Hypha, u *user.User, action, displayText string) { -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 streamhyphaInfoEntry(qw422016, h, u, action, displayText) -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 qt422016.ReleaseWriter(qw422016) -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 } -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 func hyphaInfoEntry(h hyphae.Hypha, u *user.User, action, displayText string) string { -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 qb422016 := qt422016.AcquireByteBuffer() -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 writehyphaInfoEntry(qb422016, h, u, action, displayText) -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 qs422016 := string(qb422016.B) -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 qt422016.ReleaseByteBuffer(qb422016) -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 return qs422016 -//line views/nav.qtpl:13 +//line views/nav.qtpl:14 } -//line views/nav.qtpl:15 +//line views/nav.qtpl:16 func streamhyphaInfo(qw422016 *qt422016.Writer, meta viewutil.Meta, h hyphae.Hypha) { -//line views/nav.qtpl:15 +//line views/nav.qtpl:16 qw422016.N().S(` `) -//line views/nav.qtpl:17 +//line views/nav.qtpl:18 u := meta.U lc := meta.Lc backs := backlinks.BacklinksCount(h) -//line views/nav.qtpl:20 +//line views/nav.qtpl:21 qw422016.N().S(` `) -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 } -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 func writehyphaInfo(qq422016 qtio422016.Writer, meta viewutil.Meta, h hyphae.Hypha) { -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 streamhyphaInfo(qw422016, meta, h) -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 qt422016.ReleaseWriter(qw422016) -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 } -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 func hyphaInfo(meta viewutil.Meta, h hyphae.Hypha) string { -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 qb422016 := qt422016.AcquireByteBuffer() -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 writehyphaInfo(qb422016, meta, h) -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 qs422016 := string(qb422016.B) -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 qt422016.ReleaseByteBuffer(qb422016) -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 return qs422016 -//line views/nav.qtpl:31 +//line views/nav.qtpl:32 } -//line views/nav.qtpl:33 +//line views/nav.qtpl:34 func streamcommonScripts(qw422016 *qt422016.Writer) { -//line views/nav.qtpl:33 +//line views/nav.qtpl:34 qw422016.N().S(` `) -//line views/nav.qtpl:34 +//line views/nav.qtpl:35 for _, scriptPath := range cfg.CommonScripts { -//line views/nav.qtpl:34 +//line views/nav.qtpl:35 qw422016.N().S(` `) -//line views/nav.qtpl:36 +//line views/nav.qtpl:37 } -//line views/nav.qtpl:36 +//line views/nav.qtpl:37 qw422016.N().S(` `) -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 } -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 func writecommonScripts(qq422016 qtio422016.Writer) { -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 streamcommonScripts(qw422016) -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 qt422016.ReleaseWriter(qw422016) -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 } -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 func commonScripts() string { -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 qb422016 := qt422016.AcquireByteBuffer() -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 writecommonScripts(qb422016) -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 qs422016 := string(qb422016.B) -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 qt422016.ReleaseByteBuffer(qb422016) -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 return qs422016 -//line views/nav.qtpl:37 +//line views/nav.qtpl:38 +} + +//line views/nav.qtpl:40 +func streambeautifulLink(qw422016 *qt422016.Writer, hyphaName string) { +//line views/nav.qtpl:40 + qw422016.N().S(``) +//line views/nav.qtpl:40 + qw422016.E().S(util.BeautifulName(hyphaName)) +//line views/nav.qtpl:40 + qw422016.N().S(``) +//line views/nav.qtpl:40 +} + +//line views/nav.qtpl:40 +func writebeautifulLink(qq422016 qtio422016.Writer, hyphaName string) { +//line views/nav.qtpl:40 + qw422016 := qt422016.AcquireWriter(qq422016) +//line views/nav.qtpl:40 + streambeautifulLink(qw422016, hyphaName) +//line views/nav.qtpl:40 + qt422016.ReleaseWriter(qw422016) +//line views/nav.qtpl:40 +} + +//line views/nav.qtpl:40 +func beautifulLink(hyphaName string) string { +//line views/nav.qtpl:40 + qb422016 := qt422016.AcquireByteBuffer() +//line views/nav.qtpl:40 + writebeautifulLink(qb422016, hyphaName) +//line views/nav.qtpl:40 + qs422016 := string(qb422016.B) +//line views/nav.qtpl:40 + qt422016.ReleaseByteBuffer(qb422016) +//line views/nav.qtpl:40 + return qs422016 +//line views/nav.qtpl:40 } diff --git a/web/mutators.go b/web/mutators.go index 0a1153d..4181e2a 100644 --- a/web/mutators.go +++ b/web/mutators.go @@ -3,6 +3,7 @@ package web import ( "fmt" "github.com/bouncepaw/mycomarkup/v5" + "github.com/bouncepaw/mycorrhiza/mycoopts" "github.com/bouncepaw/mycorrhiza/viewutil" "log" "net/http" @@ -208,7 +209,7 @@ func handlerUploadText(w http.ResponseWriter, rq *http.Request) { } if action == "Preview" { - ctx, _ := mycocontext.ContextFromStringInput(textData, shroom.MarkupOptions(hyphaName)) + ctx, _ := mycocontext.ContextFromStringInput(textData, mycoopts.MarkupOptions(hyphaName)) util.HTTP200Page( w, diff --git a/web/readers.go b/web/readers.go index f43e265..d8ff2b3 100644 --- a/web/readers.go +++ b/web/readers.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/bouncepaw/mycomarkup/v5" "github.com/bouncepaw/mycorrhiza/files" - "github.com/bouncepaw/mycorrhiza/shroom" + "github.com/bouncepaw/mycorrhiza/mycoopts" "github.com/bouncepaw/mycorrhiza/viewutil" "io" "log" @@ -124,7 +124,7 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) { } textContents, err = history.FileAtRevision(mycoFilePath, revHash) if err == nil { - ctx, _ := mycocontext.ContextFromStringInput(textContents, shroom.MarkupOptions(hyphaName)) + ctx, _ := mycocontext.ContextFromStringInput(textContents, mycoopts.MarkupOptions(hyphaName)) contents = mycomarkup.BlocksToHTML(ctx, mycomarkup.BlockTree(ctx)) } @@ -196,7 +196,7 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) { case hyphae.ExistingHypha: fileContentsT, errT := os.ReadFile(h.TextFilePath()) if errT == nil { - ctx, _ := mycocontext.ContextFromStringInput(string(fileContentsT), shroom.MarkupOptions(hyphaName)) + ctx, _ := mycocontext.ContextFromStringInput(string(fileContentsT), mycoopts.MarkupOptions(hyphaName)) getOpenGraph, descVisitor, imgVisitor := tools.OpenGraphVisitors(ctx) ast := mycomarkup.BlockTree(ctx, descVisitor, imgVisitor) contents = mycomarkup.BlocksToHTML(ctx, ast) @@ -204,7 +204,7 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) { } switch h := h.(type) { case *hyphae.MediaHypha: - contents = views.Media(h, lc) + contents + contents = mycoopts.Media(h, lc) + contents } util.HTTP200Page(w,