mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-22 08:06:52 +00:00
Add hypha categories to Base body data attributes
This commit is contained in:
parent
7fc48f21fc
commit
f3437d93c8
@ -33,8 +33,8 @@ func listOfCategories() (categoryList []string) {
|
|||||||
return categoryList
|
return categoryList
|
||||||
}
|
}
|
||||||
|
|
||||||
// categoriesWithHypha returns what categories have the given hypha. The hypha name must be canonical.
|
// CategoriesWithHypha returns what categories have the given hypha. The hypha name must be canonical.
|
||||||
func categoriesWithHypha(hyphaName string) (categoryList []string) {
|
func CategoriesWithHypha(hyphaName string) (categoryList []string) {
|
||||||
mutex.RLock()
|
mutex.RLock()
|
||||||
defer mutex.RUnlock()
|
defer mutex.RUnlock()
|
||||||
if node, ok := hyphaToCategories[hyphaName]; ok {
|
if node, ok := hyphaToCategories[hyphaName]; ok {
|
||||||
|
@ -52,7 +52,7 @@ func CategoryCard(meta viewutil.Meta, hyphaName string) string {
|
|||||||
var buf strings.Builder
|
var buf strings.Builder
|
||||||
err := viewCardChain.Get(meta).ExecuteTemplate(&buf, "category card", cardData{
|
err := viewCardChain.Get(meta).ExecuteTemplate(&buf, "category card", cardData{
|
||||||
HyphaName: hyphaName,
|
HyphaName: hyphaName,
|
||||||
Categories: categoriesWithHypha(hyphaName),
|
Categories: CategoriesWithHypha(hyphaName),
|
||||||
GivenPermissionToModify: meta.U.CanProceed("add-to-category"),
|
GivenPermissionToModify: meta.U.CanProceed("add-to-category"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
views2 "github.com/bouncepaw/mycorrhiza/hypview"
|
views2 "github.com/bouncepaw/mycorrhiza/hypview"
|
||||||
"github.com/bouncepaw/mycorrhiza/mycoopts"
|
"github.com/bouncepaw/mycorrhiza/mycoopts"
|
||||||
"github.com/bouncepaw/mycorrhiza/viewutil"
|
"github.com/bouncepaw/mycorrhiza/viewutil"
|
||||||
|
"github.com/bouncepaw/mycorrhiza/categories"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -210,13 +211,17 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) {
|
|||||||
contents = mycoopts.Media(h, lc) + contents
|
contents = mycoopts.Media(h, lc) + contents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cats := []string{}
|
||||||
|
for _, category := range categories.CategoriesWithHypha(h.CanonicalName()) {
|
||||||
|
cats = append(cats, "cat-" + category)
|
||||||
|
}
|
||||||
|
|
||||||
util.HTTP200Page(w,
|
util.HTTP200Page(w,
|
||||||
viewutil.Base(
|
viewutil.Base(
|
||||||
viewutil.MetaFrom(w, rq),
|
viewutil.MetaFrom(w, rq),
|
||||||
util.BeautifulName(hyphaName),
|
util.BeautifulName(hyphaName),
|
||||||
views2.Hypha(viewutil.MetaFrom(w, rq), h, contents),
|
views2.Hypha(viewutil.MetaFrom(w, rq), h, contents),
|
||||||
[]string{},
|
cats,
|
||||||
openGraph))
|
openGraph))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user