diff --git a/l18n/en/help.json b/l18n/en/help.json index e7dfbc4..0508f0c 100644 --- a/l18n/en/help.json +++ b/l18n/en/help.json @@ -5,23 +5,5 @@ "empty_error_line_1": "Try finding a different entry that would help you.", "empty_error_line_2a": "If you want to write this entry by yourself, consider", "empty_error_link": "contributing", - "empty_error_line_2b": "to Mycorrhiza Wiki directly.", - - "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)", - "lock": "Lock", - "whitelist": "Whitelist", - "telegram": "Telegram authorization", - "config_file": "Configuration file" + "empty_error_line_2b": "to Mycorrhiza Wiki directly." } diff --git a/l18n/ru/help.json b/l18n/ru/help.json index 50e94bd..1bbf8a5 100644 --- a/l18n/ru/help.json +++ b/l18n/ru/help.json @@ -5,23 +5,5 @@ "empty_error_line_1": "Попробуйте поискать другую страницу, способную вам помочь.", "empty_error_line_2a": "Если вы хотите написать эту страницу сами, будем рады вашим правкам в ", "empty_error_link": "репозитории", - "empty_error_line_2b": "Микоризы.", - - "topics": "Темы справки", - "main": "Введение", - "hypha": "Гифа", - "media": "Медиа", - "mycomarkup": "Микоразметка", - "interface": "Интерфейс", - "prevnext": "Назад/далее", - "top_bar": "Верхняя панель", - "sibling_hyphae": "Гифы-сиблинги", - "special_pages": "Специальные страницы", - "recent_changes": "Недавние изменения", - "feeds": "Ленты", - "configuration": "Конфигурация (для администраторов)", - "lock": "Блокировка", - "whitelist": "Белый список", - "telegram": "Авторизация через Телеграм", - "config_file": "Файл конфигурации" + "empty_error_line_2b": "Микоризы." } diff --git a/views/help.go b/views/help.go new file mode 100644 index 0000000..b74ad12 --- /dev/null +++ b/views/help.go @@ -0,0 +1,99 @@ +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", "Вход через Телеграм"}, +} + +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 helpTopicsHTML(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/stuff.qtpl b/views/stuff.qtpl index 9b02e68..a42fc4e 100644 --- a/views/stuff.qtpl +++ b/views/stuff.qtpl @@ -161,42 +161,6 @@ It outputs a poorly formatted JSON, but it works and is valid.

{%s lc.Get("help.empty_error_line_2a") %} {%s lc.Get("help.empty_error_link") %} {%s lc.Get("help.empty_error_line_2b") %}

{% endfunc %} -{% func helpTopicsHTML(lang string, lc *l18n.Localizer) %} - -{% endfunc %} - {% func helpTopicBadgeHTML(lang, topic string) %} ? {% endfunc %} diff --git a/views/stuff.qtpl.go b/views/stuff.qtpl.go index 638a3ff..47c96cf 100644 --- a/views/stuff.qtpl.go +++ b/views/stuff.qtpl.go @@ -604,244 +604,57 @@ func HelpEmptyErrorHTML(lc *l18n.Localizer) string { } //line views/stuff.qtpl:164 -func streamhelpTopicsHTML(qw422016 *qt422016.Writer, lang string, lc *l18n.Localizer) { +func streamhelpTopicBadgeHTML(qw422016 *qt422016.Writer, lang, topic string) { //line views/stuff.qtpl:164 qw422016.N().S(` - -`) -//line views/stuff.qtpl:198 -} - -//line views/stuff.qtpl:198 -func writehelpTopicsHTML(qq422016 qtio422016.Writer, lang string, lc *l18n.Localizer) { -//line views/stuff.qtpl:198 - qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:198 - streamhelpTopicsHTML(qw422016, lang, lc) -//line views/stuff.qtpl:198 - qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:198 -} - -//line views/stuff.qtpl:198 -func helpTopicsHTML(lang string, lc *l18n.Localizer) string { -//line views/stuff.qtpl:198 - qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:198 - writehelpTopicsHTML(qb422016, lang, lc) -//line views/stuff.qtpl:198 - qs422016 := string(qb422016.B) -//line views/stuff.qtpl:198 - qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:198 - return qs422016 -//line views/stuff.qtpl:198 -} - -//line views/stuff.qtpl:200 -func streamhelpTopicBadgeHTML(qw422016 *qt422016.Writer, lang, topic string) { -//line views/stuff.qtpl:200 - qw422016.N().S(` ? `) -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 } -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 func writehelpTopicBadgeHTML(qq422016 qtio422016.Writer, lang, topic string) { -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 streamhelpTopicBadgeHTML(qw422016, lang, topic) -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 } -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 func helpTopicBadgeHTML(lang, topic string) string { -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 writehelpTopicBadgeHTML(qb422016, lang, topic) -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 return qs422016 -//line views/stuff.qtpl:202 +//line views/stuff.qtpl:166 } -//line views/stuff.qtpl:204 +//line views/stuff.qtpl:168 func StreamUserListHTML(qw422016 *qt422016.Writer, lc *l18n.Localizer) { -//line views/stuff.qtpl:204 +//line views/stuff.qtpl:168 qw422016.N().S(`

`) -//line views/stuff.qtpl:207 +//line views/stuff.qtpl:171 qw422016.E().S(lc.Get("ui.users_heading")) -//line views/stuff.qtpl:207 +//line views/stuff.qtpl:171 qw422016.N().S(`

`) -//line views/stuff.qtpl:209 +//line views/stuff.qtpl:173 var ( admins = make([]string, 0) moderators = make([]string, 0) @@ -861,149 +674,149 @@ func StreamUserListHTML(qw422016 *qt422016.Writer, lc *l18n.Localizer) { sort.Strings(moderators) sort.Strings(editors) -//line views/stuff.qtpl:227 +//line views/stuff.qtpl:191 qw422016.N().S(`

`) -//line views/stuff.qtpl:229 +//line views/stuff.qtpl:193 qw422016.E().S(lc.Get("ui.users_admins")) -//line views/stuff.qtpl:229 +//line views/stuff.qtpl:193 qw422016.N().S(`

    `) -//line views/stuff.qtpl:230 +//line views/stuff.qtpl:194 for _, name := range admins { -//line views/stuff.qtpl:230 +//line views/stuff.qtpl:194 qw422016.N().S(`
  1. `) -//line views/stuff.qtpl:231 +//line views/stuff.qtpl:195 qw422016.E().S(name) -//line views/stuff.qtpl:231 +//line views/stuff.qtpl:195 qw422016.N().S(`
  2. `) -//line views/stuff.qtpl:232 +//line views/stuff.qtpl:196 } -//line views/stuff.qtpl:232 +//line views/stuff.qtpl:196 qw422016.N().S(`

`) -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:199 qw422016.E().S(lc.Get("ui.users_moderators")) -//line views/stuff.qtpl:235 +//line views/stuff.qtpl:199 qw422016.N().S(`

    `) -//line views/stuff.qtpl:236 +//line views/stuff.qtpl:200 for _, name := range moderators { -//line views/stuff.qtpl:236 +//line views/stuff.qtpl:200 qw422016.N().S(`
  1. `) -//line views/stuff.qtpl:237 +//line views/stuff.qtpl:201 qw422016.E().S(name) -//line views/stuff.qtpl:237 +//line views/stuff.qtpl:201 qw422016.N().S(`
  2. `) -//line views/stuff.qtpl:238 +//line views/stuff.qtpl:202 } -//line views/stuff.qtpl:238 +//line views/stuff.qtpl:202 qw422016.N().S(`

`) -//line views/stuff.qtpl:241 +//line views/stuff.qtpl:205 qw422016.E().S(lc.Get("ui.users_editors")) -//line views/stuff.qtpl:241 +//line views/stuff.qtpl:205 qw422016.N().S(`

    `) -//line views/stuff.qtpl:242 +//line views/stuff.qtpl:206 for _, name := range editors { -//line views/stuff.qtpl:242 +//line views/stuff.qtpl:206 qw422016.N().S(`
  1. `) -//line views/stuff.qtpl:243 +//line views/stuff.qtpl:207 qw422016.E().S(name) -//line views/stuff.qtpl:243 +//line views/stuff.qtpl:207 qw422016.N().S(`
  2. `) -//line views/stuff.qtpl:244 +//line views/stuff.qtpl:208 } -//line views/stuff.qtpl:244 +//line views/stuff.qtpl:208 qw422016.N().S(`
`) -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 } -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 func WriteUserListHTML(qq422016 qtio422016.Writer, lc *l18n.Localizer) { -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 StreamUserListHTML(qw422016, lc) -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 } -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 func UserListHTML(lc *l18n.Localizer) string { -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 WriteUserListHTML(qb422016, lc) -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 return qs422016 -//line views/stuff.qtpl:248 +//line views/stuff.qtpl:212 } -//line views/stuff.qtpl:250 +//line views/stuff.qtpl:214 func StreamHyphaListHTML(qw422016 *qt422016.Writer, lc *l18n.Localizer) { -//line views/stuff.qtpl:250 +//line views/stuff.qtpl:214 qw422016.N().S(`

`) -//line views/stuff.qtpl:253 +//line views/stuff.qtpl:217 qw422016.E().S(lc.Get("ui.list_heading")) -//line views/stuff.qtpl:253 +//line views/stuff.qtpl:217 qw422016.N().S(`

`) -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:218 qw422016.E().S(lc.GetPlural("ui.list_desc", hyphae.Count())) -//line views/stuff.qtpl:254 +//line views/stuff.qtpl:218 qw422016.N().S(`

`) -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 } -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 func WriteHyphaListHTML(qq422016 qtio422016.Writer, lc *l18n.Localizer) { -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 StreamHyphaListHTML(qw422016, lc) -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 } -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 func HyphaListHTML(lc *l18n.Localizer) string { -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 WriteHyphaListHTML(qb422016, lc) -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 return qs422016 -//line views/stuff.qtpl:281 +//line views/stuff.qtpl:245 } -//line views/stuff.qtpl:283 +//line views/stuff.qtpl:247 func StreamAboutHTML(qw422016 *qt422016.Writer, lc *l18n.Localizer) { -//line views/stuff.qtpl:283 +//line views/stuff.qtpl:247 qw422016.N().S(`

`) -//line views/stuff.qtpl:287 +//line views/stuff.qtpl:251 qw422016.E().S(lc.Get("ui.about_title", &l18n.Replacements{"name": cfg.WikiName})) -//line views/stuff.qtpl:287 +//line views/stuff.qtpl:251 qw422016.N().S(`

  • `) -//line views/stuff.qtpl:289 +//line views/stuff.qtpl:253 qw422016.N().S(lc.Get("ui.about_version", &l18n.Replacements{"pre": "", "post": ""})) -//line views/stuff.qtpl:289 +//line views/stuff.qtpl:253 qw422016.N().S(` 1.8.2
  • `) -//line views/stuff.qtpl:290 +//line views/stuff.qtpl:254 if cfg.UseAuth { -//line views/stuff.qtpl:290 +//line views/stuff.qtpl:254 qw422016.N().S(`
  • `) -//line views/stuff.qtpl:291 +//line views/stuff.qtpl:255 qw422016.E().S(lc.Get("ui.about_usercount")) -//line views/stuff.qtpl:291 +//line views/stuff.qtpl:255 qw422016.N().S(` `) -//line views/stuff.qtpl:291 +//line views/stuff.qtpl:255 qw422016.N().DUL(user.Count()) -//line views/stuff.qtpl:291 +//line views/stuff.qtpl:255 qw422016.N().S(`
  • `) -//line views/stuff.qtpl:292 +//line views/stuff.qtpl:256 qw422016.E().S(lc.Get("ui.about_homepage")) -//line views/stuff.qtpl:292 +//line views/stuff.qtpl:256 qw422016.N().S(` `) -//line views/stuff.qtpl:292 +//line views/stuff.qtpl:256 qw422016.E().S(cfg.HomeHypha) -//line views/stuff.qtpl:292 +//line views/stuff.qtpl:256 qw422016.N().S(`
  • `) -//line views/stuff.qtpl:293 +//line views/stuff.qtpl:257 qw422016.E().S(lc.Get("ui.about_admins")) -//line views/stuff.qtpl:293 +//line views/stuff.qtpl:257 qw422016.N().S(``) -//line views/stuff.qtpl:293 +//line views/stuff.qtpl:257 for i, username := range user.ListUsersWithGroup("admin") { -//line views/stuff.qtpl:294 +//line views/stuff.qtpl:258 if i > 0 { -//line views/stuff.qtpl:294 +//line views/stuff.qtpl:258 qw422016.N().S(` `) -//line views/stuff.qtpl:295 +//line views/stuff.qtpl:259 } -//line views/stuff.qtpl:295 +//line views/stuff.qtpl:259 qw422016.N().S(` `) -//line views/stuff.qtpl:296 +//line views/stuff.qtpl:260 qw422016.E().S(username) -//line views/stuff.qtpl:296 +//line views/stuff.qtpl:260 qw422016.N().S(``) -//line views/stuff.qtpl:296 +//line views/stuff.qtpl:260 } -//line views/stuff.qtpl:296 +//line views/stuff.qtpl:260 qw422016.N().S(`
  • `) -//line views/stuff.qtpl:297 +//line views/stuff.qtpl:261 } else { -//line views/stuff.qtpl:297 +//line views/stuff.qtpl:261 qw422016.N().S(`
  • `) -//line views/stuff.qtpl:298 +//line views/stuff.qtpl:262 qw422016.E().S(lc.Get("ui.about_noauth")) -//line views/stuff.qtpl:298 +//line views/stuff.qtpl:262 qw422016.N().S(`
  • `) -//line views/stuff.qtpl:299 +//line views/stuff.qtpl:263 } -//line views/stuff.qtpl:299 +//line views/stuff.qtpl:263 qw422016.N().S(`

`) -//line views/stuff.qtpl:301 +//line views/stuff.qtpl:265 qw422016.N().S(lc.Get("ui.about_hyphae", &l18n.Replacements{"link": "/list"})) -//line views/stuff.qtpl:301 +//line views/stuff.qtpl:265 qw422016.N().S(`

`) -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 } -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 func WriteAboutHTML(qq422016 qtio422016.Writer, lc *l18n.Localizer) { -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 StreamAboutHTML(qw422016, lc) -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 } -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 func AboutHTML(lc *l18n.Localizer) string { -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 WriteAboutHTML(qb422016, lc) -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 return qs422016 -//line views/stuff.qtpl:305 +//line views/stuff.qtpl:269 } -//line views/stuff.qtpl:307 +//line views/stuff.qtpl:271 func StreamCommonScripts(qw422016 *qt422016.Writer) { -//line views/stuff.qtpl:307 +//line views/stuff.qtpl:271 qw422016.N().S(` `) -//line views/stuff.qtpl:308 +//line views/stuff.qtpl:272 for _, scriptPath := range cfg.CommonScripts { -//line views/stuff.qtpl:308 +//line views/stuff.qtpl:272 qw422016.N().S(` `) -//line views/stuff.qtpl:310 +//line views/stuff.qtpl:274 } -//line views/stuff.qtpl:310 +//line views/stuff.qtpl:274 qw422016.N().S(` `) -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 } -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 func WriteCommonScripts(qq422016 qtio422016.Writer) { -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 StreamCommonScripts(qw422016) -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 qt422016.ReleaseWriter(qw422016) -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 } -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 func CommonScripts() string { -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 qb422016 := qt422016.AcquireByteBuffer() -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 WriteCommonScripts(qb422016) -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 qs422016 := string(qb422016.B) -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 qt422016.ReleaseByteBuffer(qb422016) -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 return qs422016 -//line views/stuff.qtpl:311 +//line views/stuff.qtpl:275 }