fix path in error message
[HTML5TV.git] / bin / calendar.pl
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use lib 'lib';
7 use HTML5TV::hCalendar;
8 use File::Slurp;
9
10 my $html = qq|<!DOCTYPE html>
11 <html>
12
13 <head>
14 <meta charset="utf-8" />
15
16 <link rel="icon" type="image/png" href="media/favicon.png">
17
18 <script src="js/jqueryhcal/jqueryhcal.js" type="text/javascript"></script>
19 <link rel="stylesheet" type="text/css" href="js/jqueryhcal/jqueryhcal.css" />
20
21 <link rel="stylesheet" type="text/css" href="hcalendar.css" />
22
23 <title>HTML5TV all media available</title>
24
25 </head>
26
27 <body>
28
29 <div id="jhCalendar"></div> 
30
31 |;
32
33 my $vevents;
34
35 foreach my $path ( glob 'media/*/hCalendar.html' ) {
36         next if $path =~ m{_editing};
37         warn "+ $path\n";
38
39         my $hcal = HTML5TV::hCalendar->new( $path );
40
41         my $media = (split(/\//, $path))[1];
42
43         if ( ! -e "www/$media.html" ) {
44                 warn "NO www/$media.html $!";
45                 next;
46         }
47
48         $vevents->{ $hcal->dtstart_iso } = $hcal->as_HTML(
49                 [ 'a', { href => "$media.html", title => 'watch video', class => 'watch' },
50                         [ 'img', { src => 'media/favicon.png' } ],
51                 ]
52         );
53 }
54
55 $html .= join("\n", map { $vevents->{$_} } sort keys %$vevents );
56
57 $html .= qq|
58
59 </body>
60 </html>
61
62 |;
63
64 write_file 'www/calendar.html', $html;