summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2007-05-15 08:37:10 +0100
committerAndrew Dolgov <[email protected]>2007-05-15 08:37:10 +0100
commit961f4c7323a840d256f95f0c026178ddf9fa13c0 (patch)
treea90a772351f39c95ca1d856a969777749afdd987
parent53761dda370de2d37dfd2cb1446b1c634b26abf2 (diff)
prefetch topmost articles on headlines load
-rw-r--r--backend.php12
-rw-r--r--functions.php10
-rw-r--r--viewfeed.js9
3 files changed, 27 insertions, 4 deletions
diff --git a/backend.php b/backend.php
index 6f37085fa..1af01a7b8 100644
--- a/backend.php
+++ b/backend.php
@@ -195,11 +195,19 @@
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>";
diff --git a/functions.php b/functions.php
index 1f8d86383..d68a4506f 100644
--- a/functions.php
+++ b/functions.php
@@ -3513,6 +3513,8 @@
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 = "";
@@ -3627,7 +3629,11 @@
$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")) {
@@ -3801,6 +3807,6 @@
print "</div>";
-
+ return $topmost_article_ids;
}
?>
diff --git a/viewfeed.js b/viewfeed.js
index f60783514..49849c199 100644
--- a/viewfeed.js
+++ b/viewfeed.js
@@ -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);