]> git.wh0rd.org Git - tt-rss.git/commitdiff
prefetch topmost articles on headlines load
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 15 May 2007 07:37:10 +0000 (08:37 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 15 May 2007 07:37:10 +0000 (08:37 +0100)
backend.php
functions.php
viewfeed.js

index 6f37085faf7554c639e733fc06904e73e8efb33e..1af01a7b8d3eb4ce762db194e833548b590911a0 100644 (file)
 
                print "<headlines id=\"$feed\"><![CDATA[";
 
-               outputHeadlinesList($link, $feed, $subop, $view_mode, $limit, $cat_view,
-                       $next_unread_feed, $offset);
+               $topmost_article_ids = outputHeadlinesList($link, $feed, $subop, 
+                       $view_mode, $limit, $cat_view, $next_unread_feed, $offset);
 
                print "]]></headlines>";
 
+               if (is_array($topmost_article_ids)) {
+                       print "<articles>";
+                       foreach ($topmost_article_ids as $id) {
+                               outputArticleXML($link, $id, $feed, false);
+                       }
+                       print "</articles>";
+               }
+
                print "<counters>";
                getAllCounters($link, $omode);
                print "</counters>";
index 1f8d86383eeb9112ac8eab4e50d3d2eab4bed244..d68a4506f87f07aff1c4696743f793a4e7e9f50f 100644 (file)
        function outputHeadlinesList($link, $feed, $subop, $view_mode, $limit, $cat_view,
                                        $next_unread_feed, $offset) {
 
+               $topmost_article_ids = array();
+
                if (!$offset) $offset = 0;
 
                if ($subop == "undefined") $subop = "";
        
                                $id = $line["id"];
                                $feed_id = $line["feed_id"];
-       
+
+                               if (count($topmost_article_ids) < 5) {
+                                       array_push($topmost_article_ids, $id);
+                               }
+
                                if ($line["last_read"] == "" && 
                                                ($line["unread"] != "t" && $line["unread"] != "1")) {
        
 
                print "</div>";
 
-
+               return $topmost_article_ids;
        }
 ?>
index f60783514113e5a1d827e59a4e00c70f5824edb8..49849c19986e0b4d6dd8171a8bfc0852d2fafb88 100644 (file)
@@ -44,9 +44,18 @@ function headlines_callback() {
                if (xmlhttp.responseXML) {
                        var headlines = xmlhttp.responseXML.getElementsByTagName("headlines")[0];
                        var counters = xmlhttp.responseXML.getElementsByTagName("counters")[0];
+                       var articles = xmlhttp.responseXML.getElementsByTagName("article");
 
                        f.innerHTML = headlines.firstChild.nodeValue;
 
+                       if (articles) {
+                               for (var i = 0; i < articles.length; i++) {
+                                       var a_id = articles[i].getAttribute("id");
+                                       debug("found id: " + a_id);
+                                       cache_inject(a_id, articles[i].firstChild.nodeValue);
+                               }
+                       }
+
                        if (counters) {
                                debug("parsing piggybacked counters: " + counters);
                                parse_counters(counters, false);