]> git.wh0rd.org Git - tt-rss.git/commitdiff
small digest page improvements
authorAndrew Dolgov <fox@bah.org.ru>
Thu, 9 Sep 2010 15:02:12 +0000 (19:02 +0400)
committerAndrew Dolgov <fox@bah.org.ru>
Thu, 9 Sep 2010 15:02:12 +0000 (19:02 +0400)
digest.css
digest.js
digest.php
functions.php
modules/backend-rpc.php

index 5139114f07d4a964341cdbf1f8351022d9eb36d1..62852adb0f703d71f59aa34a7d2a69a0c1cac3a2 100644 (file)
@@ -126,6 +126,14 @@ a:hover {
        padding : 0px;
 }
 
+#feeds ul#feeds-content li a {
+       color : #659a4c;
+}
+
+#feeds ul#feeds-content li a:hover {
+       color : gray;
+}
+
 #headlines {
        padding : 5px;
        font-size : 14px;
index 7bfd9df2757138ed3d9a5663b8e03dd1851fb19b..3d58ca95f1596be28c320a99fbe8e9c48ca6632e 100644 (file)
--- a/digest.js
+++ b/digest.js
@@ -1,5 +1,19 @@
 var last_feeds = [];
 
+function view(feed_id) {
+       try {
+
+               new Ajax.Request("backend.php", {
+                       parameters: "backend.php?op=rpc&subop=digest-init&feed_id=" + feed_id,
+                       onComplete: function(transport) {
+                               digest_update(transport);
+                               } });
+
+       } catch (e) {
+               exception_error("view", e);
+       }
+}
+
 function find_feed(feeds, feed_id) {
        try {
                for (var i = 0; i < feeds.length; i++) {
@@ -14,16 +28,40 @@ function find_feed(feeds, feed_id) {
        }
 }
 
+function get_feed_icon(feed) {
+       try {
+               if (feed.has_icon)
+                       return 'icons/' + feed.id + '.ico';
+
+               if (feed.id == -1)
+                       return 'images/mark_set.png';
+
+               if (feed.id == -2)
+                       return 'images/pub_set.png';
+
+               if (feed.id == -3)
+                       return 'images/fresh.png';
+
+               if (feed.id == -4) 
+                       return 'images/tag.png';
+
+               if (feed.id < -10) 
+                       return 'images/label.png';
+
+       } catch (e) {
+               exception_error("get_feed_icon", e);
+       }
+}
+
 function add_feed_entry(feed) {
        try {
                var icon_part = "";
 
-               if (feed.has_icon) 
-                       icon_part = "<img alt='zz' src='icons/" + feed.id + ".ico'/>";
+               icon_part = "<img src='" + get_feed_icon(feed) + "'/>";
 
                var tmp_html = "<li>" + 
                        icon_part +
-                       feed.title +
+                       "<a href=\"#\" onclick=\"view("+feed.id+")\">" + feed.title +
                        "<div class='unread-ctr'>" + feed.unread + "</div>" +   
                        "</li>";
 
@@ -34,8 +72,11 @@ function add_feed_entry(feed) {
        }
 }
 
-function add_latest_entry(article) {
+function add_latest_entry(article, feed) {
        try {
+               
+
+               //$("latest-content").innerHTML += "bbb";
 
        } catch (e) {
                exception_error("add_latest_entry", e);
@@ -55,7 +96,7 @@ function add_headline_entry(article, feed) {
                        "<a class='title'>" + article.title + "</a>" +
                        "<div class='excerpt'>" + article.excerpt + "</div>" +
                        "<div class='info'><a>" + feed.title + "</a> " + " @ " + 
-                               article.updated + "</div>" +
+                               new Date(article.updated * 1000) + "</div>" +
                        "</li>";
 
                $("headlines-content").innerHTML += tmp_html;
@@ -75,6 +116,8 @@ function digest_update(transport) {
 
                        feeds = eval("(" + feeds.firstChild.nodeValue + ")");
 
+                       $('feeds-content').innerHTML = "";
+
                        for (var i = 0; i < feeds.length; i++) {
                                add_feed_entry(feeds[i]);
                        }
@@ -83,9 +126,13 @@ function digest_update(transport) {
                if (headlines) {
                        headlines = eval("(" + headlines.firstChild.nodeValue + ")");
 
+                       $('headlines-content').innerHTML = "";
+
                        for (var i = 0; i < headlines.length; i++) {
                                add_headline_entry(headlines[i], find_feed(feeds, headlines[i].feed_id));
                        }
+
+                       $('headlines-content').innerHTML += "<li><a>More articles...</a></li>";
                }
 
        } catch (e) {
index cfe16cfe4ad52a9ea0a917266b3373a8efba732c..94489eb0bd9f251e32c6a33303fd6f6a1bc042ed 100644 (file)
@@ -39,7 +39,6 @@
        <script type="text/javascript" src="lib/prototype.js"></script>
        <script type="text/javascript" src="lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script>
        <script type="text/javascript" charset="utf-8" src="localized_js.php?<?php echo $dt_add ?>"></script>
-       <script type="text/javascript" charset="utf-8" src="tt-rss.js?<?php echo $dt_add ?>"></script>
        <script type="text/javascript" charset="utf-8" src="functions.js?<?php echo $dt_add ?>"></script>
 
        <script type="text/javascript" src="digest.js"></script>
index 78e0d4f1800fcd35d5a5c74fd32b97592ee7f83a..ce1a06a6219643b2a8ce38dd84388f57ae50ef21 100644 (file)
        }
 
        function api_get_feeds($link, $cat_id, $unread_only, $limit, $offset) {
-                       if ($limit) {
-                               $limit_qpart = "LIMIT $limit OFFSET $offset";
-                       } else {
-                               $limit_qpart = "";
-                       }
-
-                       if (!$cat_id) {
-                               $result = db_query($link, "SELECT 
-                                       id, feed_url, cat_id, title, ".
-                                               SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
-                                               FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] . 
-                                               " ORDER BY cat_id, title " . $limit_qpart);
-                       } else {
-                               $result = db_query($link, "SELECT 
-                                       id, feed_url, cat_id, title, ".
-                                               SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
-                                               FROM ttrss_feeds WHERE 
-                                               cat_id = '$cat_id' AND owner_uid = " . $_SESSION["uid"] . 
-                                               " ORDER BY cat_id, title " . $limit_qpart);
-                       }
 
                        $feeds = array();
 
-                       while ($line = db_fetch_assoc($result)) {
-
-                               $unread = getFeedUnread($link, $line["id"]);
-
-                               $has_icon = feed_has_icon($line['id']);
-
-                               if ($unread || !$unread_only) {
-
-                                       $row = array(
-                                                       "feed_url" => $line["feed_url"],
-                                                       "title" => $line["title"],
-                                                       "id" => (int)$line["id"],
-                                                       "unread" => (int)$unread,
-                                                       "has_icon" => $has_icon,
-                                                       "cat_id" => (int)$line["cat_id"],
-                                                       "last_updated" => strtotime($line["last_updated"])
-                                               );
-       
-                                       array_push($feeds, $row);
-                               }
-                       }
-
                        /* Labels */
 
                        if (!$cat_id || $cat_id == -2) {
 
                                }                       
                        }
+
+                       /* Real feeds */
+
+                       if ($limit) {
+                               $limit_qpart = "LIMIT $limit OFFSET $offset";
+                       } else {
+                               $limit_qpart = "";
+                       }
+
+                       if (!$cat_id) {
+                               $result = db_query($link, "SELECT 
+                                       id, feed_url, cat_id, title, ".
+                                               SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
+                                               FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] . 
+                                               " ORDER BY cat_id, title " . $limit_qpart);
+                       } else {
+                               $result = db_query($link, "SELECT 
+                                       id, feed_url, cat_id, title, ".
+                                               SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
+                                               FROM ttrss_feeds WHERE 
+                                               cat_id = '$cat_id' AND owner_uid = " . $_SESSION["uid"] . 
+                                               " ORDER BY cat_id, title " . $limit_qpart);
+                       }
+
+                       while ($line = db_fetch_assoc($result)) {
+
+                               $unread = getFeedUnread($link, $line["id"]);
+
+                               $has_icon = feed_has_icon($line['id']);
+
+                               if ($unread || !$unread_only) {
+
+                                       $row = array(
+                                                       "feed_url" => $line["feed_url"],
+                                                       "title" => $line["title"],
+                                                       "id" => (int)$line["id"],
+                                                       "unread" => (int)$unread,
+                                                       "has_icon" => $has_icon,
+                                                       "cat_id" => (int)$line["cat_id"],
+                                                       "last_updated" => strtotime($line["last_updated"])
+                                               );
+       
+                                       array_push($feeds, $row);
+                               }
+                       }
+
                return $feeds;
        }
 
index f8233a7cd51495abe65a356b7dbed35b330ad4ea..edf2ae2e4d254dfdbc48eaa22ddce50449451ab6 100644 (file)
                }
 
                if ($subop == "digest-init") {
+                       $feed_id = db_escape_string($_REQUEST['feed_id']);
+
+                       if (!$feed_id) $feed_id = -4;
+
                        print "<rpc-reply>";
 
                        $tmp_feeds = api_get_feeds($link, false, true, false, 0);
                        $feeds = array();
 
                        foreach ($tmp_feeds as $f) {
-                               if ($f['id'] > 0) array_push($feeds, $f);
+                               if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f);
                        }
 
                        function feeds_sort_by_unread_rev($a, $b) {
                                return ($a < $b) ? 1 : -1;
                        }
 
-//                     uasort($feeds, 'feeds_sort_by_unread_rev');
-//                     $feeds = array_slice($feeds, 0, 10);
+                       //uasort($feeds, 'feeds_sort_by_unread_rev');
+                       //$feeds = array_slice($feeds, 0, 10);
 
                        print "<feeds><![CDATA[" . json_encode($feeds) . "]]></feeds>";
 
-                       $headlines = api_get_headlines($link, -4, 20, 0,
-                               '', true, true, false, "all_articles", "updated DESC");
+                       $headlines = api_get_headlines($link, $feed_id, 10, 0,
+                               '', ($feed_id == -4), true, false, "all_articles", "updated DESC");
 
                        //function api_get_headlines($link, $feed_id, $limit, $offset,
                        //              $filter, $is_cat, $show_excerpt, $show_content, $view_mode) {