From e6c4d99cb36e0d882a6691834b7fbc2f3187a8fa Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Wed, 6 Dec 2017 22:37:49 +0100 Subject: [PATCH 1/4] added permission check, error message and german translation fixes FreshRSS/FreshRSS#1456 --- extensions.json | 4 ++-- xExtension-CustomCSS/README.md | 5 +++++ xExtension-CustomCSS/configure.phtml | 12 ++++++++---- xExtension-CustomCSS/extension.php | 11 +++++++++-- xExtension-CustomCSS/i18n/de/ext.php | 8 ++++++++ xExtension-CustomCSS/i18n/en/ext.php | 1 + xExtension-CustomCSS/i18n/fr/ext.php | 1 + xExtension-CustomJS/README.md | 5 +++++ xExtension-CustomJS/configure.phtml | 12 ++++++++---- xExtension-CustomJS/extension.php | 11 +++++++++-- xExtension-CustomJS/i18n/de/ext.php | 8 ++++++++ xExtension-CustomJS/i18n/en/ext.php | 1 + xExtension-CustomJS/i18n/fr/ext.php | 1 + xExtension-CustomJS/metadata.json | 2 +- 14 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 xExtension-CustomCSS/i18n/de/ext.php create mode 100644 xExtension-CustomJS/i18n/de/ext.php diff --git a/extensions.json b/extensions.json index 0a3cc1a..e00a72e 100644 --- a/extensions.json +++ b/extensions.json @@ -4,7 +4,7 @@ { "name": "CustomCSS", "description": "A FreshRSS extension which give ability to create user-specific CSS rules to apply in addition of the actual theme", - "version": 0.1, + "version": 0.2, "author": "Marien Fressinaud", "url": "https://github.com/FreshRSS/Extensions", "type": "gh-subdirectory" @@ -12,7 +12,7 @@ { "name": "CustomJS", "description": "A FreshRSS extension which give ability to create user-specific Javascript rules to apply in addition of the actual theme", - "version": 0.1, + "version": 0.2, "author": "Frans de Jonge", "url": "https://github.com/FreshRSS/Extensions", "type": "gh-subdirectory" diff --git a/xExtension-CustomCSS/README.md b/xExtension-CustomCSS/README.md index 049d372..672fa45 100644 --- a/xExtension-CustomCSS/README.md +++ b/xExtension-CustomCSS/README.md @@ -3,3 +3,8 @@ A FreshRSS extension which give ability to create user-specific CSS rules to apply in addition of the actual theme. To use it, upload this directory in your `./extensions` directory and enable it on the extension panel in FreshRSS. You can add CSS rules by clicking on the manage button. + +## Changelog + +- 0.2 added file permission check and german translation +- 0.1 initial version \ No newline at end of file diff --git a/xExtension-CustomCSS/configure.phtml b/xExtension-CustomCSS/configure.phtml index 51b8b46..32a5a65 100644 --- a/xExtension-CustomCSS/configure.phtml +++ b/xExtension-CustomCSS/configure.phtml @@ -8,9 +8,13 @@
-
- - -
+ permission_problem)) { ?> +

permission_problem); ?>

+ +
+ + +
+
diff --git a/xExtension-CustomCSS/extension.php b/xExtension-CustomCSS/extension.php index 2b43f55..aaae17b 100644 --- a/xExtension-CustomCSS/extension.php +++ b/xExtension-CustomCSS/extension.php @@ -19,9 +19,16 @@ class CustomCSSExtension extends Minz_Extension { $current_user = Minz_Session::param('currentUser'); $filename = 'style.' . $current_user . '.css'; - $filepath = join_path($this->getPath(), 'static', $filename); + $staticPath = join_path($this->getPath(), 'static'); + $filepath = join_path($staticPath, $filename); - if (Minz_Request::isPost()) { + if (!file_exists($filepath) && !is_writable($staticPath)) { + $tmpPath = explode(EXTENSIONS_PATH . '/', $staticPath); + $this->permission_problem = $tmpPath[1] . '/'; + } else if (file_exists($filepath) && !is_writable($filepath)) { + $tmpPath = explode(EXTENSIONS_PATH . '/', $filepath); + $this->permission_problem = $tmpPath[1]; + } else if (Minz_Request::isPost()) { $css_rules = html_entity_decode(Minz_Request::param('css-rules', '')); file_put_contents($filepath, $css_rules); } diff --git a/xExtension-CustomCSS/i18n/de/ext.php b/xExtension-CustomCSS/i18n/de/ext.php new file mode 100644 index 0000000..308d65b --- /dev/null +++ b/xExtension-CustomCSS/i18n/de/ext.php @@ -0,0 +1,8 @@ + array( + 'write_css' => 'Benutzerspezifische CSS Regeln', + 'permission_problem' => 'Dein CSS file ist nicht schreibbar, bitte ändere die Berechtigungen von %s' + ), +); diff --git a/xExtension-CustomCSS/i18n/en/ext.php b/xExtension-CustomCSS/i18n/en/ext.php index 23296fe..c5f95ed 100644 --- a/xExtension-CustomCSS/i18n/en/ext.php +++ b/xExtension-CustomCSS/i18n/en/ext.php @@ -3,5 +3,6 @@ return array( 'custom_css' => array( 'write_css' => 'Additional CSS rules', + 'permission_problem' => 'Your CSS file is not writable, please change the file permissions for %s', ), ); diff --git a/xExtension-CustomCSS/i18n/fr/ext.php b/xExtension-CustomCSS/i18n/fr/ext.php index ea9842e..657724e 100644 --- a/xExtension-CustomCSS/i18n/fr/ext.php +++ b/xExtension-CustomCSS/i18n/fr/ext.php @@ -3,5 +3,6 @@ return array( 'custom_css' => array( 'write_css' => 'Règles CSS supplémentaires', + 'permission_problem' => 'Your CSS file is not writable, please change the file permissions for %s', // @todo translate ), ); diff --git a/xExtension-CustomJS/README.md b/xExtension-CustomJS/README.md index 174fed8..216602e 100644 --- a/xExtension-CustomJS/README.md +++ b/xExtension-CustomJS/README.md @@ -3,3 +3,8 @@ A FreshRSS extension which give ability to create user-specific JS. To use it, upload this directory in your `./extensions` directory and enable it on the extension panel in FreshRSS. You can add JS by clicking on the manage button. + +## Changelog + +- 0.2 added file permission check and german translation +- 0.1 initial version \ No newline at end of file diff --git a/xExtension-CustomJS/configure.phtml b/xExtension-CustomJS/configure.phtml index e7fef3c..24b9b2d 100644 --- a/xExtension-CustomJS/configure.phtml +++ b/xExtension-CustomJS/configure.phtml @@ -8,9 +8,13 @@
-
- - -
+ permission_problem)) { ?> +

permission_problem); ?>

+ +
+ + +
+
diff --git a/xExtension-CustomJS/extension.php b/xExtension-CustomJS/extension.php index cbb1d56..db76899 100644 --- a/xExtension-CustomJS/extension.php +++ b/xExtension-CustomJS/extension.php @@ -18,9 +18,16 @@ class CustomJSExtension extends Minz_Extension { $current_user = Minz_Session::param('currentUser'); $filename = 'script.' . $current_user . '.js'; - $filepath = join_path($this->getPath(), 'static', $filename); + $staticPath = join_path($this->getPath(), 'static'); + $filepath = join_path($staticPath, $filename); - if (Minz_Request::isPost()) { + if (!file_exists($filepath) && !is_writable($staticPath)) { + $tmpPath = explode(EXTENSIONS_PATH . '/', $staticPath); + $this->permission_problem = $tmpPath[1] . '/'; + } else if (file_exists($filepath) && !is_writable($filepath)) { + $tmpPath = explode(EXTENSIONS_PATH . '/', $filepath); + $this->permission_problem = $tmpPath[1]; + } else if (Minz_Request::isPost()) { $js_rules = html_entity_decode(Minz_Request::param('js-rules', '')); file_put_contents($filepath, $js_rules); } diff --git a/xExtension-CustomJS/i18n/de/ext.php b/xExtension-CustomJS/i18n/de/ext.php new file mode 100644 index 0000000..fac604b --- /dev/null +++ b/xExtension-CustomJS/i18n/de/ext.php @@ -0,0 +1,8 @@ + array( + 'write_css' => 'Benutzerspezifische Javascript Regeln', + 'permission_problem' => 'Dein JS file ist nicht schreibbar, bitte ändere die Berechtigungen von %s' + ), +); diff --git a/xExtension-CustomJS/i18n/en/ext.php b/xExtension-CustomJS/i18n/en/ext.php index 8bc2660..fcf8538 100644 --- a/xExtension-CustomJS/i18n/en/ext.php +++ b/xExtension-CustomJS/i18n/en/ext.php @@ -3,5 +3,6 @@ return array( 'custom_js' => array( 'write_js' => 'Additional JS', + 'permission_problem' => 'Your JS file is not writable, please change the file permissions for %s', ), ); diff --git a/xExtension-CustomJS/i18n/fr/ext.php b/xExtension-CustomJS/i18n/fr/ext.php index 51d66d6..afd1864 100644 --- a/xExtension-CustomJS/i18n/fr/ext.php +++ b/xExtension-CustomJS/i18n/fr/ext.php @@ -3,5 +3,6 @@ return array( 'custom_js' => array( 'write_js' => 'JS supplémentaires', + 'permission_problem' => 'Your JS file is not writable, please change the file permissions for %s', // @todo translate ), ); diff --git a/xExtension-CustomJS/metadata.json b/xExtension-CustomJS/metadata.json index bfe19c4..ef5ea0f 100644 --- a/xExtension-CustomJS/metadata.json +++ b/xExtension-CustomJS/metadata.json @@ -2,7 +2,7 @@ "name": "Custom JS", "author": "₣rans de Jonge", "description": "Apply custom JS.", - "version": 0.1, + "version": 0.2, "entrypoint": "CustomJS", "type": "user" } From efc6c31b5c05cd767665131f99ac6654d26d6b9a Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Wed, 6 Dec 2017 22:42:00 +0100 Subject: [PATCH 2/4] adjusted german translation --- xExtension-CustomCSS/i18n/de/ext.php | 2 +- xExtension-CustomJS/i18n/de/ext.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xExtension-CustomCSS/i18n/de/ext.php b/xExtension-CustomCSS/i18n/de/ext.php index 308d65b..a0c704c 100644 --- a/xExtension-CustomCSS/i18n/de/ext.php +++ b/xExtension-CustomCSS/i18n/de/ext.php @@ -3,6 +3,6 @@ return array( 'custom_css' => array( 'write_css' => 'Benutzerspezifische CSS Regeln', - 'permission_problem' => 'Dein CSS file ist nicht schreibbar, bitte ändere die Berechtigungen von %s' + 'permission_problem' => 'Deine CSS Datei ist nicht beschreibbar, bitte ändere die Berechtigungen von %s' ), ); diff --git a/xExtension-CustomJS/i18n/de/ext.php b/xExtension-CustomJS/i18n/de/ext.php index fac604b..4c91983 100644 --- a/xExtension-CustomJS/i18n/de/ext.php +++ b/xExtension-CustomJS/i18n/de/ext.php @@ -3,6 +3,6 @@ return array( 'custom_css' => array( 'write_css' => 'Benutzerspezifische Javascript Regeln', - 'permission_problem' => 'Dein JS file ist nicht schreibbar, bitte ändere die Berechtigungen von %s' + 'permission_problem' => 'Deine JS Datei ist nicht beschreibbar, bitte ändere die Berechtigungen von %s' ), ); From dbb88a7299fcffc8dec579cd47ec9f0ee050c7fe Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Wed, 6 Dec 2017 23:50:54 +0100 Subject: [PATCH 3/4] removed un-editable static/styles.css --- xExtension-CustomCSS/README.md | 2 +- xExtension-CustomCSS/extension.php | 1 - xExtension-CustomCSS/static/style.css | 4 ---- 3 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 xExtension-CustomCSS/static/style.css diff --git a/xExtension-CustomCSS/README.md b/xExtension-CustomCSS/README.md index 672fa45..124486d 100644 --- a/xExtension-CustomCSS/README.md +++ b/xExtension-CustomCSS/README.md @@ -6,5 +6,5 @@ To use it, upload this directory in your `./extensions` directory and enable it ## Changelog -- 0.2 added file permission check and german translation +- 0.2 added file permission check, added german translation, removed un-editable file static/style.css - 0.1 initial version \ No newline at end of file diff --git a/xExtension-CustomCSS/extension.php b/xExtension-CustomCSS/extension.php index aaae17b..6860e3d 100644 --- a/xExtension-CustomCSS/extension.php +++ b/xExtension-CustomCSS/extension.php @@ -3,7 +3,6 @@ class CustomCSSExtension extends Minz_Extension { public function init() { $this->registerTranslates(); - Minz_View::appendStyle($this->getFileUrl('style.css', 'css')); $current_user = Minz_Session::param('currentUser'); $filename = 'style.' . $current_user . '.css'; diff --git a/xExtension-CustomCSS/static/style.css b/xExtension-CustomCSS/static/style.css deleted file mode 100644 index 2b94c37..0000000 --- a/xExtension-CustomCSS/static/style.css +++ /dev/null @@ -1,4 +0,0 @@ -textarea#css-rules { - width: 500px; - height: 500px; -} From 9352faac5b693990ef8f1987308e590b99222332 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 13 Dec 2017 23:04:55 +0100 Subject: [PATCH 4/4] i18n French for CustomCSS / CustomJS --- xExtension-CustomCSS/i18n/fr/ext.php | 2 +- xExtension-CustomJS/i18n/fr/ext.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xExtension-CustomCSS/i18n/fr/ext.php b/xExtension-CustomCSS/i18n/fr/ext.php index 657724e..3aa3c82 100644 --- a/xExtension-CustomCSS/i18n/fr/ext.php +++ b/xExtension-CustomCSS/i18n/fr/ext.php @@ -3,6 +3,6 @@ return array( 'custom_css' => array( 'write_css' => 'Règles CSS supplémentaires', - 'permission_problem' => 'Your CSS file is not writable, please change the file permissions for %s', // @todo translate + 'permission_problem' => 'Votre fichier CSS est en lecture seule ; veuillez adapter les permissions pour %s', ), ); diff --git a/xExtension-CustomJS/i18n/fr/ext.php b/xExtension-CustomJS/i18n/fr/ext.php index afd1864..7e6520d 100644 --- a/xExtension-CustomJS/i18n/fr/ext.php +++ b/xExtension-CustomJS/i18n/fr/ext.php @@ -3,6 +3,6 @@ return array( 'custom_js' => array( 'write_js' => 'JS supplémentaires', - 'permission_problem' => 'Your JS file is not writable, please change the file permissions for %s', // @todo translate + 'permission_problem' => 'Votre fichier JS est en lecture seule ; veuillez adapter les permissions pour %s', ), );