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;
var last_feeds = [];
+function view(feed_id) {
+ try {
+
+ new Ajax.Request("backend.php", {
+ parameters: "backend.php?op=rpc&subop=digest-init&feed_id=" + feed_id,
+ onComplete: function(transport) {
+ digest_update(transport);
+ } });
+
+ } catch (e) {
+ exception_error("view", e);
+ }
+}
+
function find_feed(feeds, feed_id) {
try {
for (var i = 0; i < feeds.length; i++) {
}
}
+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 = "";
- if (feed.has_icon)
- icon_part = "<img alt='zz' src='icons/" + feed.id + ".ico'/>";
+ icon_part = "<img src='" + get_feed_icon(feed) + "'/>";
var tmp_html = "<li>" +
icon_part +
- feed.title +
+ "<a href=\"#\" onclick=\"view("+feed.id+")\">" + feed.title +
"<div class='unread-ctr'>" + feed.unread + "</div>" +
"</li>";
}
}
-function add_latest_entry(article) {
+function add_latest_entry(article, feed) {
try {
+
+
+ //$("latest-content").innerHTML += "bbb";
} catch (e) {
exception_error("add_latest_entry", e);
"<a class='title'>" + article.title + "</a>" +
"<div class='excerpt'>" + article.excerpt + "</div>" +
"<div class='info'><a>" + feed.title + "</a> " + " @ " +
- article.updated + "</div>" +
+ new Date(article.updated * 1000) + "</div>" +
"</li>";
$("headlines-content").innerHTML += tmp_html;
feeds = eval("(" + feeds.firstChild.nodeValue + ")");
+ $('feeds-content').innerHTML = "";
+
for (var i = 0; i < feeds.length; i++) {
add_feed_entry(feeds[i]);
}
if (headlines) {
headlines = eval("(" + headlines.firstChild.nodeValue + ")");
+ $('headlines-content').innerHTML = "";
+
for (var i = 0; i < headlines.length; i++) {
add_headline_entry(headlines[i], find_feed(feeds, headlines[i].feed_id));
}
+
+ $('headlines-content').innerHTML += "<li><a>More articles...</a></li>";
}
} catch (e) {
<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="tt-rss.js?<?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>
}
function api_get_feeds($link, $cat_id, $unread_only, $limit, $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"]);
-
- $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);
- }
- }
-
/* Labels */
if (!$cat_id || $cat_id == -2) {
}
}
+
+ /* 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;
}
}
if ($subop == "digest-init") {
+ $feed_id = db_escape_string($_REQUEST['feed_id']);
+
+ if (!$feed_id) $feed_id = -4;
+
print "<rpc-reply>";
$tmp_feeds = api_get_feeds($link, false, true, false, 0);
$feeds = array();
foreach ($tmp_feeds as $f) {
- if ($f['id'] > 0) array_push($feeds, $f);
+ if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f);
}
function feeds_sort_by_unread_rev($a, $b) {
return ($a < $b) ? 1 : -1;
}
-// uasort($feeds, 'feeds_sort_by_unread_rev');
-// $feeds = array_slice($feeds, 0, 10);
+ //uasort($feeds, 'feeds_sort_by_unread_rev');
+ //$feeds = array_slice($feeds, 0, 10);
print "<feeds><![CDATA[" . json_encode($feeds) . "]]></feeds>";
- $headlines = api_get_headlines($link, -4, 20, 0,
- '', true, true, false, "all_articles", "updated DESC");
+ $headlines = api_get_headlines($link, $feed_id, 10, 0,
+ '', ($feed_id == -4), true, false, "all_articles", "updated DESC");
//function api_get_headlines($link, $feed_id, $limit, $offset,
// $filter, $is_cat, $show_excerpt, $show_content, $view_mode) {