diff options
Diffstat (limited to 'lib/core-extensions/UserCSS')
| -rw-r--r-- | lib/core-extensions/UserCSS/configure.phtml | 20 | ||||
| -rw-r--r-- | lib/core-extensions/UserCSS/extension.php | 34 | ||||
| -rw-r--r-- | lib/core-extensions/UserCSS/i18n/de/ext.php | 7 | ||||
| -rw-r--r-- | lib/core-extensions/UserCSS/i18n/en/ext.php | 7 | ||||
| -rw-r--r-- | lib/core-extensions/UserCSS/i18n/fr/ext.php | 7 | ||||
| -rw-r--r-- | lib/core-extensions/UserCSS/i18n/ja/ext.php | 7 | ||||
| -rw-r--r-- | lib/core-extensions/UserCSS/metadata.json | 8 |
7 files changed, 90 insertions, 0 deletions
diff --git a/lib/core-extensions/UserCSS/configure.phtml b/lib/core-extensions/UserCSS/configure.phtml new file mode 100644 index 000000000..22d4ea79a --- /dev/null +++ b/lib/core-extensions/UserCSS/configure.phtml @@ -0,0 +1,20 @@ +<?php + declare(strict_types=1); + /** @var UserCSSExtension $this */ +?> +<form action="<?= _url('extension', 'configure', 'e', urlencode($this->getName())); ?>" method="post"> + <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" /> + <div class="form-group"> + <label class="group-name" for="css-rules"><?= _t('ext.user_css.write_css') ?></label> + <div class="group-controls"> + <textarea name="css-rules" id="css-rules"><?= $this->css_rules ?></textarea> + </div> + </div> + + <div class="form-group form-actions"> + <div class="group-controls"> + <button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button> + <button type="reset" class="btn"><?= _t('gen.action.cancel') ?></button> + </div> + </div> +</form> diff --git a/lib/core-extensions/UserCSS/extension.php b/lib/core-extensions/UserCSS/extension.php new file mode 100644 index 000000000..5343fd39a --- /dev/null +++ b/lib/core-extensions/UserCSS/extension.php @@ -0,0 +1,34 @@ +<?php +declare(strict_types=1); + +final class UserCSSExtension extends Minz_Extension { + public string $css_rules = ''; + private const FILENAME = 'style.css'; + + #[\Override] + public function init(): void { + parent::init(); + + $this->registerTranslates(); + if ($this->hasFile(self::FILENAME)) { + Minz_View::appendStyle($this->getFileUrl(self::FILENAME, 'css', false)); + } + } + + #[\Override] + public function handleConfigureAction(): void { + parent::init(); + + $this->registerTranslates(); + + if (Minz_Request::isPost()) { + $css_rules = html_entity_decode(Minz_Request::paramString('css-rules')); + $this->saveFile(self::FILENAME, $css_rules); + } + + $this->css_rules = ''; + if ($this->hasFile(self::FILENAME)) { + $this->css_rules = htmlentities($this->getFile(self::FILENAME) ?? ''); + } + } +} diff --git a/lib/core-extensions/UserCSS/i18n/de/ext.php b/lib/core-extensions/UserCSS/i18n/de/ext.php new file mode 100644 index 000000000..cafc5f2f0 --- /dev/null +++ b/lib/core-extensions/UserCSS/i18n/de/ext.php @@ -0,0 +1,7 @@ +<?php + +return array( + 'user_css' => array( + 'write_css' => 'Benutzerspezifische CSS Regeln', + ), +); diff --git a/lib/core-extensions/UserCSS/i18n/en/ext.php b/lib/core-extensions/UserCSS/i18n/en/ext.php new file mode 100644 index 000000000..b82cd8331 --- /dev/null +++ b/lib/core-extensions/UserCSS/i18n/en/ext.php @@ -0,0 +1,7 @@ +<?php + +return array( + 'user_css' => array( + 'write_css' => 'Additional CSS rules', + ), +); diff --git a/lib/core-extensions/UserCSS/i18n/fr/ext.php b/lib/core-extensions/UserCSS/i18n/fr/ext.php new file mode 100644 index 000000000..507d8be45 --- /dev/null +++ b/lib/core-extensions/UserCSS/i18n/fr/ext.php @@ -0,0 +1,7 @@ +<?php + +return array( + 'user_css' => array( + 'write_css' => 'Règles CSS supplémentaires', + ), +); diff --git a/lib/core-extensions/UserCSS/i18n/ja/ext.php b/lib/core-extensions/UserCSS/i18n/ja/ext.php new file mode 100644 index 000000000..ce8d17c78 --- /dev/null +++ b/lib/core-extensions/UserCSS/i18n/ja/ext.php @@ -0,0 +1,7 @@ +<?php + +return array( + 'user_css' => array( + 'write_css' => '追加のCSSルール', + ), +); diff --git a/lib/core-extensions/UserCSS/metadata.json b/lib/core-extensions/UserCSS/metadata.json new file mode 100644 index 000000000..2de79af8c --- /dev/null +++ b/lib/core-extensions/UserCSS/metadata.json @@ -0,0 +1,8 @@ +{ + "name": "User CSS", + "author": "hkcomori, Marien Fressinaud", + "description": "Give possibility to overwrite the CSS with a user-specific rules.", + "version": "1.0.0", + "entrypoint": "UserCSS", + "type": "user" +} |
