From 8ee8a573f1f7e9cc45f9b3c46627d15670f14f3a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 29 Sep 2018 20:47:17 +0200 Subject: Custom labels (#2027) * First draft of custom tags https://github.com/FreshRSS/FreshRSS/issues/928 https://github.com/FreshRSS/FreshRSS/issues/1367 * SMALLINT to BIGINT for id_entry And uppercase SQL types * Fix layout for unreads * Start UI menu * Change menu order * Clean database helpers https://github.com/FreshRSS/FreshRSS/pull/2027#discussion_r217971535 * Travis rules do not understand PostgreSQL constants Grrr * Tag controller + UI * Add column attributes to tags * Use only favicon for now, for label * Fix styling for different themes * Constant for maximum InnoDB index length in Unicode https://github.com/FreshRSS/FreshRSS/pull/2027#discussion_r219052200 (I would have personnally prefered keeping the readability of a real value instead of a constant, in this case of many SQL fields) * Use FreshRSS_Factory::createCategoryDao * Add view of all articles containing any tag * Fix search in tags * Mark as read tags * Partial auto-update unread tags * More auto update tag unreads * Add tag deletion * Do not purge tagged articles * Minor comment * Fix SQLite and UI bug * Google Reader API support for user tags Add SQL check that tag names must be distinct from category names * whitespace * Add missing API for EasyRSS * Compatibility SQLite Problematic parentheses * Add SQL DISTINCT for cases with multiple tags * Fix for PostgreSQL PostgreSQL needs some additional type hint to avoid "could not determine data type of parameter $1" http://www.postgresql-archive.org/Could-not-determine-data-type-of-parameter-1-tp2171092p2171094.html --- app/Controllers/indexController.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'app/Controllers/indexController.php') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index ddffdba73..8b905c881 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -32,8 +32,15 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Error::error(404); } - $this->view->callbackBeforeContent = function($view) { + $this->view->callbackBeforeContent = function ($view) { try { + $tagDAO = FreshRSS_Factory::createTagDao(); + $view->tags = $tagDAO->listTags(true); + $view->nbUnreadTags = 0; + foreach ($view->tags as $tag) { + $view->nbUnreadTags += $tag->nbUnread(); + } + FreshRSS_Context::$number++; //+1 for pagination $entries = FreshRSS_index_Controller::listEntriesByContext(); FreshRSS_Context::$number--; @@ -158,7 +165,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { */ private function updateContext() { if (empty(FreshRSS_Context::$categories)) { - $catDAO = new FreshRSS_CategoryDAO(); + $catDAO = FreshRSS_Factory::createCategoryDao(); FreshRSS_Context::$categories = $catDAO->listCategories(); } -- cgit v1.2.3 From 5b030dcc6ff1393e29ecc6e5c76f129c7ad6c914 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 14 Oct 2018 14:37:50 +0200 Subject: Ensure fast flush of HTTP headers and HTML head (#2045) * Ensure fast flush of HTTP headers and HTML head The fast flush optimisation done in https://github.com/FreshRSS/FreshRSS/pull/1133 does not seem to work anymore (need to check if it is related to a PHP version). Work-around when PHP flush() is not working Can be tested by adding a `sleep(5);` after: https://github.com/FreshRSS/FreshRSS/blob/ee902ee7c4370421802768c3105ba269a4f97b16/app/layout/layout.phtml#L27 Follow-up of the performance checks of https://github.com/FreshRSS/FreshRSS/pull/2040 * output_buffering in .user.ini for PHP CGI / FPM * Reuse .user.ini for Docker PHP config * Longer flush Flush a bit later, to be compatible with the default value of 4096 for PHP output_buffering, and thus avoid the need of tuning the value. --- app/Controllers/indexController.php | 26 ++++++++++++++++---------- app/layout/layout.phtml | 21 ++++++++++++--------- app/views/index/global.phtml | 5 +++++ app/views/index/normal.phtml | 5 +++++ app/views/index/reader.phtml | 5 +++++ 5 files changed, 43 insertions(+), 19 deletions(-) (limited to 'app/Controllers/indexController.php') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 8b905c881..fa914ef87 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -32,7 +32,16 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Error::error(404); } - $this->view->callbackBeforeContent = function ($view) { + $this->view->categories = FreshRSS_Context::$categories; + + $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); + $title = FreshRSS_Context::$name; + if (FreshRSS_Context::$get_unread > 0) { + $title = '(' . FreshRSS_Context::$get_unread . ') ' . $title; + } + Minz_View::prependTitle($title . ' · '); + + $this->view->callbackBeforeFeeds = function ($view) { try { $tagDAO = FreshRSS_Factory::createTagDao(); $view->tags = $tagDAO->listTags(true); @@ -40,7 +49,13 @@ class FreshRSS_index_Controller extends Minz_ActionController { foreach ($view->tags as $tag) { $view->nbUnreadTags += $tag->nbUnread(); } + } catch (Exception $e) { + Minz_Log::notice($e->getMessage()); + } + }; + $this->view->callbackBeforeEntries = function ($view) { + try { FreshRSS_Context::$number++; //+1 for pagination $entries = FreshRSS_index_Controller::listEntriesByContext(); FreshRSS_Context::$number--; @@ -67,15 +82,6 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Log::notice($e->getMessage()); Minz_Error::error(404); } - - $view->categories = FreshRSS_Context::$categories; - - $view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); - $title = FreshRSS_Context::$name; - if (FreshRSS_Context::$get_unread > 0) { - $title = '(' . FreshRSS_Context::$get_unread . ') ' . $title; - } - Minz_View::prependTitle($title . ' · '); }; } diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index b244639a4..2e16672e6 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -18,13 +18,7 @@ allow_referrer) { ?> -callbackBeforeContent)) { - call_user_func($this->callbackBeforeContent, $this); - } -?> + -partial('header'); ?> +partial('header'); +?>
- render(); ?> + callbackBeforeFeeds)) { + call_user_func($this->callbackBeforeFeeds, $this); + } + $this->render(); + ?>
partial('nav_menu'); + flush(); + if (isset($this->callbackBeforeEntries)) { + call_user_func($this->callbackBeforeEntries, $this); + } + $class = ''; if (FreshRSS_Context::$user_conf->hide_read_feeds && FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) && diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index ac2ea812d..d5ae8e2f9 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -3,6 +3,11 @@ $this->partial('aside_feed'); $this->partial('nav_menu'); +flush(); +if (isset($this->callbackBeforeEntries)) { + call_user_func($this->callbackBeforeEntries, $this); +} + if (!empty($this->entries)) { $display_today = true; $display_yesterday = true; diff --git a/app/views/index/reader.phtml b/app/views/index/reader.phtml index a92767f1c..c15b936ee 100644 --- a/app/views/index/reader.phtml +++ b/app/views/index/reader.phtml @@ -1,6 +1,11 @@ partial('nav_menu'); +flush(); +if (isset($this->callbackBeforeEntries)) { + call_user_func($this->callbackBeforeEntries, $this); +} + if (!empty($this->entries)) { $lazyload = FreshRSS_Context::$user_conf->lazyload; $content_width = FreshRSS_Context::$user_conf->content_width; -- cgit v1.2.3