1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-01-09 03:00:25 +00:00
mycorrhiza/misc/views.go

56 lines
1.4 KiB
Go
Raw Normal View History

2022-04-02 07:10:32 +00:00
package misc
import (
"embed"
"github.com/bouncepaw/mycorrhiza/viewutil"
)
var (
//go:embed *html
fs embed.FS
chainList, chainTitleSearch viewutil.Chain
ruTranslation = `
2022-04-02 07:10:32 +00:00
{{define "list of hyphae"}}Список гиф{{end}}
{{define "search:"}}Поиск:{{end}}
{{define "search results for"}}Результаты поиска для «{{.}}»{{end}}
{{define "search desc"}}Название каждой из существующих гиф сопоставлено с запросом. Подходящие гифы приведены ниже.{{end}}
{{define "search no results"}}Ничего не найдено{{end}}
2022-04-02 07:10:32 +00:00
`
)
func initViews() {
chainList = viewutil.CopyEnRuWith(fs, "view_list.html", ruTranslation)
chainTitleSearch = viewutil.CopyEnRuWith(fs, "view_title_search.html", ruTranslation)
2022-04-02 07:10:32 +00:00
}
type listDatum struct {
Name string
Ext string
}
type listData struct {
*viewutil.BaseData
2022-04-02 07:10:32 +00:00
Entries []listDatum
}
func viewList(meta viewutil.Meta, entries []listDatum) {
viewutil.ExecutePage(meta, chainList, listData{
BaseData: &viewutil.BaseData{},
Entries: entries,
})
2022-04-02 07:10:32 +00:00
}
type titleSearchData struct {
*viewutil.BaseData
Query string
Results []string
}
func viewTitleSearch(meta viewutil.Meta, query string, results []string) {
viewutil.ExecutePage(meta, chainTitleSearch, titleSearchData{
BaseData: &viewutil.BaseData{},
Query: query,
Results: results,
})
}