use caching for unexpanded CDM
This commit is contained in:
parent
87085cc848
commit
b1a4b0e98f
|
@ -786,27 +786,35 @@
|
||||||
|
|
||||||
// TODO: unify with digest-get-contents?
|
// TODO: unify with digest-get-contents?
|
||||||
if ($subop == "cdmGetArticle") {
|
if ($subop == "cdmGetArticle") {
|
||||||
$id = db_escape_string($_REQUEST["id"]);
|
$ids = array(db_escape_string($_REQUEST["id"]));
|
||||||
|
$cids = explode(",", $_REQUEST["cids"]);
|
||||||
|
|
||||||
$result = db_query($link, "SELECT content,
|
$ids = array_merge($ids, $cids);
|
||||||
ttrss_feeds.site_url AS site_url FROM ttrss_user_entries, ttrss_feeds,
|
|
||||||
ttrss_entries
|
|
||||||
WHERE feed_id = ttrss_feeds.id AND ref_id = '$id' AND
|
|
||||||
ttrss_entries.id = ref_id AND
|
|
||||||
ttrss_user_entries.owner_uid = ".$_SESSION["uid"]);
|
|
||||||
|
|
||||||
if (db_num_rows($result) != 0) {
|
$rv = array();
|
||||||
$line = db_fetch_assoc($result);
|
|
||||||
|
|
||||||
$article_content = sanitize_rss($link, $line["content"],
|
foreach ($ids as $id) {
|
||||||
false, false, $line['site_url']);
|
$id = (int)$id;
|
||||||
|
|
||||||
} else {
|
$result = db_query($link, "SELECT content,
|
||||||
$article_content = '';
|
ttrss_feeds.site_url AS site_url FROM ttrss_user_entries, ttrss_feeds,
|
||||||
|
ttrss_entries
|
||||||
|
WHERE feed_id = ttrss_feeds.id AND ref_id = '$id' AND
|
||||||
|
ttrss_entries.id = ref_id AND
|
||||||
|
ttrss_user_entries.owner_uid = ".$_SESSION["uid"]);
|
||||||
|
|
||||||
|
if (db_num_rows($result) != 0) {
|
||||||
|
$line = db_fetch_assoc($result);
|
||||||
|
|
||||||
|
$article_content = sanitize_rss($link, $line["content"],
|
||||||
|
false, false, $line['site_url']);
|
||||||
|
|
||||||
|
array_push($rv,
|
||||||
|
array("id" => $id, "content" => $article_content));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print json_encode(array("article" =>
|
print json_encode($rv);
|
||||||
array("id" => $id, "content" => $article_content)));
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
35
viewfeed.js
35
viewfeed.js
|
@ -1235,28 +1235,39 @@ function cdmExpandArticle(id) {
|
||||||
|
|
||||||
var query = "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id);
|
var query = "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id);
|
||||||
|
|
||||||
//console.log(query);
|
var neighbor_ids = getRelativePostIds(id);
|
||||||
|
|
||||||
|
/* only request uncached articles */
|
||||||
|
var cids_to_request = [];
|
||||||
|
|
||||||
|
for (var i = 0; i < neighbor_ids.length; i++) {
|
||||||
|
if (cids_requested.indexOf(neighbor_ids[i]) == -1)
|
||||||
|
if ($("CWRAP-" + neighbor_ids[i]).innerHTML == "") {
|
||||||
|
cids_to_request.push(neighbor_ids[i]);
|
||||||
|
cids_requested.push(neighbor_ids[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("additional ids: " + cids_to_request.toString());
|
||||||
|
|
||||||
|
query = query + "&cids=" + cids_to_request.toString();
|
||||||
|
|
||||||
|
console.log(query);
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
new Ajax.Request("backend.php", {
|
||||||
parameters: query,
|
parameters: query,
|
||||||
onComplete: function(transport) {
|
onComplete: function(transport) {
|
||||||
|
|
||||||
$("FUPDPIC-" + id).src = 'images/blank_icon.gif';
|
$("FUPDPIC-" + id).src = 'images/blank_icon.gif';
|
||||||
|
|
||||||
handle_rpc_json(transport);
|
handle_rpc_json(transport);
|
||||||
|
|
||||||
var reply = JSON.parse(transport.responseText);
|
var reply = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
if (reply) {
|
reply.each(function(article) {
|
||||||
var article = reply['article']['content'];
|
$("CWRAP-" + article['id']).innerHTML = article['content']
|
||||||
var recv_id = reply['article']['id'];
|
cids_requested.remove(article['id']);
|
||||||
|
});
|
||||||
if (recv_id == id)
|
|
||||||
$("CWRAP-" + id).innerHTML = article;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$("CWRAP-" + id).innerHTML = __("Unable to load article.");
|
|
||||||
|
|
||||||
}
|
|
||||||
}});
|
}});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue