#!/usr/bin/perl
use Cwd;
use Config;
print "Setting up a Bryar blog in this directory\n\n";
sub write_file {
my ($name, $content) = @_;
open OUT, ">".$name or die "Couldn't write to $name - $!\n";
print OUT $content;
close OUT;
}
# These are defaults which are written out to be customized, so I don't
# feel bad about including them here inline.
# Blatant assumption of standard Unix
write_file("bryar.cgi", "#!/usr/bin/perl\nuse Bryar; Bryar->go()\n");
chmod 0755, "bryar.cgi";
write_file("bryar.conf",<
Wow, this Bryar thing is neat, huh? This space should fill up with helpful hints on what else you can do with Bryar.
EOC write_file("blogmacros.tt2", <<'EOC'); # Accepts a DateTime object and returns a date string suitable for ATOM feeds # (i.e. in the format specified by ISO 8601). MACRO datetimetz(time) BLOCK; SET tz = time.strftime('%z'); SET tz = tz.replace('(\d{2})$', ':$1'); SET tz = 'Z' IF tz == '+00:00'; time.datetime _ tz; END; # Accepts a DateTime object and returns a date string suitable for email Date # headers (i.e. in the format specified by RFC 822). MACRO datetime822(time) GET time.strftime('%a, %d %b %Y %H:%M:%S %z'); [% MACRO day(entry_time) BLOCK; entry_time.day _ ", " _ entry_time.mday _ " " _ entry_time.month _ " " _ entry_time.year; END; MACRO category(entry) BLOCK; "Category : " _ entry.category; END; MACRO author(entry) BLOCK; "Author : " _ entry.author; END; MACRO comment_form(entry) BLOCK; 'Post a new comment!"; END; END; MACRO google_link(query, label) BLOCK; ''; label; ""; END; MACRO keywords(entry) BLOCK; "Keywords :"; FOREACH key = entry.keywords.slice(0,2); '[ '; google_link(key, key); '] '; END; END; %] EOC write_file("template.html", <<'EOC'); [% PROCESS blogmacros.tt2 %] [% INCLUDE head.html %] [% IF bryar.http_headers.Status.match('^404') %]
