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