2021-02-20 14:03:54 +00:00
|
|
|
package shroom
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/bouncepaw/mycorrhiza/hyphae"
|
2021-02-20 15:48:51 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/views"
|
2021-05-12 13:34:24 +00:00
|
|
|
|
|
|
|
"github.com/bouncepaw/mycomarkup/legacy"
|
2021-02-20 14:03:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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 != "" {
|
2021-02-20 15:48:51 +00:00
|
|
|
binaryBlock = views.AttachmentHTML(h)
|
2021-02-20 14:03:54 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
err = errors.New("Hypha " + hyphaName + " does not exist")
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
markup.HyphaIterate = func(λ func(string)) {
|
|
|
|
for h := range hyphae.YieldExistingHyphae() {
|
|
|
|
λ(h.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|