]> git.deb.at Git - pkg/blosxom.git/blob - blosxom.cgi
5d2d6e6da1d07c8e50ccc3d2684e1a2763755a60
[pkg/blosxom.git] / blosxom.cgi
1 #!/usr/bin/perl
2
3 # Blosxom
4 # Author: Rael Dornfest <rael@oreilly.com>
5 # Version: 2.0.2
6 # Home/Docs/Licensing: http://blosxom.sourceforge.net/
7 # Development/Downloads: http://sourceforge.net/projects/blosxom
8
9 package blosxom;
10
11 # --- Configurable variables -----
12
13 # What's this blog's title?
14 $blog_title = "My Weblog";
15
16 # What's this blog's description (for outgoing RSS feed)?
17 $blog_description = "Yet another Blosxom weblog.";
18
19 # What's this blog's primary language (for outgoing RSS feed)?
20 $blog_language = "en";
21
22 # What's this blog's text encoding ?
23 $blog_encoding = "UTF-8";
24
25 # Where are this blog's entries kept?
26 $datadir = "/Library/WebServer/Documents/blosxom";
27
28 # What's my preferred base URL for this blog (leave blank for automatic)?
29 $url = "";
30
31 # Should I stick only to the datadir for items or travel down the
32 # directory hierarchy looking for items?  If so, to what depth?
33 # 0 = infinite depth (aka grab everything), 1 = datadir only, n = n levels down
34 $depth = 0;
35
36 # How many entries should I show on the home page?
37 $num_entries = 40;
38
39 # What file extension signifies a blosxom entry?
40 $file_extension = "txt";
41
42 # What is the default flavour?
43 $default_flavour = "html";
44
45 # Should I show entries from the future (i.e. dated after now)?
46 $show_future_entries = 0;
47
48 # --- Plugins (Optional) -----
49
50 # File listing plugins blosxom should load
51 # (if empty blosxom will load all plugins in $plugin_path directories)
52 $plugin_list = "";
53
54 # Where are my plugins kept?
55 # List of directories, separated by ';' on windows, ':' everywhere else
56 $plugin_path = "";
57
58 # Where should my plugins keep their state information?
59 $plugin_state_dir = "";
60
61 #$plugin_state_dir = "/var/lib/blosxom/state";
62
63 # --- Static Rendering -----
64
65 # Where are this blog's static files to be created?
66 $static_dir = "/Library/WebServer/Documents/blog";
67
68 # What's my administrative password (you must set this for static rendering)?
69 $static_password = "";
70
71 # What flavours should I generate statically?
72 @static_flavours = qw/html rss/;
73
74 # Should I statically generate individual entries?
75 # 0 = no, 1 = yes
76 $static_entries = 0;
77
78 # --------------------------------
79
80 use vars
81     qw! $version $blog_title $blog_description $blog_language $blog_encoding $datadir $url %template $template $depth $num_entries $file_extension $default_flavour $static_or_dynamic $config_dir $plugin_list $plugin_path $plugin_dir $plugin_state_dir @plugins %plugins $static_dir $static_password @static_flavours $static_entries $path_info $path_info_yr $path_info_mo $path_info_da $path_info_mo_num $flavour $static_or_dynamic %month2num @num2month $interpolate $entries $output $header $show_future_entries %files %indexes %others !;
82
83 use strict;
84 use FileHandle;
85 use File::Find;
86 use File::stat;
87 use Time::Local;
88 use CGI qw/:standard :netscape/;
89
90 $version = "2.0.2";
91
92 # Load configuration from $ENV{BLOSXOM_CONFIG_DIR}/blosxom.conf, if it exists
93 my $blosxom_config;
94 if ( $ENV{BLOSXOM_CONFIG_FILE} && -r $ENV{BLOSXOM_CONFIG_FILE} ) {
95     $blosxom_config = $ENV{BLOSXOM_CONFIG_FILE};
96     ( $config_dir = $blosxom_config ) =~ s! / [^/]* $ !!x;
97 }
98 else {
99     for my $blosxom_config_dir ( $ENV{BLOSXOM_CONFIG_DIR}, '/etc/blosxom',
100         '/etc' )
101     {
102         if ( -r "$blosxom_config_dir/blosxom.conf" ) {
103             $config_dir     = $blosxom_config_dir;
104             $blosxom_config = "$blosxom_config_dir/blosxom.conf";
105             last;
106         }
107     }
108 }
109
110 # Load $blosxom_config
111 if ($blosxom_config) {
112     if ( -r $blosxom_config ) {
113         eval { require $blosxom_config }
114             or warn "Error reading blosxom config file '$blosxom_config'"
115             . ( $@ ? ": $@" : '' );
116     }
117     else {
118         warn "Cannot find or read blosxom config file '$blosxom_config'";
119     }
120 }
121
122 my $fh = new FileHandle;
123
124 %month2num = (
125     nil => '00',
126     Jan => '01',
127     Feb => '02',
128     Mar => '03',
129     Apr => '04',
130     May => '05',
131     Jun => '06',
132     Jul => '07',
133     Aug => '08',
134     Sep => '09',
135     Oct => '10',
136     Nov => '11',
137     Dec => '12'
138 );
139 @num2month = sort { $month2num{$a} <=> $month2num{$b} } keys %month2num;
140
141 # Use the stated preferred URL or figure it out automatically
142 $url ||= url( -path_info => 1 );
143 $url =~ s/^included:/http:/ if $ENV{SERVER_PROTOCOL} eq 'INCLUDED';
144
145 # NOTE: Since v3.12, it looks as if CGI.pm misbehaves for SSIs and
146 # always appends path_info to the url. To fix this, we always
147 # request an url with path_info, and always remove it from the end of the
148 # string.
149 my $pi_len = length $ENV{PATH_INFO};
150 my $might_be_pi = substr( $url, -$pi_len );
151 substr( $url, -length $ENV{PATH_INFO} ) = ''
152     if $might_be_pi eq $ENV{PATH_INFO};
153
154 $url =~ s!/$!!;
155
156 # Drop ending any / from dir settings
157 $datadir    =~ s!/$!!;
158 $plugin_dir =~ s!/$!!;
159 $static_dir =~ s!/$!!;
160
161 # Fix depth to take into account datadir's path
162 $depth += ( $datadir =~ tr[/][] ) - 1 if $depth;
163
164 # Global variable to be used in head/foot.{flavour} templates
165 $path_info = '';
166
167 if (    !$ENV{GATEWAY_INTERFACE}
168     and param('-password')
169     and $static_password
170     and param('-password') eq $static_password )
171 {
172     $static_or_dynamic = 'static';
173 }
174 else {
175     $static_or_dynamic = 'dynamic';
176     param( -name => '-quiet', -value => 1 );
177 }
178
179 # Path Info Magic
180 # Take a gander at HTTP's PATH_INFO for optional blog name, archive yr/mo/day
181 my @path_info = split m{/}, path_info() || param('path');
182 shift @path_info;
183
184 while ( $path_info[0]
185     and $path_info[0] =~ /^[a-zA-Z].*$/
186     and $path_info[0] !~ /(.*)\.(.*)/ )
187 {
188     $path_info .= '/' . shift @path_info;
189 }
190
191 # Flavour specified by ?flav={flav} or index.{flav}
192 $flavour = '';
193
194 if ( $path_info[$#path_info] =~ /(.+)\.(.+)$/ ) {
195     $flavour = $2;
196     $path_info .= "/$1.$2" if $1 ne 'index';
197     pop @path_info;
198 }
199 else {
200     $flavour = param('flav') || $default_flavour;
201 }
202
203 # Strip spurious slashes
204 $path_info =~ s!(^/*)|(/*$)!!g;
205
206 # Date fiddling
207 ( $path_info_yr, $path_info_mo, $path_info_da ) = @path_info;
208 $path_info_mo_num
209     = $path_info_mo
210     ? ( $path_info_mo =~ /\d{2}/
211     ? $path_info_mo
212     : ( $month2num{ ucfirst( lc $path_info_mo ) } || undef ) )
213     : undef;
214
215 # Define standard template subroutine, plugin-overridable at Plugins: Template
216 $template = sub {
217     my ( $path, $chunk, $flavour ) = @_;
218
219     do {
220         return join '', <$fh>
221             if $fh->open("< $datadir/$path/$chunk.$flavour");
222     } while ( $path =~ s/(\/*[^\/]*)$// and $1 );
223
224     # Check for definedness, since flavour can be the empty string
225     if ( defined $template{$flavour}{$chunk} ) {
226         return $template{$flavour}{$chunk};
227     }
228     elsif ( defined $template{error}{$chunk} ) {
229         return $template{error}{$chunk};
230     }
231     else {
232         return '';
233     }
234 };
235
236 # Bring in the templates
237 %template = ();
238 while (<DATA>) {
239     last if /^(__END__)$/;
240     my ( $ct, $comp, $txt ) = /^(\S+)\s(\S+)(?:\s(.*))?$/ or next;
241     $txt =~ s/\\n/\n/mg;
242     $template{$ct}{$comp} .= $txt . "\n";
243 }
244
245 # Plugins: Start
246 my $path_sep = $^O eq 'MSWin32' ? ';' : ':';
247 my @plugin_dirs = split /$path_sep/, ( $plugin_path || $plugin_dir );
248 my @plugin_list = ();
249 my %plugin_hash = ();
250
251 # If $plugin_list is set, read plugins to use from that file
252 $plugin_list = "$config_dir/$plugin_list"
253     if $plugin_list && $plugin_list !~ m!^\s*/!;
254 if ( $plugin_list and -r $plugin_list and $fh->open("< $plugin_list") ) {
255     @plugin_list = map { chomp $_; $_ } grep { /\S/ && !/^#/ } <$fh>;
256     $fh->close;
257 }
258
259 # Otherwise walk @plugin_dirs to get list of plugins to use
260 elsif (@plugin_dirs) {
261     for my $plugin_dir (@plugin_dirs) {
262         next unless -d $plugin_dir;
263         if ( opendir PLUGINS, $plugin_dir ) {
264             for my $plugin (
265                 grep { /^[\w:]+$/ && !/~$/ && -f "$plugin_dir/$_" }
266                 readdir(PLUGINS) )
267             {
268
269                 # Ignore duplicates
270                 next if $plugin_hash{$plugin};
271
272                 # Add to @plugin_list and %plugin_hash
273                 $plugin_hash{$plugin} = "$plugin_dir/$plugin";
274                 push @plugin_list, $plugin;
275             }
276             closedir PLUGINS;
277         }
278     }
279     @plugin_list = sort @plugin_list;
280 }
281
282 # Load all plugins in @plugin_list
283 unshift @INC, @plugin_dirs;
284 foreach my $plugin (@plugin_list) {
285     my ( $plugin_name, $off ) = $plugin =~ /^\d*([\w:]+?)(_?)$/;
286     my $on_off = $off eq '_' ? -1 : 1;
287
288     # Allow perl module plugins
289     if ( $plugin =~ m/::/ && -z $plugin_hash{$plugin} ) {
290
291      # For Blosxom::Plugin::Foo style plugins, we need to use a string require
292         eval "require $plugin_name";
293     }
294     else {
295         eval { require $plugin };
296     }
297
298     if ($@) {
299         warn "error finding or loading blosxom plugin '$plugin_name': $@";
300         next;
301     }
302     if ( $plugin_name->start() and ( $plugins{$plugin_name} = $on_off ) ) {
303         push @plugins, $plugin_name;
304     }
305
306 }
307 shift @INC foreach @plugin_dirs;
308
309 # Plugins: Template
310 # Allow for the first encountered plugin::template subroutine to override the
311 # default built-in template subroutine
312 foreach my $plugin (@plugins) {
313     if ( $plugins{$plugin} > 0 and $plugin->can('template') ) {
314         if ( my $tmp = $plugin->template() ) {
315             $template = $tmp;
316             last;
317         }
318     }
319 }
320
321 # Provide backward compatibility for Blosxom < 2.0rc1 plug-ins
322 sub load_template {
323     return &$template(@_);
324 }
325
326 # Define default entries subroutine
327 $entries = sub {
328     my ( %files, %indexes, %others );
329     find(
330         sub {
331             my $d;
332             my $curr_depth = $File::Find::dir =~ tr[/][];
333             return if $depth and $curr_depth > $depth;
334
335             if (
336
337                 # a match
338                 $File::Find::name
339                 =~ m!^$datadir/(?:(.*)/)?(.+)\.$file_extension$!
340
341                 # not an index, .file, and is readable
342                 and $2 ne 'index' and $2 !~ /^\./ and ( -r $File::Find::name )
343                 )
344             {
345
346                 # read modification time
347                 my $mtime = stat($File::Find::name)->mtime or return;
348
349                 # to show or not to show future entries
350                 return unless ( $show_future_entries or $mtime < time );
351
352                 # add the file and its associated mtime to the list of files
353                 $files{$File::Find::name} = $mtime;
354
355                 # static rendering bits
356                 my $static_file
357                     = "$static_dir/$1/index." . $static_flavours[0];
358                 if (   param('-all')
359                     or !-f $static_file
360                     or stat($static_file)->mtime < $mtime )
361                 {
362                     $indexes{$1} = 1;
363                     $d = join( '/', ( nice_date($mtime) )[ 5, 2, 3 ] );
364                     $indexes{$d} = $d;
365                     $indexes{ ( $1 ? "$1/" : '' ) . "$2.$file_extension" } = 1
366                         if $static_entries;
367                 }
368             }
369
370             # not an entries match
371             elsif ( !-d $File::Find::name and -r $File::Find::name ) {
372                 $others{$File::Find::name} = stat($File::Find::name)->mtime;
373             }
374         },
375         $datadir
376     );
377
378     return ( \%files, \%indexes, \%others );
379 };
380
381 # Plugins: Entries
382 # Allow for the first encountered plugin::entries subroutine to override the
383 # default built-in entries subroutine
384 foreach my $plugin (@plugins) {
385     if ( $plugins{$plugin} > 0 and $plugin->can('entries') ) {
386         if ( my $tmp = $plugin->entries() ) {
387             $entries = $tmp;
388             last;
389         }
390     }
391 }
392
393 my ( $files, $indexes, $others ) = &$entries();
394 %indexes = %$indexes;
395
396 # Static
397 if (    !$ENV{GATEWAY_INTERFACE}
398     and param('-password')
399     and $static_password
400     and param('-password') eq $static_password )
401 {
402
403     param('-quiet') or print "Blosxom is generating static index pages...\n";
404
405     # Home Page and Directory Indexes
406     my %done;
407     foreach my $path ( sort keys %indexes ) {
408         my $p = '';
409         foreach ( ( '', split /\//, $path ) ) {
410             $p .= "/$_";
411             $p =~ s!^/!!;
412             next if $done{$p}++;
413             mkdir "$static_dir/$p", 0755
414                 unless ( -d "$static_dir/$p" or $p =~ /\.$file_extension$/ );
415             foreach $flavour (@static_flavours) {
416                 my $content_type
417                     = ( &$template( $p, 'content_type', $flavour ) );
418                 $content_type =~ s!\n.*!!s;
419                 my $fn = $p =~ m!^(.+)\.$file_extension$! ? $1 : "$p/index";
420                 param('-quiet') or print "$fn.$flavour\n";
421                 my $fh_w = new FileHandle "> $static_dir/$fn.$flavour"
422                     or die "Couldn't open $static_dir/$p for writing: $!";
423                 $output = '';
424                 if ( $indexes{$path} == 1 ) {
425
426                     # category
427                     $path_info = $p;
428
429                     # individual story
430                     $path_info =~ s!\.$file_extension$!\.$flavour!;
431                     print $fh_w &generate( 'static', $path_info, '', $flavour,
432                         $content_type );
433                 }
434                 else {
435
436                     # date
437                     local (
438                         $path_info_yr, $path_info_mo,
439                         $path_info_da, $path_info
440                     ) = split /\//, $p, 4;
441                     unless ( defined $path_info ) { $path_info = "" }
442                     print $fh_w &generate( 'static', '', $p, $flavour,
443                         $content_type );
444                 }
445                 $fh_w->close;
446             }
447         }
448     }
449 }
450
451 # Dynamic
452 else {
453     my $content_type = ( &$template( $path_info, 'content_type', $flavour ) );
454     $content_type =~ s!\n.*!!s;
455
456     $content_type =~ s/(\$\w+(?:::)?\w*)/"defined $1 ? $1 : ''"/gee;
457     $header = { -type => $content_type };
458
459     print generate( 'dynamic', $path_info,
460         "$path_info_yr/$path_info_mo_num/$path_info_da",
461         $flavour, $content_type );
462 }
463
464 # Plugins: End
465 foreach my $plugin (@plugins) {
466     if ( $plugins{$plugin} > 0 and $plugin->can('end') ) {
467         $entries = $plugin->end();
468     }
469 }
470
471 # Generate
472 sub generate {
473     my ( $static_or_dynamic, $currentdir, $date, $flavour, $content_type )
474         = @_;
475
476     %files = %$files;
477     %others = ref $others ? %$others : ();
478
479     # Plugins: Filter
480     foreach my $plugin (@plugins) {
481         if ( $plugins{$plugin} > 0 and $plugin->can('filter') ) {
482             $entries = $plugin->filter( \%files, \%others );
483         }
484     }
485
486     my %f = %files;
487
488     # Plugins: Skip
489     # Allow plugins to decide if we can cut short story generation
490     my $skip;
491     foreach my $plugin (@plugins) {
492         if ( $plugins{$plugin} > 0 and $plugin->can('skip') ) {
493             if ( my $tmp = $plugin->skip() ) {
494                 $skip = $tmp;
495                 last;
496             }
497         }
498     }
499
500     # Define default interpolation subroutine
501     $interpolate = sub {
502
503         package blosxom;
504         my $template = shift;
505         $template =~ s/(\$\w+(?:::)?\w*)/"defined $1 ? $1 : ''"/gee;
506         return $template;
507     };
508
509     unless ( defined($skip) and $skip ) {
510
511         # Plugins: Interpolate
512         # Allow for the first encountered plugin::interpolate subroutine to
513         # override the default built-in interpolate subroutine
514         foreach my $plugin (@plugins) {
515             if ( $plugins{$plugin} > 0 and $plugin->can('interpolate') ) {
516                 if ( my $tmp = $plugin->interpolate() ) {
517                     $interpolate = $tmp;
518                     last;
519                 }
520             }
521         }
522
523         # Head
524         my $head = ( &$template( $currentdir, 'head', $flavour ) );
525
526         # Plugins: Head
527         foreach my $plugin (@plugins) {
528             if ( $plugins{$plugin} > 0 and $plugin->can('head') ) {
529                 $entries = $plugin->head( $currentdir, \$head );
530             }
531         }
532
533         $head = &$interpolate($head);
534
535         $output .= $head;
536
537         # Stories
538         my $curdate = '';
539         my $ne      = $num_entries;
540
541         if ( $currentdir =~ /(.*?)([^\/]+)\.(.+)$/ and $2 ne 'index' ) {
542             $currentdir = "$1$2.$file_extension";
543             %f = ( "$datadir/$currentdir" => $files{"$datadir/$currentdir"} )
544                 if $files{"$datadir/$currentdir"};
545         }
546         else {
547             $currentdir =~ s!/index\..+$!!;
548         }
549
550         # Define a default sort subroutine
551         my $sort = sub {
552             my ($files_ref) = @_;
553             return
554                 sort { $files_ref->{$b} <=> $files_ref->{$a} }
555                 keys %$files_ref;
556         };
557
558      # Plugins: Sort
559      # Allow for the first encountered plugin::sort subroutine to override the
560      # default built-in sort subroutine
561         foreach my $plugin (@plugins) {
562             if ( $plugins{$plugin} > 0 and $plugin->can('sort') ) {
563                 if ( my $tmp = $plugin->sort() ) {
564                     $sort = $tmp;
565                     last;
566                 }
567             }
568         }
569
570         foreach my $path_file ( &$sort( \%f, \%others ) ) {
571             last if $ne <= 0 && $date !~ /\d/;
572             use vars qw/ $path $fn /;
573             ( $path, $fn )
574                 = $path_file =~ m!^$datadir/(?:(.*)/)?(.*)\.$file_extension!;
575
576             # Only stories in the right hierarchy
577             $path =~ /^$currentdir/
578                 or $path_file eq "$datadir/$currentdir"
579                 or next;
580
581             # Prepend a slash for use in templates only if a path exists
582             $path &&= "/$path";
583
584             # Date fiddling for by-{year,month,day} archive views
585             use vars
586                 qw/ $dw $mo $mo_num $da $ti $yr $hr $min $hr12 $ampm $utc_offset/;
587             ( $dw, $mo, $mo_num, $da, $ti, $yr, $utc_offset )
588                 = nice_date( $files{"$path_file"} );
589             ( $hr, $min ) = split /:/, $ti;
590             ( $hr12, $ampm ) = $hr >= 12 ? ( $hr - 12, 'pm' ) : ( $hr, 'am' );
591             $hr12 =~ s/^0//;
592             if ( $hr12 == 0 ) { $hr12 = 12 }
593
594             # Only stories from the right date
595             my ( $path_info_yr, $path_info_mo_num, $path_info_da )
596                 = split /\//, $date;
597             next if $path_info_yr     && $yr != $path_info_yr;
598             last if $path_info_yr     && $yr < $path_info_yr;
599             next if $path_info_mo_num && $mo ne $num2month[$path_info_mo_num];
600             next if $path_info_da     && $da != $path_info_da;
601             last if $path_info_da     && $da < $path_info_da;
602
603             # Date
604             my $date = ( &$template( $path, 'date', $flavour ) );
605
606             # Plugins: Date
607             foreach my $plugin (@plugins) {
608                 if ( $plugins{$plugin} > 0 and $plugin->can('date') ) {
609                     $entries
610                         = $plugin->date( $currentdir, \$date,
611                         $files{$path_file}, $dw, $mo, $mo_num, $da, $ti,
612                         $yr );
613                 }
614             }
615
616             $date = &$interpolate($date);
617
618             if ( $date && $curdate ne $date ) {
619                 $curdate = $date;
620                 $output .= $date;
621             }
622
623             use vars qw/ $title $body $raw /;
624             if ( -f "$path_file" && $fh->open("< $path_file") ) {
625                 chomp( $title = <$fh> );
626                 chomp( $body = join '', <$fh> );
627                 $fh->close;
628                 $raw = "$title\n$body";
629             }
630             my $story = ( &$template( $path, 'story', $flavour ) );
631
632             # Plugins: Story
633             foreach my $plugin (@plugins) {
634                 if ( $plugins{$plugin} > 0 and $plugin->can('story') ) {
635                     $entries = $plugin->story( $path, $fn, \$story, \$title,
636                         \$body );
637                 }
638             }
639
640             if ( $content_type =~ m{\bxml\b} ) {
641
642                 # Escape <, >, and &, and to produce valid RSS
643                 my %escape = (
644                     '<' => '&lt;',
645                     '>' => '&gt;',
646                     '&' => '&amp;',
647                     '"' => '&quot;'
648                 );
649                 my $escape_re = join '|' => keys %escape;
650                 $title =~ s/($escape_re)/$escape{$1}/g;
651                 $body  =~ s/($escape_re)/$escape{$1}/g;
652             }
653
654             $story = &$interpolate($story);
655
656             $output .= $story;
657             $fh->close;
658
659             $ne--;
660         }
661
662         # Foot
663         my $foot = ( &$template( $currentdir, 'foot', $flavour ) );
664
665         # Plugins: Foot
666         foreach my $plugin (@plugins) {
667             if ( $plugins{$plugin} > 0 and $plugin->can('foot') ) {
668                 $entries = $plugin->foot( $currentdir, \$foot );
669             }
670         }
671
672         $foot = &$interpolate($foot);
673         $output .= $foot;
674
675         # Plugins: Last
676         foreach my $plugin (@plugins) {
677             if ( $plugins{$plugin} > 0 and $plugin->can('last') ) {
678                 $entries = $plugin->last();
679             }
680         }
681
682     }    # End skip
683
684     # Finally, add the header, if any and running dynamically
685     $output = header($header) . $output
686         if ( $static_or_dynamic eq 'dynamic' and $header );
687
688     $output;
689 }
690
691 sub nice_date {
692     my ($unixtime) = @_;
693
694     my $c_time = CORE::localtime($unixtime);
695     my ( $dw, $mo, $da, $hr, $min, $yr )
696         = ( $c_time
697             =~ /(\w{3}) +(\w{3}) +(\d{1,2}) +(\d{2}):(\d{2}):\d{2} +(\d{4})$/
698         );
699     $ti = "$hr:$min";
700     $da = sprintf( "%02d", $da );
701     my $mo_num = $month2num{$mo};
702
703     my $offset
704         = timegm( 00, $min, $hr, $da, $mo_num - 1, $yr - 1900 ) - $unixtime;
705     my $utc_offset = sprintf( "%+03d", int( $offset / 3600 ) )
706         . sprintf( "%02d", ( $offset % 3600 ) / 60 );
707
708     return ( $dw, $mo, $mo_num, $da, $ti, $yr, $utc_offset );
709 }
710
711 # Default HTML and RSS template bits
712 __DATA__
713 html content_type text/html; charset=$blog_encoding
714
715 html head <html>
716 html head     <head>
717 html head         <meta http-equiv="content-type" content="text/html;charset=$blog_encoding" />
718 html head         <link rel="alternate" type="type="application/rss+xml" title="RSS" href="$url/index.rss" />
719 html head         <title>$blog_title $path_info_da $path_info_mo $path_info_yr
720 html head         </title>
721 html head     </head>
722 html head     <body>
723 html head         <center>
724 html head             <font size="+3">$blog_title</font><br />
725 html head             $path_info_da $path_info_mo $path_info_yr
726 html head         </center>
727 html head         <p />
728
729 html story        <p>
730 html story            <a name="$fn"><b>$title</b></a><br />
731 html story            $body<br />
732 html story            <br />
733 html story            posted at: $ti | path: <a href="$url$path">$path </a> | <a href="$url/$yr/$mo_num/$da#$fn">permanent link to this entry</a>
734 html story        </p>
735
736 html date         <h3>$dw, $da $mo $yr</h3>
737
738 html foot
739 html foot         <p />
740 html foot         <center>
741 html foot             <a href="http://blosxom.sourceforge.net/"><img src="http://blosxom.sourceforge.net/images/pb_blosxom.gif" border="0" /></a>
742 html foot         </center>
743 html foot     </body>
744 html foot </html>
745
746 rss content_type text/xml; charset=$blog_encoding
747
748 rss head <?xml version="1.0" encoding="$blog_encoding"?>
749 rss head <rss version="2.0">
750 rss head   <channel>
751 rss head     <title>$blog_title</title>
752 rss head     <link>$url/$path_info</link>
753 rss head     <description>$blog_description</description>
754 rss head     <language>$blog_language</language>
755 rss head     <docs>http://blogs.law.harvard.edu/tech/rss</docs>
756 rss head     <generator>blosxom/$version</generator>
757
758 rss story   <item>
759 rss story     <title>$title</title>
760 rss story     <pubDate>$dw, $da $mo $yr $ti:00 $utc_offset</pubDate>
761 rss story     <link>$url/$yr/$mo_num/$da#$fn</link>
762 rss story     <category>$path</category>
763 rss story     <guid isPermaLink="false">$path/$fn</guid>
764 rss story     <description>$body</description>
765 rss story   </item>
766
767 rss date 
768
769 rss foot   </channel>
770 rss foot </rss>
771
772 error content_type text/html
773
774 error head <html>
775 error head <body>
776 error head     <p><font color="red">Error: I'm afraid this is the first I've heard of a "$flavour" flavoured Blosxom.  Try dropping the "/+$flavour" bit from the end of the URL.</font></p>
777
778
779 error story <p><b>$title</b><br />
780 error story $body <a href="$url/$yr/$mo_num/$da#fn.$default_flavour">#</a></p>
781
782 error date <h3>$dw, $da $mo $yr</h3>
783
784 error foot     </body>
785 error foot </html>
786 __END__
787