mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
ui: correct html lang tag
set according to the language picked.
This commit is contained in:
@@ -164,7 +164,7 @@ func (app *appContext) confirmMyAction(gc *gin.Context, key string) {
|
|||||||
var target ConfirmationTarget
|
var target ConfirmationTarget
|
||||||
var id string
|
var id string
|
||||||
fail := func() {
|
fail := func() {
|
||||||
app.gcHTML(gc, 404, "404.html", OtherPage, gin.H{
|
app.gcHTML(gc, 404, "404.html", OtherPage, "en-us", gin.H{
|
||||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="{{ .cssClass }}">
|
<html lang="{{ .shortLang }}" class="{{ .cssClass }}">
|
||||||
<head>
|
<head>
|
||||||
<title>404 - jfa-go</title>
|
<title>404 - jfa-go</title>
|
||||||
{{ template "header.html" . }}
|
{{ template "header.html" . }}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="{{ .cssClass }}">
|
<html lang="{{ .shortLang }}" class="{{ .cssClass }}">
|
||||||
<head>
|
<head>
|
||||||
{{ template "syntaxhighlighting.html" . }}
|
{{ template "syntaxhighlighting.html" . }}
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="{{ .shortLang }}">
|
||||||
<head>
|
<head>
|
||||||
<!--- This CSS is inlined so we should keep this here! -->
|
<!--- This CSS is inlined so we should keep this here! -->
|
||||||
<link inline rel="stylesheet" type="text/css" href="web/css/v0.6.0bundle.css">
|
<link inline rel="stylesheet" type="text/css" href="web/css/v0.6.0bundle.css">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="{{ .cssClass }}">
|
<html lang="{{ .shortLang }}" class="{{ .cssClass }}">
|
||||||
<head>
|
<head>
|
||||||
{{ template "header.html" . }}
|
{{ template "header.html" . }}
|
||||||
<title>{{ .strings.successHeader }} - jfa-go</title>
|
<title>{{ .strings.successHeader }} - jfa-go</title>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="{{ .cssClass }}">
|
<html lang="{{ .shortLang }}" class="{{ .cssClass }}">
|
||||||
<head>
|
<head>
|
||||||
{{ template "header.html" . }}
|
{{ template "header.html" . }}
|
||||||
{{ if .passwordReset }}
|
{{ if .passwordReset }}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="{{ .cssClass }}">
|
<html lang="{{ .shortLang }}" class="{{ .cssClass }}">
|
||||||
<head>
|
<head>
|
||||||
{{ template "header.html" . }}
|
{{ template "header.html" . }}
|
||||||
<title>Invalid Code - jfa-go</title>
|
<title>Invalid Code - jfa-go</title>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="{{ .cssClass }}">
|
<html lang="{{ .shortLang }}" class="{{ .cssClass }}">
|
||||||
<head>
|
<head>
|
||||||
{{ template "header.html" . }}
|
{{ template "header.html" . }}
|
||||||
<title>{{ .strings.passwordReset }} - jfa-go</title>
|
<title>{{ .strings.passwordReset }} - jfa-go</title>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="light">
|
<html lang="{{ .shortLang }}" class="light">
|
||||||
<head>
|
<head>
|
||||||
{{ template "header.html" . }}
|
{{ template "header.html" . }}
|
||||||
<title>{{ .lang.Strings.pageTitle }}</title>
|
<title>{{ .lang.Strings.pageTitle }}</title>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="light">
|
<html lang="{{ .shortLang }}" class="light">
|
||||||
<head>
|
<head>
|
||||||
<script>
|
<script>
|
||||||
window.langFile = JSON.parse({{ .language }});
|
window.langFile = JSON.parse({{ .language }});
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ export function throttle (callback: () => void, limitMilliseconds: number): () =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SetupCopyButton(button: HTMLButtonElement, text: string | () => string, baseClass?: string, notif?: string) {
|
export function SetupCopyButton(button: HTMLButtonElement, text: string | (() => string), baseClass?: string, notif?: string) {
|
||||||
if (!notif) notif = window.lang.strings("copied");
|
if (!notif) notif = window.lang.strings("copied");
|
||||||
if (!baseClass) baseClass = "~info";
|
if (!baseClass) baseClass = "~info";
|
||||||
// script will probably turn this into multiple
|
// script will probably turn this into multiple
|
||||||
@@ -392,9 +392,9 @@ export function SetupCopyButton(button: HTMLButtonElement, text: string | () =>
|
|||||||
button.appendChild(icon)
|
button.appendChild(icon)
|
||||||
button.onclick = () => {
|
button.onclick = () => {
|
||||||
if (typeof text === "string") {
|
if (typeof text === "string") {
|
||||||
toClipboard(text);
|
toClipboard(text);
|
||||||
} else {
|
} else {
|
||||||
toClipboard(text());
|
toClipboard(text());
|
||||||
}
|
}
|
||||||
icon.classList.remove("ri-file-copy-line");
|
icon.classList.remove("ri-file-copy-line");
|
||||||
icon.classList.add("ri-check-line");
|
icon.classList.add("ri-check-line");
|
||||||
@@ -410,7 +410,7 @@ export function SetupCopyButton(button: HTMLButtonElement, text: string | () =>
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CopyButton(text: string, baseClass?: string, notif?: string): HTMLButtonElement {
|
export function CopyButton(text: string | (() => string), baseClass?: string, notif?: string): HTMLButtonElement {
|
||||||
const button = document.createElement("button");
|
const button = document.createElement("button");
|
||||||
SetupCopyButton(button, text, baseClass, notif);
|
SetupCopyButton(button, text, baseClass, notif);
|
||||||
return button;
|
return button;
|
||||||
|
|||||||
43
views.go
43
views.go
@@ -52,9 +52,9 @@ func (app *appContext) getURLBase(gc *gin.Context) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *appContext) gcHTML(gc *gin.Context, code int, file string, page Page, templ gin.H) {
|
func (app *appContext) gcHTML(gc *gin.Context, code int, file string, page Page, lang string, templ gin.H) {
|
||||||
gc.Header("Cache-Control", "no-cache")
|
gc.Header("Cache-Control", "no-cache")
|
||||||
app.BasePageTemplateValues(gc, page, templ)
|
app.BasePageTemplateValues(gc, lang, page, templ)
|
||||||
gc.HTML(code, file, templ)
|
gc.HTML(code, file, templ)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ func (app *appContext) pushResources(gc *gin.Context, page Page) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns a gin.H with general values (url base, css version, etc.)
|
// Returns a gin.H with general values (url base, css version, etc.)
|
||||||
func (app *appContext) BasePageTemplateValues(gc *gin.Context, page Page, base gin.H) {
|
func (app *appContext) BasePageTemplateValues(gc *gin.Context, lang string, page Page, base gin.H) {
|
||||||
set := func(k string, v any) {
|
set := func(k string, v any) {
|
||||||
if _, ok := base[k]; !ok {
|
if _, ok := base[k]; !ok {
|
||||||
base[k] = v
|
base[k] = v
|
||||||
@@ -121,6 +121,15 @@ func (app *appContext) BasePageTemplateValues(gc *gin.Context, page Page, base g
|
|||||||
set("pwrEnabled", app.config.Section("password_resets").Key("enabled").MustBool(false))
|
set("pwrEnabled", app.config.Section("password_resets").Key("enabled").MustBool(false))
|
||||||
}
|
}
|
||||||
set("referralsEnabled", app.config.Section("user_page").Key("enabled").MustBool(false) && app.config.Section("user_page").Key("referrals").MustBool(false))
|
set("referralsEnabled", app.config.Section("user_page").Key("enabled").MustBool(false) && app.config.Section("user_page").Key("referrals").MustBool(false))
|
||||||
|
langComponents := strings.Split(lang, "-")
|
||||||
|
var shortLang string
|
||||||
|
if len(langComponents) < 1 {
|
||||||
|
shortLang = "en"
|
||||||
|
} else {
|
||||||
|
shortLang = langComponents[0]
|
||||||
|
}
|
||||||
|
set("langName", lang)
|
||||||
|
set("shortLang", shortLang)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Page int
|
type Page int
|
||||||
@@ -202,7 +211,7 @@ func (app *appContext) AdminPage(gc *gin.Context) {
|
|||||||
builtBy = "???"
|
builtBy = "???"
|
||||||
}
|
}
|
||||||
|
|
||||||
app.gcHTML(gc, http.StatusOK, "admin.html", AdminPage, gin.H{
|
app.gcHTML(gc, http.StatusOK, "admin.html", AdminPage, lang, gin.H{
|
||||||
"contactMessage": "",
|
"contactMessage": "",
|
||||||
"linkResetEnabled": app.config.Section("password_resets").Key("link_reset").MustBool(false),
|
"linkResetEnabled": app.config.Section("password_resets").Key("link_reset").MustBool(false),
|
||||||
"version": version,
|
"version": version,
|
||||||
@@ -214,7 +223,6 @@ func (app *appContext) AdminPage(gc *gin.Context) {
|
|||||||
"strings": app.storage.lang.Admin[lang].Strings,
|
"strings": app.storage.lang.Admin[lang].Strings,
|
||||||
"quantityStrings": app.storage.lang.Admin[lang].QuantityStrings,
|
"quantityStrings": app.storage.lang.Admin[lang].QuantityStrings,
|
||||||
"language": app.storage.lang.Admin[lang].JSON,
|
"language": app.storage.lang.Admin[lang].JSON,
|
||||||
"langName": lang,
|
|
||||||
"license": license,
|
"license": license,
|
||||||
"jellyfinLogin": app.jellyfinLogin,
|
"jellyfinLogin": app.jellyfinLogin,
|
||||||
"jfAdminOnly": jfAdminOnly,
|
"jfAdminOnly": jfAdminOnly,
|
||||||
@@ -236,7 +244,6 @@ func (app *appContext) MyUserPage(gc *gin.Context) {
|
|||||||
"strings": app.storage.lang.User[lang].Strings,
|
"strings": app.storage.lang.User[lang].Strings,
|
||||||
"validationStrings": app.storage.lang.User[lang].validationStringsJSON,
|
"validationStrings": app.storage.lang.User[lang].validationStringsJSON,
|
||||||
"language": app.storage.lang.User[lang].JSON,
|
"language": app.storage.lang.User[lang].JSON,
|
||||||
"langName": lang,
|
|
||||||
"jfLink": app.EvaluateRelativePath(gc, app.config.Section("ui").Key("redirect_url").String()),
|
"jfLink": app.EvaluateRelativePath(gc, app.config.Section("ui").Key("redirect_url").String()),
|
||||||
"requirements": app.validator.getCriteria(),
|
"requirements": app.validator.getCriteria(),
|
||||||
}
|
}
|
||||||
@@ -282,7 +289,7 @@ func (app *appContext) MyUserPage(gc *gin.Context) {
|
|||||||
data[name+"MessageContent"] = template.HTML(markdown.ToHTML([]byte(msg.Content), nil, markdownRenderer))
|
data[name+"MessageContent"] = template.HTML(markdown.ToHTML([]byte(msg.Content), nil, markdownRenderer))
|
||||||
}
|
}
|
||||||
|
|
||||||
app.gcHTML(gc, http.StatusOK, "user.html", UserPage, data)
|
app.gcHTML(gc, http.StatusOK, "user.html", UserPage, lang, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *appContext) ResetPassword(gc *gin.Context) {
|
func (app *appContext) ResetPassword(gc *gin.Context) {
|
||||||
@@ -315,7 +322,6 @@ func (app *appContext) ResetPassword(gc *gin.Context) {
|
|||||||
data["validationStrings"] = app.storage.lang.User[lang].validationStringsJSON
|
data["validationStrings"] = app.storage.lang.User[lang].validationStringsJSON
|
||||||
// ewwwww, reusing an existing field, FIXME!
|
// ewwwww, reusing an existing field, FIXME!
|
||||||
data["notifications"] = app.storage.lang.User[lang].notificationsJSON
|
data["notifications"] = app.storage.lang.User[lang].notificationsJSON
|
||||||
data["langName"] = lang
|
|
||||||
data["passwordReset"] = true
|
data["passwordReset"] = true
|
||||||
data["telegramEnabled"] = false
|
data["telegramEnabled"] = false
|
||||||
data["discordEnabled"] = false
|
data["discordEnabled"] = false
|
||||||
@@ -324,10 +330,10 @@ func (app *appContext) ResetPassword(gc *gin.Context) {
|
|||||||
data["reCAPTCHA"] = app.config.Section("captcha").Key("recaptcha").MustBool(false)
|
data["reCAPTCHA"] = app.config.Section("captcha").Key("recaptcha").MustBool(false)
|
||||||
data["reCAPTCHASiteKey"] = app.config.Section("captcha").Key("recaptcha_site_key").MustString("")
|
data["reCAPTCHASiteKey"] = app.config.Section("captcha").Key("recaptcha_site_key").MustString("")
|
||||||
data["pwrPIN"] = pin
|
data["pwrPIN"] = pin
|
||||||
app.gcHTML(gc, http.StatusOK, "form-loader.html", PWRPage, data)
|
app.gcHTML(gc, http.StatusOK, "form-loader.html", PWRPage, lang, data)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer app.gcHTML(gc, http.StatusOK, "password-reset.html", PWRPage, data)
|
defer app.gcHTML(gc, http.StatusOK, "password-reset.html", PWRPage, lang, data)
|
||||||
// If it's a bot, pretend to be a success so the preview is nice.
|
// If it's a bot, pretend to be a success so the preview is nice.
|
||||||
if isBot {
|
if isBot {
|
||||||
app.debug.Println(lm.IgnoreBotPWR)
|
app.debug.Println(lm.IgnoreBotPWR)
|
||||||
@@ -428,7 +434,7 @@ func (app *appContext) GetCaptcha(gc *gin.Context) {
|
|||||||
if !isPWR {
|
if !isPWR {
|
||||||
inv, ok = app.storage.GetInvitesKey(code)
|
inv, ok = app.storage.GetInvitesKey(code)
|
||||||
if !ok {
|
if !ok {
|
||||||
app.gcHTML(gc, 404, "invalidCode.html", OtherPage, gin.H{
|
app.gcHTML(gc, 404, "invalidCode.html", OtherPage, "en-us", gin.H{
|
||||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -465,7 +471,7 @@ func (app *appContext) GenCaptcha(gc *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
app.gcHTML(gc, 404, "invalidCode.html", OtherPage, gin.H{
|
app.gcHTML(gc, 404, "invalidCode.html", OtherPage, "en-us", gin.H{
|
||||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -596,7 +602,7 @@ func (app *appContext) VerifyCaptcha(gc *gin.Context) {
|
|||||||
if !isPWR {
|
if !isPWR {
|
||||||
inv, ok = app.storage.GetInvitesKey(code)
|
inv, ok = app.storage.GetInvitesKey(code)
|
||||||
if !ok {
|
if !ok {
|
||||||
app.gcHTML(gc, 404, "invalidCode.html", OtherPage, gin.H{
|
app.gcHTML(gc, 404, "invalidCode.html", OtherPage, "en-us", gin.H{
|
||||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@@ -623,7 +629,7 @@ func (app *appContext) VerifyCaptcha(gc *gin.Context) {
|
|||||||
|
|
||||||
func (app *appContext) NewUserFromConfirmationKey(invite Invite, key string, lang string, gc *gin.Context) {
|
func (app *appContext) NewUserFromConfirmationKey(invite Invite, key string, lang string, gc *gin.Context) {
|
||||||
fail := func() {
|
fail := func() {
|
||||||
app.gcHTML(gc, 404, "404.html", OtherPage, gin.H{
|
app.gcHTML(gc, 404, "404.html", OtherPage, lang, gin.H{
|
||||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -694,7 +700,7 @@ func (app *appContext) NewUserFromConfirmationKey(invite Invite, key string, lan
|
|||||||
if app.config.Section("ui").Key("auto_redirect").MustBool(false) {
|
if app.config.Section("ui").Key("auto_redirect").MustBool(false) {
|
||||||
gc.Redirect(301, jfLink)
|
gc.Redirect(301, jfLink)
|
||||||
} else {
|
} else {
|
||||||
app.gcHTML(gc, http.StatusOK, "create-success.html", OtherPage, gin.H{
|
app.gcHTML(gc, http.StatusOK, "create-success.html", OtherPage, lang, gin.H{
|
||||||
"strings": app.storage.lang.User[lang].Strings,
|
"strings": app.storage.lang.User[lang].Strings,
|
||||||
"successMessage": app.config.Section("ui").Key("success_message").String(),
|
"successMessage": app.config.Section("ui").Key("success_message").String(),
|
||||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||||
@@ -725,7 +731,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
|||||||
// if app.checkInvite(code, false, "") {
|
// if app.checkInvite(code, false, "") {
|
||||||
invite, ok := app.storage.GetInvitesKey(gc.Param("invCode"))
|
invite, ok := app.storage.GetInvitesKey(gc.Param("invCode"))
|
||||||
if !ok {
|
if !ok {
|
||||||
app.gcHTML(gc, 404, "invalidCode.html", FormPage, gin.H{
|
app.gcHTML(gc, 404, "invalidCode.html", FormPage, lang, gin.H{
|
||||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@@ -777,7 +783,6 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
|||||||
"userExpiryHours": invite.UserHours,
|
"userExpiryHours": invite.UserHours,
|
||||||
"userExpiryMinutes": invite.UserMinutes,
|
"userExpiryMinutes": invite.UserMinutes,
|
||||||
"userExpiryMessage": app.storage.lang.User[lang].Strings.get("yourAccountIsValidUntil"),
|
"userExpiryMessage": app.storage.lang.User[lang].Strings.get("yourAccountIsValidUntil"),
|
||||||
"langName": lang,
|
|
||||||
"passwordReset": false,
|
"passwordReset": false,
|
||||||
"customSuccessCard": false,
|
"customSuccessCard": false,
|
||||||
"telegramEnabled": telegram,
|
"telegramEnabled": telegram,
|
||||||
@@ -851,12 +856,12 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
|||||||
// pin := ""
|
// pin := ""
|
||||||
// for _, token := range app.discord.tokens {
|
// for _, token := range app.discord.tokens {
|
||||||
// if
|
// if
|
||||||
app.gcHTML(gc, http.StatusOK, "form-loader.html", OtherPage, data)
|
app.gcHTML(gc, http.StatusOK, "form-loader.html", OtherPage, lang, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *appContext) NoRouteHandler(gc *gin.Context) {
|
func (app *appContext) NoRouteHandler(gc *gin.Context) {
|
||||||
app.pushResources(gc, OtherPage)
|
app.pushResources(gc, OtherPage)
|
||||||
app.gcHTML(gc, 404, "404.html", OtherPage, gin.H{
|
app.gcHTML(gc, 404, "404.html", OtherPage, "en-us", gin.H{
|
||||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user