Bryar
    
    
  
  
  
view release on metacpan or search on metacpan
Revision history for Perl extension Bryar.
4.0 - 2009-10-25
    - First release by new maintainer Marco d'Itri.
    - Fixed and improved the calendar template.
    - Removed debugging statements from posts_calendar().
    - Added support for FastCGI using CGI::Fast.
    - Use croak instead of exit in report_error() or FastCGI processes will die.
    - Made report_error() return status 500.
    - HTML-escape the text output by report_error().
    - Added a Renderer class which generates a Google sitemap using
      WWW::Google::SiteMap.
    - Use Template::Provider::Encoding to support non-ASCII posts.
    - Moved the Template Toolkit macros to a common file.
    - Added the ".tt2" extension to the calendar template.
    - Added macros to print DateTime objects as ISO 8601 and RFC 822 strings.
    - Updated the ATOM template to the 1.0 format.
    - Added a Bryar::Document::url() method useful in templates to get the
      relative URL of posts.
    - Fixed the permalinks when categories are used.
    - Added support to generate arbitrary HTTP headers. Templates can modify
      them by manipulating the bryar.http_headers hash.
    - Added support for caching the formatted pages using Cache::Cache.
    - Return a 404 error when no posts matching the parameters are available.
    - Treat all input and output streams as UTF-8.
2.5 - Sun Feb  8 21:26:16 GMT 2004
    - Emergency release - unbreak comments.
2.4 - Sun Feb  8 15:12:21 GMT 2004
    - Get default MIME types right
    - Refactor FlatFile to allow selecting post extensions, etc.
2.3 - Fri Jan 23 13:21:18 GMT 2004
    - Added ETag support from Marco d'Itri
    - Added calendars, again from Marco d'Itri
2.2 - Fri Jan 23 12:57:18 GMT 2004
    - Added the dummy files that *really* allow a runthrough without
      mod_perl
    - Added support for Atom, made this generic by allowing you to register
      your own formats and skins.
    - Added an Atom template, thanks to Steve Peters
2.1 - Thu Dec 11 13:55:09 GMT 2003
    - Bryar::DataSource::Base now returns a true value, which is always
    Creates a new Bryar instance. You probably don't need to use this unless
    you're programming your blog to do clever stuff. Use "go" instead.
  go
        $self->go()
        Bryar->go(%params)
    Does all the work of producing the blog. For parameters you might be
    interested in setting, see "Bryar::Config".
  posts_calendar
    TODO: Move this out to something that is more flexible.
    Return a data structure containing the days and weeks of a given month
    and year with blog posts attached. See the "calendar" template for an
    example.
  config
    Returns the Bryar::Config object for this blog. This is useful as the
    blog object is passed into the templates by default.
LICENSE
    This module is free software, and may be distributed under the same
    terms as Perl itself.
THANKS
    Steve Peters provided Atom support. Marco d'Itri contributed the
    calendar, HTTP validators, caching, FastCGI, sitemaps, non-ASCII
    charsets, bug fixes and optimizations.
AUTHOR
    Copyright (C) 2003, Simon Cozens "simon@cpan.org"
    some parts Copyright 2007 David Cantrell "david@cantrell.org.uk"
    some parts Copyright 2009 Marco d'Itri "md@linux.it"
bryar-newblog view on Meta::CPAN
    </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";
lib/Bryar.pm view on Meta::CPAN
# create the key used to index the cache
sub cache_key {
    my $self = shift;
    return 'Bryar: ' . join(' | ', map {
        $_ . ' => ' . $self->{arguments}->{$_}
    } sort keys %{$self->{arguments}});
}
=head2 posts_calendar
TODO:  Move this out to something that is more flexible.
Return a data structure containing the days and weeks of a given month and
year with blog posts attached. See the C<calendar> template for an example.
=cut
sub posts_calendar {
	my ($self, $month, $year) = @_;
    my $today = DateTime->today( time_zone => $self->config->{time_zone} );
	$month ||= $today->month(); 
	$year  ||= $today->year(); 
	my $this_month = DateTime->new( month => $month, year => $year,  time_zone => $self->config->{time_zone} );
	my @documents = $self->config->collector->collect(
		$self->config,
		since => $this_month->epoch()
	);
	# make an hash with keys the days with a post
	my %posts = map { DateTime->from_epoch( epoch => $_->{epoch},  time_zone => $self->config->{time_zone} )->day() => $_->{id} } @documents;
	my @m = calendar($month, $year);
	my @month;
	foreach my $week (@m) {
		my @weekdays;
		foreach my $day (@$week) {
			my $d = { day => $day };
			if ($day and exists $posts{$day}) {
				$d->{idlink} = $posts{$day};
				$d->{link} = "$year/" . $this_month->month_abbr() . "/$day";
			}
			push(@weekdays, $d);
		}
		# mark the first day of the week, if it exists
		$weekdays[0]{sunday} = 1 if defined $weekdays[0]{day};
		push(@month, \@weekdays);
	}
	return { year => $year, month => $month, monthname => $this_month->month_name(), calendar => \@month };
}
=head2 config
Returns the L<Bryar::Config|Bryar::Config> object for this blog. This is
useful as the blog object is passed into the templates by default.
=cut
sub config { return $_[0]->{config} }
sub arguments {return $_[0]->{arguments} }
=head1 LICENSE
This module is free software, and may be distributed under the same
terms as Perl itself.
=head1 THANKS
Steve Peters provided Atom support.
Marco d'Itri contributed the calendar, HTTP validators, caching, FastCGI,
sitemaps, non-ASCII charsets, bug fixes and optimizations.
=head1 AUTHOR
Copyright (C) 2003, Simon Cozens C<simon@cpan.org>
some parts Copyright 2007 David Cantrell C<david@cantrell.org.uk>
some parts Copyright 2009 Marco d'Itri C<md@linux.it>
( run in 0.474 second using v1.01-cache-2.11-cpan-c333fce770f )