#!/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",<First post! First post!

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!
Your name:
Your address/home page:

Your rant:

'; END; MACRO permalink(entry, params) BLOCK; bryar.config.baseurl; IF bryar.arguments.subblog; '/' _ bryar.arguments.subblog; END; entry.url; "?" _ params IF params; END; MACRO comments(entry) BLOCK; ''; entry.comments.size || 0; " Comments"; IF bryar.arguments.comments; "

"; FOREACH comment = entry.comments; '
'; comment.content; '

'; 'Posted by '; comment.author; ' at '; day(comment.timepiece); ' '; comment.timepiece.time; '
'; '
'; END; comment_form(entry); "

"; 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') %]

Error 404: the requested page does not exist!

[% END %] [% FOREACH entry = documents; entry_time = entry.timepiece; IF entry == documents.first or entry_time.ymd != previous.timepiece.ymd %]
[% day(entry_time) %]
[% END %] [% previous = entry %]

[% entry.title | html %]

[% entry.content %]
Posted at [% entry_time.time %] by [% bryar.config.author | html %]
[% END %] [% IF NOT bryar.arguments.id AND NOT bryar.arguments.since AND documents.last.id != 1 %]

Older posts

[% END %] [% INCLUDE foot.html %] EOC write_file("head.html", < [% IF http_error == '404' %] Error 404: The requested page does not exist! [% ELSIF bryar.arguments.id %] [% documents.first.title | html %] [% ELSE %] [% bryar.config.name | html %] [% END %]

[% bryar.config.name | html %]

EOC write_file("foot.html", < Powered by Bryar!
Search "[% bryar.config.name | html %]":

Subscribe to full text feeds via: ATOM | RSS2 | RSS
Subscribe to preview feeds via: ATOM | RSS2 | RSS
[Valid Atom] EOC write_file("template.rss", < [% bryar.config.name | html %] [% bryar.config.baseurl %]/ [% bryar.config.description | html %] [% bryar.config.author || item.author | html %] en-us [% datetimetz(documents.first.datetime) %] [% IF 0 %] daily 1 2000-01-01T12:00+00:00 [% END %] [% FOREACH item=documents %] [% END %] [% FOREACH item = documents %] [% item.title | html %] [% permalink(item) %] [% item.content | html %] [% datetimetz(item.datetime) %] [% bryar.config.author || item.author | html %] [% END %] EOC write_file("template.rss2", < [% bryar.config.name | html %] [% bryar.config.baseurl %] [% bryar.config.description | html %] en-us [%documents.first.timepiece.datetime%]-05:00 [% FOREACH item=documents %] [% END %] EOC write_file("template.atom", < [% bryar.config.name | html %] [% bryar.config.description | html %] [% bryar.config.baseurl %]/?format=atom [% datetimetz(documents.first.datetime) %] [% bryar.config.author | html %] [% bryar.config.baseurl %]/ Bryar [% FOREACH item = documents %] [% item.title | html %] [% idURL = bryar.config.baseurl | replace('http://', '') | replace('/.*', '') %] tag:[% idURL _ "," _ item.timepiece.year _ ":id_" _ item.id %] [% datetimetz(item.datetime) %] [% datetimetz(item.datetime) %] [#% [% FILTER truncate(252) %] [% item.excerpt(bryar.config.excerpt_words) %] [% END %] %] [% END %] EOC write_file("calendar.tt2", < S M T W T F S [% FOREACH week = bryar.posts_calendar.calendar %] [% FOREACH day = week %] [% '' IF day.link%] [% day.day || ' ' %][% '' IF day.link %] [% END %] [% END %] EOC chmod 0644, $_ for ("bryar.conf", "1.txt", "head.html", "foot.html", "template.html","template.rss", "template.atom", "calendar.tt2", "blogmacros.tt2"); print "\nDone. Now you want to probably customize 'bryar.conf'.\n"; print "You should probably also customize template.html, head.html and foot.html\n"; print "Then point your browser at bryar.cgi, and get blogging!\n";