From f4c10d4408c8acad944756fb843703f51a2082a1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 5 Sep 2005 05:04:31 +0100 Subject: [PATCH] added support for marking posts --- NEWS | 2 ++ backend.php | 38 ++++++++++++++++++++++++++++++++------ functions.php | 1 + tt-rss.js | 30 ++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 5c4c7907..f60e9bbc 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ v1.0.3 (Sep xx, 2005) - Support for simple content filtering (expression should be valid regexp, checking is case insensitive) - Reworked preferences dialog + - Added ability to mark posts as "starred". These posts are not expired + automatically. v1.0.2 (Sep 02, 2005) diff --git a/backend.php b/backend.php index 82b9e9b6..eab9341f 100644 --- a/backend.php +++ b/backend.php @@ -112,8 +112,22 @@ $subop = $_GET["subop"]; + if ($subop == "mark") { + $mark = $_GET["mark"]; + $id = pg_escape_string($_GET["id"]); + + if ($mark == "1") { + $mark = "true"; + } else { + $mark = "false"; + } + + $result = pg_query("UPDATE ttrss_entries SET marked = $mark + WHERE id = '$id'"); + } + if ($subop == "updateFeed") { - $feed_id = $_GET["feed"]; + $feed_id = pg_escape_string($_GET["feed"]); $result = pg_query($link, "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'"); @@ -253,14 +267,14 @@ $feed_last_updated = "Updated: " . $line["last_updated"]; - print " + print " Search: Reset "; print " - " . $line["title"] . ""; + " . $line["title"] . ""; $search = $_GET["search"]; @@ -277,7 +291,7 @@ $total_entries = pg_fetch_result($result, 0, "total_entries"); $result = pg_query("SELECT - id,title,updated,unread,feed_id, + id,title,updated,unread,feed_id,marked, EXTRACT(EPOCH FROM last_read) AS last_read_ts, EXTRACT(EPOCH FROM updated) AS updated_ts FROM @@ -309,12 +323,24 @@ $id = $line["id"]; $feed_id = $line["feed_id"]; + if ($line["marked"] == "t") { + $marked_pic = "\"Reset"; + } else { + $marked_pic = "\"Set"; + } + $content_link = "" . $line["title"] . ""; print ""; - print "$update_pic"; + print "$update_pic"; + + print "$marked_pic"; print " ".$line["updated"].""; @@ -336,7 +362,7 @@ // start unholy navbar block - print ""; + print ""; $next_skip = $skip + HEADLINES_PER_PAGE; $prev_skip = $skip - HEADLINES_PER_PAGE; diff --git a/functions.php b/functions.php index ea2c2235..d572ee78 100644 --- a/functions.php +++ b/functions.php @@ -6,6 +6,7 @@ function purge_old_posts() { if (PURGE_OLD_DAYS > 0) { $result = pg_query("DELETE FROM ttrss_entries WHERE + marked = false AND date_entered < NOW() - INTERVAL '".PURGE_OLD_DAYS." days'"); } } diff --git a/tt-rss.js b/tt-rss.js index fcafd39b..e1cee735 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -554,6 +554,36 @@ function localHotkeyHandler(keycode) { } +function toggleMark(id, toggle) { + +// notify("Toggle mark: " + id + ", " + toggle); + + if (!xmlhttp_ready(xmlhttp_rpc)) { + printLockingError(); + return; + } + + var mark_img = document.getElementById("FMARKPIC-" + id); + + var query = "backend.php?op=rpc&id=" + id + "&subop=mark"; + + if (toggle == true) { + mark_img.src = "images/mark_set.png"; + mark_img.alt = "Reset mark"; + mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', false)'); + query = query + "&mark=1"; + } else { + mark_img.src = "images/mark_unset.png"; + mark_img.alt = "Set mark"; + mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', true)'); + query = query + "&mark=0"; + } + + xmlhttp_rpc.open("GET", query, true); + xmlhttp_rpc.onreadystatechange=rpc_notify_callback; + xmlhttp_rpc.send(null); + +} function init() { -- 2.39.5