From e24ee07d2bed5982c07b91d3586ea54158a418b7 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 5 Sep 2012 18:45:13 +0000 Subject: html5 theme --- Blogsum/Config.pm.dist | 5 +++-- admin.cgi | 1 + index.cgi | 17 ++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Blogsum/Config.pm.dist b/Blogsum/Config.pm.dist index fb4cf6e..493b12b 100644 --- a/Blogsum/Config.pm.dist +++ b/Blogsum/Config.pm.dist @@ -15,13 +15,14 @@ use strict; # user options # ########################### our $database = 'data/site.db'; -our $blog_theme = 'default'; +our $blog_theme = 'html5'; our $blog_title = 'example.com'; our $blog_subtitle = 'My New Blog'; our $blog_url = 'http://www.example.com/'; our $blog_owner = 'user@example.com'; -our $blog_rights = 'Copyright 2009, Example User'; +our $blog_rights = 'Copyright © 2012 Example User'; our $feed_updates = 'hourly'; +our $captcha_api_server = 'http://www.google.com/recaptcha/api'; our $captcha_pubkey = ''; our $captcha_seckey = ''; our $comment_max_length = '1000'; diff --git a/admin.cgi b/admin.cgi index 21de7c0..e8e92cb 100755 --- a/admin.cgi +++ b/admin.cgi @@ -43,6 +43,7 @@ my $blog_title = $Blogsum::Config::blog_title; # main execution # ########################### my $cgi = CGI->new; +$cgi->charset('UTF-8'); my $dbh = DBI->connect("DBI:SQLite:dbname=$database", '', '', { RaiseError => 1 }) || die $DBI::errstr; my $template = HTML::Template->new(filename => "themes/${blog_theme}/admin.tmpl", die_on_bad_params => 0); $template->param( theme => $blog_theme ); diff --git a/index.cgi b/index.cgi index 9c2321c..28a0737 100755 --- a/index.cgi +++ b/index.cgi @@ -43,6 +43,7 @@ $blog_url .= '/' unless ($blog_url =~ /^.*\/$/); my $blog_owner = $Blogsum::Config::blog_owner; my $blog_rights = $Blogsum::Config::blog_rights; my $feed_updates = $Blogsum::Config::feed_updates; +my $captcha_api_server = $Blogsum::Config::captcha_api_server; my $captcha_pubkey = $Blogsum::Config::captcha_pubkey; my $captcha_seckey = $Blogsum::Config::captcha_seckey; my $comment_max_length = $Blogsum::Config::comment_max_length; @@ -61,6 +62,7 @@ $page_not_found_error ||= '404 page not found'; # main execution # ########################### my $cgi = CGI->new; +$cgi->charset('UTF-8'); my $dbh = DBI->connect("DBI:SQLite:dbname=$database", '', '', { RaiseError => 1 }) || die $DBI::errstr; my $template = HTML::Template->new(filename => "themes/${blog_theme}/index.tmpl", die_on_bad_params => 0); if ($cgi->param('rss')) { @@ -70,6 +72,7 @@ if ($cgi->param('rss')) { my $articles = get_articles(); my $archives = get_archives(); my $tagcloud = get_tag_cloud(); + my @status = (); $template->param( archives => $archives ); $template->param( tagcloud => $tagcloud ); $template->param( theme => $blog_theme ); @@ -88,8 +91,9 @@ if ($cgi->param('rss')) { } } else { $template->param( error => $page_not_found_error ); + @status = ( -status => '404 Not Found' ); } - print $cgi->header(), $template->output; + print $cgi->header(@status), $template->output; } $dbh->disconnect; @@ -269,10 +273,7 @@ sub get_archives { while (my $result = $sth->fetchrow_hashref) { $result->{'date'} =~ /(\d{4})\-(\d{2})\-\d{2} \d{2}\:\d{2}\:\d{2}/; ($result->{'year'}, $result->{'month'}) = ($1, $2); - my $title = my $full_title = $result->{'title'}; - if (length($title) > 28) { - $title = substr($title, 0, 25) . '...'; - } + my $title = $result->{'title'}; if (($result->{'year'} eq $current_year) && ($result->{'month'} eq $current_month) && $result->{'uri'}) { push(@{$history{$result->{'year'}}{$result->{'month'}}->{'uri_loop'}}, @@ -281,7 +282,6 @@ sub get_archives { month => $result->{'month'}, month_name => $months{$result->{'month'}}, title => $title, - full_title => $full_title, uri => $result->{'uri'}, } ); @@ -343,13 +343,12 @@ sub read_comment { if ($result->{'success'}) { # save comment - my $comment = HTML::Entities::encode($cgi->param('comment')); my $stmt = "INSERT INTO comments VALUES (NULL, ?, datetime('now', 'localtime'), ?, ?, ?, ?, 0)"; my $sth = $dbh->prepare($stmt); my $comment_name = $cgi->param('name') ? substr($cgi->param('name'), 0, 100) : 'anonymous'; my $comment_email = $cgi->param('email') ? substr($cgi->param('email'), 0, 100) : undef; my $comment_url = $cgi->param('url') ? substr($cgi->param('url'), 0, 100) : undef; - my $comment_body = substr(HTML::Entities::encode($cgi->param('comment')), 0, $comment_max_length); + my $comment_body = substr(HTML::Entities::encode($cgi->param('comment'), "<>&"), 0, $comment_max_length); $sth->execute($cgi->param('id'), $comment_name, $comment_email, $comment_url, $comment_body) || die $dbh->errstr; $template->param( message => 'comment awaiting moderation, thank you' ); @@ -386,7 +385,7 @@ sub read_comment { } # present the challenge - $template->param( captcha_api_server => 'http://api.recaptcha.net', captcha_pubkey => $captcha_pubkey ); + $template->param( captcha_api_server => $captcha_api_server, captcha_pubkey => $captcha_pubkey ); } sub verify_captcha { -- cgit v1.2.3