From a20153510b9bc070a9efb3e5ab04832f26fa26b2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Aug 2005 08:32:11 +0100 Subject: [PATCH] updated schema (md5_hash is not unique any more), feed parsing fixes --- backend.php | 18 ++++++++++++------ functions.php | 24 +++++++++++++++++------- tt-rss.css | 12 ++++++++++++ ttrss_schema.sql | 21 ++++++++++----------- 4 files changed, 51 insertions(+), 24 deletions(-) diff --git a/backend.php b/backend.php index e34cc401..e5244fb6 100644 --- a/backend.php +++ b/backend.php @@ -1,5 +1,5 @@ "; + $feed_last_updated = "Updated: " . $line["last_updated"]; + print " Search: "; - print "" . $line["title"] . ""; + print " + " . $line["title"] . ""; if ($ext == "SEARCH") { $search = $_GET["search"]; @@ -259,6 +262,9 @@ } print " "; + // start unholy navbar block + + if ($next_skip < $total_entries) { print "Next Page"; @@ -266,9 +272,6 @@ print "Next Page"; } print "  Feed: "; -// print "Refresh Page"; -// print " "; print "Update"; @@ -282,6 +285,9 @@ href=\"javascript:viewfeed($feed, $skip, 'MarkAllRead');\">All Posts"; print ""; + + // end unholy navbar block + print ""; $result = pg_query("SELECT id, (SELECT count(id) FROM ttrss_entries diff --git a/functions.php b/functions.php index d2cb65d2..bada34c0 100644 --- a/functions.php +++ b/functions.php @@ -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]
"; + + 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 "
".htmlspecialchars($query)."
"; + $result = pg_query($link, $query); if ($result) ++$num_unread; } - + } if ($result) { diff --git a/tt-rss.css b/tt-rss.css index ba1d08a1..ed326aa4 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -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; } + + diff --git a/ttrss_schema.sql b/ttrss_schema.sql index fec7e4cf..e926ef22 100644 --- a/ttrss_schema.sql +++ b/ttrss_schema.sql @@ -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, -- 2.39.5