summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2005-10-13 04:15:09 +0100
committerAndrew Dolgov <[email protected]>2005-10-13 04:15:09 +0100
commitd148926e2b96602707a4b012966e943e865d48d2 (patch)
treeb0609c6f509eecf1503d6bba41a9cff938180e52
parent1cae701741421b38ec9e7f982e2b22a7de9c7a41 (diff)
per-feed update intervals
-rw-r--r--backend.php28
-rw-r--r--config.php-dist2
-rw-r--r--functions.php14
-rw-r--r--prefs.js10
-rw-r--r--schema/ttrss_schema_mysql.sql1
-rw-r--r--schema/ttrss_schema_pgsql.sql1
-rw-r--r--tt-rss.css2
7 files changed, 48 insertions, 10 deletions
diff --git a/backend.php b/backend.php
index b5de559c9..b947a1471 100644
--- a/backend.php
+++ b/backend.php
@@ -693,10 +693,15 @@
if ($subop == "editSave") {
$feed_title = db_escape_string($_GET["t"]);
$feed_link = db_escape_string($_GET["l"]);
+ $upd_intl = db_escape_string($_GET["ui"]);
$feed_id = $_GET["id"];
+ if (strtoupper($upd_intl) == "DEFAULT")
+ $upd_intl = 0;
+
$result = db_query($link, "UPDATE ttrss_feeds SET
- title = '$feed_title', feed_url = '$feed_link' WHERE id = '$feed_id'");
+ title = '$feed_title', feed_url = '$feed_link',
+ update_interval = '$upd_intl' WHERE id = '$feed_id'");
}
@@ -743,14 +748,16 @@
</table>";
$result = db_query($link, "SELECT
- id,title,feed_url,substring(last_updated,1,16) as last_updated
+ id,title,feed_url,substring(last_updated,1,16) as last_updated,
+ update_interval
FROM
ttrss_feeds ORDER by title");
print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">";
print "<tr class=\"title\">
<td>&nbsp;</td><td>Select</td><td width=\"40%\">Title</td>
- <td width=\"40%\">Link</td><td>Last updated</td></tr>";
+ <td width=\"30%\">Link</td><td width=\"10%\">Update Interval</td>
+ <td>Last updated</td></tr>";
$lnum = 0;
@@ -787,7 +794,12 @@
$line["title"] . "</td>";
print "<td><a href=\"javascript:editFeed($feed_id);\">" .
$line["feed_url"] . "</td>";
-
+
+ if ($line["update_interval"] == "0")
+ $line["update_interval"] = "Default";
+
+ print "<td>" . $line["update_interval"] . "</td>";
+
} else if ($feed_id != $edit_feed_id) {
@@ -797,13 +809,19 @@
print "<td>".$line["title"]."</td>";
print "<td>".$line["feed_url"]."</td>";
+ if ($line["update_interval"] == "0")
+ $line["update_interval"] = "Default";
+
+ print "<td>" . $line["update_interval"] . "</td>";
+
} else {
print "<td><input disabled=\"true\" type=\"checkbox\"></td>";
print "<td><input id=\"iedit_title\" value=\"".$line["title"]."\"></td>";
print "<td><input id=\"iedit_link\" value=\"".$line["feed_url"]."\"></td>";
-
+ print "<td><input id=\"iedit_updintl\" value=\"".$line["update_interval"]."\"></td>";
+
}
if (!$line["last_updated"]) $line["last_updated"] = "Never";
diff --git a/config.php-dist b/config.php-dist
index a0940820e..f56fb6dc9 100644
--- a/config.php-dist
+++ b/config.php-dist
@@ -30,5 +30,7 @@
// crafted SQL queries. This feature is highly experimental and
// at this point not user friendly. Use with caution.
+ define(MIN_UPDATE_INTERVAL, 30);
+ // min. interval between feed updates, minutes
?>
diff --git a/functions.php b/functions.php
index 0c0fc047f..a2e29655b 100644
--- a/functions.php
+++ b/functions.php
@@ -24,12 +24,20 @@
db_query($link, "BEGIN");
- $result = db_query($link, "SELECT feed_url,id,last_updated FROM ttrss_feeds");
+ $result = db_query($link, "SELECT feed_url,id,
+ substring(last_updated,1,19) as last_updated,
+ update_interval FROM ttrss_feeds");
while ($line = db_fetch_assoc($result)) {
-// if (!$line["last_updated"] || time() - strtotime($line["last_updated"]) > 1800) {
+ $upd_intl = $line["update_interval"];
+
+ if (!$upd_intl) $upd_intl = MIN_UPDATE_INTERVAL;
+
+ if (!$line["last_updated"] ||
+ time() - strtotime($line["last_updated"]) > ($upd_intl * 60)) {
+
update_rss_feed($link, $line["feed_url"], $line["id"]);
-// }
+ }
}
purge_old_posts($link);
diff --git a/prefs.js b/prefs.js
index 2d04efedc..1b5277674 100644
--- a/prefs.js
+++ b/prefs.js
@@ -454,9 +454,16 @@ function feedEditSave() {
var link = document.getElementById("iedit_link").value;
var title = document.getElementById("iedit_title").value;
+ var upd_intl = document.getElementById("iedit_updintl").value;
// notify("Saving feed.");
+ if (upd_intl < 0) {
+ notify("Update interval must be &gt;= 0 (0 = default)");
+ return;
+ }
+
+
if (link.length == 0) {
notify("Feed link cannot be blank.");
return;
@@ -470,7 +477,8 @@ function feedEditSave() {
active_feed = false;
xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
- feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) ,true);
+ feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
+ "&ui=" + param_escape(upd_intl), true);
xmlhttp.onreadystatechange=feedlist_callback;
xmlhttp.send(null);
diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql
index de01f20d6..408402c70 100644
--- a/schema/ttrss_schema_mysql.sql
+++ b/schema/ttrss_schema_mysql.sql
@@ -6,6 +6,7 @@ create table ttrss_feeds (id integer not null auto_increment primary key,
title varchar(200) not null unique,
feed_url varchar(250) unique not null,
icon_url varchar(250) not null default '',
+ update_interval integer not null default 0,
last_updated datetime default '') TYPE=InnoDB;
insert into ttrss_feeds (title,feed_url) values ('Footnotes', 'http://gnomedesktop.org/node/feed');
diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql
index 77e88a158..085bcc675 100644
--- a/schema/ttrss_schema_pgsql.sql
+++ b/schema/ttrss_schema_pgsql.sql
@@ -6,6 +6,7 @@ create table ttrss_feeds (id serial not null primary key,
title varchar(200) not null unique,
feed_url varchar(250) unique not null,
icon_url varchar(250) not null default '',
+ update_interval integer not null default 0,
last_updated timestamp default null);
insert into ttrss_feeds (title,feed_url) values ('Footnotes', 'http://gnomedesktop.org/node/feed');
diff --git a/tt-rss.css b/tt-rss.css
index 079ce827c..c0380934e 100644
--- a/tt-rss.css
+++ b/tt-rss.css
@@ -204,7 +204,7 @@ a:hover {
opacity : 0.8;
}
-#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr {
+#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl {
width : 100%;
padding-left : 2px;
}