summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2010-09-09 19:02:12 +0400
committerAndrew Dolgov <[email protected]>2010-09-09 19:02:12 +0400
commitb41c254984df3fcb9fc7db4bb5218f2391e62164 (patch)
tree61d198af5365d9d01e934c05569b782320290c94
parentc01f40f4d9c8fae847ecec5a18ff52c0a15dd57b (diff)
small digest page improvements
-rw-r--r--digest.css8
-rw-r--r--digest.js57
-rw-r--r--digest.php1
-rw-r--r--functions.php88
-rw-r--r--modules/backend-rpc.php14
5 files changed, 115 insertions, 53 deletions
diff --git a/digest.css b/digest.css
index 5139114f0..62852adb0 100644
--- a/digest.css
+++ b/digest.css
@@ -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;
diff --git a/digest.js b/digest.js
index 7bfd9df27..3d58ca95f 100644
--- a/digest.js
+++ b/digest.js
@@ -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,8 +72,11 @@ 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) {
diff --git a/digest.php b/digest.php
index cfe16cfe4..94489eb0b 100644
--- a/digest.php
+++ b/digest.php
@@ -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>
diff --git a/functions.php b/functions.php
index 78e0d4f18..ce1a06a62 100644
--- a/functions.php
+++ b/functions.php
@@ -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;
}
diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php
index f8233a7cd..edf2ae2e4 100644
--- a/modules/backend-rpc.php
+++ b/modules/backend-rpc.php
@@ -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) {