]> git.wh0rd.org Git - tt-rss.git/commitdiff
updated schema (md5_hash is not unique any more), feed parsing fixes
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 23 Aug 2005 07:32:11 +0000 (08:32 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 23 Aug 2005 07:32:11 +0000 (08:32 +0100)
backend.php
functions.php
tt-rss.css
ttrss_schema.sql

index e34cc4017e3dc2f8ba6507f1c28e8fba8b9d5336..e5244fb609be23d4cb26b75070802f7d4363fc31 100644 (file)
@@ -1,5 +1,5 @@
 <?
-       header("Content-Type: application/xml");
+//     header("Content-Type: application/xml");
 
        require_once "config.php";
        require_once "functions.php";
 
                // 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'");
 
 
                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"];
                }
                print "&nbsp;";
 
+               // start unholy navbar block
+
+
                if ($next_skip < $total_entries) {              
                        print "<a class=\"button\" 
                                href=\"javascript:viewfeed($feed, $next_skip);\">Next Page</a>";
                        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>";
                        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 
index d2cb65d2c36b7b3a1bff81430d17f6fe78c4ea72..bada34c0263a83dc7072a8950cecdb00fc2aca64 100644 (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) {
        
                                                $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) {
index ba1d08a1237bc57dc3294a71055a45ee69558088..ed326aa47befb685b33c8d5f7ac4177f6704eb31 100644 (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;
 }
+
+
index fec7e4cfe4f4b65534505dd543943dc7de578af8..e926ef226e65bf19e67f0dc9b3df5d245bbceb88 100644 (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,