/[pg-getfeed]/getfeed.sql
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /getfeed.sql

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by dpavlin, Thu Mar 15 10:31:41 2007 UTC revision 5 by dpavlin, Sat Mar 15 21:57:40 2008 UTC
# Line 1  Line 1 
1  create type blog as (feed text, title text, content text, pubdate timestamptz, link text);  create type blog as (feed text, title text, content text, pubdate timestamptz, author text, link text);
2    
3  create or replace function getfeed(text)  create or replace function getfeed(text)
4  returns setof blog  returns setof blog
# Line 10  as $$ Line 10  as $$
10    
11          my $feed = XML::Feed->parse(URI->new($uri)) or die XML::Feed->errstr;          my $feed = XML::Feed->parse(URI->new($uri)) or die XML::Feed->errstr;
12    
13            sub strip_html {
14                    my $t = shift;
15                    $t =~ s/<\/?[^>]+>//gs;
16                    $t =~ s/\s\s+/ /gs;
17                    return $t;
18            }
19    
20          for my $entry ($feed->entries) {          for my $entry ($feed->entries) {
21                  return_next({                  return_next({
22                          feed => $feed->title,                          feed    => $feed->title,
23                          title => $entry->title,                          title   => $entry->title,
24                          content => $entry->content->body,                          content => strip_html( $entry->content->body ),
25                          link => $entry->link,                          link    => $entry->link,
26                          pubdate => $entry->issued,                          pubdate => $entry->issued,
27                            author  => $entry->author,
28                  });                  });
29          }          }
30    
# Line 24  as $$ Line 32  as $$
32  $$;  $$;
33    
34  create view my_feeds as  create view my_feeds as
35  select feed,title,content,pubdate,link from getfeed('http://blog.rot13.org/index.xml')  select feed,author,title,content,pubdate,link from getfeed('http://blog.rot13.org/index.xml')
36  union  union
37  select feed,title,content,pubdate,link from getfeed('http://saturn.ffzg.hr/noauth/feed/workspace/rot13?category=Recent%20Changes;type=Atom')  select feed,author,title,content,pubdate,link from getfeed('http://saturn.ffzg.hr/noauth/feed/workspace/rot13?category=Recent%20Changes;type=Atom')
38  ;  ;
39    
40  -- if your terminal isn't iso-8859-2, change this!  -- if your terminal isn't iso-8859-2, change this!
# Line 39  from my_feeds Line 47  from my_feeds
47  ;  ;
48    
49  select  select
50          feed,title,substr(content,0,50),pubdate,link          feed,author,title,substr(content,0,80),pubdate,link
51  from feeds  from feeds
52  order by pubdate desc  order by pubdate desc
53  limit 30  limit 30

Legend:
Removed from v.2  
changed lines
  Added in v.5

  ViewVC Help
Powered by ViewVC 1.1.26