]> git.wh0rd.org Git - tt-rss.git/commitdiff
added support for marking posts
authorAndrew Dolgov <fox@madoka.spb.ru>
Mon, 5 Sep 2005 04:04:31 +0000 (05:04 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Mon, 5 Sep 2005 04:04:31 +0000 (05:04 +0100)
NEWS
backend.php
functions.php
tt-rss.js

diff --git a/NEWS b/NEWS
index 5c4c790720fc213ac4e3646d355221ec0331b975..f60e9bbcca95a871d4385cd59fc24e92442c0b5c 100644 (file)
--- 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)
 
index 82b9e9b6cb9845b1bc5e4e7abf5d62ffec0b63de..eab9341f8a32662c5998f6136bc7f323e3482c4c 100644 (file)
 
                $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'");
 
                $feed_last_updated = "Updated: " . $line["last_updated"];
 
-               print "<tr><td class=\"search\" colspan=\"3\">
+               print "<tr><td class=\"search\" colspan=\"4\">
                        Search: <input id=\"searchbox\"
                        onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\"
                        onchange=\"javascript:search($feed);\">
                        <a class=\"button\" href=\"javascript:resetSearch()\">Reset</a>
                        </td></tr>"; 
                print "<tr>
-               <td colspan=\"3\" class=\"title\">" . $line["title"] . "</td></tr>"; 
+               <td colspan=\"4\" class=\"title\">" . $line["title"] . "</td></tr>"; 
 
                $search = $_GET["search"];
 
                $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
                        $id = $line["id"];
                        $feed_id = $line["feed_id"];
 
+                       if ($line["marked"] == "t") {
+                               $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\" 
+                                       alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>";
+                       } else {
+                               $marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_unset.png\" 
+                                       alt=\"Set mark\" onclick='javascript:toggleMark($id, true)'>";
+                       }
+
                        $content_link = "<a href=\"javascript:view($id,$feed_id);\">" .
                                $line["title"] . "</a>";
                                
                        print "<tr class='$class' id='RROW-$id'>";
 
-                       print "<td id='FUPDPIC-$id' valign='center' class='headlineUpdateMark'>$update_pic</td>";
+                       print "<td id='FUPDPIC-$id' valign='center' 
+                               class='headlineUpdateMark'>$update_pic</td>";
+
+                       print "<td valign='center' 
+                               class='headlineUpdateMark'>$marked_pic</td>";
 
                        print "<td class='headlineUpdated'>
                                <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>";
 
                // start unholy navbar block
 
-               print "<tr><td colspan=\"3\" class=\"headlineToolbar\">";
+               print "<tr><td colspan=\"4\" class=\"headlineToolbar\">";
                
                $next_skip = $skip + HEADLINES_PER_PAGE;
                $prev_skip = $skip - HEADLINES_PER_PAGE;
index ea2c2235d9c73484647cfaccc8403d9fb772c731..d572ee78005b2532a5bca4e31ee2c54f5d4178fd 100644 (file)
@@ -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'");
                }
        }
index fcafd39bab24a3538549ec06ae74a9a107112757..e1cee7353b1f8b97f4a96adb0ac53b9fb2550111 100644 (file)
--- 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() {