This commit is contained in:
Alexandre Alapetite 2024-05-16 13:09:29 +02:00 committed by GitHub
commit 2b4c82eb66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 285 additions and 0 deletions

View File

@ -0,0 +1,89 @@
# CustomCSS extension
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, added german translation, removed un-editable file static/style.css
- 0.1 initial version
## Examples
### Enhancing mobile view
The following CSS rules let you have a more comfortable mobile view by hiding some icons (read/unread article, mark as favorite and RSS feed's favicon) and by reducing text size. It also displays the name of the subscribed feed, instead of the favicon:
```css
@media (max-width: 840px)
{
.flux_header .item.website
{
width:20%;
padding:3px;
}
.flux .website .favicon, .flux_header .item.manage
{
display:none;
}
.flux_header .item.website span
{
display:inline;
font-size:0.7rem;
}
}
```
The result is shown below:
Desktop screen resolution:
![Desktop](desktop_resolution.png)
Mobile screen resolution:
![Mobile](mobile_resolution.png)
#### Getting rid of Top Menu Items
The Top Menu within the mobile view might look a little bit cluttered, depending on the theme. The following CSS rules allow to hide unneccessary top menu buttons or input boxes.
```css
@media (max-width: 840px)
{
/* Hides "Actions" Menu in Mobile View */
#nav_menu_actions {
display: none;
}
/* Hides "Views" Menu in Mobile View */
#nav_menu_views {
display: none;
}
/* Hides "Search" Input Box in Mobile View */
.nav_menu .item.search {
display: none;
}
/* Hides the Dropdown Menu Button next to the "Mark all read" Button in Mobile View */
#mark-read-menu .dropdown {
display: none;
}
}
```
### Sidebar: Move the unread count to the right side of a feed
Some people prefer to have the unread count number of a feed on the right side after the feed's name, instead placing it between the favicon and the feeds name, as this is also the common location in other tools (e.g. e-mail inbox folder). Use this CSS code to move the number to the right side.
```css
.feed .item-title:not([data-unread="0"])::before {
display: none
}
.feed .item-title:not([data-unread="0"])::after {
content: " (" attr(data-unread) ")";
}
```

View File

@ -0,0 +1,20 @@
<form action="<?php echo _url('extension', 'configure', 'e', urlencode($this->getName())); ?>" method="post">
<input type="hidden" name="_csrf" value="<?php echo FreshRSS_Auth::csrfToken(); ?>" />
<div class="form-group">
<label class="group-name" for="css-rules"><?php echo _t('ext.custom_css.write_css'); ?></label>
<div class="group-controls">
<textarea name="css-rules" id="css-rules"><?php echo $this->css_rules; ?></textarea>
</div>
</div>
<div class="form-group form-actions">
<?php if (isset($this->permission_problem)) { ?>
<p class="alert alert-error"><?php echo _t('ext.custom_css.permission_problem', $this->permission_problem); ?></p>
<?php } else { ?>
<div class="group-controls">
<button type="submit" class="btn btn-important"><?php echo _t('gen.action.submit'); ?></button>
<button type="reset" class="btn"><?php echo _t('gen.action.cancel'); ?></button>
</div>
<?php } ?>
</div>
</form>

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,40 @@
<?php
class CustomCSSExtension extends Minz_Extension {
public function init() {
$this->registerTranslates();
$current_user = Minz_Session::param('currentUser');
$filename = 'style.' . $current_user . '.css';
$filepath = join_path($this->getPath(), 'static', $filename);
if (file_exists($filepath)) {
Minz_View::appendStyle($this->getFileUrl($filename, 'css'));
}
}
public function handleConfigureAction() {
$this->registerTranslates();
$current_user = Minz_Session::param('currentUser');
$filename = 'style.' . $current_user . '.css';
$staticPath = join_path($this->getPath(), 'static');
$filepath = join_path($staticPath, $filename);
if (!file_exists($filepath) && !is_writable($staticPath)) {
$tmpPath = explode(EXTENSIONS_PATH . '/', $staticPath);
$this->permission_problem = $tmpPath[1] . '/';
} elseif (file_exists($filepath) && !is_writable($filepath)) {
$tmpPath = explode(EXTENSIONS_PATH . '/', $filepath);
$this->permission_problem = $tmpPath[1];
} elseif (Minz_Request::isPost()) {
$css_rules = html_entity_decode(Minz_Request::param('css-rules', ''));
file_put_contents($filepath, $css_rules);
}
$this->css_rules = '';
if (file_exists($filepath)) {
$this->css_rules = htmlentities(file_get_contents($filepath));
}
}
}

View File

@ -0,0 +1,8 @@
<?php
return array(
'custom_css' => array(
'write_css' => 'Benutzerspezifische CSS Regeln',
'permission_problem' => 'Deine CSS Datei ist nicht beschreibbar, bitte ändere die Berechtigungen von %s'
),
);

View File

@ -0,0 +1,8 @@
<?php
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',
),
);

View File

@ -0,0 +1,8 @@
<?php
return array(
'custom_css' => array(
'write_css' => 'Règles CSS supplémentaires',
'permission_problem' => 'Votre fichier CSS est en lecture seule ; veuillez adapter les permissions pour %s',
),
);

View File

@ -0,0 +1,8 @@
{
"name": "Custom CSS",
"author": "Marien Fressinaud",
"description": "Give possibility to overwrite the CSS with a user-specific rules.",
"version": 0.3,
"entrypoint": "CustomCSS",
"type": "user"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1 @@
style.*.css

View File

@ -0,0 +1,10 @@
# CustomJS extension
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

View File

@ -0,0 +1,20 @@
<form action="<?php echo _url('extension', 'configure', 'e', urlencode($this->getName())); ?>" method="post">
<input type="hidden" name="_csrf" value="<?php echo FreshRSS_Auth::csrfToken(); ?>" />
<div class="form-group">
<label class="group-name" for="js-rules"><?php echo _t('ext.custom_js.write_js'); ?></label>
<div class="group-controls">
<textarea name="js-rules" id="js-rules"><?php echo $this->js_rules; ?></textarea>
</div>
</div>
<div class="form-group form-actions">
<?php if (isset($this->permission_problem)) { ?>
<p class="alert alert-error"><?php echo _t('ext.custom_js.permission_problem', $this->permission_problem); ?></p>
<?php } else { ?>
<div class="group-controls">
<button type="submit" class="btn btn-important"><?php echo _t('gen.action.submit'); ?></button>
<button type="reset" class="btn"><?php echo _t('gen.action.cancel'); ?></button>
</div>
<?php } ?>
</div>
</form>

View File

@ -0,0 +1,40 @@
<?php
class CustomJSExtension extends Minz_Extension {
public function init() {
$this->registerTranslates();
$current_user = Minz_Session::param('currentUser');
$filename = 'script.' . $current_user . '.js';
$filepath = join_path($this->getPath(), 'static', $filename);
if (file_exists($filepath)) {
Minz_View::appendScript($this->getFileUrl($filename, 'js'));
}
}
public function handleConfigureAction() {
$this->registerTranslates();
$current_user = Minz_Session::param('currentUser');
$filename = 'script.' . $current_user . '.js';
$staticPath = join_path($this->getPath(), 'static');
$filepath = join_path($staticPath, $filename);
if (!file_exists($filepath) && !is_writable($staticPath)) {
$tmpPath = explode(EXTENSIONS_PATH . '/', $staticPath);
$this->permission_problem = $tmpPath[1] . '/';
} elseif (file_exists($filepath) && !is_writable($filepath)) {
$tmpPath = explode(EXTENSIONS_PATH . '/', $filepath);
$this->permission_problem = $tmpPath[1];
} elseif (Minz_Request::isPost()) {
$js_rules = html_entity_decode(Minz_Request::param('js-rules', ''));
file_put_contents($filepath, $js_rules);
}
$this->js_rules = '';
if (file_exists($filepath)) {
$this->js_rules = htmlentities(file_get_contents($filepath));
}
}
}

View File

@ -0,0 +1,8 @@
<?php
return array(
'custom_js' => array(
'write_js' => 'Benutzerspezifische Javascript Regeln',
'permission_problem' => 'Deine JS Datei ist nicht beschreibbar, bitte ändere die Berechtigungen von %s'
),
);

View File

@ -0,0 +1,8 @@
<?php
return array(
'custom_js' => array(
'write_js' => 'Additional JS',
'permission_problem' => 'Your JS file is not writable, please change the file permissions for %s',
),
);

View File

@ -0,0 +1,8 @@
<?php
return array(
'custom_js' => array(
'write_js' => 'JS supplémentaires',
'permission_problem' => 'Votre fichier JS est en lecture seule ; veuillez adapter les permissions pour %s',
),
);

View File

@ -0,0 +1,8 @@
{
"name": "Custom JS",
"author": "Frans de Jonge",
"description": "Apply custom JS.",
"version": 0.3,
"entrypoint": "CustomJS",
"type": "user"
}

View File

@ -0,0 +1 @@
script.*.js