Apache-Blog

 view release on metacpan or  search on metacpan

Blog.pm  view on Meta::CPAN

		} # end mkdir
	} # end no directory

	# need a filename. we start at 1 and move upwards. there's
	# almost certainly a race condition here, but this is written
	# for my site where i get about one comment a week. if yours is
	# so busy you're worried about this breaking, then feel free to
	# fix it.
	my @existing_files = glob("$comment_dir/*");
	my $new_basename = scalar(@existing_files) + 1;

	open (COMMENT, ">$comment_dir/$new_basename");
	print COMMENT "$name\n";
	print COMMENT scalar(localtime)."\n";
	print COMMENT $comment;
	close COMMENT;

	# not quite sure what this will do if the user is being a bitch
	# and have proxied away the referer header. this could be
	# construed as a bug.
	$r->header_out( 'Location' => $r->header_in( 'Referer' ));

	return 302;
} # end handle_comment


1;

__END__

=head1 NAME

Apache::Blog - mod_perl weblog handler

=head1 SYNOPSIS

In httpd.conf

  Alias /blog/ /home/daniel/blog/
  <Location /blog>
    SetHandler perl-script
    PerlHandler +Apache::Blog
  </Location>

=head1 DESCRIPTION

Apache::Blog is a simple handler for online diaries. At the moment it
works on the one-entry-one-page paradigm, but would be easy to apapt to
multiple entries per page if this is prefered. In the future this will
be a configuration option.

It is inspired by the service offered at http://www.diaryland.com/

It uses HTML::Template, so it is easy to design new layouts. There are
some samples included with the distribution.

All diary entries are stored as plain text files, there's no database
stuff going on here. This is to make it simple to add entries - any
editor can be used to write entries.

To use, decide on a directory which is to hold your weblog entries,
and set PerlHandler like in the example. The alias isn't nessasary,
but I like it that way.

Also in that directory need to be two template files, one called
entry-template.html, and one called older.html.

Entries take the format:

  Short Title
  Thu Jun 20 17:24:52 BST 2002

  The entry down here.

The date can be in any format that Date::Manip likes. In vim I do :r!date
to add the date line.

Apache::Blog does some simple manipulation on the text. It will turn
lines which start with a * into bullet lists, and blank lines are turned
into <p> tags. You can also *bold* text. It doesn't highlight links or
anything. A more sophisticated text->html converter may be included in
the future.

The module can also allow comments on entries, for this to work properly
the webserver must have write access to the directory containing your
entries.

Entry filenames can be anything you like, as long as it doesn't end in
.html or start with a period. I generally go with filenames like "2002-06-20"

See the sample layouts, especially the "simple" layout, to see how to
create your own.

Someone should write a blogger -> Apache::Blog template converter, one
for diaryland templates as well. Best way to do that would probably be
an HTML::Template filter so it's transparent. There's a lot of templates
for the different services out there so that's probably a good itch to
get scratched.

=head1 AUTHOR

Daniel Gardner <daniel@danielgardner.org>

=head1 SEE ALSO

HTML::Template, Date::Manip

=cut



( run in 0.671 second using v1.01-cache-2.11-cpan-39bf76dae61 )