fix presentation symlink
[HTML5TV.git] / bin / calendar.pl
index f730fbb..71ab065 100755 (executable)
@@ -7,9 +7,24 @@ use lib 'lib';
 use HTML5TV::hCalendar;
 use File::Slurp;
 use XML::FeedPP;
+use HTML::ResolveLink;
 
 my $url = 'http://html5tv.rot13.org';
 
+my $style = qq|
+<style type="text/css">
+
+|
+. read_file('www/css/hCalendar.css')
+. qq|
+
+.watch {
+       margin-right: 0.1em;
+}
+
+</style>
+|;
+
 my $html = qq|<!DOCTYPE html>
 <html>
 
@@ -25,7 +40,9 @@ my $html = qq|<!DOCTYPE html>
 <script src="js/jqueryhcal/jqueryhcal.js" type="text/javascript"></script>
 <link rel="stylesheet" type="text/css" href="js/jqueryhcal/jqueryhcal.css" />
 
-<link rel="stylesheet" type="text/css" href="hcalendar.css" />
+<link rel="stylesheet" type="text/css" href="css/hCalendar.css" />
+
+$style
 
 <title>HTML5TV all media available</title>
 
@@ -33,7 +50,7 @@ my $html = qq|<!DOCTYPE html>
 
 <body>
 
-<div id="jhCalendar"></div> 
+<div id="jhCalendar"></div>
 
 |;
 
@@ -42,6 +59,8 @@ my $feed = XML::FeedPP::RSS->new;
 $feed->title( 'HTML5TV' );
 $feed->link( $url );
 
+my $resolver = HTML::ResolveLink->new( base => $url );
+
 foreach my $path ( glob 'media/*/hCalendar.html' ) {
        next if $path =~ m{_editing};
        warn "+ $path\n";
@@ -56,14 +75,14 @@ foreach my $path ( glob 'media/*/hCalendar.html' ) {
        }
 
        my $html = $hcal->as_HTML(
-               [ 'div',
-                       [ 'a', { href => "$media.html", title => 'watch video', class => 'watch' },
+               [ 'span', { class => 'watch' },
+                       [ 'a', { href => "$media.html", title => $media, },
                                [ 'img', { src => 'media/favicon.png', border => 0 } ],
                        ]
                ]
        );
 
-       $vevents->{ $hcal->dtstart_iso } = $html;
+       $vevents->{ $hcal->dtstart_iso . $media } = $html;
 
        my $pubDate = $hcal->dtstart_iso;
        $pubDate =~ s{^(\d\d\d\d)(\d\d)(\d\d).*$}{$1-$2-$3};
@@ -71,7 +90,7 @@ foreach my $path ( glob 'media/*/hCalendar.html' ) {
        my $item = $feed->add_item( "$url/$media.html" );
        $item->title( $hcal->summary );
        $item->pubDate( $pubDate );
-       $item->description( $html );
+       $item->description( $style . $resolver->resolve( $html ) );
 }
 
 $feed->to_file( 'www/calendar.xml' );
@@ -80,6 +99,8 @@ $html .= join("\n", map { $vevents->{$_} } sort keys %$vevents );
 
 $html .= qq|
 
+<a href="calendar.xml">rss</a>
+
 </body>
 </html>