]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement dumb article downloader
authorAndrew Dolgov <fox@bah.org.ru>
Tue, 3 Feb 2009 13:11:44 +0000 (16:11 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Tue, 3 Feb 2009 13:11:44 +0000 (16:11 +0300)
modules/backend-rpc.php
modules/popup-dialog.php
tt-rss.css
tt-rss.js

index 55ab73a20f61d54c4249f884e5bf37ca236cbc79..53635f9665bc45f3aca7de84fc436ae9d04d851b 100644 (file)
 
                if ($subop == "download") {
                        $stage = (int) $_REQUEST["stage"];
+                       $amount = (int) $_REQUEST["amount"];
+                       $unread_only = db_escape_string($_REQUEST["unread_only"]);
+
+                       if (!$amount) $amount = 50;
 
                        print "<rpc-reply>";
 
 
                        }
 
+                       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>";
 
                        return;
index d89547fe9291346039c53943d0279bec9db10386..e62f84e9c7cda76715b44a12a597268e0b159e5b 100644 (file)
                        $amount = array(
                                50  => 50,
                                100 => 100,
-                               0   => "All unread");
+                               250 => 250);
 
                        print_select_hash("amount", 50, $amount);
 
                        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 "</form>";
 
                        print "<div class=\"dlgButtons\">
-                       <div id=\"d_progress_o\" style=\"display : none\">
-                               <div id=\"d_progress_i\"></div>
-                       </div>
                                <input class=\"button\"                                 
                                        type=\"submit\" onclick=\"return initiate_offline_download()\" value=\"".__('Download')."\">
                                <input class=\"button\"
index 4909b20a3bb746b3a5a4c27255b0e210ba0c8777..95938bc910cb02a89e5f4725b8593526f83c9847 100644 (file)
@@ -1976,20 +1976,6 @@ div#l_progress_i {
        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 {
        background-color : white;
        overflow : auto;
index 3a44867078d1739cf733f0c0245d5e6bdb8d4c46..5a92282d838c847177bff5043717cc125e0ca606 100644 (file)
--- a/tt-rss.js
+++ b/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_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");
                        if (qmcDownload) Element.show(qmcDownload);
@@ -1552,33 +1552,35 @@ function offline_download_parse(stage, transport) {
                                }
                
                                window.setTimeout("initiate_offline_download("+(stage+1)+")", 50);
-                       }
+                       } else {
 
-                       notify_info("All done.");
+                               var articles = transport.responseXML.getElementsByTagName("article");
 
-               }
-       } catch (e) {
-               exception_error("offline_download_parse", e);
-       }
-}
+                               var articles_found = 0;
 
-function download_set_progress(p) {
-       try {
-               var o = document.getElementById("d_progress_i");
+                               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 (!o) return;
+                                       }
+                               }
 
-               Element.show(o);
+                               if (articles_found > 0) {
+                                       window.setTimeout("initiate_offline_download("+(stage+1)+")", 50);
+                               }
+                       }
 
-               new Effect.Scale(o, p, { 
-                       scaleY : false,
-                       scaleFrom : download_progress_last,
-                       scaleMode: { originalWidth : 100 },
-                       queue: { position: 'end', scope: 'LSP-Q', limit: 3 } }); 
+                       notify_info("All done.");
 
-               download_progress_last = p;
+               }
        } catch (e) {
-               exception_error("download_progress", e);
+               exception_error("offline_download_parse", e);
        }
 }
 
@@ -1587,8 +1589,7 @@ function initiate_offline_download(stage) {
 
                if (!stage) stage = 0;
 
-               notify_progress("Loading, please wait... S" + stage, true);
-               download_set_progress(20);
+               notify_progress("Loading, please wait... (" + stage +")", true);
 
                var query = "backend.php?op=rpc&subop=download&stage=" + stage;