From 2d24f03266de2be331b18150886039aed50e6816 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 23 Aug 2007 08:23:27 +0100 Subject: [PATCH] implement fresh virtual feed, load it by default on startup --- feedlist.js | 4 ++- functions.php | 70 ++++++++++++++++++++++++++++++++++++++--------- images/fresh.png | Bin 0 -> 3795 bytes 3 files changed, 60 insertions(+), 14 deletions(-) create mode 100644 images/fresh.png diff --git a/feedlist.js b/feedlist.js index 4946d7fc..3a44f331 100644 --- a/feedlist.js +++ b/feedlist.js @@ -293,7 +293,9 @@ function feedlist_init() { if (getActiveFeedId()) { debug("some feed is open on feedlist refresh, reloading"); setTimeout("viewCurrentFeed()", 100); - } + } else { + setTimeout("viewfeed(-3)", 100); + } } catch (e) { exception_error("feedlist/init", e); diff --git a/functions.php b/functions.php index 545df596..272d50c5 100644 --- a/functions.php +++ b/functions.php @@ -1646,6 +1646,20 @@ WHERE published = true AND owner_uid = ".$_SESSION["uid"]); } + if ($feed == -3) { + + if (DB_TYPE == "pgsql") { + $match_part .= " AND date_entered > NOW() - INTERVAL '1 day' "; + } else { + $match_part .= " AND date_entered > DATE_SUB(NOW(), + INTERVAL 1 DAY) "; + } + + db_query($link, "UPDATE ttrss_user_entries + SET unread = false,last_read = NOW() + WHERE $match_part AND owner_uid = ".$_SESSION["uid"]); + } + } else if ($feed < -10) { // label // TODO make this more efficient @@ -1814,7 +1828,7 @@ return $unread; } else if ($cat == -1) { - return getFeedUnread($link, -1) + getFeedUnread($link, -2); + return getFeedUnread($link, -1) + getFeedUnread($link, -2) + getFeedUnread($link, -3); } else if ($cat == -2) { $rv = getLabelCounters($link, false, true); @@ -1839,6 +1853,15 @@ $match_part = "marked = true"; } else if ($n_feed == -2) { $match_part = "published = true"; + } else if ($n_feed == -3) { + $match_part = "unread = true"; + + if (DB_TYPE == "pgsql") { + $match_part .= " AND date_entered > NOW() - INTERVAL '1 day' "; + } else { + $match_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL 1 DAY) "; + } + } else if ($n_feed > 0) { $result = db_query($link, "SELECT id FROM ttrss_feeds @@ -2006,12 +2029,7 @@ $old_counters = $_SESSION["lctr_last_value"]; $lctrs_modified = false; - $result = db_query($link, "SELECT count(ttrss_entries.id) as count FROM ttrss_entries,ttrss_user_entries,ttrss_feeds - WHERE marked = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND - ttrss_user_entries.feed_id = ttrss_feeds.id AND - hidden = false AND unread = true AND ttrss_user_entries.owner_uid = ".$_SESSION["uid"]); - - $count = db_fetch_result($result, 0, "count"); + $count = getFeedUnread($link, -1); if (!$ret_mode) { print ""; @@ -2020,12 +2038,7 @@ $ret_arr["-1"]["description"] = __("Starred articles"); } - $result = db_query($link, "SELECT count(ttrss_entries.id) as count FROM ttrss_entries,ttrss_user_entries,ttrss_feeds - WHERE published = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND - ttrss_user_entries.feed_id = ttrss_feeds.id AND - hidden = false AND unread = true AND ttrss_user_entries.owner_uid = ".$_SESSION["uid"]); - - $count = db_fetch_result($result, 0, "count"); + $count = getFeedUnread($link, -2); if (!$ret_mode) { print ""; @@ -2034,6 +2047,15 @@ $ret_arr["-2"]["description"] = __("Published articles"); } + $count = getFeedUnread($link, -3); + + if (!$ret_mode) { + print ""; + } else { + $ret_arr["-3"]["counter"] = $count; + $ret_arr["-3"]["description"] = __("Fresh articles"); + } + $result = db_query($link, "SELECT owner_uid,id,sql_exp,description FROM ttrss_labels WHERE owner_uid = ".$_SESSION["uid"]." ORDER by description"); @@ -2340,6 +2362,8 @@ return __("Starred articles"); } else if ($id == -2) { return __("Published articles"); + } else if ($id == -3) { + return __("Fresh articles"); } else if ($id < -10) { $label_id = -10 - $id; $result = db_query($link, "SELECT description FROM ttrss_labels WHERE id = '$label_id'"); @@ -2609,6 +2633,16 @@ $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else if ($feed == -2) { // published virtual feed $query_strategy_part = "published = true"; + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; + } else if ($feed == -3) { // fresh virtual feed + $query_strategy_part = "unread = true"; + + if (DB_TYPE == "pgsql") { + $query_strategy_part .= " AND date_entered > NOW() - INTERVAL '1 day' "; + } else { + $query_strategy_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL 1 DAY) "; + } + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else if ($feed <= -10) { // labels $label_id = -$feed - 11; @@ -2679,6 +2713,8 @@ $feed_title = __("Starred articles"); } else if ($feed == -2) { $feed_title = __("Published articles"); + } else if ($feed == -3) { + $feed_title = __("Fresh articles"); } else if ($feed < -10) { $label_id = -$feed - 11; $result = db_query($link, "SELECT description FROM ttrss_labels @@ -3355,6 +3391,14 @@ $num_starred = getFeedUnread($link, -1); $num_published = getFeedUnread($link, -2); + $num_fresh = getFeedUnread($link, -3); + + $class = "virt"; + + if ($num_fresh > 0) $class .= "Unread"; + + printFeedEntry(-3, $class, __("Fresh articles"), $num_fresh, + "images/fresh.png", $link); $class = "virt"; diff --git a/images/fresh.png b/images/fresh.png new file mode 100644 index 0000000000000000000000000000000000000000..398a10aeb5a5769a0e859239175faa81be0c53a5 GIT binary patch literal 3795 zcmbW3^;gtQ8;8F|N&YV0nx?m%7 zQ8IW302FusD*_-R^F9EOYuZ7fT3WWw?#}OQon2Uzp->hVH)k6=M{5A^oJZ>-V7fc> zl4r{&5Y=#GlB%-~9Vv?rBno*io`Z{(j8-L_HD``ayYsfZJQ3qSb~s^73^JNdo0~F{ ze3oQ`H8&hI}W z-Qbl8AZK?0&s}H5`tFL2066!Tka+&MgQN{0@SLO|1v=DG9WNe*-O%hp(v1m_!2})d z@vl@#k@o-@?-)oSAfrHlM5l4+0@*}>*|4R>I-tb^m_7ZtH3=Zm=jlEKfKd`F9YJg-W)4)kpX~JcmMHg zZoayQNO5AM({=8X10vfu6xr|3qHJnuWEz0%oq2t{%YWI(=fq*><~BDrW>tD1M&?8M ze%FXD(+>SB$3OlOmuIKn+t%0v1WW=Hi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