Bryar
view release on metacpan or search on metacpan
bryar-newblog view on Meta::CPAN
#!/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",<<EOC);
name : My Bryar Weblog!
description : A blog without a more useful description
baseurl : http://where.will.i.be/
datadir : @{[ cwd() ]}
author : your name here
email : me\@example.com
EOC
write_file("bryar_first_post.txt", <<EOC);
My first Bryar blog post!
<p>First post! First post!</p>
<p>Wow, this Bryar thing is neat, huh? This space should fill up with helpful
hints on what else you can do with Bryar.</p>
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!
<DIV class="comment">
<FORM METHOD="POST">
Your name: <INPUT NAME="author"><BR>
Your address/home page: <INPUT NAME="url"><BR>
<HR WIDTH="98%">
Your rant:<BR>
<textarea NAME="content" COLS=80 ROWS=7></textarea>
<BR>
<INPUT TYPE="submit" VALUE="Vent">
<INPUT TYPE="hidden" NAME="id" VALUE="'; entry.id;
'"><INPUT TYPE="hidden" NAME="newcomment" VALUE="1">
bryar-newblog view on Meta::CPAN
<link rel="self" type="application/atom+xml" title="ATOM"
href="[% bryar.config.baseurl %]/?format=atom"/>
<updated>[% datetimetz(documents.first.datetime) %]</updated>
<author>
<name>[% bryar.config.author | html %]</name>
<uri>[% bryar.config.baseurl %]/</uri>
</author>
<generator uri="http://search.cpan.org/dist/Bryar/" version="3.0">Bryar</generator>
[% FOREACH item = documents %]
<entry>
<title>[% item.title | html %]</title>
<link rel="alternate" type="text/html"
href="[% permalink(item) %]"/>
[% idURL = bryar.config.baseurl | replace('http://', '') | replace('/.*', '') %]
<id>tag:[% idURL _ "," _ item.timepiece.year _ ":id_" _ item.id %]</id>
<published>[% datetimetz(item.datetime) %]</published>
<updated>[% datetimetz(item.datetime) %]</updated>
[#%
<summary type="text">[% FILTER truncate(252) %]
[% item.excerpt(bryar.config.excerpt_words) %]
[% END %]
</summary>
%]
<content type="html" xml:lang="en" xml:base="[% bryar.config.baseurl %]/">
<![CDATA[[% item.content %]]]>
</content>
</entry>
[% END %]
</feed>
EOC
write_file("calendar.tt2", <<EOC);
<table class="calendar">
<thead>
<tr class="days">
<th abbr='Sunday' scope='col' title='Sunday'>S</th>
<th abbr='Monday' scope='col' title='Monday'>M</th>
<th abbr='Tuesday' scope='col' title='Tuesday'>T</th>
<th abbr='Wednesday' scope='col' title='Wednesday'>W</th>
<th abbr='Thursday' scope='col' title='Thursday'>T</th>
<th abbr='Friday' scope='col' title='Friday'>F</th>
<th abbr='Saturday' scope='col' title='Saturday'>S</th>
</tr>
</thead>
<tbody>
[% FOREACH week = bryar.posts_calendar.calendar %]
<tr>
[% FOREACH day = week %]
<td[% IF day.sunday %] class="sunday"[% END %]>
[% '<a href="' _ bryar.config.baseurl _ '/' _ day.link _ '">' IF day.link%]
[% day.day || ' ' %][% '</a>' IF day.link %]</td>
[% END %]
</tr>
[% END %]
</tbody>
</table>
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";
( run in 1.787 second using v1.01-cache-2.11-cpan-ceb78f64989 )