1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-10-30 03:36:16 +00:00

Backlinks: Fix the bug

This commit is contained in:
Timur Ismagilov 2022-06-10 18:45:27 +03:00
parent c0495fbfcc
commit 9713c18b6b
13 changed files with 392 additions and 389 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

54
mycoopts/mycoopts.go Normal file
View File

@ -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()
}

View File

@ -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) %}<a href="/hypha/{%s= hyphaName %}">{%s util.BeautifulName(hyphaName) %}</a>{% 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()) %}

190
mycoopts/view.qtpl.go Normal file
View File

@ -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(`
<div class="binary-container binary-container_with-img">
<a href="/binary/`)
//line mycoopts/view.qtpl:13
qw422016.N().S(h.CanonicalName())
//line mycoopts/view.qtpl:13
qw422016.N().S(`"><img src="/binary/`)
//line mycoopts/view.qtpl:13
qw422016.N().S(h.CanonicalName())
//line mycoopts/view.qtpl:13
qw422016.N().S(`"/></a>
</div>
`)
//line mycoopts/view.qtpl:16
case ".ogg", ".webm", ".mp4":
//line mycoopts/view.qtpl:16
qw422016.N().S(`
<div class="binary-container binary-container_with-video">
<video controls>
<source src="/binary/`)
//line mycoopts/view.qtpl:19
qw422016.N().S(h.CanonicalName())
//line mycoopts/view.qtpl:19
qw422016.N().S(`"/>
<p>`)
//line mycoopts/view.qtpl:20
qw422016.E().S(lc.Get("ui.media_novideo"))
//line mycoopts/view.qtpl:20
qw422016.N().S(` <a href="/binary/`)
//line mycoopts/view.qtpl:20
qw422016.N().S(h.CanonicalName())
//line mycoopts/view.qtpl:20
qw422016.N().S(`">`)
//line mycoopts/view.qtpl:20
qw422016.E().S(lc.Get("ui.media_novideo_link"))
//line mycoopts/view.qtpl:20
qw422016.N().S(`</a></p>
</video>
</div>
`)
//line mycoopts/view.qtpl:24
case ".mp3":
//line mycoopts/view.qtpl:24
qw422016.N().S(`
<div class="binary-container binary-container_with-audio">
<audio controls>
<source src="/binary/`)
//line mycoopts/view.qtpl:27
qw422016.N().S(h.CanonicalName())
//line mycoopts/view.qtpl:27
qw422016.N().S(`"/>
<p>`)
//line mycoopts/view.qtpl:28
qw422016.E().S(lc.Get("ui.media_noaudio"))
//line mycoopts/view.qtpl:28
qw422016.N().S(` <a href="/binary/`)
//line mycoopts/view.qtpl:28
qw422016.N().S(h.CanonicalName())
//line mycoopts/view.qtpl:28
qw422016.N().S(`">`)
//line mycoopts/view.qtpl:28
qw422016.E().S(lc.Get("ui.media_noaudio_link"))
//line mycoopts/view.qtpl:28
qw422016.N().S(`</a></p>
</audio>
</div>
`)
//line mycoopts/view.qtpl:32
default:
//line mycoopts/view.qtpl:32
qw422016.N().S(`
<div class="binary-container binary-container_with-nothing">
<p><a href="/binary/`)
//line mycoopts/view.qtpl:34
qw422016.N().S(h.CanonicalName())
//line mycoopts/view.qtpl:34
qw422016.N().S(`">`)
//line mycoopts/view.qtpl:34
qw422016.E().S(lc.Get("ui.media_download"))
//line mycoopts/view.qtpl:34
qw422016.N().S(`</a></p>
</div>
`)
//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
}

View File

@ -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) {

View File

@ -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()
}

View File

@ -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(`<a href="/hypha/`)
//line views/hypha.qtpl:7
qw422016.N().S(hyphaName)
//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(`</a>`)
//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(`
<div class="binary-container binary-container_with-img">
<a href="/binary/`)
//line views/hypha.qtpl:16
qw422016.N().S(h.CanonicalName())
//line views/hypha.qtpl:16
qw422016.N().S(`"><img src="/binary/`)
//line views/hypha.qtpl:16
qw422016.N().S(h.CanonicalName())
//line views/hypha.qtpl:16
qw422016.N().S(`"/></a>
</div>
`)
//line views/hypha.qtpl:19
case ".ogg", ".webm", ".mp4":
//line views/hypha.qtpl:19
qw422016.N().S(`
<div class="binary-container binary-container_with-video">
<video controls>
<source src="/binary/`)
//line views/hypha.qtpl:22
qw422016.N().S(h.CanonicalName())
//line views/hypha.qtpl:22
qw422016.N().S(`"/>
<p>`)
//line views/hypha.qtpl:23
qw422016.E().S(lc.Get("ui.media_novideo"))
//line views/hypha.qtpl:23
qw422016.N().S(` <a href="/binary/`)
//line views/hypha.qtpl:23
qw422016.N().S(h.CanonicalName())
//line views/hypha.qtpl:23
qw422016.N().S(`">`)
//line views/hypha.qtpl:23
qw422016.E().S(lc.Get("ui.media_novideo_link"))
//line views/hypha.qtpl:23
qw422016.N().S(`</a></p>
</video>
</div>
`)
//line views/hypha.qtpl:27
case ".mp3":
//line views/hypha.qtpl:27
qw422016.N().S(`
<div class="binary-container binary-container_with-audio">
<audio controls>
<source src="/binary/`)
//line views/hypha.qtpl:30
qw422016.N().S(h.CanonicalName())
//line views/hypha.qtpl:30
qw422016.N().S(`"/>
<p>`)
//line views/hypha.qtpl:31
qw422016.E().S(lc.Get("ui.media_noaudio"))
//line views/hypha.qtpl:31
qw422016.N().S(` <a href="/binary/`)
//line views/hypha.qtpl:31
qw422016.N().S(h.CanonicalName())
//line views/hypha.qtpl:31
qw422016.N().S(`">`)
//line views/hypha.qtpl:31
qw422016.E().S(lc.Get("ui.media_noaudio_link"))
//line views/hypha.qtpl:31
qw422016.N().S(`</a></p>
</audio>
</div>
`)
//line views/hypha.qtpl:35
default:
//line views/hypha.qtpl:35
qw422016.N().S(`
<div class="binary-container binary-container_with-nothing">
<p><a href="/binary/`)
//line views/hypha.qtpl:37
qw422016.N().S(h.CanonicalName())
//line views/hypha.qtpl:37
qw422016.N().S(`">`)
//line views/hypha.qtpl:37
qw422016.E().S(lc.Get("ui.media_download"))
//line views/hypha.qtpl:37
qw422016.N().S(`</a></p>
</div>
`)
//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
}

View File

@ -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 @@
<script src="{%s scriptPath %}"></script>
{% endfor %}
{% endfunc %}
{% func beautifulLink(hyphaName string) %}<a href="/hypha/{%s= hyphaName %}">{%s util.BeautifulName(hyphaName) %}</a>{% endfunc %}

View File

@ -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(`
<li class="hypha-info__entry hypha-info__entry_`)
//line views/nav.qtpl:9
//line views/nav.qtpl:10
qw422016.E().S(action)
//line views/nav.qtpl:9
//line views/nav.qtpl:10
qw422016.N().S(`">
<a class="hypha-info__link" href="/`)
//line views/nav.qtpl:10
//line views/nav.qtpl:11
qw422016.E().S(action)
//line views/nav.qtpl:10
//line views/nav.qtpl:11
qw422016.N().S(`/`)
//line views/nav.qtpl:10
//line views/nav.qtpl:11
qw422016.E().S(h.CanonicalName())
//line views/nav.qtpl:10
//line views/nav.qtpl:11
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(`</a>
</li>
`)
//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(`
<nav class="hypha-info">
<ul class="hypha-info__list">
`)
//line views/nav.qtpl:23
//line views/nav.qtpl:24
streamhyphaInfoEntry(qw422016, h, u, "history", lc.Get("ui.history_link"))
//line views/nav.qtpl:23
//line views/nav.qtpl:24
qw422016.N().S(`
`)
//line views/nav.qtpl:24
//line views/nav.qtpl:25
streamhyphaInfoEntry(qw422016, h, u, "rename", lc.Get("ui.rename_link"))
//line views/nav.qtpl:24
//line views/nav.qtpl:25
qw422016.N().S(`
`)
//line views/nav.qtpl:25
//line views/nav.qtpl:26
streamhyphaInfoEntry(qw422016, h, u, "delete", lc.Get("ui.delete_link"))
//line views/nav.qtpl:25
//line views/nav.qtpl:26
qw422016.N().S(`
`)
//line views/nav.qtpl:26
//line views/nav.qtpl:27
streamhyphaInfoEntry(qw422016, h, u, "text", lc.Get("ui.text_link"))
//line views/nav.qtpl:26
//line views/nav.qtpl:27
qw422016.N().S(`
`)
//line views/nav.qtpl:27
//line views/nav.qtpl:28
streamhyphaInfoEntry(qw422016, h, u, "media", lc.Get("ui.media_link"))
//line views/nav.qtpl:27
//line views/nav.qtpl:28
qw422016.N().S(`
`)
//line views/nav.qtpl:28
//line views/nav.qtpl:29
streamhyphaInfoEntry(qw422016, h, u, "backlinks", lc.GetPlural("ui.backlinks_link", backs))
//line views/nav.qtpl:28
//line views/nav.qtpl:29
qw422016.N().S(`
</ul>
</nav>
`)
//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(`
<script src="`)
//line views/nav.qtpl:35
//line views/nav.qtpl:36
qw422016.E().S(scriptPath)
//line views/nav.qtpl:35
//line views/nav.qtpl:36
qw422016.N().S(`"></script>
`)
//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(`<a href="/hypha/`)
//line views/nav.qtpl:40
qw422016.N().S(hyphaName)
//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(`</a>`)
//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
}

View File

@ -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,

View File

@ -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,