updated schema (md5_hash is not unique any more), feed parsing fixes

This commit is contained in:
Andrew Dolgov 2005-08-23 08:32:11 +01:00
parent 3ad5aa855c
commit a20153510b
4 changed files with 51 additions and 24 deletions

View File

@ -1,5 +1,5 @@
<?
header("Content-Type: application/xml");
// header("Content-Type: application/xml");
require_once "config.php";
require_once "functions.php";
@ -156,7 +156,7 @@
// FIXME: check for null value here
$result = pg_query("SELECT *,
$result = pg_query("SELECT *,SUBSTRING(last_updated,1,16) as last_updated,
EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) as update_timeout
FROM ttrss_feeds WHERE id = '$feed'");
@ -181,9 +181,12 @@
print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">";
$feed_last_updated = "Updated: " . $line["last_updated"];
print "<tr><td class=\"search\" colspan=\"3\">
Search: <input onchange=\"javascript:search($feed,this);\"></td></tr>";
print "<tr><td colspan=\"3\" class=\"title\">" . $line["title"] . "</td></tr>";
print "<tr>
<td colspan=\"3\" class=\"title\">" . $line["title"] . "</td></tr>";
if ($ext == "SEARCH") {
$search = $_GET["search"];
@ -259,6 +262,9 @@
}
print "&nbsp;";
// start unholy navbar block
if ($next_skip < $total_entries) {
print "<a class=\"button\"
href=\"javascript:viewfeed($feed, $next_skip);\">Next Page</a>";
@ -266,9 +272,6 @@
print "<a class=\"disabledButton\">Next Page</a>";
}
print "&nbsp;&nbsp;Feed: ";
// print "<a class=\"button\"
// href=\"javascript:viewfeed($feed, $skip, '');\">Refresh Page</a>";
// print "&nbsp;";
print "<a class=\"button\"
href=\"javascript:viewfeed($feed, 0, 'ForceUpdate');\">Update</a>";
@ -282,6 +285,9 @@
href=\"javascript:viewfeed($feed, $skip, 'MarkAllRead');\">All Posts</a>";
print "</td></tr>";
// end unholy navbar block
print "</table>";
$result = pg_query("SELECT id, (SELECT count(id) FROM ttrss_entries

View File

@ -37,8 +37,6 @@
if ($rss) {
pg_query("BEGIN");
$result = pg_query("SELECT title FROM ttrss_feeds WHERE id = '$feed'");
$registered_title = pg_fetch_result($result, 0, "title");
@ -48,6 +46,8 @@
pg_query("UPDATE ttrss_feeds SET title = '$feed_title' WHERE id = '$feed'");
}
pg_query("BEGIN");
foreach ($rss->items as $item) {
$entry_guid = $item["id"];
@ -83,7 +83,9 @@
$entry_content = $item["description"];
if (!$entry_content) $entry_content = $item["content"];
if (!$entry_content) continue;
$entry_content = pg_escape_string($entry_content);
$entry_title = pg_escape_string($entry_title);
@ -96,7 +98,7 @@
FROM
ttrss_entries
WHERE
guid = '$entry_guid' OR md5_hash = '$content_md5'");
guid = '$entry_guid'");
if (pg_num_rows($result) == 0) {
@ -150,24 +152,32 @@
$update_timestamp_qpart = "updated = '$entry_timestamp_fmt',";
}
// print "$content_md5 vs $md5_hash [$entry_title vs $orig_title, $entry_id, $feed_id]<br>";
if ($content_md5 != $md5_hash) {
$update_md5_qpart = "md5_hash = '$content_md5',";
}
$query = "UPDATE ttrss_entries
SET
title ='$entry_title',
link = '$entry_link',
$update_timestamp_qpart
$last_read_qpart
$update_md5_qpart
content = '$entry_content',
md5_hash = '$content_md5',
unread = '$unread'
WHERE
id = '$entry_id'";
// print "<pre>".htmlspecialchars($query)."</pre>";
$result = pg_query($link, $query);
if ($result) ++$num_unread;
}
}
if ($result) {

View File

@ -73,6 +73,16 @@ table.headlinesList td.title {
padding-bottom : 3px;
}
table.headlinesList td.feedLastUpdateNotice {
font-size : x-small;
border-width : 0px 0px 1px 0px;
border-color : #d0d0d0;
border-style : solid;
text-align : left;
padding-bottom : 3px;
color : #a0a0a0;
}
table.headlinesList td.headlineUpdated {
width : 200px;
}
@ -282,3 +292,5 @@ td.headlineUpdateMark {
width : 25px;
text-align : center;
}

View File

@ -6,23 +6,22 @@ create table ttrss_feeds (id serial not null primary key,
feed_url varchar(250) unique not null,
last_updated timestamp default null);
insert into ttrss_feeds (id,title,feed_url) values (0, 'Daily Strips', 'http://naboo.lan/~fox/strips/backend.php?op=rss');
insert into ttrss_feeds (id,title,feed_url) values (1, 'Footnotes', 'http://gnomedesktop.org/node/feed');
insert into ttrss_feeds (id,title,feed_url) values (2, 'Freedesktop.org', 'http://planet.freedesktop.org/rss20.xml');
insert into ttrss_feeds (id,title,feed_url) values (3, 'Planet Debian', 'http://planet.debian.org/rss20.xml');
insert into ttrss_feeds (id,title,feed_url) values (5, 'Planet GNOME', 'http://planet.gnome.org/rss20.xml');
insert into ttrss_feeds (id,title,feed_url) values (6, 'Monologue', 'http://www.go-mono.com/monologue/index.rss');
insert into ttrss_feeds (title,feed_url) values ('Footnotes', 'http://gnomedesktop.org/node/feed');
insert into ttrss_feeds (title,feed_url) values ('Freedesktop.org', 'http://planet.freedesktop.org/rss20.xml');
insert into ttrss_feeds (title,feed_url) values ('Planet Debian', 'http://planet.debian.org/rss20.xml');
insert into ttrss_feeds (title,feed_url) values ('Planet GNOME', 'http://planet.gnome.org/rss20.xml');
insert into ttrss_feeds (title,feed_url) values ('Monologue', 'http://www.go-mono.com/monologue/index.rss');
insert into ttrss_feeds (id,title,feed_url) values (8, 'Latest Linux Kernel Versions',
insert into ttrss_feeds (title,feed_url) values ('Latest Linux Kernel Versions',
'http://kernel.org/kdist/rss.xml');
insert into ttrss_feeds (id,title,feed_url) values (9, 'RPGDot Newsfeed',
insert into ttrss_feeds (title,feed_url) values ('RPGDot Newsfeed',
'http://www.rpgdot.com/team/rss/rss0.xml');
insert into ttrss_feeds (id,title,feed_url) values (10, 'Digg.com News',
insert into ttrss_feeds (title,feed_url) values ('Digg.com News',
'http://digg.com/rss/index.xml');
insert into ttrss_feeds (id,title,feed_url) values (11, 'Technocrat.net',
insert into ttrss_feeds (id,title,feed_url) values ('Technocrat.net',
'http://syndication.technocrat.net/rss');
create table ttrss_entries (id serial not null primary key,
@ -31,7 +30,7 @@ create table ttrss_entries (id serial not null primary key,
title varchar(250) not null,
guid varchar(300) not null unique,
link varchar(300) not null unique,
md5_hash varchar(200) not null unique,
md5_hash varchar(200) not null,
content text not null,
last_read timestamp,
no_orig_date boolean not null default false,