From e2b570615ed9281593f392ae62090fa08ae2e4e3 Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Sat, 9 Apr 2022 14:55:55 +0300 Subject: [PATCH] Help: Bring the topic sidebar closer --- help/view_help.html | 36 +++++++++++++++- help/web.go | 31 ++++++++++---- views/help.go | 101 -------------------------------------------- views/nav.qtpl | 6 +++ views/nav.qtpl.go | 49 +++++++++++++++++++++ views/stuff.qtpl | 7 --- views/stuff.qtpl.go | 70 ------------------------------ 7 files changed, 113 insertions(+), 187 deletions(-) delete mode 100644 views/help.go delete mode 100644 views/stuff.qtpl delete mode 100644 views/stuff.qtpl.go diff --git a/help/view_help.html b/help/view_help.html index 17f1d7f..ed426b7 100644 --- a/help/view_help.html +++ b/help/view_help.html @@ -11,6 +11,40 @@ {{end}} - {{.HelpTopicsHTML}} + {{end}} + diff --git a/help/web.go b/help/web.go index 8c904cd..a717435 100644 --- a/help/web.go +++ b/help/web.go @@ -14,8 +14,6 @@ import ( "github.com/gorilla/mux" - "github.com/bouncepaw/mycorrhiza/views" - "github.com/bouncepaw/mycomarkup/v4/mycocontext" ) @@ -25,6 +23,25 @@ var ( {{define "title"}}Справка{{end}} {{define "entry not found"}}Статья не найдена{{end}} {{define "entry not found invitation"}}Если вы хотите написать эту статью сами, то будем рады вашим правкам в репозитории Миокризы.{{end}} + +{{define "topics"}}Темы справки{{end}} +{{define "main"}}Введение{{end}} +{{define "hypha"}}Гифа{{end}} +{{define "media"}}Медиа{{end}} +{{define "mycomarkup"}}Микоразметка{{end}} +{{define "category"}}Категории{{end}} +{{define "interface"}}Интерфейс{{end}} +{{define "prevnext"}}Пред/след{{end}} +{{define "top_bar"}}Верхняя панель{{end}} +{{define "sibling_hyphae"}}Гифы-сиблинги{{end}} +{{define "special pages"}}Специальные страницы{{end}} +{{define "recent_changes"}}Недавние изменения{{end}} +{{define "feeds"}}Ленты{{end}} +{{define "configuration"}}Конфигурация (для администраторов){{end}} +{{define "config_file"}}Файл конфигурации{{end}} +{{define "lock"}}Замок{{end}} +{{define "whitelist"}}Белый список{{end}} +{{define "telegram"}}Вход через Телеграм{{end}} ` ) @@ -75,9 +92,8 @@ func handlerHelp(w http.ResponseWriter, rq *http.Request) { type helpData struct { viewutil.BaseData - ContentsHTML string - HelpTopicsHTML string - Lang string + ContentsHTML string + Lang string } func viewHelp(meta viewutil.Meta, lang, contentsHTML string) { @@ -87,9 +103,8 @@ func viewHelp(meta viewutil.Meta, lang, contentsHTML string) { HeaderLinks: cfg.HeaderLinks, CommonScripts: cfg.CommonScripts, }, - ContentsHTML: contentsHTML, - HelpTopicsHTML: views.HelpTopics(lang, meta.Lc), - Lang: lang, + ContentsHTML: contentsHTML, + Lang: lang, }); err != nil { log.Println(err) } diff --git a/views/help.go b/views/help.go deleted file mode 100644 index 41de7b7..0000000 --- a/views/help.go +++ /dev/null @@ -1,101 +0,0 @@ -package views - -import ( - "fmt" - "github.com/bouncepaw/mycorrhiza/l18n" - "log" - "strings" - "text/template" -) - -var helpTopicsL10n = map[string][]string{ - "topics": {"Help topics", "Темы справки"}, - "main": {"Main", "Введение"}, - "hypha": {"Hypha", "Гифа"}, - "media": {"Media", "Медиа"}, - "mycomarkup": {"Mycomarkup", "Микоразметка"}, - "interface": {"Interface", "Интерфейс"}, - "prevnext": {"Previous/next", "Назад/далее"}, // пред след? - "top_bar": {"Top bar", "Верхняя панель"}, - "sibling_hyphae": {"Sibling hyphae", "Гифы-сиблинги"}, - "special_pages": {"Special pages", "Специальные страницы"}, - "recent_changes": {"Recent changes", "Недавние изменения"}, // так ли? В медиавики свежие правки - "feeds": {"Feeds", "Ленты"}, - "configuration": {"Configuration (for administrators)", "Конфигурация (для администраторов)"}, - "config_file": {"Configuration file", "Файл конфигурации"}, - "lock": {"Lock", "Блокировка"}, // Не Замок ли? - "whitelist": {"Whitelist", "Белый список"}, - "telegram": {"Telegram authentication", "Вход через Телеграм"}, - "category": {"Categories", "Категории"}, -} - -const helpTopicTemplate = `` - -// helpTopicsLinkWrapper wraps in -func helpTopicsLinkWrapper(lang string) func(string, string) string { - return func(path, contents string) string { - return fmt.Sprintf(`%s`, lang, path, contents) - } -} - -func helpTopicsLocalizedTopic(lang string) func(string) string { - pos := 0 - if lang == "ru" { - pos = 1 - } - return func(topic string) string { - return helpTopicsL10n[topic][pos] - } -} - -func HelpTopics(lang string, lc *l18n.Localizer) string { - temp, err := template. - New("help topics"). - Funcs(template.FuncMap{ - "a": helpTopicsLinkWrapper(lang), - "l": helpTopicsLocalizedTopic(lc.Locale), - }). - Parse(helpTopicTemplate) - if err != nil { - log.Println(err) - return "" - } - - // TODO: one day, it should write to a better place - var out strings.Builder - _ = temp.Execute(&out, nil) // Shall not fail! - return out.String() -} diff --git a/views/nav.qtpl b/views/nav.qtpl index 58f94f4..32353e8 100644 --- a/views/nav.qtpl +++ b/views/nav.qtpl @@ -53,3 +53,9 @@ {% endif %} {% endfunc %} + +{% func commonScripts() %} +{% for _, scriptPath := range cfg.CommonScripts %} + +{% endfor %} +{% endfunc %} diff --git a/views/nav.qtpl.go b/views/nav.qtpl.go index 83cc255..de41b2d 100644 --- a/views/nav.qtpl.go +++ b/views/nav.qtpl.go @@ -292,3 +292,52 @@ func Subhyphae(subhyphae string, lc *l18n.Localizer) string { return qs422016 //line views/nav.qtpl:55 } + +//line views/nav.qtpl:57 +func streamcommonScripts(qw422016 *qt422016.Writer) { +//line views/nav.qtpl:57 + qw422016.N().S(` +`) +//line views/nav.qtpl:58 + for _, scriptPath := range cfg.CommonScripts { +//line views/nav.qtpl:58 + qw422016.N().S(` + +`) +//line views/nav.qtpl:60 + } +//line views/nav.qtpl:60 + qw422016.N().S(` +`) +//line views/nav.qtpl:61 +} + +//line views/nav.qtpl:61 +func writecommonScripts(qq422016 qtio422016.Writer) { +//line views/nav.qtpl:61 + qw422016 := qt422016.AcquireWriter(qq422016) +//line views/nav.qtpl:61 + streamcommonScripts(qw422016) +//line views/nav.qtpl:61 + qt422016.ReleaseWriter(qw422016) +//line views/nav.qtpl:61 +} + +//line views/nav.qtpl:61 +func commonScripts() string { +//line views/nav.qtpl:61 + qb422016 := qt422016.AcquireByteBuffer() +//line views/nav.qtpl:61 + writecommonScripts(qb422016) +//line views/nav.qtpl:61 + qs422016 := string(qb422016.B) +//line views/nav.qtpl:61 + qt422016.ReleaseByteBuffer(qb422016) +//line views/nav.qtpl:61 + return qs422016 +//line views/nav.qtpl:61 +} diff --git a/views/stuff.qtpl b/views/stuff.qtpl deleted file mode 100644 index acb68a5..0000000 --- a/views/stuff.qtpl +++ /dev/null @@ -1,7 +0,0 @@ -{% import "github.com/bouncepaw/mycorrhiza/cfg" %} - -{% func commonScripts() %} -{% for _, scriptPath := range cfg.CommonScripts %} - -{% endfor %} -{% endfunc %} diff --git a/views/stuff.qtpl.go b/views/stuff.qtpl.go deleted file mode 100644 index c0b4e29..0000000 --- a/views/stuff.qtpl.go +++ /dev/null @@ -1,70 +0,0 @@ -// Code generated by qtc from "stuff.qtpl". DO NOT EDIT. -// See https://github.com/valyala/quicktemplate for details. - -//line views/stuff.qtpl:1 -package views - -//line views/stuff.qtpl:1 -import "github.com/bouncepaw/mycorrhiza/cfg" - -//line views/stuff.qtpl:3 -import ( - qtio422016 "io" - - qt422016 "github.com/valyala/quicktemplate" -) - -//line views/stuff.qtpl:3 -var ( - _ = qtio422016.Copy - _ = qt422016.AcquireByteBuffer -) - -//line views/stuff.qtpl:3 -func streamcommonScripts(qw422016 *qt422016.Writer) { -//line views/stuff.qtpl:3 - qw422016.N().S(` -`) -//line views/stuff.qtpl:4 - for _, scriptPath := range cfg.CommonScripts { -//line views/stuff.qtpl:4 - qw422016.N().S(` - -`) -//line views/stuff.qtpl:6 - } -//line views/stuff.qtpl:6 - qw422016.N().S(` -`) -//line views/stuff.qtpl:7 -} - -//line views/stuff.qtpl:7 -func writecommonScripts(qq422016 qtio422016.Writer) { -//line views/stuff.qtpl:7 - qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:7 - streamcommonScripts(qw422016) -//line views/stuff.qtpl:7 - qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:7 -} - -//line views/stuff.qtpl:7 -func commonScripts() string { -//line views/stuff.qtpl:7 - qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:7 - writecommonScripts(qb422016) -//line views/stuff.qtpl:7 - qs422016 := string(qb422016.B) -//line views/stuff.qtpl:7 - qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:7 - return qs422016 -//line views/stuff.qtpl:7 -}