/[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

Annotation of /getfeed.sql

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations)
Sat Mar 15 21:22:02 2008 UTC (11 years, 3 months ago) by dpavlin
File size: 1073 byte(s)
indent
1 dpavlin 3 create type blog as (feed text, title text, content text, pubdate timestamptz, author text, link text);
2 dpavlin 1
3     create or replace function getfeed(text)
4     returns setof blog
5     language plperlu
6     as $$
7     my ($uri) = @_;
8    
9     use XML::Feed;
10    
11     my $feed = XML::Feed->parse(URI->new($uri)) or die XML::Feed->errstr;
12    
13     for my $entry ($feed->entries) {
14     return_next({
15 dpavlin 4 feed => $feed->title,
16     title => $entry->title,
17     content => $entry->content->body,
18     link => $entry->link,
19     pubdate => $entry->issued,
20     author => $entry->author,
21 dpavlin 1 });
22     }
23    
24     return undef;
25     $$;
26    
27     create view my_feeds as
28 dpavlin 3 select feed,author,title,content,pubdate,link from getfeed('http://blog.rot13.org/index.xml')
29 dpavlin 1 union
30 dpavlin 3 select feed,author,title,content,pubdate,link from getfeed('http://saturn.ffzg.hr/noauth/feed/workspace/rot13?category=Recent%20Changes;type=Atom')
31 dpavlin 1 ;
32    
33     -- if your terminal isn't iso-8859-2, change this!
34     set client_encoding = 'iso-8859-2';
35    
36 dpavlin 2 -- materialize view
37 dpavlin 1 select *
38 dpavlin 2 into feeds
39 dpavlin 1 from my_feeds
40 dpavlin 2 ;
41    
42     select
43 dpavlin 3 feed,author,title,substr(content,0,50),pubdate,link
44 dpavlin 2 from feeds
45 dpavlin 1 order by pubdate desc
46 dpavlin 2 limit 30
47     ;

  ViewVC Help
Powered by ViewVC 1.1.26