small digest page improvements

master
Andrew Dolgov 14 years ago
parent c01f40f4d9
commit b41c254984

@ -126,6 +126,14 @@ a:hover {
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;

@ -1,5 +1,19 @@
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++) {
@ -14,16 +28,40 @@ function find_feed(feeds, feed_id) {
}
}
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>";
@ -34,9 +72,12 @@ function add_feed_entry(feed) {
}
}
function add_latest_entry(article) {
function add_latest_entry(article, feed) {
try {
//$("latest-content").innerHTML += "bbb";
} catch (e) {
exception_error("add_latest_entry", e);
}
@ -55,7 +96,7 @@ function add_headline_entry(article, feed) {
"<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;
@ -75,6 +116,8 @@ function digest_update(transport) {
feeds = eval("(" + feeds.firstChild.nodeValue + ")");
$('feeds-content').innerHTML = "";
for (var i = 0; i < feeds.length; i++) {
add_feed_entry(feeds[i]);
}
@ -83,9 +126,13 @@ function digest_update(transport) {
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) {

@ -39,7 +39,6 @@
<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>

@ -6653,51 +6653,9 @@
}
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) {
@ -6741,6 +6699,52 @@
}
}
/* 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;
}

@ -979,13 +979,17 @@
}
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) {
@ -998,13 +1002,13 @@
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) {

Loading…
Cancel
Save