1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-10-30 19:56:16 +00:00
mycorrhiza/shroom/init.go
Timur Ismagilov da6ea25bb6 Delete the markup module, depend on the library instead
The old module had been moved to the library, but I changed it a little, so now both projects are broken. I sure do love programming.
2021-05-12 18:34:24 +05:00

33 lines
726 B
Go

package shroom
import (
"errors"
"github.com/bouncepaw/mycorrhiza/hyphae"
"github.com/bouncepaw/mycorrhiza/views"
"github.com/bouncepaw/mycomarkup/legacy"
)
func init() {
markup.HyphaExists = func(hyphaName string) bool {
return hyphae.ByName(hyphaName).Exists
}
markup.HyphaAccess = func(hyphaName string) (rawText, binaryBlock string, err error) {
if h := hyphae.ByName(hyphaName); h.Exists {
rawText, err = FetchTextPart(h)
if h.BinaryPath != "" {
binaryBlock = views.AttachmentHTML(h)
}
} else {
err = errors.New("Hypha " + hyphaName + " does not exist")
}
return
}
markup.HyphaIterate = func(λ func(string)) {
for h := range hyphae.YieldExistingHyphae() {
λ(h.Name)
}
}
}