]> git.wh0rd.org - tt-rss.git/commitdiff
Merge branch 'master' into digest-experimental
authorAndrew Dolgov <fox@bah.org.ru>
Thu, 9 Sep 2010 18:08:55 +0000 (22:08 +0400)
committerAndrew Dolgov <fox@bah.org.ru>
Thu, 9 Sep 2010 18:08:55 +0000 (22:08 +0400)
api/index.php
digest.css [new file with mode: 0644]
digest.js [new file with mode: 0644]
digest.php [new file with mode: 0644]
functions.php
modules/backend-rpc.php

index 8d69e1a7351bd63383b3372fceafa9384fda1e52..ae4f1eb5df6c566efb94f4e1afe10fd712b4c904 100644 (file)
                        $limit = (int) db_escape_string($_REQUEST["limit"]);
                        $offset = (int) db_escape_string($_REQUEST["offset"]);
 
-                       if ($limit) {
-                               $limit_qpart = "LIMIT $limit OFFSET $offset";
-                       } else {
-                               $limit_qpart = "";
-                       }
-
-                       if (!$cat_id) {
-                               $result = db_query($link, "SELECT 
-                                       id, feed_url, cat_id, title, ".
-                                               SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
-                                               FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] . 
-                                               " ORDER BY cat_id, title " . $limit_qpart);
-                       } else {
-                               $result = db_query($link, "SELECT 
-                                       id, feed_url, cat_id, title, ".
-                                               SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
-                                               FROM ttrss_feeds WHERE 
-                                               cat_id = '$cat_id' AND owner_uid = " . $_SESSION["uid"] . 
-                                               " ORDER BY cat_id, title " . $limit_qpart);
-                       }
-
-                       $feeds = array();
-
-                       while ($line = db_fetch_assoc($result)) {
-
-                               $unread = getFeedUnread($link, $line["id"]);
-
-                               $icon_path = "../" . ICONS_DIR . "/" . $line["id"] . ".ico";
-                               $has_icon = file_exists($icon_path) && filesize($icon_path) > 0;
-
-                               if ($unread || !$unread_only) {
-
-                                       $row = array(
-                                                       "feed_url" => $line["feed_url"],
-                                                       "title" => $line["title"],
-                                                       "id" => (int)$line["id"],
-                                                       "unread" => (int)$unread,
-                                                       "has_icon" => $has_icon,
-                                                       "cat_id" => (int)$line["cat_id"],
-                                                       "last_updated" => strtotime($line["last_updated"])
-                                               );
-       
-                                       array_push($feeds, $row);
-                               }
-                       }
-
-                       /* Labels */
-
-                       if (!$cat_id || $cat_id == -2) {
-                               $counters = getLabelCounters($link, true);
-
-                               foreach (array_keys($counters) as $id) {
-
-                                       $unread = $counters[$id]["counter"];
-       
-                                       if ($unread || !$unread_only) {
-       
-                                               $row = array(
-                                                               "id" => $id,
-                                                               "title" => $counters[$id]["description"],
-                                                               "unread" => $counters[$id]["counter"],
-                                                               "cat_id" => -2,
-                                                       );
-       
-                                               array_push($feeds, $row);
-                                       }
-                               }
-                       }
-
-                       /* Virtual feeds */
-
-                       if (!$cat_id || $cat_id == -1) {
-                               foreach (array(-1, -2, -3, -4, 0) as $i) {
-                                       $unread = getFeedUnread($link, $i);
-
-                                       if ($unread || !$unread_only) {
-                                               $title = getFeedTitle($link, $i);
-
-                                               $row = array(
-                                                               "id" => $i,
-                                                               "title" => $title,
-                                                               "unread" => $unread,
-                                                               "cat_id" => -1,
-                                                       );
-                                               array_push($feeds, $row);
-                                       }
-
-                               }
-                       }
+                       $feeds = api_get_feeds($link, $cat_id, $unread_only, $limit, $offset);
 
                        print json_encode($feeds);
 
                        /* all_articles, unread, adaptive, marked, updated */
                        $view_mode = db_escape_string($_REQUEST["view_mode"]);
 
-                       /* do not rely on params below */
-
-                       $search = db_escape_string($_REQUEST["search"]);
-                       $search_mode = db_escape_string($_REQUEST["search_mode"]);
-                       $match_on = db_escape_string($_REQUEST["match_on"]);
-                       
-                       $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit, 
-                               $view_mode, $is_cat, $search, $search_mode, $match_on,
-                               false, $offset);
-
-                       $result = $qfh_ret[0];
-                       $feed_title = $qfh_ret[1];
-
-                       $headlines = array();
-
-                       while ($line = db_fetch_assoc($result)) {
-                               $is_updated = ($line["last_read"] == "" && 
-                                       ($line["unread"] != "t" && $line["unread"] != "1"));
-
-                               $headline_row = array(
-                                               "id" => (int)$line["id"],
-                                               "unread" => sql_bool_to_bool($line["unread"]),
-                                               "marked" => sql_bool_to_bool($line["marked"]),
-                                               "updated" => strtotime($line["updated"]),
-                                               "is_updated" => $is_updated,
-                                               "title" => $line["title"],
-                                               "link" => $line["link"],
-                                               "feed_id" => $line["feed_id"],
-                                       );
-
-                               if ($show_excerpt) {
-                                       $excerpt = truncate_string(strip_tags($line["content_preview"]), 100);
-                                       $headline_row["excerpt"] = $excerpt;
-                               }
-
-                               if ($show_content) {
-                                       $headline_row["content"] = $line["content_preview"];
-                               }
-
-                               array_push($headlines, $headline_row);
-                       }
+                       $headlines = api_get_headlines($link, $feed_id, $limit, $offset,
+                               $filter, $is_cat, $show_excerpt, $show_content, $view_mode, false);
 
                        print json_encode($headlines);
 
diff --git a/digest.css b/digest.css
new file mode 100644 (file)
index 0000000..3c770b7
--- /dev/null
@@ -0,0 +1,183 @@
+body {
+       background : #f0f0f0;
+       color : gray;
+       font-family : sans-serif;
+       font-size : 12px;
+}
+
+a {
+       color : #0069D8;
+       text-decoration : none;
+}
+
+a:hover {
+       color : gray;
+}
+
+#header a, #footer a {
+       color : gray;
+}
+
+#header {
+       font-weight : bold;
+       font-size : 14px;
+       font-family : "Lucida Grande", "Segoe UI", Tahoma, Arial, sans-serif;
+       margin-left : 1em;
+       margin-right : 1em;
+}
+
+#header div.links {
+       float : right;
+}
+
+#search {
+       float : right;
+       clear : left;
+
+}
+
+#content {
+       border : 1px solid #e0e0e0;
+       background : white;
+       padding : 0.8em;
+       margin : 0.5em;
+}
+
+#footer {
+       font-size : 12px;
+       text-align : center;
+}
+
+/*#content h1 {
+       font-weight : bold;
+       font-size : 25px;
+       font-family : "Lucida Grande", "Segoe UI", Tahoma, Arial, sans-serif;
+       letter-spacing : -2;
+       margin : 0px 0px 0.5em 0px;
+       color : black;
+}
+
+#content h2 {
+       font-weight : bold;
+       font-size : 20px;
+       font-family : "Lucida Grande", "Segoe UI", Tahoma, Arial, sans-serif;
+       letter-spacing : 2;
+       margin : 0px 0px 0.5em 0px;
+       color : #684C99;
+}
+
+#content h3 {
+       font-weight : bold;
+       font-size : 16px;
+       font-family : "Lucida Grande", "Segoe UI", Tahoma, Arial, sans-serif;
+       letter-spacing : 2;
+       margin : 0px 0px 0.5em 0px;
+       color : #659a4c;
+} */
+
+#content h1 {
+       margin : 0px 0px 20px 0px;
+       font-family : "Lucida Grande", "Segoe UI", Tahoma, Arial, sans-serif;
+       font-size : 18px;
+       letter-spacing : 1px;
+       color : #684C99;
+}
+
+#title {
+}
+
+#latest {
+       padding : 5px;
+}
+
+#feeds {
+       float : right;
+       width : 30%;
+       min-width : 300px;
+       padding : 5px;
+       font-size : 14px;
+}
+
+#feeds h1 {
+       text-align : right;
+}
+
+#feeds ul#feeds-content img {
+       width : 16px;
+       height : 16px;
+       vertical-align : middle;
+       margin-right : 5px;
+}
+
+#feeds ul#feeds-content div.unread-ctr {
+       color : gray;
+       float : right;
+}
+
+#feeds ul#feeds-content li {
+       margin : 0px 0px 2px 0px;
+}
+
+#feeds ul#feeds-content {
+       list-style-type : none;
+       font-weight : bold;
+       color : #659a4c;
+       margin : 0px;
+       padding : 0px;
+}
+
+#feeds ul#feeds-content li a {
+       color : #659a4c;
+}
+
+#feeds ul#feeds-content li a:hover {
+       color : gray;
+}
+
+#headlines {
+       padding : 5px;
+       font-size : 14px;
+}
+
+#headlines ul#headlines-content img {
+       width : 16px;
+       height : 16px;
+       vertical-align : middle;
+       margin-right : 5px;
+}
+
+#headlines ul#headlines-content {
+       list-style-type : none;
+       color : gray;
+       margin : 0px;
+       padding : 0px;
+}
+
+#headlines ul#headlines-content li {
+       margin : 0px 0px 10px 0px;
+       color : #909090;
+       clear : left;
+}
+
+#headlines ul#headlines-content a.title {
+       font-weight : bold;
+       font-size : 16px;
+}
+
+#headlines ul#headlines-content div.excerpt {
+       color : #404040;
+}
+
+#headlines ul#headlines-content div.body {
+       margin-left : 21px;
+}
+
+#headlines ul#headlines-content div.info {
+       margin-top : 2px;
+       font-size : 11px;
+}
+
+#headlines ul#headlines-content div.info a {
+       color : gray;
+}
+
diff --git a/digest.js b/digest.js
new file mode 100644 (file)
index 0000000..d641733
--- /dev/null
+++ b/digest.js
@@ -0,0 +1,194 @@
+var last_feeds = [];
+
+var _active_feed_id = false;
+var _active_feed_offset = false;
+
+function view(article_id) {
+       try {
+               new Effect.Fade('A-' + article_id, {duration : 0.3});
+
+               return true;
+       } catch (e) {
+               exception_error("view", e);
+       }
+}
+
+function viewfeed(feed_id, offset) {
+       try {
+
+               if (!feed_id) feed_id = _active_feed_id;
+
+               if (!offset) 
+                       offset = 0;
+               else
+                       offset = _active_feed_offset + offset;
+
+               var query = "backend.php?op=rpc&subop=digest-update&feed_id=" + feed_id +
+                               "&offset=" + offset;
+
+               console.log(query);
+
+               new Ajax.Request("backend.php", {
+                       parameters: query, 
+                       onComplete: function(transport) {
+                               digest_update(transport);
+                               _active_feed_id = feed_id;
+                               _active_feed_offset = offset;
+                               } });
+
+       } catch (e) {
+               exception_error("view", e);
+       }
+}
+
+function find_feed(feeds, feed_id) {
+       try {
+               for (var i = 0; i < feeds.length; i++) {
+                       if (feeds[i].id == feed_id)
+                               return feeds[i];
+               }
+
+               return false;
+
+       } catch (e) {
+               exception_error("find_feed", e);
+       }
+}
+
+function get_feed_icon(feed) {
+       try {
+               if (feed.has_icon)
+                       return 'icons/' + feed.id + '.ico';
+
+               if (feed.id == -1)
+                       return 'images/mark_set.png';
+
+               if (feed.id == -2)
+                       return 'images/pub_set.png';
+
+               if (feed.id == -3)
+                       return 'images/fresh.png';
+
+               if (feed.id == -4) 
+                       return 'images/tag.png';
+
+               if (feed.id < -10) 
+                       return 'images/label.png';
+
+       } catch (e) {
+               exception_error("get_feed_icon", e);
+       }
+}
+
+function add_feed_entry(feed) {
+       try {
+               var icon_part = "";
+
+               icon_part = "<img src='" + get_feed_icon(feed) + "'/>";
+
+               var tmp_html = "<li>" + 
+                       icon_part +
+                       "<a href=\"#\" onclick=\"viewfeed("+feed.id+")\">" + feed.title +
+                       "<div class='unread-ctr'>" + feed.unread + "</div>" +   
+                       "</li>";
+
+               $("feeds-content").innerHTML += tmp_html;
+
+       } catch (e) {
+               exception_error("add_feed_entry", e);
+       }
+}
+
+function add_latest_entry(article, feed) {
+       try {
+               
+
+               //$("latest-content").innerHTML += "bbb";
+
+       } catch (e) {
+               exception_error("add_latest_entry", e);
+       }
+}
+
+function add_headline_entry(article, feed) {
+       try {
+
+               var icon_part = "";
+
+               if (article.has_icon) 
+                       icon_part = "<img src='icons/" + article.feed_id + ".ico'/>";
+
+               var tmp_html = "<li id=\"A-"+article.id+"\">" + 
+                       icon_part +
+                       "<a target=\"_blank\" href=\""+article.link+"\""+
+                               "onclick=\"return view("+article.id+")\" class='title'>" + 
+                               article.title + "</a>" +
+                       "<div class='body'><div class='excerpt'>" + article.excerpt + "</div>" +
+                       "<div class='info'><a>" + feed.title + "</a> " + " @ " + 
+                               new Date(article.updated * 1000) + "</div>" +
+                       "</div></li>";
+
+               $("headlines-content").innerHTML += tmp_html;
+
+       } catch (e) {
+               exception_error("add_headline_entry", e);
+       }
+}
+
+function digest_update(transport) {
+       try {
+               var feeds = transport.responseXML.getElementsByTagName('feeds')[0];
+               var headlines = transport.responseXML.getElementsByTagName('headlines')[0];
+
+               if (feeds) {
+                       feeds = eval("(" + feeds.firstChild.nodeValue + ")");
+
+                       last_feeds = feeds;
+
+                       $('feeds-content').innerHTML = "";
+
+                       for (var i = 0; i < feeds.length; i++) {
+                               add_feed_entry(feeds[i]);
+                       }
+               } else {
+                       feeds = last_feeds;
+               }
+
+               if (headlines) {
+                       headlines = eval("(" + headlines.firstChild.nodeValue + ")");
+
+                       $('headlines-content').innerHTML = "";
+
+                       Element.hide('headlines-content');
+
+                       for (var i = 0; i < headlines.length; i++) {
+                               add_headline_entry(headlines[i], find_feed(feeds, headlines[i].feed_id));
+                       }
+
+//                     $('headlines-content').innerHTML += "<li>" +
+//                             "<div class='body'><a href=\"#\" onclick=\"viewfeed(false, 10)\">" +
+//                             __("More articles...") + "</a></div></li>";
+
+                       new Effect.Appear('headlines-content');
+
+               }
+
+       } catch (e) {
+               exception_error("digest_update", e);
+       }
+       }
+
+function digest_init() {
+       try {
+               
+               new Ajax.Request("backend.php", {
+                       parameters: "backend.php?op=rpc&subop=digest-init",
+                       onComplete: function(transport) {
+                               digest_update(transport);
+                               window.setTimeout('viewfeed(-4)', 100);
+                               } });
+
+       } catch (e) {
+               exception_error("digest_init", e);
+       }
+}
diff --git a/digest.php b/digest.php
new file mode 100644 (file)
index 0000000..94489eb
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+       error_reporting(E_ERROR | E_WARNING | E_PARSE);
+
+       require_once "functions.php"; 
+       require_once "sessions.php";
+       require_once "sanity_check.php";
+       require_once "version.php"; 
+       require_once "config.php";
+       require_once "db-prefs.php";
+
+       $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
+
+       login_sequence($link);
+
+       $dt_add = get_script_dt_add();
+
+       no_cache_incantation();
+
+       header('Content-Type: text/html; charset=utf-8');
+       
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+       <title>Tiny Tiny Digest</title>
+       <link rel="stylesheet" type="text/css" href="digest.css?<?php echo $dt_add ?>"/>
+
+       <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+
+       <?php $user_css_url = get_pref($link, 'USER_STYLESHEET_URL'); ?>
+       <?php if ($user_css_url) { ?>
+               <link rel="stylesheet" type="text/css" href="<?php echo $user_css_url ?>"/> 
+       <?php } ?>
+
+       <link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
+
+       <script type="text/javascript" src="lib/prototype.js"></script>
+       <script type="text/javascript" src="lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script>
+       <script type="text/javascript" charset="utf-8" src="localized_js.php?<?php echo $dt_add ?>"></script>
+       <script type="text/javascript" charset="utf-8" src="functions.js?<?php echo $dt_add ?>"></script>
+
+       <script type="text/javascript" src="digest.js"></script>
+
+       <script type="text/javascript">
+               Event.observe(window, 'load', function() {
+                       digest_init();
+               });
+       </script>
+</head>
+<body id="ttrssDigest">
+       <div id="header">
+
+       <div class="links">
+
+       <?php if (!SINGLE_USER_MODE) { ?>
+                       <?php echo __('Hello,') ?> <b><?php echo $_SESSION["name"] ?></b> |
+       <?php } ?>
+
+       <?php if (!SINGLE_USER_MODE) { ?>
+                       <a href="logout.php"><?php echo __('Logout') ?></a>
+       <?php } ?>
+
+       </div>
+
+       Tiny Tiny Digest
+
+       </div>
+       <div id="content">
+               <div id="title">
+                       <div id="search">
+                               <input name="search" type="search"></input>
+                               <button>Search</button>
+                       </div>
+
+               </div>
+
+               <div id="latest">
+                       <h1>latest articles</h1>
+
+                       <em>TODO</em>
+
+                       <div id="latest-content"> </div>
+               </div>
+
+               <div id="feeds">
+                       <h1>feeds</h1>
+
+                       <ul id="feeds-content"> </ul>
+               </div>
+
+               <div id="headlines">
+                       <h1>headlines</h1>
+
+                       <ul id="headlines-content"> </ul>
+               </div>
+
+               <br clear="both">
+
+       </div>
+
+       <div id="footer">
+
+       <a href="http://tt-rss.org/">Tiny Tiny RSS</a>
+       <?php if (!defined('HIDE_VERSION')) { ?>
+                v<?php echo VERSION ?> 
+       <?php } ?>
+       &copy; 2005&ndash;<?php echo date('Y') ?> 
+       <a href="http://fakecake.org/">Andrew Dolgov</a></div>
+
+</body>
index 2f895cd3019082099fb764b81a053b8b3330ef80..735fd2c73b66f23217fec5e7d2ab025e6c77234b 100644 (file)
                return $rv;
        }
 
+       function api_get_feeds($link, $cat_id, $unread_only, $limit, $offset) {
+
+                       $feeds = array();
+
+                       /* Labels */
+
+                       if (!$cat_id || $cat_id == -2) {
+                               $counters = getLabelCounters($link, true);
+
+                               foreach (array_keys($counters) as $id) {
+
+                                       $unread = $counters[$id]["counter"];
+       
+                                       if ($unread || !$unread_only) {
+       
+                                               $row = array(
+                                                               "id" => $id,
+                                                               "title" => $counters[$id]["description"],
+                                                               "unread" => $counters[$id]["counter"],
+                                                               "cat_id" => -2,
+                                                       );
+       
+                                               array_push($feeds, $row);
+                                       }
+                               }
+                       }
+
+                       /* Virtual feeds */
+
+                       if (!$cat_id || $cat_id == -1) {
+                               foreach (array(-1, -2, -3, -4, 0) as $i) {
+                                       $unread = getFeedUnread($link, $i);
+
+                                       if ($unread || !$unread_only) {
+                                               $title = getFeedTitle($link, $i);
+
+                                               $row = array(
+                                                               "id" => $i,
+                                                               "title" => $title,
+                                                               "unread" => $unread,
+                                                               "cat_id" => -1,
+                                                       );
+                                               array_push($feeds, $row);
+                                       }
+
+                               }                       
+                       }
+
+                       /* Real feeds */
+
+                       if ($limit) {
+                               $limit_qpart = "LIMIT $limit OFFSET $offset";
+                       } else {
+                               $limit_qpart = "";
+                       }
+
+                       if (!$cat_id) {
+                               $result = db_query($link, "SELECT 
+                                       id, feed_url, cat_id, title, ".
+                                               SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
+                                               FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] . 
+                                               " ORDER BY cat_id, title " . $limit_qpart);
+                       } else {
+                               $result = db_query($link, "SELECT 
+                                       id, feed_url, cat_id, title, ".
+                                               SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
+                                               FROM ttrss_feeds WHERE 
+                                               cat_id = '$cat_id' AND owner_uid = " . $_SESSION["uid"] . 
+                                               " ORDER BY cat_id, title " . $limit_qpart);
+                       }
+
+                       while ($line = db_fetch_assoc($result)) {
+
+                               $unread = getFeedUnread($link, $line["id"]);
+
+                               $has_icon = feed_has_icon($line['id']);
+
+                               if ($unread || !$unread_only) {
+
+                                       $row = array(
+                                                       "feed_url" => $line["feed_url"],
+                                                       "title" => $line["title"],
+                                                       "id" => (int)$line["id"],
+                                                       "unread" => (int)$unread,
+                                                       "has_icon" => $has_icon,
+                                                       "cat_id" => (int)$line["cat_id"],
+                                                       "last_updated" => strtotime($line["last_updated"])
+                                               );
+       
+                                       array_push($feeds, $row);
+                               }
+                       }
+
+               return $feeds;
+       }
+
+       function api_get_headlines($link, $feed_id, $limit, $offset,
+                                       $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order) {
+
+                       /* do not rely on params below */
+
+                       $search = db_escape_string($_REQUEST["search"]);
+                       $search_mode = db_escape_string($_REQUEST["search_mode"]);
+                       $match_on = db_escape_string($_REQUEST["match_on"]);
+                       
+                       $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit, 
+                               $view_mode, $is_cat, $search, $search_mode, $match_on,
+                               $order, $offset);
+
+                       $result = $qfh_ret[0];
+                       $feed_title = $qfh_ret[1];
+
+                       $headlines = array();
+
+                       while ($line = db_fetch_assoc($result)) {
+                               $is_updated = ($line["last_read"] == "" && 
+                                       ($line["unread"] != "t" && $line["unread"] != "1"));
+
+                               $headline_row = array(
+                                               "id" => (int)$line["id"],
+                                               "unread" => sql_bool_to_bool($line["unread"]),
+                                               "marked" => sql_bool_to_bool($line["marked"]),
+                                               "updated" => strtotime($line["updated"]),
+                                               "is_updated" => $is_updated,
+                                               "title" => $line["title"],
+                                               "link" => $line["link"],
+                                               "feed_id" => $line["feed_id"],
+                                               "has_icon" => feed_has_icon($line["feed_id"])
+                                       );
+
+                               if ($show_excerpt) {
+                                       $excerpt = truncate_string(strip_tags($line["content_preview"]), 100);
+                                       $headline_row["excerpt"] = $excerpt;
+                               }
+
+                               if ($show_content) {
+                                       $headline_row["content"] = $line["content_preview"];
+                               }
+
+                               array_push($headlines, $headline_row);
+                       }
+
+                       return $headlines;
+       }
+
 ?>
index b21e161e41d2cb99ad18cfd94494a3bfdff5d8a2..80eda7c3f592a047aa774718511a91254091c3ff 100644 (file)
                        return;
                }
 
+               if ($subop == "digest-update") {
+                       $feed_id = db_escape_string($_REQUEST['feed_id']);
+                       $offset = db_escape_string($_REQUEST['offset']);
+               
+                       if (!$feed_id) $feed_id = -4;
+                       if (!$offset) $offset = 0;
+
+
+                       print "<rpc-reply>";
+
+                       $headlines = api_get_headlines($link, $feed_id, 10, $offset,
+                               '', ($feed_id == -4), true, false, "unread", "updated DESC");
+
+                       //function api_get_headlines($link, $feed_id, $limit, $offset,
+                       //              $filter, $is_cat, $show_excerpt, $show_content, $view_mode) {
+
+                       print "<headlines><![CDATA[" . json_encode($headlines) . "]]></headlines>";
+
+                       print "</rpc-reply>";
+                       return;
+               }
+
+               if ($subop == "digest-init") {
+                       print "<rpc-reply>";
+
+                       $tmp_feeds = api_get_feeds($link, false, true, false, 0);
+                       $feeds = array();
+
+                       foreach ($tmp_feeds as $f) {
+                               if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f);
+                       }
+
+                       function feeds_sort_by_unread_rev($a, $b) {
+                               $a = $a['unread'];
+                               $b = $b['unread'];
+
+                               if ($a == $b) {
+                                       return 0;
+                               }
+                               return ($a < $b) ? 1 : -1;
+                       }
+
+                       //uasort($feeds, 'feeds_sort_by_unread_rev');
+                       //$feeds = array_slice($feeds, 0, 10);
+
+                       print "<feeds><![CDATA[" . json_encode($feeds) . "]]></feeds>";
+
+                       print "</rpc-reply>";
+                       return;
+               }
+
                print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>";
        }
 ?>