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

Contents of /getfeed.sql

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations)
Sat Mar 15 21:22:02 2008 UTC (16 years ago) by dpavlin
File size: 1073 byte(s)
indent
1 create type blog as (feed text, title text, content text, pubdate timestamptz, author text, link text);
2
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 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 });
22 }
23
24 return undef;
25 $$;
26
27 create view my_feeds as
28 select feed,author,title,content,pubdate,link from getfeed('http://blog.rot13.org/index.xml')
29 union
30 select feed,author,title,content,pubdate,link from getfeed('http://saturn.ffzg.hr/noauth/feed/workspace/rot13?category=Recent%20Changes;type=Atom')
31 ;
32
33 -- if your terminal isn't iso-8859-2, change this!
34 set client_encoding = 'iso-8859-2';
35
36 -- materialize view
37 select *
38 into feeds
39 from my_feeds
40 ;
41
42 select
43 feed,author,title,substr(content,0,50),pubdate,link
44 from feeds
45 order by pubdate desc
46 limit 30
47 ;

  ViewVC Help
Powered by ViewVC 1.1.26