From 90c907710cdd4919a539a5a428316fd7efb715ea Mon Sep 17 00:00:00 2001 From: Mateusz Makowski Date: Sun, 23 Feb 2020 13:23:25 +0100 Subject: [PATCH] Display username in header --- locales/ar.json | 2 ++ locales/de.json | 2 ++ locales/el.json | 2 ++ locales/en-US.json | 2 ++ locales/eo.json | 2 ++ locales/es.json | 2 ++ locales/fa.json | 2 ++ locales/fi.json | 2 ++ locales/fr.json | 2 ++ locales/he.json | 2 ++ locales/hr.json | 2 ++ locales/id.json | 2 ++ locales/is.json | 2 ++ locales/it.json | 2 ++ locales/ja.json | 2 ++ locales/nb-NO.json | 2 ++ locales/nl.json | 2 ++ locales/pl.json | 2 ++ locales/pt-BR.json | 2 ++ locales/pt-PT.json | 2 ++ locales/ro.json | 2 ++ locales/ru.json | 2 ++ locales/sv-SE.json | 2 ++ locales/tr.json | 2 ++ locales/uk.json | 2 ++ locales/zh-CN.json | 2 ++ locales/zh-TW.json | 2 ++ src/invidious/helpers/helpers.cr | 1 + src/invidious/routes/preferences.cr | 5 +++++ src/invidious/users.cr | 1 + src/invidious/views/preferences.ecr | 6 ++++++ src/invidious/views/template.ecr | 5 +++++ 32 files changed, 72 insertions(+) diff --git a/locales/ar.json b/locales/ar.json index 119c36e4..65d1587e 100644 --- a/locales/ar.json +++ b/locales/ar.json @@ -117,6 +117,8 @@ "Administrator preferences": "إعدادات المدير", "Default homepage: ": "الصفحة الرئيسية الافتراضية ", "Feed menu: ": "قائمة التدفقات: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "تفعيل 'الأفضل' ؟ ", "CAPTCHA enabled: ": "تفعيل الكابتشا: ", "Login enabled: ": "تفعيل الولوج: ", diff --git a/locales/de.json b/locales/de.json index 1a8870ec..a799c68d 100644 --- a/locales/de.json +++ b/locales/de.json @@ -117,6 +117,8 @@ "Administrator preferences": "Administrator-Einstellungen", "Default homepage: ": "Standard-Startseite: ", "Feed menu: ": "Feed-Menü: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Top aktiviert? ", "CAPTCHA enabled: ": "CAPTCHA aktiviert? ", "Login enabled: ": "Anmeldung aktiviert: ", diff --git a/locales/el.json b/locales/el.json index e6aec01a..489dafe6 100644 --- a/locales/el.json +++ b/locales/el.json @@ -117,6 +117,8 @@ "Administrator preferences": "Προτιμήσεις διαχειριστή", "Default homepage: ": "Προεπιλεγμένη αρχική: ", "Feed menu: ": "Μενού ροής συνδρομών: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Ενεργοποίηση κορυφαίων; ", "CAPTCHA enabled: ": "Ενεργοποίηση CAPTCHA; ", "Login enabled: ": "Ενεργοποίηση σύνδεσης; ", diff --git a/locales/en-US.json b/locales/en-US.json index 0cddb4c0..cf1b9141 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -117,6 +117,8 @@ "Administrator preferences": "Administrator preferences", "Default homepage: ": "Default homepage: ", "Feed menu: ": "Feed menu: ", + "Show nickname on top: ": "Show nickname on top: ", + "Welcome, `x`": "Welcome, `x`", "Top enabled: ": "Top enabled: ", "CAPTCHA enabled: ": "CAPTCHA enabled: ", "Login enabled: ": "Login enabled: ", diff --git a/locales/eo.json b/locales/eo.json index 8be07305..e76fae71 100644 --- a/locales/eo.json +++ b/locales/eo.json @@ -117,6 +117,8 @@ "Administrator preferences": "Agordoj de administranto", "Default homepage: ": "Defaŭlta hejmpaĝo: ", "Feed menu: ": "Flua menuo: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Ĉu pli bonaj ŝaltitaj? ", "CAPTCHA enabled: ": "Ĉu CAPTCHA ŝaltita? ", "Login enabled: ": "Ĉu ensaluto aktivita? ", diff --git a/locales/es.json b/locales/es.json index fa377151..7507779e 100644 --- a/locales/es.json +++ b/locales/es.json @@ -117,6 +117,8 @@ "Administrator preferences": "Preferencias de administrador", "Default homepage: ": "Página de inicio por defecto: ", "Feed menu: ": "Menú de fuentes: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "¿Habilitar los destacados? ", "CAPTCHA enabled: ": "¿Habilitar los CAPTCHA? ", "Login enabled: ": "¿Habilitar el inicio de sesión? ", diff --git a/locales/fa.json b/locales/fa.json index 145479ad..bd7691cb 100644 --- a/locales/fa.json +++ b/locales/fa.json @@ -117,6 +117,8 @@ "Administrator preferences": "ترجیحات مدیریت", "Default homepage: ": "صفحه خانه پیشفرض ", "Feed menu: ": "منو خوراک: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "بالا فعال شده: ", "CAPTCHA enabled: ": "CAPTCHA فعال شده: ", "Login enabled: ": "ورود فعال شده: ", diff --git a/locales/fi.json b/locales/fi.json index e9cee129..eb4337da 100644 --- a/locales/fi.json +++ b/locales/fi.json @@ -117,6 +117,8 @@ "Administrator preferences": "Järjestelmänvalvojan asetukset", "Default homepage: ": "Oletuskotisivu: ", "Feed menu: ": "Syötevalikko: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Yläosa käytössä: ", "CAPTCHA enabled: ": "CAPTCHA käytössä: ", "Login enabled: ": "Kirjautuminen käytössä: ", diff --git a/locales/fr.json b/locales/fr.json index 9bb2fe16..2f8a0039 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -117,6 +117,8 @@ "Administrator preferences": "Préferences d'Administration", "Default homepage: ": "Page d'accueil par défaut : ", "Feed menu: ": "Préferences des abonnements : ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Top activé : ", "CAPTCHA enabled: ": "CAPTCHA activé : ", "Login enabled: ": "Autoriser l'ouverture de sessions utilisateur : ", diff --git a/locales/he.json b/locales/he.json index 5345b93d..177e07a8 100644 --- a/locales/he.json +++ b/locales/he.json @@ -117,6 +117,8 @@ "Administrator preferences": "הגדרות ניהול מערכת", "Default homepage: ": "Default homepage: ", "Feed menu: ": "תפריט ההזנה: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "", "CAPTCHA enabled: ": "", "Login enabled: ": "", diff --git a/locales/hr.json b/locales/hr.json index 2f78469b..6d16812f 100644 --- a/locales/hr.json +++ b/locales/hr.json @@ -117,6 +117,8 @@ "Administrator preferences": "Postavke administratora", "Default homepage: ": "Standardna početna stranica: ", "Feed menu: ": "Izbornik za feedove: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Najbolji aktivirani: ", "CAPTCHA enabled: ": "Aktivirani CAPTCHA: ", "Login enabled: ": "Prijava aktivirana: ", diff --git a/locales/id.json b/locales/id.json index 679a3403..970c19f1 100644 --- a/locales/id.json +++ b/locales/id.json @@ -117,6 +117,8 @@ "Administrator preferences": "Preferensi administrator", "Default homepage: ": "Laman beranda default: ", "Feed menu: ": "Menu umpan: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Teratas diaktifkan: ", "CAPTCHA enabled: ": "CAPTCHA diaktifkan: ", "Login enabled: ": "Masuk diaktifkan: ", diff --git a/locales/is.json b/locales/is.json index 05893333..2fbbfb3b 100644 --- a/locales/is.json +++ b/locales/is.json @@ -117,6 +117,8 @@ "Administrator preferences": "Kjörstillingar stjórnanda", "Default homepage: ": "Sjálfgefin heimasíða: ", "Feed menu: ": "Straum valmynd: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Toppur virkur? ", "CAPTCHA enabled: ": "CAPTCHA virk? ", "Login enabled: ": "Innskráning virk? ", diff --git a/locales/it.json b/locales/it.json index ec45d2eb..d2e7c0ff 100644 --- a/locales/it.json +++ b/locales/it.json @@ -117,6 +117,8 @@ "Administrator preferences": "Preferenze amministratore", "Default homepage: ": "Pagina principale predefinita: ", "Feed menu: ": "Menu iscrizioni: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Top abilitato: ", "CAPTCHA enabled: ": "CAPTCHA attivati: ", "Login enabled: ": "Accesso attivato: ", diff --git a/locales/ja.json b/locales/ja.json index af5dac7a..63bff9da 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -117,6 +117,8 @@ "Administrator preferences": "管理者設定", "Default homepage: ": "デフォルトのホーム: ", "Feed menu: ": "フィードメニュー: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "トップページを有効化: ", "CAPTCHA enabled: ": "CAPTCHA を有効化: ", "Login enabled: ": "ログインを有効化: ", diff --git a/locales/nb-NO.json b/locales/nb-NO.json index 6d66527d..0ec779da 100644 --- a/locales/nb-NO.json +++ b/locales/nb-NO.json @@ -117,6 +117,8 @@ "Administrator preferences": "Administratorinnstillinger", "Default homepage: ": "Forvalgt hjemmeside: ", "Feed menu: ": "Kilde-meny: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Topp påskrudd? ", "CAPTCHA enabled: ": "CAPTCHA påskrudd? ", "Login enabled: ": "Innlogging påskrudd? ", diff --git a/locales/nl.json b/locales/nl.json index 5f2fa265..d896f03c 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -117,6 +117,8 @@ "Administrator preferences": "Beheerdersinstellingen", "Default homepage: ": "Standaard startpagina: ", "Feed menu: ": "Feedmenu: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Bovenkant inschakelen? ", "CAPTCHA enabled: ": "CAPTCHA gebruiken? ", "Login enabled: ": "Inloggen toestaan? ", diff --git a/locales/pl.json b/locales/pl.json index 227a9cbb..83711e2e 100644 --- a/locales/pl.json +++ b/locales/pl.json @@ -117,6 +117,8 @@ "Administrator preferences": "Preferencje administratora", "Default homepage: ": "Domyślna strona główna: ", "Feed menu: ": "Menu aktualności: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "\"Top\" aktywne: ", "CAPTCHA enabled: ": "CAPTCHA aktywna? ", "Login enabled: ": "Logowanie włączone? ", diff --git a/locales/pt-BR.json b/locales/pt-BR.json index 7810671e..940e1d55 100644 --- a/locales/pt-BR.json +++ b/locales/pt-BR.json @@ -117,6 +117,8 @@ "Administrator preferences": "Preferências de administrador", "Default homepage: ": "Página de início padrão: ", "Feed menu: ": "Menu do feed: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Habilitar destaques: ", "CAPTCHA enabled: ": "Habilitar CAPTCHA: ", "Login enabled: ": "Habilitar login: ", diff --git a/locales/pt-PT.json b/locales/pt-PT.json index 0aa19d3f..a90e72fb 100644 --- a/locales/pt-PT.json +++ b/locales/pt-PT.json @@ -117,6 +117,8 @@ "Administrator preferences": "Preferências de administrador", "Default homepage: ": "Página inicial predefinida: ", "Feed menu: ": "Menu de subscrições: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Top ativado: ", "CAPTCHA enabled: ": "CAPTCHA ativado: ", "Login enabled: ": "Iniciar sessão ativado: ", diff --git a/locales/ro.json b/locales/ro.json index 71e50ca5..e93b686e 100644 --- a/locales/ro.json +++ b/locales/ro.json @@ -117,6 +117,8 @@ "Administrator preferences": "Preferințele Administratorului", "Default homepage: ": "Pagina principală implicită: ", "Feed menu: ": "Preferințe legate de pagina de abonamente: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Top activat: ", "CAPTCHA enabled: ": "CAPTCHA activat : ", "Login enabled: ": "Autentificare activată : ", diff --git a/locales/ru.json b/locales/ru.json index 15d97862..67d924bd 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -117,6 +117,8 @@ "Administrator preferences": "Администраторские настройки", "Default homepage: ": "Главная страница по умолчанию: ", "Feed menu: ": "Меню ленты видео: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Включить топ видео? ", "CAPTCHA enabled: ": "Включить капчу? ", "Login enabled: ": "Включить авторизацию? ", diff --git a/locales/sv-SE.json b/locales/sv-SE.json index 911df096..25ac23e5 100644 --- a/locales/sv-SE.json +++ b/locales/sv-SE.json @@ -117,6 +117,8 @@ "Administrator preferences": "Administratörsinställningar", "Default homepage: ": "Förvald hemsida: ", "Feed menu: ": "Flödesmeny: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Topp påslaget? ", "CAPTCHA enabled: ": "CAPTCHA påslaget? ", "Login enabled: ": "Inloggning påslaget? ", diff --git a/locales/tr.json b/locales/tr.json index 436cb512..021e9fd6 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -117,6 +117,8 @@ "Administrator preferences": "Yönetici tercihleri", "Default homepage: ": "Öntanımlı ana sayfa: ", "Feed menu: ": "Akış menüsü: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Top etkin: ", "CAPTCHA enabled: ": "CAPTCHA etkin: ", "Login enabled: ": "Oturum açma etkin: ", diff --git a/locales/uk.json b/locales/uk.json index 91ac8626..da1e80eb 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -117,6 +117,8 @@ "Administrator preferences": "Адміністраторські налаштування", "Default homepage: ": "Усталена домашня сторінка: ", "Feed menu: ": "Меню потоку з відео: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "Увімкнути топ відео? ", "CAPTCHA enabled: ": "Увімкнути капчу? ", "Login enabled: ": "Увімкнути авторизацію? ", diff --git a/locales/zh-CN.json b/locales/zh-CN.json index e7150627..5952b4e0 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -117,6 +117,8 @@ "Administrator preferences": "管理员选项", "Default homepage: ": "默认主页: ", "Feed menu: ": "Feed 菜单: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "是否启用“热门视频”页: ", "CAPTCHA enabled: ": "是否启用验证码: ", "Login enabled: ": "是否启用登录: ", diff --git a/locales/zh-TW.json b/locales/zh-TW.json index d9a486ef..c8644de3 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -117,6 +117,8 @@ "Administrator preferences": "管理員偏好設定", "Default homepage: ": "預設首頁: ", "Feed menu: ": "Feed 選單: ", + "Show nickname on top: ": "", + "Welcome, `x`": "", "Top enabled: ": "頂部啟用: ", "CAPTCHA enabled: ": "CAPTCHA 啟用: ", "Login enabled: ": "啟用登入: ", diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 0c70cb02..7353f2d9 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -54,6 +54,7 @@ struct ConfigPreferences property extend_desc : Bool = false property volume : Int32 = 100 property vr_mode : Bool = true + property show_nick : Bool = true def to_tuple {% begin %} diff --git a/src/invidious/routes/preferences.cr b/src/invidious/routes/preferences.cr index d6002ffd..21d79218 100644 --- a/src/invidious/routes/preferences.cr +++ b/src/invidious/routes/preferences.cr @@ -68,6 +68,10 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute vr_mode ||= "off" vr_mode = vr_mode == "on" + show_nick = env.params.body["show_nick"]?.try &.as(String) + show_nick ||= "off" + show_nick = show_nick == "on" + comments = [] of String 2.times do |i| comments << (env.params.body["comments[#{i}]"]?.try &.as(String) || CONFIG.default_user_preferences.comments[i]) @@ -155,6 +159,7 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute volume: volume, extend_desc: extend_desc, vr_mode: vr_mode, + show_nick: show_nick, }.to_json).to_json if user = env.get? "user" diff --git a/src/invidious/users.cr b/src/invidious/users.cr index 98ef8792..aff76b53 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -55,6 +55,7 @@ struct Preferences property listen : Bool = CONFIG.default_user_preferences.listen property local : Bool = CONFIG.default_user_preferences.local property vr_mode : Bool = CONFIG.default_user_preferences.vr_mode + property show_nick : Bool = CONFIG.default_user_preferences.show_nick @[JSON::Field(converter: Preferences::ProcessString)] property locale : String = CONFIG.default_user_preferences.locale diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr index c5b64ad6..d98c3bb5 100644 --- a/src/invidious/views/preferences.ecr +++ b/src/invidious/views/preferences.ecr @@ -175,6 +175,12 @@ <% end %> + <% if env.get? "user" %> +
+ + checked<% end %>> +
+ <% end %> <%= translate(locale, "Miscellaneous preferences") %> diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr index a13d3928..070b3087 100644 --- a/src/invidious/views/template.ecr +++ b/src/invidious/views/template.ecr @@ -67,6 +67,11 @@ + <% if env.get("preferences").as(Preferences).show_nick %> +
+ <%= translate(locale, "Welcome, `x`", env.get("user").as(User).email) %> +
+ <% end %>
" method="post"> ">