This commit is contained in:
Aeris 2022-05-20 20:07:42 +02:00
parent c1387e4331
commit a8e6de1964
6 changed files with 5 additions and 103 deletions

View File

@ -1,48 +0,0 @@
<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="image-height"><?php echo _t('ext.reddit_image.image_height'); ?></label>
<div class="group-controls">
<input type="number" name="image-height" id="image-height" value="<?php echo $this->image_height; ?>" min="1" max="100"/>
<?php echo _t('ext.reddit_image.image_height_unit'); ?>
</div>
</div>
<div class="form-group">
<div class="group-controls">
<label class="checkbox" for="muted-video">
<input type="checkbox" name="muted-video" id="muted-video" value="1" <?= $this->muted_video ? 'checked=true' : '' ?>/>
<?= _t('ext.reddit_image.muted_video'); ?>
</label>
</div>
</div>
<div class="form-group">
<div class="group-controls">
<label class="checkbox" for="display-image">
<input type="checkbox" name="display-image" id="display-image" value="1" <?= $this->display_image ? 'checked=true' : '' ?>/>
<?= _t('ext.reddit_image.display_image'); ?>
</label>
</div>
</div>
<div class="form-group">
<div class="group-controls">
<label class="checkbox" for="display-video">
<input type="checkbox" name="display-video" id="display-video" value="1" <?= $this->display_video ? 'checked=true' : '' ?>/>
<?= _t('ext.reddit_image.display_video'); ?>
</label>
</div>
</div>
<div class="form-group form-actions">
<?php if (isset($this->permission_problem)) { ?>
<p class="alert alert-error"><?php echo _t('ext.reddit_image.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

@ -1,9 +1,6 @@
<?php
class RedditImageExtension extends Minz_Extension {
const DEFAULT_MUTEDVIDEO = true;
const DEFAULT_DISPLAYIMAGE = true;
const DEFAULT_DISPLAYVIDEO = true;
class ReadabilityExtension extends Minz_Extension {
public function init() {
$this->registerTranslates();
@ -13,31 +10,8 @@ class RedditImageExtension extends Minz_Extension {
$this->registerHook('entry_before_insert', array($this, 'fetchStuff'));
}
public function handleConfigureAction() {
$this->registerTranslates();
$current_user = Minz_Session::param('currentUser');
$filename = 'configuration.' . $current_user . '.json';
$filepath = join_path($this->getPath(), 'static', $filename);
if (Minz_Request::isPost()) {
$configuration = array(
'imageHeight' => (int) Minz_Request::param('image-height', static::DEFAULT_HEIGHT),
'mutedVideo' => (bool) Minz_Request::param('muted-video'),
'displayImage' => (bool) Minz_Request::param('display-image'),
'displayVideo' => (bool) Minz_Request::param('display-video'),
);
file_put_contents($filepath, json_encode($configuration));
file_put_contents(join_path($this->getPath(), 'static', "style.{$current_user}.css"), sprintf(
'img.reddit-image, video.reddit-image {max-height:%svh;}',
$configuration['imageHeight']
));
}
$this->getConfiguration();
}
public function fetchStuff($entry) {
$data = "{\"url\": \"" . $entry->link() ."\"}";
$headers[] = 'Content-Type: application/json';

View File

@ -1,12 +0,0 @@
<?php
return array(
'reddit_image' => array(
'display_image' => 'Display images',
'display_video' => 'Display videos',
'image_height' => 'Media height',
'image_height_unit' => '%% of the viewport',
'muted_video' => 'Muted video',
'permission_problem' => 'Your configuration file is not writable, please change the file permissions for %s',
),
);

View File

@ -1,12 +0,0 @@
<?php
return array(
'reddit_image' => array(
'display_image' => 'Afficher les images',
'display_video' => 'Afficher les vidéos',
'image_height' => 'Hauteur des médias',
'image_height_unit' => '%% de la fenêtre',
'muted_video' => 'Vidéo silencieuse',
'permission_problem' => 'Votre fichier de configuration est en lecture seule ; veuillez adapter les permissions pour %s',
),
);

View File

@ -1,7 +1,7 @@
{
"name": "Reddit Image",
"author": "Alexis Degrugillier",
"description": "Modify reddit entries by displaying known medias and easing access to the linked resource",
"name": "Readability Enhance",
"author": "printfuck",
"description": "fetch article content for every feed with readability",
"version": "0.7.1",
"entrypoint": "RedditImage",
"type": "user"

View File