implement dumb article downloader
This commit is contained in:
parent
87b16a0a61
commit
6a1cd59192
|
@ -516,6 +516,10 @@
|
||||||
|
|
||||||
if ($subop == "download") {
|
if ($subop == "download") {
|
||||||
$stage = (int) $_REQUEST["stage"];
|
$stage = (int) $_REQUEST["stage"];
|
||||||
|
$amount = (int) $_REQUEST["amount"];
|
||||||
|
$unread_only = db_escape_string($_REQUEST["unread_only"]);
|
||||||
|
|
||||||
|
if (!$amount) $amount = 50;
|
||||||
|
|
||||||
print "<rpc-reply>";
|
print "<rpc-reply>";
|
||||||
|
|
||||||
|
@ -537,6 +541,43 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($stage > 0) {
|
||||||
|
|
||||||
|
print "<articles>";
|
||||||
|
|
||||||
|
$limit = 50;
|
||||||
|
$skip = $limit*($stage-1);
|
||||||
|
|
||||||
|
if ($amount > 0) $amount -= $skip;
|
||||||
|
|
||||||
|
if ($amount > 0) {
|
||||||
|
|
||||||
|
$limit = min($limit, $amount);
|
||||||
|
|
||||||
|
if ($unread_only) {
|
||||||
|
$unread_qpart = "unread = true AND ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = db_query($link,
|
||||||
|
"SELECT DISTINCT id,title,guid,link,
|
||||||
|
feed_id,content,updated,unread,marked FROM
|
||||||
|
ttrss_user_entries,ttrss_entries
|
||||||
|
WHERE $unread_qpart
|
||||||
|
ref_id = id AND owner_uid = ".$_SESSION["uid"]."
|
||||||
|
ORDER BY updated DESC LIMIT $limit OFFSET $skip");
|
||||||
|
|
||||||
|
while ($line = db_fetch_assoc($result)) {
|
||||||
|
print "<article><![CDATA[";
|
||||||
|
print json_encode($line);
|
||||||
|
print "]]></article>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</articles>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
print "</rpc-reply>";
|
print "</rpc-reply>";
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -474,20 +474,22 @@
|
||||||
$amount = array(
|
$amount = array(
|
||||||
50 => 50,
|
50 => 50,
|
||||||
100 => 100,
|
100 => 100,
|
||||||
0 => "All unread");
|
250 => 250);
|
||||||
|
|
||||||
print_select_hash("amount", 50, $amount);
|
print_select_hash("amount", 50, $amount);
|
||||||
|
|
||||||
print " " . __("newest articles for offline reading.");
|
print " " . __("newest articles for offline reading.");
|
||||||
|
|
||||||
|
print "<br/>";
|
||||||
|
|
||||||
|
print "<input checked='yes' type='checkbox' name='unread_only' id='unread_only'>";
|
||||||
|
print "<label for='unread_only'>".__('Only include unread articles')."</label>";
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
||||||
print "</form>";
|
print "</form>";
|
||||||
|
|
||||||
print "<div class=\"dlgButtons\">
|
print "<div class=\"dlgButtons\">
|
||||||
<div id=\"d_progress_o\" style=\"display : none\">
|
|
||||||
<div id=\"d_progress_i\"></div>
|
|
||||||
</div>
|
|
||||||
<input class=\"button\"
|
<input class=\"button\"
|
||||||
type=\"submit\" onclick=\"return initiate_offline_download()\" value=\"".__('Download')."\">
|
type=\"submit\" onclick=\"return initiate_offline_download()\" value=\"".__('Download')."\">
|
||||||
<input class=\"button\"
|
<input class=\"button\"
|
||||||
|
|
14
tt-rss.css
14
tt-rss.css
|
@ -1976,20 +1976,6 @@ div#l_progress_i {
|
||||||
height : 10px;
|
height : 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div#d_progress_o {
|
|
||||||
width : 100px;
|
|
||||||
border : 1px solid black;
|
|
||||||
background-color : white;
|
|
||||||
float : left;
|
|
||||||
margin-left : 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div#d_progress_i {
|
|
||||||
width : 10px;
|
|
||||||
background-color : #88b0f0;
|
|
||||||
height : 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content-insert {
|
#content-insert {
|
||||||
background-color : white;
|
background-color : white;
|
||||||
overflow : auto;
|
overflow : auto;
|
||||||
|
|
47
tt-rss.js
47
tt-rss.js
|
@ -1505,7 +1505,7 @@ function init_gears() {
|
||||||
|
|
||||||
db.execute("CREATE TABLE if not exists offline_feeds (id integer, title text)");
|
db.execute("CREATE TABLE if not exists offline_feeds (id integer, title text)");
|
||||||
|
|
||||||
db.execute("CREATE TABLE if not exists offline_data (id integer, feed_id integer, title text, updated text, content text, tags text)");
|
db.execute("CREATE TABLE if not exists offline_data (id integer, feed_id integer, title text, link text, guid text, updated text, content text, tags text)");
|
||||||
|
|
||||||
var qmcDownload = document.getElementById("qmcDownload");
|
var qmcDownload = document.getElementById("qmcDownload");
|
||||||
if (qmcDownload) Element.show(qmcDownload);
|
if (qmcDownload) Element.show(qmcDownload);
|
||||||
|
@ -1552,6 +1552,28 @@ function offline_download_parse(stage, transport) {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.setTimeout("initiate_offline_download("+(stage+1)+")", 50);
|
window.setTimeout("initiate_offline_download("+(stage+1)+")", 50);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
var articles = transport.responseXML.getElementsByTagName("article");
|
||||||
|
|
||||||
|
var articles_found = 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < articles.length; i++) {
|
||||||
|
var a = eval("("+articles[i].firstChild.nodeValue+")");
|
||||||
|
articles_found++;
|
||||||
|
if (a) {
|
||||||
|
db.execute("DELETE FROM offline_data WHERE id = ?", [a.id]);
|
||||||
|
db.execute("INSERT INTO offline_data "+
|
||||||
|
"(id, feed_id, title, link, guid, updated, content) "+
|
||||||
|
"VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||||
|
[a.id, a.feed_id, a.title, a.link, a.guid, a.updated, a.content]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (articles_found > 0) {
|
||||||
|
window.setTimeout("initiate_offline_download("+(stage+1)+")", 50);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notify_info("All done.");
|
notify_info("All done.");
|
||||||
|
@ -1562,33 +1584,12 @@ function offline_download_parse(stage, transport) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function download_set_progress(p) {
|
|
||||||
try {
|
|
||||||
var o = document.getElementById("d_progress_i");
|
|
||||||
|
|
||||||
if (!o) return;
|
|
||||||
|
|
||||||
Element.show(o);
|
|
||||||
|
|
||||||
new Effect.Scale(o, p, {
|
|
||||||
scaleY : false,
|
|
||||||
scaleFrom : download_progress_last,
|
|
||||||
scaleMode: { originalWidth : 100 },
|
|
||||||
queue: { position: 'end', scope: 'LSP-Q', limit: 3 } });
|
|
||||||
|
|
||||||
download_progress_last = p;
|
|
||||||
} catch (e) {
|
|
||||||
exception_error("download_progress", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function initiate_offline_download(stage) {
|
function initiate_offline_download(stage) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!stage) stage = 0;
|
if (!stage) stage = 0;
|
||||||
|
|
||||||
notify_progress("Loading, please wait... S" + stage, true);
|
notify_progress("Loading, please wait... (" + stage +")", true);
|
||||||
download_set_progress(20);
|
|
||||||
|
|
||||||
var query = "backend.php?op=rpc&subop=download&stage=" + stage;
|
var query = "backend.php?op=rpc&subop=download&stage=" + stage;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue