Optimise away some more bits we don't need for guests and members.
This commit is contained in:
parent
50fef78078
commit
5009a8b04c
|
@ -48,7 +48,8 @@ type LanguagePack struct {
|
||||||
UserAgents map[string]string
|
UserAgents map[string]string
|
||||||
OperatingSystems map[string]string
|
OperatingSystems map[string]string
|
||||||
HumanLanguages map[string]string
|
HumanLanguages map[string]string
|
||||||
Errors map[string]string
|
Errors map[string]string // Temp stand-in
|
||||||
|
ErrorsBytes map[string][]byte
|
||||||
NoticePhrases map[string]string
|
NoticePhrases map[string]string
|
||||||
PageTitles map[string]string
|
PageTitles map[string]string
|
||||||
TmplPhrases map[string]string
|
TmplPhrases map[string]string
|
||||||
|
@ -85,6 +86,11 @@ func InitPhrases(lang string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
langPack.ErrorsBytes = make(map[string][]byte)
|
||||||
|
for name, phrase := range langPack.Errors {
|
||||||
|
langPack.ErrorsBytes[name] = []byte(phrase)
|
||||||
|
}
|
||||||
|
|
||||||
// [prefix][name]phrase
|
// [prefix][name]phrase
|
||||||
langPack.TmplPhrasesPrefixes = make(map[string]map[string]string)
|
langPack.TmplPhrasesPrefixes = make(map[string]map[string]string)
|
||||||
for name, phrase := range langPack.TmplPhrases {
|
for name, phrase := range langPack.TmplPhrases {
|
||||||
|
@ -222,6 +228,13 @@ func GetErrorPhrase(name string) string {
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
func GetErrorPhraseBytes(name string) []byte {
|
||||||
|
res, ok := currentLangPack.Load().(*LanguagePack).ErrorsBytes[name]
|
||||||
|
if !ok {
|
||||||
|
return getPlaceholderBytes("error", name)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
func GetNoticePhrase(name string) string {
|
func GetNoticePhrase(name string) string {
|
||||||
res, ok := currentLangPack.Load().(*LanguagePack).NoticePhrases[name]
|
res, ok := currentLangPack.Load().(*LanguagePack).NoticePhrases[name]
|
||||||
|
@ -275,6 +288,9 @@ func GetTmplPhrasesByPrefix(prefix string) (phrases map[string]string, ok bool)
|
||||||
func getPlaceholder(prefix string, suffix string) string {
|
func getPlaceholder(prefix string, suffix string) string {
|
||||||
return "{lang." + prefix + "[" + suffix + "]}"
|
return "{lang." + prefix + "[" + suffix + "]}"
|
||||||
}
|
}
|
||||||
|
func getPlaceholderBytes(prefix string, suffix string) []byte {
|
||||||
|
return []byte("{lang." + prefix + "[" + suffix + "]}")
|
||||||
|
}
|
||||||
|
|
||||||
// Please don't mutate *LanguagePack
|
// Please don't mutate *LanguagePack
|
||||||
func GetCurrentLangPack() *LanguagePack {
|
func GetCurrentLangPack() *LanguagePack {
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="content_container">
|
<div class="content_container">
|
||||||
<div class="hide_on_edit topic_content user_content" itemprop="text">{{.Topic.ContentHTML}}</div>
|
<div class="hide_on_edit topic_content user_content" itemprop="text">{{.Topic.ContentHTML}}</div>
|
||||||
<textarea name="topic_content" class="show_on_edit topic_content_input">{{.Topic.Content}}</textarea>
|
{{if .CurrentUser.Loggedin}}{{if .CurrentUser.Perms.EditTopic}}<textarea name="topic_content" class="show_on_edit topic_content_input">{{.Topic.Content}}</textarea>{{end}}{{end}}
|
||||||
<div class="controls button_container{{if .Topic.LikeCount}} has_likes{{end}}">
|
<div class="controls button_container{{if .Topic.LikeCount}} has_likes{{end}}">
|
||||||
<div class="action_button_left">
|
<div class="action_button_left">
|
||||||
{{if .CurrentUser.Loggedin}}
|
{{if .CurrentUser.Loggedin}}
|
||||||
|
|
Loading…
Reference in New Issue