From 911d4c0836cf6d1be53be5917739defc91277a7e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 9 Sep 2010 16:49:06 +0400 Subject: add experimental digest thingie --- functions.php | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) (limited to 'functions.php') diff --git a/functions.php b/functions.php index 05eb85909..78e0d4f18 100644 --- a/functions.php +++ b/functions.php @@ -6652,4 +6652,145 @@ return $rv; } + 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) { + $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); + } + + } + } + 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; + } + ?> -- cgit v1.2.3-54-g00ecf From b41c254984df3fcb9fc7db4bb5218f2391e62164 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 9 Sep 2010 19:02:12 +0400 Subject: small digest page improvements --- digest.css | 8 +++++ digest.js | 57 +++++++++++++++++++++++++++++--- digest.php | 1 - functions.php | 88 ++++++++++++++++++++++++++----------------------- modules/backend-rpc.php | 14 +++++--- 5 files changed, 115 insertions(+), 53 deletions(-) (limited to 'functions.php') 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 = "zz"; + icon_part = ""; var tmp_html = "
  • " + icon_part + - feed.title + + "" + feed.title + "
    " + feed.unread + "
    " + "
  • "; @@ -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) { "" + article.title + "" + "
    " + article.excerpt + "
    " + "
    " + feed.title + " " + " @ " + - article.updated + "
    " + + new Date(article.updated * 1000) + "" + ""; $("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 += "
  • More articles...
  • "; } } catch (e) { diff --git a/digest.php b/digest.php index cfe16cfe4..94489eb0b 100644 --- a/digest.php +++ b/digest.php @@ -39,7 +39,6 @@ - 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 ""; $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 ""; - $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) { -- cgit v1.2.3-54-g00ecf From d5d5632952914611c0ddf93959034aa1e7d87c21 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 11 Sep 2010 15:25:47 +0400 Subject: code cleanup --- digest.css | 5 +- digest.js | 188 +++++++++++++++++++++++++++++++++++++++------------------- digest.php | 2 +- functions.php | 1 - 4 files changed, 130 insertions(+), 66 deletions(-) (limited to 'functions.php') diff --git a/digest.css b/digest.css index b94044f98..b500a47e7 100644 --- a/digest.css +++ b/digest.css @@ -117,6 +117,7 @@ a:hover { #feeds ul#feeds-content li { margin : 0px 0px 2px 0px; padding : 2px; + clear : both; } #feeds ul#feeds-content li.selected { @@ -181,10 +182,6 @@ a:hover { clear : left; } -#headlines ul#headlines-content li:hover { - background : #fafafa; -} - #headlines ul#headlines-content a.title { font-weight : bold; font-size : 16px; diff --git a/digest.js b/digest.js index 0e567193f..38e2224bb 100644 --- a/digest.js +++ b/digest.js @@ -4,7 +4,23 @@ var _active_feed_id = false; var _active_feed_offset = false; var _update_timeout = false; -function mark_selected_feed(feed_id) { +function catchup_article(article_id, callback) { + try { + var query = "?op=rpc&subop=catchupSelected" + + "&cmode=0&ids=" + article_id; + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + if (callback) callback(transport); + } }); + + } catch (e) { + exception_error("catchup_article", e); + } +} + +function set_selected_feed(feed_id) { try { var feeds = $("feeds-content").getElementsByTagName("LI"); @@ -15,6 +31,8 @@ function mark_selected_feed(feed_id) { feeds[i].className = ""; } + _active_feed_id = feed_id; + } catch (e) { exception_error("mark_selected_feed", e); } @@ -36,14 +54,8 @@ function zoom(article_id) { } } - var query = "backend.php?op=rpc&subop=digest-mark&article_id=" + article_id; - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - window.clearTimeout(_update_timeout); - _update_timeout = window.setTimeout('update()', 1000); - } }); + catchup_article(article_id, + function() { update(); }); } catch (e) { exception_error("zoom", e); @@ -52,13 +64,6 @@ function zoom(article_id) { function load_more() { try { - var elem = $('MORE-PROMPT'); - - if (elem) { - elem.id = ''; - Element.hide(elem); - } - viewfeed(_active_feed_id, _active_feed_offset + 10); } catch (e) { exception_error("load_more", e); @@ -67,30 +72,42 @@ function load_more() { function update() { try { - viewfeed(_active_feed_id, _active_feed_offset); + console.log('updating feeds...'); + + window.clearTimeout(_update_timeout); + + new Ajax.Request("backend.php", { + parameters: "?op=rpc&subop=digest-init", + onComplete: function(transport) { + parse_feeds(transport); + set_selected_feed(_active_feed_id); + } }); + + _update_timeout = window.setTimeout('update()', 5*1000); } catch (e) { exception_error("update", e); } } -function view(article_id, dismiss_only) { +function remove_headline_entry(article_id) { try { var elem = $('A-' + article_id); - elem.id = ''; - - //new Effect.Fade(elem, {duration : 0.3}); + if (elem) { + elem.parentNode.removeChild(elem); + } - Element.hide(elem); + } catch (e) { + exception_error("remove_headline_entry", e); + } +} - var query = "backend.php?op=rpc&subop=digest-mark&article_id=" + article_id; +function view(article_id, dismiss_only) { + try { + remove_headline_entry(article_id); - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - window.clearTimeout(_update_timeout); - _update_timeout = window.setTimeout('update()', 1000); - } }); + catchup_article(article_id, + function() { update(); }); return dismiss_only != true; } catch (e) { @@ -103,23 +120,21 @@ function viewfeed(feed_id, offset) { if (!feed_id) feed_id = _active_feed_id; - if (!offset) + if (!offset) { offset = 0; - else + } 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, feed_id); - _active_feed_id = feed_id; + parse_headlines(transport, offset == 0); + set_selected_feed(feed_id); _active_feed_offset = offset; - mark_selected_feed(feed_id); } }); } catch (e) { @@ -175,6 +190,8 @@ function get_feed_icon(feed) { if (feed.id < -10) return 'images/label.png'; + return 'images/blank_icon.gif'; + } catch (e) { exception_error("get_feed_icon", e); } @@ -199,24 +216,12 @@ function add_feed_entry(feed) { } } -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 = ""; + icon_part = ""; var tmp_html = "
  • " + icon_part + @@ -245,7 +250,66 @@ function add_headline_entry(article, feed) { } } -function digest_update(transport, feed_id) { +function parse_feeds(transport) { + try { + + var feeds = transport.responseXML.getElementsByTagName('feeds')[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]); + } + } + + } catch (e) { + exception_error("parse_feeds", e); + } +} + +function parse_headlines(transport, replace) { + try { + var headlines = transport.responseXML.getElementsByTagName('headlines')[0]; + + if (headlines) { + headlines = eval("(" + headlines.firstChild.nodeValue + ")"); + + if (replace) $('headlines-content').innerHTML = ''; + + var pr = $('MORE-PROMPT'); + + if (pr) pr.parentNode.removeChild(pr); + + for (var i = 0; i < headlines.length; i++) { + + if (!$('A-' + headlines[i].id)) { + add_headline_entry(headlines[i], + find_feed(last_feeds, headlines[i].feed_id)); + } + } + + if (pr) { + $('headlines-content').appendChild(pr); + } else { + $('headlines-content').innerHTML += "
  • " + + "
  • "; + } + + new Effect.Appear('headlines-content'); + } + + } catch (e) { + exception_error("parse_headlines", e); + } +} + +/*function digest_update(transport, feed_id, offset) { try { var feeds = transport.responseXML.getElementsByTagName('feeds')[0]; var headlines = transport.responseXML.getElementsByTagName('headlines')[0]; @@ -267,11 +331,9 @@ function digest_update(transport, feed_id) { if (headlines) { headlines = eval("(" + headlines.firstChild.nodeValue + ")"); - if (_active_feed_id != feed_id) + if (_active_feed_id != feed_id || !offset) $('headlines-content').innerHTML = ""; - //Element.hide('headlines-content'); - var pr = $('MORE-PROMPT'); if (pr) { @@ -283,7 +345,8 @@ function digest_update(transport, feed_id) { var elem = $('A-' + headlines[i].id); if (elem && Element.visible(elem)) { - + if (!headlines[i].unread) + remove_headline_entry(headlines[i].id); } else { add_headline_entry(headlines[i], find_feed(feeds, headlines[i].feed_id)); @@ -295,22 +358,30 @@ function digest_update(transport, feed_id) { __("More articles...") + ""; new Effect.Appear('headlines-content'); + } + if (feed_id != undefined) { + _active_feed_id = feed_id; } + if (offset != undefined) _active_feed_offset = offset; + + mark_selected_feed(_active_feed_id); + } catch (e) { exception_error("digest_update", e); } - } +} */ -function digest_init() { +function init() { try { new Ajax.Request("backend.php", { parameters: "backend.php?op=rpc&subop=digest-init", onComplete: function(transport) { - digest_update(transport, -4); + parse_feeds(transport); window.setTimeout('viewfeed(-4)', 100); + _update_timeout = window.setTimeout('update()', 5*1000); } }); } catch (e) { @@ -363,9 +434,6 @@ function toggleMark(mark_img, id) { if (!mark_img) return; - var vfeedu = $("FEEDU--1"); - var crow = $("RROW-" + id); - if (mark_img.src.match("mark_unset")) { mark_img.src = mark_img.src.replace("mark_unset", "mark_set"); mark_img.alt = __("Unstar article"); diff --git a/digest.php b/digest.php index 7b1bfd23d..467f6c286 100644 --- a/digest.php +++ b/digest.php @@ -45,7 +45,7 @@ diff --git a/functions.php b/functions.php index 735fd2c73..e53995335 100644 --- a/functions.php +++ b/functions.php @@ -6782,7 +6782,6 @@ "title" => $line["title"], "link" => $line["link"], "feed_id" => $line["feed_id"], - "has_icon" => feed_has_icon($line["feed_id"]) ); if ($show_excerpt) { -- cgit v1.2.3-54-g00ecf From 9ed133e7a97e4ad591df2557646519a2f451adf3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 12 Sep 2010 13:38:57 +0400 Subject: api: support published status in getHeadlines; digest: code cleanup --- digest.css | 11 ++++++---- digest.js | 70 +++++++++++++++++++++-------------------------------------- functions.php | 1 + 3 files changed, 33 insertions(+), 49 deletions(-) (limited to 'functions.php') diff --git a/digest.css b/digest.css index 2c30b0eb8..f7ddff689 100644 --- a/digest.css +++ b/digest.css @@ -159,14 +159,17 @@ a:hover { max-width : 65%; } -#headlines ul#headlines-content img.digest-check { - cursor : pointer; +#headlines ul#headlines-content div.digest-check { + float : right; } -#headlines ul#headlines-content div.digest-check { - float : right; +#headlines ul#headlines-content div.digest-check img { + cursor : pointer; + margin-right : 0px; + margin-left : 3px; } + #headlines ul#headlines-content img.icon { width : 16px; height : 16px; diff --git a/digest.js b/digest.js index ce9c325b5..ba066a15f 100644 --- a/digest.js +++ b/digest.js @@ -14,7 +14,7 @@ function catchup_feed(feed_id, callback) { var is_cat = ""; - if (feed_id == -4) is_cat = "true"; + if (feed_id < 0) is_cat = "true"; // KLUDGE var query = "?op=rpc&subop=catchupFeed&feed_id=" + feed_id + "&is_cat=" + is_cat; @@ -290,18 +290,32 @@ function add_headline_entry(article, feed) { icon_part = ""; + var mark_part = ""; + var publ_part = ""; + + if (article.marked) + mark_part = ""; + else + mark_part = ""; + + if (article.published) + publ_part = ""; + else + publ_part = ""; + + var tmp_html = "
  • " + icon_part + "
    " + - "" + - "" + - "" + + mark_part + + publ_part + + "" + "
    " + "" + article.title + "" + "
    " + - "
    " + + "
    " + article.excerpt + "
    " + "" + @@ -450,41 +464,7 @@ function init() { } } -function tMark_afh_off(effect) { - try { - var elem = effect.effects[0].element; - - console.log("tMark_afh_off : " + elem.id); - - if (elem) { - elem.src = elem.src.replace("mark_set", "mark_unset"); - elem.alt = __("Star article"); - Element.show(elem); - } - - } catch (e) { - exception_error("tMark_afh_off", e); - } -} - -function tPub_afh_off(effect) { - try { - var elem = effect.effects[0].element; - - console.log("tPub_afh_off : " + elem.id); - - if (elem) { - elem.src = elem.src.replace("pub_set", "pub_unset"); - elem.alt = __("Publish article"); - Element.show(elem); - } - - } catch (e) { - exception_error("tPub_afh_off", e); - } -} - -function toggleMark(mark_img, id) { +function toggle_mark(mark_img, id) { try { @@ -510,15 +490,15 @@ function toggleMark(mark_img, id) { new Ajax.Request("backend.php", { parameters: query, onComplete: function(transport) { - // + update(); } }); } catch (e) { - exception_error("toggleMark", e); + exception_error("toggle_mark", e); } } -function togglePub(mark_img, id, note) { +function toggle_pub(mark_img, id, note) { try { @@ -552,11 +532,11 @@ function togglePub(mark_img, id, note) { new Ajax.Request("backend.php", { parameters: query, onComplete: function(transport) { - // + update(); } }); } catch (e) { - exception_error("togglePub", e); + exception_error("toggle_pub", e); } } diff --git a/functions.php b/functions.php index e53995335..2174460b4 100644 --- a/functions.php +++ b/functions.php @@ -6777,6 +6777,7 @@ "id" => (int)$line["id"], "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), + "published" => sql_bool_to_bool($line["published"]), "updated" => strtotime($line["updated"]), "is_updated" => $is_updated, "title" => $line["title"], -- cgit v1.2.3-54-g00ecf From 78ac6caf001402142951ec90e8d0a1dac02e433b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 12 Sep 2010 14:37:47 +0400 Subject: digest: support tags --- digest.css | 30 +++++++++++++++++++++++++++--- digest.js | 31 +++++++++++++++++++++++++++---- digest.php | 12 ++++++++++-- functions.php | 1 + modules/backend-rpc.php | 5 +++-- 5 files changed, 68 insertions(+), 11 deletions(-) (limited to 'functions.php') diff --git a/digest.css b/digest.css index f7ddff689..cfee28bcf 100644 --- a/digest.css +++ b/digest.css @@ -18,6 +18,10 @@ a:hover { color : gray; } +#header a:hover, #footer a:hover { + color : #0069D8; +} + #header { font-weight : bold; font-size : 14px; @@ -159,6 +163,18 @@ a:hover { max-width : 65%; } +#headlines h1 a { + color : #684C99; +} + +#headlines h1 a:hover { + color : gray; +} + +#headlines h1 #headlines-title { + color : gray; +} + #headlines ul#headlines-content div.digest-check { float : right; } @@ -214,15 +230,23 @@ a:hover { } #headlines ul#headlines-content div.info { - margin-top : 2px; font-size : 11px; } #headlines ul#headlines-content div.info a { color : gray; - font-weight : bold; } -#headlines ul#headlines-content div.info a:hover { +#headlines ul#headlines-content span.tags { + font-size : 11px; + margin-bottom : 2px; +} + +#headlines ul#headlines-content span.tags a { + color : #684C99; +} + +#headlines ul#headlines-content div.info a:hover, +#headlines ul#headlines-content span.tags a:hover { color : #659a4c; } diff --git a/digest.js b/digest.js index 82abe6676..51c824ee4 100644 --- a/digest.js +++ b/digest.js @@ -186,8 +186,10 @@ function viewfeed(feed_id, offset) { offset = _active_feed_offset + offset; } - var query = "backend.php?op=rpc&subop=digest-update&feed_id=" + feed_id + - "&offset=" + offset; + var query = "backend.php?op=rpc&subop=digest-update&feed_id=" + + param_escape(feed_id) + "&offset=" + offset; + + console.log(query); new Ajax.Request("backend.php", { parameters: query, @@ -293,6 +295,22 @@ function add_headline_entry(article, feed) { var mark_part = ""; var publ_part = ""; + var tags_part = ""; + + if (article.tags.length > 0) { + + tags_part = " " + __("in") + " "; + + for (var i = 0; i < Math.min(5, article.tags.length); i++) { + tags_part += "" + + article.tags[i] + ", "; + } + + tags_part = tags_part.replace(/, $/, ""); + tags_part = "" + tags_part + ""; + } + if (article.marked) mark_part = ""; else @@ -320,7 +338,7 @@ function add_headline_entry(article, feed) { "" + "
    " + - feed.title + " " + " @ " + + feed.title + " " + tags_part + " @ " + new Date(article.updated * 1000) + "
    " + "
  • "; @@ -410,10 +428,15 @@ function parse_headlines(transport, replace) { if (!transport.responseXML) return; var headlines = transport.responseXML.getElementsByTagName('headlines')[0]; + var headlines_title = transport.responseXML.getElementsByTagName('headlines-title')[0]; - if (headlines) { + if (headlines && headlines_title) { headlines = eval("(" + headlines.firstChild.nodeValue + ")"); + var title = headlines_title.firstChild.nodeValue; + + $("headlines-title").innerHTML = title; + if (replace) $('headlines-content').innerHTML = ''; var pr = $('H-MORE-PROMPT'); diff --git a/digest.php b/digest.php index c217d2abf..2b7f91807 100644 --- a/digest.php +++ b/digest.php @@ -91,7 +91,8 @@
    -

    +

    : +

    @@ -107,6 +108,13 @@ v © 2005– - Andrew Dolgov + Andrew Dolgov + +
    + + + + + diff --git a/functions.php b/functions.php index 2174460b4..232ee7c1f 100644 --- a/functions.php +++ b/functions.php @@ -6783,6 +6783,7 @@ "title" => $line["title"], "link" => $line["link"], "feed_id" => $line["feed_id"], + "tags" => get_article_tags($link, $line["id"]), ); if ($show_excerpt) { diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 976fac15c..a0e4e77df 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -984,8 +984,6 @@ if (!$feed_id) $feed_id = -4; if (!$offset) $offset = 0; - - print ""; $headlines = api_get_headlines($link, $feed_id, 10, $offset, @@ -994,6 +992,9 @@ //function api_get_headlines($link, $feed_id, $limit, $offset, // $filter, $is_cat, $show_excerpt, $show_content, $view_mode) { + print ""; + print ""; print ""; -- cgit v1.2.3-54-g00ecf From a16a62c02d36668877b81487f8e3e363e203a979 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 11 Oct 2010 11:24:29 +0400 Subject: outputHeadlinesList: properly handle always_display_enclosures when feed_id is null --- functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'functions.php') diff --git a/functions.php b/functions.php index cdbfa4cae..527e78f85 100644 --- a/functions.php +++ b/functions.php @@ -5520,7 +5520,9 @@ } $tmp_result = db_query($link, "SELECT always_display_enclosures FROM - ttrss_feeds WHERE id = ".$line['feed_id']." AND owner_uid = ".$_SESSION["uid"]); + ttrss_feeds WHERE id = ". + (($line['feed_id'] == null) ? $line['orig_feed_id'] : + $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]); $always_display_enclosures = db_fetch_result($tmp_result, 0, "always_display_enclosures"); -- cgit v1.2.3-54-g00ecf