A free, self-hostable news aggregator…
Add a configuration option to get sticky articles
Alexis Degrugillier1e105a64ab12
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.phpindex 104fa8900..f831f25d0 100755--- a/app/Controllers/configureController.php+++ b/app/Controllers/configureController.php@@ -148,6 +148,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {$this->view->conf->_display_posts(Minz_Request::param('display_posts', false));$this->view->conf->_onread_jump_next(Minz_Request::param('onread_jump_next', false));$this->view->conf->_lazyload (Minz_Request::param('lazyload', false));+ $this->view->conf->_sticky_post (Minz_Request::param('sticky_post', false));$this->view->conf->_sort_order(Minz_Request::param('sort_order', 'DESC'));$this->view->conf->_mark_when (array('article' => Minz_Request::param('mark_open_article', false),diff --git a/app/Models/Configuration.php b/app/Models/Configuration.phpindex bacb79510..48efe3bf6 100644--- a/app/Models/Configuration.php+++ b/app/Models/Configuration.php@@ -17,6 +17,7 @@ class FreshRSS_Configuration {'display_posts' => false,'onread_jump_next' => true,'lazyload' => true,+ 'sticky_post' => true,'sort_order' => 'DESC','anon_access' => false,'mark_when' => array(@@ -140,6 +141,9 @@ class FreshRSS_Configuration {public function _lazyload ($value) {$this->data['lazyload'] = ((bool)$value) && $value !== 'no';}+ public function _sticky_post($value) {+ $this->data['sticky_post'] = ((bool)$value) && $value !== 'no';+ }public function _sort_order ($value) {$this->data['sort_order'] = $value === 'ASC' ? 'ASC' : 'DESC';}diff --git a/app/i18n/en.php b/app/i18n/en.phpindex 69c2fd310..e67447520 100644--- a/app/i18n/en.php+++ b/app/i18n/en.php@@ -215,6 +215,7 @@ return array ('top_line' => 'Top line','bottom_line' => 'Bottom line','img_with_lazyload' => 'Use "lazy load" mode to load pictures',+ 'sticky_post' => 'Stick the article to the top when opened','auto_read_when' => 'Mark article as read…','article_selected' => 'when article is selected','article_open_on_website' => 'when article is opened on its original website',diff --git a/app/i18n/fr.php b/app/i18n/fr.phpindex 452c560a7..2bd4fabab 100644--- a/app/i18n/fr.php+++ b/app/i18n/fr.php@@ -215,6 +215,7 @@ return array ('top_line' => 'Ligne du haut','bottom_line' => 'Ligne du bas','img_with_lazyload' => 'Utiliser le mode “chargement différé” pour les images',+ 'sticky_post' => 'Aligner l’article en haut quand il est ouvert','auto_read_when' => 'Marquer un article comme lu…','article_selected' => 'lorsque l’article est sélectionné','article_open_on_website' => 'lorsque l’article est ouvert sur le site d’origine',diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtmlindex 9104e4ef1..846db4b4c 100644--- a/app/views/configure/display.phtml+++ b/app/views/configure/display.phtml@@ -110,6 +110,16 @@</div></div>+ <div class="form-group">+ <div class="group-controls">+ <label class="checkbox" for="sticky_post">+ <input type="checkbox" name="sticky_post" id="sticky_post" value="1"<?php echo $this->conf->sticky_post ? ' checked="checked"' : ''; ?> />+ <?php echo Minz_Translate::t ('sticky_post'); ?>+ <noscript> — <strong><?php echo Minz_Translate::t ('javascript_should_be_activated'); ?></strong></noscript>+ </label>+ </div>+ </div>+<div class="form-group"><label class="group-name"><?php echo Minz_Translate::t ('auto_read_when'); ?></label><div class="group-controls">diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtmlindex afe0ab258..2ce11d7d7 100644--- a/app/views/helpers/javascript_vars.phtml+++ b/app/views/helpers/javascript_vars.phtml@@ -11,7 +11,8 @@ echo 'var ',',auto_mark_scroll=', $mark['scroll'] ? 'true' : 'false',',auto_load_more=', $this->conf->auto_load_more ? 'true' : 'false',',full_lazyload=', $this->conf->lazyload && ($this->conf->display_posts || Minz_Request::param('output') === 'reader') ? 'true' : 'false',- ',does_lazyload=', $this->conf->lazyload ? 'true' : 'false';+ ',does_lazyload=', $this->conf->lazyload ? 'true' : 'false',+ ',sticky_post=', $this->conf->sticky_post ? 'true' : 'false';$s = $this->conf->shortcuts;echo ',shortcuts={',diff --git a/p/scripts/main.js b/p/scripts/main.jsindex ec27bd50c..6cc992379 100644--- a/p/scripts/main.js+++ b/p/scripts/main.js@@ -238,26 +238,28 @@ function toggleContent(new_active, old_active) {var new_pos = new_active.position().top,old_scroll = $(box_to_move).scrollTop();- if (hide_posts) {+ if (sticky_post) {+ if (hide_posts) {- new_pos = new_active.position().top;- old_scroll = $(box_to_move).scrollTop();+ new_pos = new_active.position().top;+ old_scroll = $(box_to_move).scrollTop();- if (relative_move) {- new_pos += old_scroll;- }+ if (relative_move) {+ new_pos += old_scroll;+ }- if (old_active[0] !== new_active[0]) {- new_active.children(".flux_content").first().each(function () {- $(box_to_move).scrollTop(new_pos).scrollTop();- });- }- } else {- if (relative_move) {- new_pos += old_scroll;- }+ if (old_active[0] !== new_active[0]) {+ new_active.children(".flux_content").first().each(function () {+ $(box_to_move).scrollTop(new_pos).scrollTop();+ });+ }+ } else {+ if (relative_move) {+ new_pos += old_scroll;+ }- $(box_to_move).scrollTop(new_pos).scrollTop();+ $(box_to_move).scrollTop(new_pos).scrollTop();+ }}if (auto_mark_article) {