mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-06-06 04:44:05 +00:00
Interwiki: Start migrating to new API
Come to think of it, it is a breaking API change out there, right? Gotta bump Mycomarkup to v5 one day.
This commit is contained in:
parent
b5093b0b76
commit
79e79c6efd
@ -31,8 +31,8 @@ func ParseHeaderLinks(text string) {
|
|||||||
case blocks.LaunchPad:
|
case blocks.LaunchPad:
|
||||||
for _, rocket := range launchpad.Rockets {
|
for _, rocket := range launchpad.Rockets {
|
||||||
HeaderLinks = append(HeaderLinks, HeaderLink{
|
HeaderLinks = append(HeaderLinks, HeaderLink{
|
||||||
Href: rocket.Href(),
|
Href: rocket.LinkHref(ctx),
|
||||||
Display: rocket.Display(),
|
Display: rocket.DisplayedText(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
go.mod
4
go.mod
@ -3,7 +3,7 @@ module github.com/bouncepaw/mycorrhiza
|
|||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bouncepaw/mycomarkup/v4 v4.2.0
|
github.com/bouncepaw/mycomarkup/v4 v4.3.0
|
||||||
github.com/go-ini/ini v1.63.2
|
github.com/go-ini/ini v1.63.2
|
||||||
github.com/gorilla/feeds v1.1.1
|
github.com/gorilla/feeds v1.1.1
|
||||||
github.com/gorilla/mux v1.8.0
|
github.com/gorilla/mux v1.8.0
|
||||||
@ -23,7 +23,7 @@ require (
|
|||||||
|
|
||||||
// Use this trick to test local Mycomarkup changes, replace the path with yours,
|
// Use this trick to test local Mycomarkup changes, replace the path with yours,
|
||||||
// but do not commit the change to the path:
|
// but do not commit the change to the path:
|
||||||
// replace github.com/bouncepaw/mycomarkup/v4 v4.0.0 => "/Users/bouncepaw/GolandProjects/mycomarkup"
|
// replace github.com/bouncepaw/mycomarkup/v4 v4.3.0 => "/Users/bouncepaw/GolandProjects/mycomarkup"
|
||||||
|
|
||||||
// Use this utility every time Mycomarkup gets a major update:
|
// Use this utility every time Mycomarkup gets a major update:
|
||||||
// https://github.com/marwan-at-work/mod
|
// https://github.com/marwan-at-work/mod
|
||||||
|
4
go.sum
4
go.sum
@ -1,7 +1,7 @@
|
|||||||
github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||||
github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||||
github.com/bouncepaw/mycomarkup/v4 v4.2.0 h1:YpxVL3I9X94T7B/2R/5/u1McfVXomlPdXcX/x+Ur3kI=
|
github.com/bouncepaw/mycomarkup/v4 v4.3.0 h1:Sj2spSzNbd/o5AKOi/Y/vRPpebaz5s9HOKP42UDA9Dg=
|
||||||
github.com/bouncepaw/mycomarkup/v4 v4.2.0/go.mod h1:y0b8U6Xfnh3KfNUpG3QuAXRJwqFPPpmS2kYvLzaf688=
|
github.com/bouncepaw/mycomarkup/v4 v4.3.0/go.mod h1:y0b8U6Xfnh3KfNUpG3QuAXRJwqFPPpmS2kYvLzaf688=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/go-ini/ini v1.63.2 h1:kwN3umicd2HF3Tgvap4um1ZG52/WyKT9GGdPx0CJk6Y=
|
github.com/go-ini/ini v1.63.2 h1:kwN3umicd2HF3Tgvap4um1ZG52/WyKT9GGdPx0CJk6Y=
|
||||||
|
@ -30,6 +30,13 @@ func Init() {
|
|||||||
log.Printf("Loaded %d interwiki entries\n", len(theMap.list))
|
log.Printf("Loaded %d interwiki entries\n", len(theMap.list))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HrefLinkFormatFor(prefix string) string {
|
||||||
|
if wiki, ok := theMap.byName[prefix]; ok {
|
||||||
|
return wiki.LinkFormat
|
||||||
|
}
|
||||||
|
return "{NAME}"
|
||||||
|
}
|
||||||
|
|
||||||
func readInterwiki() ([]Wiki, error) {
|
func readInterwiki() ([]Wiki, error) {
|
||||||
var (
|
var (
|
||||||
record []Wiki
|
record []Wiki
|
||||||
|
@ -5,27 +5,31 @@ import (
|
|||||||
"github.com/bouncepaw/mycomarkup/v4/options"
|
"github.com/bouncepaw/mycomarkup/v4/options"
|
||||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||||
"github.com/bouncepaw/mycorrhiza/hyphae"
|
"github.com/bouncepaw/mycorrhiza/hyphae"
|
||||||
|
"github.com/bouncepaw/mycorrhiza/interwiki"
|
||||||
|
"github.com/bouncepaw/mycorrhiza/util"
|
||||||
"github.com/bouncepaw/mycorrhiza/views"
|
"github.com/bouncepaw/mycorrhiza/views"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MarkupOptions(hyphaName string) options.Options {
|
func MarkupOptions(hyphaName string) options.Options {
|
||||||
return fillMycomarkupOptions(options.Options{
|
return options.Options{
|
||||||
HyphaName: hyphaName,
|
HyphaName: hyphaName,
|
||||||
WebSiteURL: cfg.URL,
|
WebSiteURL: cfg.URL,
|
||||||
TransclusionSupported: true,
|
TransclusionSupported: true,
|
||||||
})
|
RedLinksSupported: true,
|
||||||
}
|
HyphaExists: func(hyphaName string) bool {
|
||||||
|
|
||||||
func fillMycomarkupOptions(opts options.Options) options.Options {
|
|
||||||
opts.HyphaExists = func(hyphaName string) bool {
|
|
||||||
switch hyphae.ByName(hyphaName).(type) {
|
switch hyphae.ByName(hyphaName).(type) {
|
||||||
case *hyphae.EmptyHypha:
|
case *hyphae.EmptyHypha:
|
||||||
return false
|
return false
|
||||||
default:
|
default:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
IterateHyphaNamesWith: func(λ func(string)) {
|
||||||
|
for h := range hyphae.YieldExistingHyphae() {
|
||||||
|
λ(h.CanonicalName())
|
||||||
}
|
}
|
||||||
opts.HyphaHTMLData = func(hyphaName string) (rawText, binaryBlock string, err error) {
|
},
|
||||||
|
HyphaHTMLData: func(hyphaName string) (rawText, binaryBlock string, err error) {
|
||||||
switch h := hyphae.ByName(hyphaName).(type) {
|
switch h := hyphae.ByName(hyphaName).(type) {
|
||||||
case *hyphae.EmptyHypha:
|
case *hyphae.EmptyHypha:
|
||||||
err = errors.New("Hypha " + hyphaName + " does not exist")
|
err = errors.New("Hypha " + hyphaName + " does not exist")
|
||||||
@ -36,11 +40,14 @@ func fillMycomarkupOptions(opts options.Options) options.Options {
|
|||||||
binaryBlock = views.MediaRaw(h)
|
binaryBlock = views.MediaRaw(h)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
},
|
||||||
opts.IterateHyphaNamesWith = func(λ func(string)) {
|
LocalLinkHref: func(hyphaName string) string {
|
||||||
for h := range hyphae.YieldExistingHyphae() {
|
return "/hypha/" + util.CanonicalName(hyphaName)
|
||||||
λ(h.CanonicalName())
|
},
|
||||||
}
|
LocalImgSrc: func(hyphaName string) string {
|
||||||
}
|
return "/binary/" + util.CanonicalName(hyphaName)
|
||||||
return opts.FillTheRest()
|
},
|
||||||
|
LinkHrefFormatForInterwikiPrefix: interwiki.HrefLinkFormatFor,
|
||||||
|
ImgSrcFormatForInterwikiPrefix: interwiki.HrefLinkFormatFor, // TODO: dewrong
|
||||||
|
}.FillTheRest()
|
||||||
}
|
}
|
||||||
|
@ -242,6 +242,7 @@ main { background-color: white; }
|
|||||||
.shy-link { color: black; }
|
.shy-link { color: black; }
|
||||||
|
|
||||||
blockquote { border-left: 2px #999 solid; }
|
blockquote { border-left: 2px #999 solid; }
|
||||||
|
.wikilink_interwiki {color:#080;}
|
||||||
.wikilink_new {color:#a55858;}
|
.wikilink_new {color:#a55858;}
|
||||||
.transclusion code, .transclusion .codeblock {background-color:#ddd;}
|
.transclusion code, .transclusion .codeblock {background-color:#ddd;}
|
||||||
.transclusion__link { color: black; }
|
.transclusion__link { color: black; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user