]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement fresh virtual feed, load it by default on startup
authorAndrew Dolgov <fox@madoka.spb.ru>
Thu, 23 Aug 2007 07:23:27 +0000 (08:23 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Thu, 23 Aug 2007 07:23:27 +0000 (08:23 +0100)
feedlist.js
functions.php
images/fresh.png [new file with mode: 0644]

index 4946d7fc97ce299066e345deffb5fef6a5c27803..3a44f331b281fa7b333420265a74d2ad654f3317 100644 (file)
@@ -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);
index 545df59680688c25a27322385360ba2dcc171feb..272d50c5dd64e00a1317638f515c860517952edd 100644 (file)
                                                        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
        
                        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);
                        $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 
                $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 "<counter type=\"label\" id=\"-1\" counter=\"$count\"/>";
                        $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 "<counter type=\"label\" id=\"-2\" counter=\"$count\"/>";
                        $ret_arr["-2"]["description"] = __("Published articles");
                }
 
+               $count = getFeedUnread($link, -3);
+
+               if (!$ret_mode) {
+                       print "<counter type=\"label\" id=\"-3\" counter=\"$count\"/>";
+               } 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");
                        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'");
                                $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;
                                $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
 
                $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 (file)
index 0000000..398a10a
Binary files /dev/null and b/images/fresh.png differ