From 80cffa6de51771cd80995fb1c4f1e04ee868eb45 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 21 Oct 2014 16:46:36 +0200 Subject: Views are in dedicated actions + improve Context - Seperate normal, global and rss outputs in dedicated actions (NOT WORKING YET!) - Rewrite aside_flux and nav_menu to use Context object - Improve Context object See https://github.com/marienfressinaud/FreshRSS/issues/634 --- app/views/index/normal.phtml | 191 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 app/views/index/normal.phtml (limited to 'app/views/index/normal.phtml') diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml new file mode 100644 index 000000000..6333d63db --- /dev/null +++ b/app/views/index/normal.phtml @@ -0,0 +1,191 @@ +partial('aside_flux'); +$this->partial('nav_menu'); + +if (!empty($this->entries)) { + $display_today = true; + $display_yesterday = true; + $display_others = true; + if (FreshRSS_Auth::hasAccess()) { + $sharing = FreshRSS_Context::$conf->sharing; + } else { + $sharing = array(); + } + $hidePosts = !FreshRSS_Context::$conf->display_posts; + $lazyload = FreshRSS_Context::$conf->lazyload; + $topline_read = FreshRSS_Context::$conf->topline_read; + $topline_favorite = FreshRSS_Context::$conf->topline_favorite; + $topline_date = FreshRSS_Context::$conf->topline_date; + $topline_link = FreshRSS_Context::$conf->topline_link; + $bottomline_read = FreshRSS_Context::$conf->bottomline_read; + $bottomline_favorite = FreshRSS_Context::$conf->bottomline_favorite; + $bottomline_sharing = FreshRSS_Context::$conf->bottomline_sharing && (count($sharing)); + $bottomline_tags = FreshRSS_Context::$conf->bottomline_tags; + $bottomline_date = FreshRSS_Context::$conf->bottomline_date; + $bottomline_link = FreshRSS_Context::$conf->bottomline_link; + + $content_width = FreshRSS_Context::$conf->content_width; +?> + +
+ +
entries as $item) { + if ($display_today && $item->isDay(FreshRSS_Days::TODAY, $this->today)) { + ?>
currentName; ?>
isDay(FreshRSS_Days::YESTERDAY, $this->today)) { + ?>
currentName; ?>
isDay(FreshRSS_Days::BEFORE_YESTERDAY, $this->today)) { + ?>
currentName; ?>
+
  • 'entry', 'a' => 'read', 'params' => array('id' => $item->id())); + if ($item->isRead()) { + $arUrl['params']['is_read'] = 0; + } + ?>isRead() ? 'read' : 'unread'); ?>
  • 'entry', 'a' => 'bookmark', 'params' => array('id' => $item->id())); + if ($item->isFavorite()) { + $arUrl['params']['is_favorite'] = 0; + } + ?>isFavorite() ? 'starred' : 'non-starred'); ?>
  • categories, $item->feed()); //We most likely already have the feed object in cache + if ($feed == null) { + $feed = $item->feed(true); + if ($feed == null) { + $feed = FreshRSS_Feed::example(); + } + } + ?>
  • ✇ name(); ?>
  • +
  • title(); ?>
  • +
  • date(); ?> 
  • + +
+ +
+
+

title(); ?>

+ author(); + echo $author != '' ? '
' . _t('by_author', $author) . '
' : '', + $lazyload && $hidePosts ? lazyimg($item->content()) : $item->content(); + ?> +
+
  • 'entry', 'a' => 'read', 'params' => array('id' => $item->id())); + if ($item->isRead()) { + $arUrl['params']['is_read'] = 0; + } + ?>isRead() ? 'read' : 'unread'); ?>
  • 'entry', 'a' => 'bookmark', 'params' => array('id' => $item->id())); + if ($item->isFavorite()) { + $arUrl['params']['is_favorite'] = 0; + } + ?>isFavorite() ? 'starred' : 'non-starred'); ?>
  • +
  • link()); + $title = urlencode($item->title() . ' · ' . $feed->name()); + ?> + +
  • tags() : null; + if (!empty($tags)) { + ?>
  • + +
  • date(); ?>
  • +
+
+
+ + + renderHelper('pagination'); ?> +
+ +partial('nav_entries'); ?> + + +
+

+

+
+ -- cgit v1.2.3 From b446a510ebacddd1437d907e795c83b3d05a9b98 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 22 Oct 2014 13:35:30 +0200 Subject: Finish to update context object See See https://github.com/marienfressinaud/FreshRSS/issues/634 --- app/Controllers/indexController.php | 82 ++++++++++--------------------------- app/Models/Context.php | 6 +++ app/views/index/normal.phtml | 8 ++-- 3 files changed, 32 insertions(+), 64 deletions(-) (limited to 'app/views/index/normal.phtml') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index f163da53d..be85aa68d 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -17,70 +17,13 @@ class FreshRSS_index_Controller extends Minz_ActionController { return; - // On récupère les différents éléments de filtrage - $this->view->state = Minz_Request::param('state', FreshRSS_Context::$conf->default_view); - $state_param = Minz_Request::param('state', null); - $filter = Minz_Request::param('search', ''); - $this->view->order = $order = Minz_Request::param('order', FreshRSS_Context::$conf->sort_order); - $nb = Minz_Request::param('nb', FreshRSS_Context::$conf->posts_per_page); - $first = Minz_Request::param('next', ''); - - $ajax_request = Minz_Request::param('ajax', false); - if ($output === 'reader') { - $nb = max(1, round($nb / 2)); - } - - if ($this->view->state === FreshRSS_Entry::STATE_NOT_READ) { //Any unread article in this category at all? - switch ($getType) { - case 'a': - $hasUnread = $this->view->nb_not_read > 0; - break; - case 's': - // This is deprecated. The favorite button does not exist anymore - $hasUnread = $this->view->nb_favorites['unread'] > 0; - break; - case 'c': - $hasUnread = (!isset($this->view->cat_aside[$getId]) || - $this->view->cat_aside[$getId]->nbNotRead() > 0); - break; - case 'f': - $myFeed = FreshRSS_CategoryDAO::findFeed($this->view->cat_aside, $getId); - $hasUnread = ($myFeed === null) || ($myFeed->nbNotRead() > 0); - break; - default: - $hasUnread = true; - break; - } - if (!$hasUnread && ($state_param === null)) { - $this->view->state = FreshRSS_Entry::STATE_ALL; - } - } - - $this->view->today = @strtotime('today'); - try { $entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb + 1, $first, $filter); - // Si on a récupéré aucun article "non lus" - // on essaye de récupérer tous les articles - if ($this->view->state === FreshRSS_Entry::STATE_NOT_READ && empty($entries) && ($state_param === null) && ($filter == '')) { - Minz_Log::debug('Conflicting information about nbNotRead!'); - $feedDAO = FreshRSS_Factory::createFeedDao(); - try { - $feedDAO->updateCachedValues(); - } catch (Exception $ex) { - Minz_Log::notice('Failed to automatically correct nbNotRead! ' + $ex->getMessage()); - } - $this->view->state = FreshRSS_Entry::STATE_ALL; - $entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb, $first, $filter); - } - Minz_Request::_param('state', $this->view->state); - - if (count($entries) <= $nb) { - $this->view->nextId = ''; - } else { //We have more elements for pagination - $lastEntry = array_pop($entries); - $this->view->nextId = $lastEntry->id(); + if (count($entries) > $nb) { + // We have more elements for pagination + $last_entry = array_pop($entries); + FreshRSS_Context::$next_id = $last_entry->id(); } $this->view->entries = $entries; @@ -168,6 +111,23 @@ class FreshRSS_index_Controller extends Minz_ActionController { */ private function updateContext() { FreshRSS_Context::_get(Minz_Request::param('get', 'a')); + + FreshRSS_Context::$state |= Minz_Request::param( + 'state', FreshRSS_Context::$conf->default_view + ); + if (FreshRSS_Context::$state & FreshRSS_Entry::STATE_NOT_READ && + FreshRSS_Context::$get_unread <= 0) { + FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ; + } + + FreshRSS_Context::$search = Minz_Request::param('search', ''); + FreshRSS_Context::$order = Minz_Request::param( + 'order', FreshRSS_Context::$conf->sort_order + ); + FreshRSS_Context::$number = Minz_Request::param( + 'nb', FreshRSS_Context::$conf->posts_per_page + ); + FreshRSS_Context::$first_id = Minz_Request::param('next', ''); } /** diff --git a/app/Models/Context.php b/app/Models/Context.php index 7138fd638..31ac60207 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -26,6 +26,9 @@ class FreshRSS_Context { ); public static $get_unread = 0; public static $order = 'DESC'; + public static $number = 0; + public static $search = ''; + public static $first_id = 0; public static function init() { // Init configuration. @@ -80,6 +83,9 @@ class FreshRSS_Context { self::$current_get['starred'] = true; self::$name = _t('your_favorites'); self::$get_unread = self::$total_starred['unread']; + + // Update state if favorite is not yet enabled. + self::$state = self::$state | FreshRSS_Entry::STATE_FAVORITE; break; case 'f': self::$current_get['feed'] = $id; diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index 6333d63db..c39dba0a9 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -26,6 +26,8 @@ if (!empty($this->entries)) { $bottomline_link = FreshRSS_Context::$conf->bottomline_link; $content_width = FreshRSS_Context::$conf->content_width; + + $today = @strtotime('today'); ?>
entries)) {
entries as $item) { - if ($display_today && $item->isDay(FreshRSS_Days::TODAY, $this->today)) { + if ($display_today && $item->isDay(FreshRSS_Days::TODAY, $today)) { ?>
entries)) { ?>
isDay(FreshRSS_Days::YESTERDAY, $this->today)) { + if ($display_yesterday && $item->isDay(FreshRSS_Days::YESTERDAY, $today)) { ?>
entries)) { ?>
isDay(FreshRSS_Days::BEFORE_YESTERDAY, $this->today)) { + if ($display_others && $item->isDay(FreshRSS_Days::BEFORE_YESTERDAY, $today)) { ?>
currentName; ?> Date: Wed, 22 Oct 2014 13:52:20 +0200 Subject: Entries are loaded again! It's working :) See https://github.com/marienfressinaud/FreshRSS/issues/634 --- app/Controllers/indexController.php | 58 ++++++++++++++++++++++++++----------- app/Models/Context.php | 17 ++++++++--- app/layout/layout.phtml | 4 +-- app/views/index/normal.phtml | 8 ++--- 4 files changed, 60 insertions(+), 27 deletions(-) (limited to 'app/views/index/normal.phtml') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index be85aa68d..d711997be 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -14,23 +14,6 @@ class FreshRSS_index_Controller extends Minz_ActionController { 'c' => 'index', 'a' => $prefered_output )); - - return; - - try { - $entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb + 1, $first, $filter); - - if (count($entries) > $nb) { - // We have more elements for pagination - $last_entry = array_pop($entries); - FreshRSS_Context::$next_id = $last_entry->id(); - } - - $this->view->entries = $entries; - } catch (FreshRSS_EntriesGetter_Exception $e) { - Minz_Log::notice($e->getMessage()); - Minz_Error::error(404); - } } /** @@ -48,6 +31,21 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Error::error(404); } + try { + $entries = $this->listByContext(); + + if (count($entries) > FreshRSS_Context::$number) { + // We have more elements for pagination + $last_entry = array_pop($entries); + FreshRSS_Context::$next_id = $last_entry->id(); + } + + $this->view->entries = $entries; + } catch (FreshRSS_EntriesGetter_Exception $e) { + Minz_Log::notice($e->getMessage()); + Minz_Error::error(404); + } + $this->view->categories = FreshRSS_Context::$categories; $title = FreshRSS_Context::$name; @@ -100,6 +98,13 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Error::error(404); } + try { + $this->view->entries = $this->listByContext(); + } catch (FreshRSS_EntriesGetter_Exception $e) { + Minz_Log::notice($e->getMessage()); + Minz_Error::error(404); + } + // No layout for RSS output. $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); $this->view->_useLayout(false); @@ -130,6 +135,25 @@ class FreshRSS_index_Controller extends Minz_ActionController { FreshRSS_Context::$first_id = Minz_Request::param('next', ''); } + private function listByContext() { + $entryDAO = FreshRSS_Factory::createEntryDao(); + + $get = FreshRSS_Context::currentGet(true); + if (count($get) > 1) { + $type = $get[0]; + $id = $get[1]; + } else { + $type = $get; + $id = ''; + } + + return $entryDAO->listWhere( + $type, $id, FreshRSS_Context::$state, FreshRSS_Context::$order, + FreshRSS_Context::$number + 1, FreshRSS_Context::$first_id, + FreshRSS_Context::$search + ); + } + /** * This action displays the about page of FreshRSS. */ diff --git a/app/Models/Context.php b/app/Models/Context.php index 31ac60207..54fb1e64a 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -28,7 +28,8 @@ class FreshRSS_Context { public static $order = 'DESC'; public static $number = 0; public static $search = ''; - public static $first_id = 0; + public static $first_id = ''; + public static $next_id = ''; public static function init() { // Init configuration. @@ -127,15 +128,23 @@ class FreshRSS_Context { } } - public static function currentGet() { + public static function currentGet($array = false) { if (self::$current_get['all']) { return 'a'; } elseif (self::$current_get['starred']) { return 's'; } elseif (self::$current_get['feed']) { - return 'f_' . self::$current_get['feed']; + if ($array) { + return array('f', self::$current_get['feed']); + } else { + return 'f_' . self::$current_get['feed']; + } } elseif (self::$current_get['category']) { - return 'c_' . self::$current_get['category']; + if ($array) { + return array('c', self::$current_get['category']); + } else { + return 'c_' . self::$current_get['category']; + } } } diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index a8c70ec64..2b38df4a1 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -10,9 +10,9 @@ renderHelper('javascript_vars'); ?> //]]> nextId)) { + if (FreshRSS_Context::$next_id !== '') { $params = Minz_Request::params(); - $params['next'] = $this->nextId; + $params['next'] = FreshRSS_Context::$next_id; $params['ajax'] = 1; ?> diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index c39dba0a9..36adef2f2 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -32,14 +32,14 @@ if (!empty($this->entries)) {
- +
entries as $item) { if ($display_today && $item->isDay(FreshRSS_Days::TODAY, $today)) { ?>
currentName; ?>
entries)) { ?>
currentName; ?>
isDay(FreshRSS_Days::BEFORE_YESTERDAY, $today)) { ?>
currentName; ?>
Date: Thu, 23 Oct 2014 09:32:02 +0200 Subject: Rename aside_flux in aside_feed. --- app/layout/aside_feed.phtml | 95 ++++++++++++++++++++++++++++++++++++++++ app/layout/aside_flux.phtml | 95 ---------------------------------------- app/layout/nav_menu.phtml | 2 +- app/views/index/normal.phtml | 2 +- p/scripts/main.js | 26 +++++------ p/themes/Origine/origine.css | 8 ++-- p/themes/base-theme/base.css | 8 ++-- p/themes/base-theme/template.css | 22 +++++----- 8 files changed, 129 insertions(+), 129 deletions(-) create mode 100644 app/layout/aside_feed.phtml delete mode 100644 app/layout/aside_flux.phtml (limited to 'app/views/index/normal.phtml') diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml new file mode 100644 index 000000000..66b7b51af --- /dev/null +++ b/app/layout/aside_feed.phtml @@ -0,0 +1,95 @@ +hide_read_feeds && + FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) && + !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ)) { + $class = ' state_unread'; + } +?> + +
+ + + +
+ + +
+ + + + + + +
    +
  • +
    + +
    +
  • + +
  • +
    + +
    +
  • + + categories as $cat) { + $feeds = $cat->feeds(); + if (!empty($feeds)) { + $c_active = FreshRSS_Context::isCurrentGet('c_' . $cat->id()); + $c_show = $c_active && (!FreshRSS_Context::$conf->display_categories || + FreshRSS_Context::$current_get['feed']); + ?> +
  • + + + +
  • + +
+
+ + diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml deleted file mode 100644 index 30f362348..000000000 --- a/app/layout/aside_flux.phtml +++ /dev/null @@ -1,95 +0,0 @@ -hide_read_feeds && - FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) && - !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ)) { - $class = ' state_unread'; - } -?> - -
- - - -
- - -
- - - - - - -
    -
  • -
    - -
    -
  • - -
  • -
    - -
    -
  • - - categories as $cat) { - $feeds = $cat->feeds(); - if (!empty($feeds)) { - $c_active = FreshRSS_Context::isCurrentGet('c_' . $cat->id()); - $c_show = $c_active && (!FreshRSS_Context::$conf->display_categories || - FreshRSS_Context::$current_get['feed']); - ?> -
  • - - - -
  • - -
-
- - diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index 2c9f8724d..6f555c3d0 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -2,7 +2,7 @@