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