1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-10-30 03:36:16 +00:00

Add hypha categories to Base body data attributes

This commit is contained in:
kez 2022-08-13 05:03:21 -07:00 committed by Timur Ismagilov
parent 7fc48f21fc
commit f3437d93c8
3 changed files with 9 additions and 4 deletions

View File

@ -33,8 +33,8 @@ func listOfCategories() (categoryList []string) {
return categoryList
}
// categoriesWithHypha returns what categories have the given hypha. The hypha name must be canonical.
func categoriesWithHypha(hyphaName string) (categoryList []string) {
// CategoriesWithHypha returns what categories have the given hypha. The hypha name must be canonical.
func CategoriesWithHypha(hyphaName string) (categoryList []string) {
mutex.RLock()
defer mutex.RUnlock()
if node, ok := hyphaToCategories[hyphaName]; ok {

View File

@ -52,7 +52,7 @@ func CategoryCard(meta viewutil.Meta, hyphaName string) string {
var buf strings.Builder
err := viewCardChain.Get(meta).ExecuteTemplate(&buf, "category card", cardData{
HyphaName: hyphaName,
Categories: categoriesWithHypha(hyphaName),
Categories: CategoriesWithHypha(hyphaName),
GivenPermissionToModify: meta.U.CanProceed("add-to-category"),
})
if err != nil {

View File

@ -7,6 +7,7 @@ import (
views2 "github.com/bouncepaw/mycorrhiza/hypview"
"github.com/bouncepaw/mycorrhiza/mycoopts"
"github.com/bouncepaw/mycorrhiza/viewutil"
"github.com/bouncepaw/mycorrhiza/categories"
"io"
"log"
"net/http"
@ -210,13 +211,17 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) {
contents = mycoopts.Media(h, lc) + contents
}
cats := []string{}
for _, category := range categories.CategoriesWithHypha(h.CanonicalName()) {
cats = append(cats, "cat-" + category)
}
util.HTTP200Page(w,
viewutil.Base(
viewutil.MetaFrom(w, rq),
util.BeautifulName(hyphaName),
views2.Hypha(viewutil.MetaFrom(w, rq), h, contents),
[]string{},
cats,
openGraph))
}
}