mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-05 02:29:54 +00:00
Help: Bring the topic sidebar closer
This commit is contained in:
parent
8702660484
commit
e2b570615e
@ -11,6 +11,40 @@
|
||||
{{end}}
|
||||
</article>
|
||||
</main>
|
||||
{{.HelpTopicsHTML}}
|
||||
<aside class="help-topics layout-card">
|
||||
<h2 class="layout-card__title">{{block "topics" .}}Help topics{{end}}</h2>
|
||||
<ul class="help-topics__list">
|
||||
<li><a href="/help/en">{{block "main" .}}Main{{end}}</a></li>
|
||||
<li><a href="/help/en/hypha">{{block "hypha" .}}Hypha{{end}}</a>
|
||||
<ul>
|
||||
<a href="/help/en/media">{{block "media" .}}Media{{end}}</a>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="/help/en/mycomarkup">{{block "mycomarkup" .}}Mycomarkup{{end}}</a></li>
|
||||
<li><a href="/help/en/category">{{block "category" .}}Categories{{end}}</a></li>
|
||||
<li>{{block "interface" .}}Interface{{end}}
|
||||
<ul>
|
||||
<li><a href="/help/en/prevnext">{{block "prevnext" .}}Previous/next{{end}}</a></li>
|
||||
<li><a href="/help/en/top_bar">{{block "top_bar" .}}Top bar{{end}}</a></li>
|
||||
<li><a href="/help/en/sibling_hyphae_section">{{block "sibling_hyphae" .}}Sibling hyphae{{end}}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>{{block "special pages" .}}Special pages{{end}}
|
||||
<ul>
|
||||
<li><a href="/help/en/recent_changes">{{block "recent_changes" .}}Recent changes{{end}}</a></li>
|
||||
<li><a href="/help/en/feeds">{{block "feeds" .}}Feeds{{end}}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>{{block "configuration" .}}Configuration (for administrators){{end}}
|
||||
<ul>
|
||||
<li><a href="/help/en/config_file">{{block "config_file" .}}Configuration file{{end}}</a></li>
|
||||
<li><a href="/help/en/lock">{{block "lock" .}}Lock{{end}}</a></li>
|
||||
<li><a href="/help/en/whitelist">{{block "whitelist" .}}Whitelist{{end}}</a></li>
|
||||
<li><a href="/help/en/telegram">{{block "telegram" .}}Telegram authentication{{end}}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
|
31
help/web.go
31
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"}}Если вы хотите написать эту статью сами, то будем рады вашим правкам <a class="wikilink wikilink_external wikilink_https" href="https://github.com/bouncepaw/mycorrhiza">в репозитории Миокризы</a>.{{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)
|
||||
}
|
||||
|
101
views/help.go
101
views/help.go
@ -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 = `<aside class="help-topics layout-card">
|
||||
<h2 class="layout-card__title">{{l "topics"}}</h2>
|
||||
<ul class="help-topics__list">
|
||||
<li>{{l "main" | a ""}}</li>
|
||||
<li>{{l "hypha" | a "/hypha"}}
|
||||
<ul>
|
||||
{{l "media" | a "/media"}}
|
||||
</ul>
|
||||
</li>
|
||||
<li>{{l "mycomarkup" | a "/mycomarkup"}}</li>
|
||||
<li>{{l "category" | a "/category"}}</li>
|
||||
<li>{{l "interface"}}
|
||||
<ul>
|
||||
<li>{{l "prevnext" | a "/prevnext"}}</li>
|
||||
<li>{{l "top_bar" | a "/top_bar"}}</li>
|
||||
<li>{{l "sibling_hyphae" | a "/sibling_hyphae_section"}}</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>{{l "special_pages"}}
|
||||
<ul>
|
||||
<li>{{l "recent_changes" | a "/recent_changes"}}</li>
|
||||
<li>{{l "feeds" | a "/feeds"}}</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>{{l "configuration"}}
|
||||
<ul>
|
||||
<li>{{l "config_file" | a "/config_file"}}</li>
|
||||
<li>{{l "lock" | a "/lock"}}</li>
|
||||
<li>{{l "whitelist" | a "/whitelist"}}</li>
|
||||
<li>{{l "telegram" | a "/telegram"}}</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>`
|
||||
|
||||
// helpTopicsLinkWrapper wraps in <a>
|
||||
func helpTopicsLinkWrapper(lang string) func(string, string) string {
|
||||
return func(path, contents string) string {
|
||||
return fmt.Sprintf(`<a href="/help/%s%s">%s</a>`, 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()
|
||||
}
|
@ -53,3 +53,9 @@
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endfunc %}
|
||||
|
||||
{% func commonScripts() %}
|
||||
{% for _, scriptPath := range cfg.CommonScripts %}
|
||||
<script src="{%s scriptPath %}"></script>
|
||||
{% endfor %}
|
||||
{% endfunc %}
|
||||
|
@ -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(`
|
||||
<script src="`)
|
||||
//line views/nav.qtpl:59
|
||||
qw422016.E().S(scriptPath)
|
||||
//line views/nav.qtpl:59
|
||||
qw422016.N().S(`"></script>
|
||||
`)
|
||||
//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
|
||||
}
|
||||
|
@ -1,7 +0,0 @@
|
||||
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
||||
|
||||
{% func commonScripts() %}
|
||||
{% for _, scriptPath := range cfg.CommonScripts %}
|
||||
<script src="{%s scriptPath %}"></script>
|
||||
{% endfor %}
|
||||
{% endfunc %}
|
@ -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(`
|
||||
<script src="`)
|
||||
//line views/stuff.qtpl:5
|
||||
qw422016.E().S(scriptPath)
|
||||
//line views/stuff.qtpl:5
|
||||
qw422016.N().S(`"></script>
|
||||
`)
|
||||
//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
|
||||
}
|
Loading…
Reference in New Issue
Block a user