mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-12 05:20:26 +00:00
5dd74da8ed
Some stuff is broken, but at least it compiles. Funnily enough, the API turned out to be not broken. This is surprising.
34 lines
794 B
Go
34 lines
794 B
Go
package shroom
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/bouncepaw/mycorrhiza/hyphae"
|
|
"github.com/bouncepaw/mycorrhiza/views"
|
|
|
|
"github.com/bouncepaw/mycomarkup/v3/globals"
|
|
)
|
|
|
|
func init() {
|
|
globals.HyphaExists = func(hyphaName string) bool {
|
|
return hyphae.ByName(hyphaName).Exists
|
|
}
|
|
globals.HyphaAccess = func(hyphaName string) (rawText, binaryBlock string, err error) {
|
|
if h := hyphae.ByName(hyphaName); h.Exists {
|
|
rawText, err = FetchTextPart(h)
|
|
if h.BinaryPath != "" {
|
|
// the view is localized, but we can't pass it, so...
|
|
binaryBlock = views.AttachmentHTMLRaw(h)
|
|
}
|
|
} else {
|
|
err = errors.New("Hypha " + hyphaName + " does not exist")
|
|
}
|
|
return
|
|
}
|
|
globals.HyphaIterate = func(λ func(string)) {
|
|
for h := range hyphae.YieldExistingHyphae() {
|
|
λ(h.Name)
|
|
}
|
|
}
|
|
}
|