From 2ec9e089f43ea6aa8ed864be0a11fd438e220533 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Fri, 26 Dec 2008 21:24:13 +0100 Subject: lifestream script, template, and configuration file --- lifestream.pl | 47 ++++++++++++++++++++ lifestream.tt | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lifestream.yaml | 19 ++++++++ 3 files changed, 201 insertions(+) create mode 100644 lifestream.pl create mode 100644 lifestream.tt create mode 100644 lifestream.yaml diff --git a/lifestream.pl b/lifestream.pl new file mode 100644 index 0000000..891e945 --- /dev/null +++ b/lifestream.pl @@ -0,0 +1,47 @@ +#!/usr/bin/perl -w +use strict; +use feature 'say'; + +use XML::Feed; +use YAML::Syck; +use URI; +use Template; + +my $feeds = LoadFile( shift ); + +my $hash_entries; +foreach ( @$feeds ) { + my $feed = XML::Feed->parse( URI->new( $_->{ url } ) ); + for my $e ( $feed->entries ) { + my $date = $e->issued->strftime( '%Y.%m.%d' ); + push @{ $hash_entries->{ $date } }, + { + source => $_->{ source }, + date => $e->issued->hms, + title => $e->title, + link => $e->link, + source_url => $_->{ source_url }, + }; + } +} + +my @dates = keys %$hash_entries; +my @sorted_dates = sort { $a cmp $b } @dates; + +my $hash_templates; +foreach my $date ( reverse @sorted_dates ) { + my @actions = sort { $b->{ date } cmp $a->{ date } } + @{ $hash_entries->{ $date } }; + push @{ $hash_templates->{ entries } }, + { + date => $date, + actions => \@actions + }; +} + +my $template = Template->new; +$template->process( 'lifestream.tt', $hash_templates, \my $content ) + or die $!; +open my $fh, '>:utf8', 'public/index.html'; +print $fh $content; +close $fh; diff --git a/lifestream.tt b/lifestream.tt new file mode 100644 index 0000000..844ace2 --- /dev/null +++ b/lifestream.tt @@ -0,0 +1,135 @@ + + + + + + lumberjaph.net | lifestream + + + +
+
+ +
+
+
+
+
+
franck
+

franck cuny

+ lumberjpah.net +
+
+ [% USE Dumper %] + [% FOREACH entry IN entries %] +

actions for [% entry.date %]

+ + [% END %] + +
+ + + +
+
+ + +
+
+ + +
+

+ + find me elsewhere + +

+
+ + +
+
+ + + + + + + +
+
+ + + + + + +
+
+ + + + \ No newline at end of file diff --git a/lifestream.yaml b/lifestream.yaml new file mode 100644 index 0000000..79944e2 --- /dev/null +++ b/lifestream.yaml @@ -0,0 +1,19 @@ +- + source: delicious + url: http://feeds.delicious.com/v2/rss/franck?count=20 + source_url: http://delicious.com/franck +- + source: identica + url: http://identi.ca/api/statuses/user_timeline/franck.atom + source_url: http://identi.ca/franck +- + source: googlereader + url: http://www.google.com/reader/public/atom/user%2F17077268849154926648%2Fstate%2Fcom.google%2Fbroadcast +- + source: myblog + url: http://lumberjaph.net/blog/index.php/feed/ + source_url: http://lumberjaph.net/blog/ +- + source: lastfm + url: http://ws.audioscrobbler.com/1.0/user/franckcuny/recenttracks.rss + source_url: http://www.last.fm/user/franckcuny -- cgit v1.2.3