added support for marking posts

This commit is contained in:
Andrew Dolgov 2005-09-05 05:04:31 +01:00
parent 6cc36202c7
commit f4c10d4408
4 changed files with 65 additions and 6 deletions

2
NEWS
View File

@ -4,6 +4,8 @@ v1.0.3 (Sep xx, 2005)
- Support for simple content filtering (expression should be valid regexp, - Support for simple content filtering (expression should be valid regexp,
checking is case insensitive) checking is case insensitive)
- Reworked preferences dialog - Reworked preferences dialog
- Added ability to mark posts as "starred". These posts are not expired
automatically.
v1.0.2 (Sep 02, 2005) v1.0.2 (Sep 02, 2005)

View File

@ -112,8 +112,22 @@
$subop = $_GET["subop"]; $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") { if ($subop == "updateFeed") {
$feed_id = $_GET["feed"]; $feed_id = pg_escape_string($_GET["feed"]);
$result = pg_query($link, $result = pg_query($link,
"SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'"); "SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'");
@ -253,14 +267,14 @@
$feed_last_updated = "Updated: " . $line["last_updated"]; $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\" Search: <input id=\"searchbox\"
onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\"
onchange=\"javascript:search($feed);\"> onchange=\"javascript:search($feed);\">
<a class=\"button\" href=\"javascript:resetSearch()\">Reset</a> <a class=\"button\" href=\"javascript:resetSearch()\">Reset</a>
</td></tr>"; </td></tr>";
print "<tr> print "<tr>
<td colspan=\"3\" class=\"title\">" . $line["title"] . "</td></tr>"; <td colspan=\"4\" class=\"title\">" . $line["title"] . "</td></tr>";
$search = $_GET["search"]; $search = $_GET["search"];
@ -277,7 +291,7 @@
$total_entries = pg_fetch_result($result, 0, "total_entries"); $total_entries = pg_fetch_result($result, 0, "total_entries");
$result = pg_query("SELECT $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 last_read) AS last_read_ts,
EXTRACT(EPOCH FROM updated) AS updated_ts EXTRACT(EPOCH FROM updated) AS updated_ts
FROM FROM
@ -309,12 +323,24 @@
$id = $line["id"]; $id = $line["id"];
$feed_id = $line["feed_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);\">" . $content_link = "<a href=\"javascript:view($id,$feed_id);\">" .
$line["title"] . "</a>"; $line["title"] . "</a>";
print "<tr class='$class' id='RROW-$id'>"; 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'> print "<td class='headlineUpdated'>
<a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>"; <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>";
@ -336,7 +362,7 @@
// start unholy navbar block // start unholy navbar block
print "<tr><td colspan=\"3\" class=\"headlineToolbar\">"; print "<tr><td colspan=\"4\" class=\"headlineToolbar\">";
$next_skip = $skip + HEADLINES_PER_PAGE; $next_skip = $skip + HEADLINES_PER_PAGE;
$prev_skip = $skip - HEADLINES_PER_PAGE; $prev_skip = $skip - HEADLINES_PER_PAGE;

View File

@ -6,6 +6,7 @@
function purge_old_posts() { function purge_old_posts() {
if (PURGE_OLD_DAYS > 0) { if (PURGE_OLD_DAYS > 0) {
$result = pg_query("DELETE FROM ttrss_entries WHERE $result = pg_query("DELETE FROM ttrss_entries WHERE
marked = false AND
date_entered < NOW() - INTERVAL '".PURGE_OLD_DAYS." days'"); date_entered < NOW() - INTERVAL '".PURGE_OLD_DAYS." days'");
} }
} }

View File

@ -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() { function init() {