From 74d87fe54c2934c1a34b0791e6e9d8017af3c1a2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 5 Dec 2021 12:52:59 +0000 Subject: [PATCH] Button to reset theme designer settings --- daemon.py | 10 ++++++++-- theme.py | 15 +++++++++++++++ translations/ar.json | 2 +- translations/ca.json | 2 +- translations/cy.json | 2 +- translations/de.json | 2 +- translations/en.json | 2 +- translations/es.json | 2 +- translations/fr.json | 2 +- translations/ga.json | 2 +- translations/hi.json | 2 +- translations/it.json | 2 +- translations/ja.json | 2 +- translations/ku.json | 2 +- translations/oc.json | 2 +- translations/pt.json | 2 +- translations/ru.json | 2 +- translations/sw.json | 2 +- translations/zh.json | 2 +- webapp_themeDesigner.py | 8 ++++---- 20 files changed, 44 insertions(+), 23 deletions(-) diff --git a/daemon.py b/daemon.py index 4fa763028..d153d9f4d 100644 --- a/daemon.py +++ b/daemon.py @@ -317,6 +317,7 @@ from cache import storePersonInCache from cache import getPersonFromCache from cache import getPersonPubKey from httpsig import verifyPostHeaders +from theme import resetThemeDesignerSettings from theme import setThemeFromDesigner from theme import scanThemesForScripts from theme import importTheme @@ -2150,10 +2151,15 @@ class PubServer(BaseHTTPRequestHandler): urllib.parse.unquote_plus(themeParams) print('themeDesigner1') - # theme designer screen, back button + # theme designer screen, reset button # See htmlThemeDesigner - if 'submitThemeDesignerCancel=' in themeParams or \ + if 'submitThemeDesignerReset=' in themeParams or \ 'submitThemeDesigner=' not in themeParams: + if 'submitThemeDesignerReset=' in themeParams: + resetThemeDesignerSettings(baseDir, themeName, domain, + allowLocalNetworkAccess, + systemLanguage) + if callingDomain.endswith('.onion') and onionDomain: originPathStr = \ 'http://' + onionDomain + usersPath + '/' + defaultTimeline diff --git a/theme.py b/theme.py index 9f5d2f31c..25ec9407e 100644 --- a/theme.py +++ b/theme.py @@ -502,6 +502,21 @@ def setThemeFromDesigner(baseDir: str, themeName: str, domain: str, allowLocalNetworkAccess, systemLanguage) +def resetThemeDesignerSettings(baseDir: str, themeName: str, domain: str, + allowLocalNetworkAccess: bool, + systemLanguage: str) -> None: + """Resets the theme designer settings + """ + customVariablesFile = baseDir + '/accounts/theme.json' + if os.path.isfile(customVariablesFile): + try: + os.remove(customVariablesFile) + except OSError: + print('EX: unable to remove theme designer settings on reset') + setTheme(baseDir, themeName, domain, + allowLocalNetworkAccess, systemLanguage) + + def _readVariablesFile(baseDir: str, themeName: str, variablesFile: str, allowLocalNetworkAccess: bool) -> None: diff --git a/translations/ar.json b/translations/ar.json index 89a0dbaab..939b0004c 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -500,5 +500,5 @@ "New feed URL": "موجز جديد URL", "New link title and URL": "عنوان الارتباط الجديد وعنوان URL", "Theme Designer": "مصمم المظهر", - "Reset": "" + "Reset": "إعادة ضبط" } diff --git a/translations/ca.json b/translations/ca.json index 9628f7408..97083eb75 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -500,5 +500,5 @@ "New feed URL": "URL de feed nou", "New link title and URL": "Títol i URL de l'enllaç nous", "Theme Designer": "Dissenyador temàtic", - "Reset": "" + "Reset": "Restableix" } diff --git a/translations/cy.json b/translations/cy.json index ecb53dafd..e6059f4db 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -500,5 +500,5 @@ "New feed URL": "URL porthiant newydd", "New link title and URL": "Teitl dolen ac URL newydd", "Theme Designer": "Dylunydd Thema", - "Reset": "" + "Reset": "Ail gychwyn" } diff --git a/translations/de.json b/translations/de.json index 75c0c451e..dbd21fb9e 100644 --- a/translations/de.json +++ b/translations/de.json @@ -500,5 +500,5 @@ "New feed URL": "Neue Feed-URL", "New link title and URL": "Neuer Linktitel und URL", "Theme Designer": "Themendesigner", - "Reset": "" + "Reset": "Zurücksetzen" } diff --git a/translations/en.json b/translations/en.json index cc69d7a28..b670f135b 100644 --- a/translations/en.json +++ b/translations/en.json @@ -500,5 +500,5 @@ "New feed URL": "New feed URL", "New link title and URL": "New link title and URL", "Theme Designer": "Theme Designer", - "Reset": "" + "Reset": "Reset" } diff --git a/translations/es.json b/translations/es.json index e25809255..a8a793b12 100644 --- a/translations/es.json +++ b/translations/es.json @@ -500,5 +500,5 @@ "New feed URL": "URL de nuevo feed", "New link title and URL": "Nuevo título de enlace y URL", "Theme Designer": "Diseñadora de temas", - "Reset": "" + "Reset": "Reiniciar" } diff --git a/translations/fr.json b/translations/fr.json index df8002117..67f351fdb 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -500,5 +500,5 @@ "New feed URL": "Nouvelle URL de flux", "New link title and URL": "Nouveau titre et URL du lien", "Theme Designer": "Concepteur de thème", - "Reset": "" + "Reset": "Réinitialiser" } diff --git a/translations/ga.json b/translations/ga.json index 8bdb197b3..6c6068dc1 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -500,5 +500,5 @@ "New feed URL": "URL beathaithe nua", "New link title and URL": "Teideal nasc nua agus URL", "Theme Designer": "Dearthóir Téama", - "Reset": "" + "Reset": "Athshocraigh" } diff --git a/translations/hi.json b/translations/hi.json index 08d260e61..16cd2920e 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -500,5 +500,5 @@ "New feed URL": "नया फ़ीड URL", "New link title and URL": "नया लिंक शीर्षक और URL", "Theme Designer": "थीम डिजाइनर", - "Reset": "" + "Reset": "रीसेट" } diff --git a/translations/it.json b/translations/it.json index 40bd516b0..39bbeabe3 100644 --- a/translations/it.json +++ b/translations/it.json @@ -500,5 +500,5 @@ "New feed URL": "Nuovo URL del feed", "New link title and URL": "Nuovo titolo e URL del collegamento", "Theme Designer": "Progettista di temi", - "Reset": "" + "Reset": "Ripristina" } diff --git a/translations/ja.json b/translations/ja.json index ed952f963..c2734f6e4 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -500,5 +500,5 @@ "New feed URL": "新しいフィードURL", "New link title and URL": "新しいリンクのタイトルとURL", "Theme Designer": "テーマデザイナー", - "Reset": "" + "Reset": "リセット" } diff --git a/translations/ku.json b/translations/ku.json index bce17a036..c5b1b5458 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -500,5 +500,5 @@ "New feed URL": "URL-ya feed nû", "New link title and URL": "Sernav û URL-ya girêdana nû", "Theme Designer": "Theme Designer", - "Reset": "" + "Reset": "Reset" } diff --git a/translations/oc.json b/translations/oc.json index ae7187aae..62b17aee9 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -496,5 +496,5 @@ "New feed URL": "New feed URL", "New link title and URL": "New link title and URL", "Theme Designer": "Theme Designer", - "Reset": "" + "Reset": "Reset" } diff --git a/translations/pt.json b/translations/pt.json index 2164b7d1b..6c99c9813 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -500,5 +500,5 @@ "New feed URL": "Novo URL de feed", "New link title and URL": "Novo título e URL do link", "Theme Designer": "Designer de Tema", - "Reset": "" + "Reset": "Redefinir" } diff --git a/translations/ru.json b/translations/ru.json index a545363a4..6dbd3070b 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -500,5 +500,5 @@ "New feed URL": "URL нового канала", "New link title and URL": "Новое название ссылки и URL", "Theme Designer": "Дизайнер тем", - "Reset": "" + "Reset": "Сброс настроек" } diff --git a/translations/sw.json b/translations/sw.json index f1725f390..75bb2aa74 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -500,5 +500,5 @@ "New feed URL": "URL mpya ya mipasho", "New link title and URL": "Kichwa kipya cha kiungo na URL", "Theme Designer": "Mbuni wa Mandhari", - "Reset": "" + "Reset": "Weka upya" } diff --git a/translations/zh.json b/translations/zh.json index 417dacbe1..3e2dfdf13 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -500,5 +500,5 @@ "New feed URL": "新供稿网址", "New link title and URL": "新链接标题和 URL", "Theme Designer": "主题设计师", - "Reset": "" + "Reset": "重启" } diff --git a/webapp_themeDesigner.py b/webapp_themeDesigner.py index 869a860a2..12cde75d0 100644 --- a/webapp_themeDesigner.py +++ b/webapp_themeDesigner.py @@ -203,14 +203,14 @@ def htmlThemeDesigner(cssCache: {}, baseDir: str, themeForm += '
\n' - timelineKey = accessKeys['menuTimeline'] + resetKey = accessKeys['menuLogout'] submitKey = accessKeys['submitButton'] themeForm += \ '
\n' + \ ' \n' + \ + 'name="submitThemeDesignerReset" ' + \ + 'accesskey="' + resetKey + '">' + \ + translate['Reset'] + '\n' + \ ' \n
\n'