diff --git a/backend.php b/backend.php index 3b9ff542..6ea1355b 100644 --- a/backend.php +++ b/backend.php @@ -11,10 +11,11 @@ pg_query("set client_encoding = 'utf-8'"); $op = $_GET["op"]; + $fetch = $_GET["fetch"]; if ($op == "feeds") { - update_all_feeds($link); + if ($fetch) update_all_feeds($link); $result = pg_query("SELECT *, (SELECT count(id) FROM ttrss_entries @@ -53,7 +54,7 @@ } print " - Update all feeds"; + Update all feeds"; print ""; @@ -201,9 +202,43 @@ if ($op == "pref-feeds") { + $subop = $_GET["subop"]; + + if ($subop == "edit") { + print "

[Edit feed placeholder]

"; + } + + if ($subop == "remove") { + $ids = split(",", $_GET["ids"]); + + foreach ($ids as $id) { + pg_query("BEGIN"); + pg_query("DELETE FROM ttrss_entries WHERE feed_id = '$id'"); + pg_query("DELETE FROM ttrss_feeds WHERE id = '$id'"); + pg_query("COMMIT"); + + } + } + + if ($subop == "add") { + $feed_link = pg_escape_string($_GET["link"]); + + $result = pg_query( + "INSERT INTO ttrss_feeds (feed_url,title) VALUES ('$feed_link', '')"); + + $result = pg_query("SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'"); + + $feed_id = pg_fetch_result($result, 0, "id"); + + if ($feed_id) { + update_rss_feed($link, $feed_link, $feed_id); + } + + } + $result = pg_query("SELECT * FROM ttrss_feeds ORDER by title"); - print "

"; + print "

"; print ""; @@ -212,13 +247,18 @@ while ($line = pg_fetch_assoc($result)) { $class = ($lnum % 2) ? "even" : "odd"; - - print ""; + + $feed_id = $line["id"]; + + print ""; print ""; - print ""; - print ""; + type=\"checkbox\" id=\"FRCHK-".$line["id"]."\">"; + print ""; + print ""; + print ""; print ""; diff --git a/functions.php b/functions.php index d49c951f..3da349f1 100644 --- a/functions.php +++ b/functions.php @@ -4,7 +4,7 @@ function update_all_feeds($link) { $result = pg_query($link, "SELECT feed_url,id FROM ttrss_feeds WHERE - last_updated is null OR + last_updated is null OR title = '' OR EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) > " . MIN_UPDATE_TIME); @@ -19,6 +19,16 @@ $rss = fetch_rss($feed_url); if ($rss) { + + $result = pg_query("SELECT title FROM ttrss_feeds WHERE id = '$feed'"); + + $registered_title = pg_fetch_result($result, 0, "title"); + + if (!$registered_title) { + + $feed_title = $rss->channel["title"]; + pg_query("UPDATE ttrss_feeds SET title = '$feed_title' WHERE id = '$feed'"); + } foreach ($rss->items as $item) { @@ -30,7 +40,9 @@ $entry_timestamp = $item["pubdate"]; if (!$entry_timestamp) $entry_timestamp = $item["modified"]; if (!$entry_timestamp) $entry_timestamp = $item["updated"]; - + + if (!$entry_timestamp) continue; + $entry_timestamp = strtotime($entry_timestamp); if (!$entry_timestamp) continue; diff --git a/prefs.js b/prefs.js index b068e01b..7fb4562f 100644 --- a/prefs.js +++ b/prefs.js @@ -24,33 +24,6 @@ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } -function param_escape(arg) { - if (typeof encodeURIComponent != 'undefined') - return encodeURIComponent(arg); - else - return escape(arg); -} - -function param_unescape(arg) { - if (typeof decodeURIComponent != 'undefined') - return decodeURIComponent(arg); - else - return unescape(arg); -} - -function notify(msg) { - - var n = document.getElementById("notify"); - - n.innerHTML = msg; - - if (msg.length == 0) { - n.style.display = "none"; - } else { - n.style.display = "block"; - } - -} function feedlist_callback() { var container = document.getElementById('feeds'); @@ -85,13 +58,62 @@ function toggleSelectRow(sender) { function addFeed() { - var link = document.getElementById("fadd_link").value; - var title = document.getElementById("fadd_title").value; + var link = document.getElementById("fadd_link"); - if (link.length == 0 || title.length == 0) { - notify("Error: all fields must be filled in."); + if (link.length == 0) { + notify("Missing feed URL."); } else { - notify("addFeed : " + link + ", " + title); + notify("Adding feed..."); + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" + + param_escape(link.value), true); + xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.send(null); + + link.value = ""; + + } + +} + +function editFeed(feed) { + + notify("Editing feed..."); + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" + + param_escape(feed), true); + xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.send(null); + +} + + +function removeSelectedFeeds() { + + var content = document.getElementById("prefFeedList"); + + var sel_rows = new Array(); + + for (i = 0; i < content.rows.length; i++) { + if (content.rows[i].className.match("Selected")) { + var row_id = content.rows[i].id.replace("FEEDR-", ""); + sel_rows.push(row_id); + } + } + + if (sel_rows.length > 0) { + + notify("Removing selected feeds..."); + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ + param_escape(sel_rows.toString()), true); + xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.send(null); + + } else { + + notify("Please select some feeds first."); + } } diff --git a/prefs.php b/prefs.php index 6ec78a5b..7f2a8cb3 100644 --- a/prefs.php +++ b/prefs.php @@ -2,6 +2,7 @@ Tiny Tiny RSS + @@ -23,27 +24,19 @@ - diff --git a/tt-rss.css b/tt-rss.css index 4bde1885..38187380 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -32,22 +32,6 @@ a:hover { color : #5050aa; } -a.button { - border : 1px solid #d0d0d0; - background-image : url("button.png"); - background-position : top; - background-repeat : repeat-x; - background-color : white; - color : black; - padding : 2px 10px 2px 10px; - font-size : small; -} - -a.button:hover { - background : white; - text-decoration : none; -} - table.feedOverview { margin : 5px; border : 1px solid #c0c0c0; @@ -112,7 +96,7 @@ table.main td.toolbar { font-weight : bold; border : 1px solid #c0c0c0; font-size : small; - display : block; + display : none; background : white; -moz-border-radius : 5px; padding : 3px 10px 3px 10px; @@ -149,12 +133,18 @@ table.main td.headlines { overflow : scroll; } +table.main td.prefContent { + padding : 10px; + border-width : 1px 0px 0px 0px; + border-color : #c0c0c0; + border-style : solid; +} + table.main td.content { padding : 10px; border-width : 1px 0px 0px 0px; border-color : #c0c0c0; border-style : solid; - overflow : scroll; } td.content a { @@ -240,3 +230,21 @@ table.prefFeedList tr.title td { background-color : #c0c0c0; } +a.button { + border : 1px solid #d0d0d0; + background-image : url("button.png"); + background-position : top; + background-repeat : repeat-x; + background-color : white; + color : black; + padding : 2px 10px 2px 10px; + font-size : small; +} + +a.button:hover { + background : white; + text-decoration : none; + color : black; +} + + diff --git a/tt-rss.js b/tt-rss.js index 5426e4f3..3f6aab00 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -24,28 +24,6 @@ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } -function param_escape(arg) { - if (typeof encodeURIComponent != 'undefined') - return encodeURIComponent(arg); - else - return escape(arg); -} - -function param_unescape(arg) { - if (typeof decodeURIComponent != 'undefined') - return decodeURIComponent(arg); - else - return unescape(arg); -} - -function notify(msg) { - - var n = document.getElementById("notify"); - - n.innerHTML = msg; - -} - function feedlist_callback() { var container = document.getElementById('feeds'); if (xmlhttp.readyState == 4) { @@ -90,13 +68,17 @@ function view_callback() { } -function update_feed_list(called_from_timer) { +function update_feed_list(called_from_timer, fetch) { if (called_from_timer != true) { - document.getElementById("feeds").innerHTML = "Updating feeds, please wait..."; + document.getElementById("feeds").innerHTML = "Loading feeds, please wait..."; } - xmlhttp.open("GET", "backend.php?op=feeds", true); + var query_str = "backend.php?op=feeds"; + + if (fetch) query_str = query_str + "&fetch=yes"; + + xmlhttp.open("GET", query_str, true); xmlhttp.onreadystatechange=feedlist_callback; xmlhttp.send(null); @@ -105,7 +87,7 @@ function update_feed_list(called_from_timer) { function viewfeed(feed, skip, ext) { - notify("view-feed: " + feed); +// notify("view-feed: " + feed); document.getElementById('headlines').innerHTML='Loading headlines, please wait...'; document.getElementById('content').innerHTML=' '; @@ -164,8 +146,9 @@ function search(feed, sender) { function init() { - update_feed_list(); + update_feed_list(false, false); setTimeout("timeout()", 1800*1000); + } diff --git a/tt-rss.php b/tt-rss.php index 34d99ff4..f267a3b4 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -2,6 +2,7 @@ Tiny Tiny RSS + @@ -15,12 +16,12 @@ - - @@ -36,7 +37,7 @@ -
SelectTitleLinkLast Updated
" . $line["title"] . "" . $line["feed_url"] . "" . + $line["title"] . "" . + $line["feed_url"] . "" . $line["last_updated"] . "
+

Feed Configuration

- - - - - - - +
Title:Link:
+ Add feed
 
+

Remove Selected  +


- Preferences - + + + + +
 
+ Preferences
+ Tiny-Tiny RSS v0.1 © 2005 Andrew Dolgov