Blog-Simple-HTMLOnly

 view release on metacpan or  search on metacpan

blog.cgi  view on Meta::CPAN

#!/usr/bin/perl

=head1 NAME

blog.cgi - simple blog example

=head1 USE

	blog.cgi        			- display the current blog
	blog.cgi?x      			- where 'x' is anything: add a blog
	blog.cgi?all=1&author=y     - display all the blogs of author 'y'
	blog.cgi?date=x&author=y	- where 'x' and 'y' are a timestamp
								  and an author name: shows that blog
	 ...&template=false         - do not use the template

If the template is used, it should be HTML with a comment <!-- insert ---> where
the calendar is to go.

Copyright (C) 2003, Lee Goddard (lgoddard -at- cpan -dot- org)
All Rights Reserved. Available under the same terms as Perl.

=cut

my $VERSION = 0.3;

use CGI::Carp qw(fatalsToBrowser);
use strict;
use Blog::Simple::HTMLOnly;
use HTML::Calendar::Simple;
use CGI 2.47 qw/:standard/;
use Cwd;

my $PASSWORD 		= 'password!';
my $TEMPLATE_PATH	= $^O =~ /win/i? 'D:/www/leegoddard_net/blank.html' : "/home/leeg1644/public_html/blank.html";
my $BLOG_DIR		= $^O =~ /win/i? 'D:/www/leegoddard_net/.blog/' : "/home/leeg1644/private_data/Lee_Blog";
my $CGI 	= CGI->new;
my $TITLE   = 'Moaning&nbsp;and Groaing at the Edge of ...';
my $FORMAT = {
	simple_blog_wrap => '<div class="blogs">',
	simple_blog => '<div class="blog">',
	title       => '<h3>',
	author      => '<span style="display:none">',
	email       => '<span style="display:none">',
	ts          => '<div class="ts">',
	summary     => '<div class="summary">',
	content     => '<div class="content">',
};

my ($TEMPLATE_TOP, $TEMPLATE_BOTTOM);
my $BLOGGER = Blog::Simple::HTMLOnly->new($BLOG_DIR);

$CGI->param('author' => 'Lee');

if (!-e $BLOGGER->{blog_idx}){
	$BLOGGER->create_index();
	$BLOGGER->add(
		"Blogging...",
		$CGI->param('author'),
		'code@leegoddard.com',
		'Started to blog',
		"<p>This is the first blog using <code>Blog::Simple</code> from CPAN.</p>"
	);
}

if ($CGI->param('template') and $CGI->param('template') eq 'false'){
	print $CGI->header;
	$ENV{QUERY_STRING} =~ s/template=false;?//g;
} else {
	&print_header
}

if ($ENV{QUERY_STRING}){
	my $n;
	if ($CGI->param('all') or $ENV{QUERY_STRING} eq 'all'){
		$BLOGGER->render_all($FORMAT);
	}



( run in 1.232 second using v1.01-cache-2.11-cpan-71847e10f99 )