summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-09-05 18:34:48 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-09-05 18:34:48 +0000
commitacb38afcd4780191569ee809f3e8bdb550a634bc (patch)
treed54e4354f5758ee547c14c04bed307c5a473c854 /examples
blogsum
Diffstat (limited to 'examples')
-rw-r--r--examples/create_sqlite.sql36
-rw-r--r--examples/httpd-blogsum.conf50
-rw-r--r--examples/httpd2-blogsum.conf49
-rwxr-xr-xexamples/wp2blogsum.pl75
4 files changed, 210 insertions, 0 deletions
diff --git a/examples/create_sqlite.sql b/examples/create_sqlite.sql
new file mode 100644
index 0000000..8bc8850
--- /dev/null
+++ b/examples/create_sqlite.sql
@@ -0,0 +1,36 @@
+BEGIN TRANSACTION;
+CREATE TABLE articles (id integer primary key, date date, title text, uri text, body text, tags text, enabled boolean, author text);
+INSERT INTO "articles" VALUES(1,'2009-11-16 18:07:10','Welcome to Blogsum','Welcome-to-Blogsum','<h3>Introduction</h3>
+
+<p>Blogsum is a very basic blogging application. It was written from scratch with a focus on simplicity and security, favoring practicality over feature bloat.</p>
+
+<h3>Writing Articles</h3>
+
+<p>The Administration interface is straightforward and bereft of unnecessary features. Three views allow you to <a href="/admin.cgi?view=edit">create</a> posts, <a href="/admin.cgi?view=moderate">moderate</a> comments and <a href="/admin.cgi">administrate</a> (manage posts). Blogsum uses HTML markup for article formatting. New articles are saved as a <em>draft</em> <img align="absmiddle" src="/themes/default/images/draft.gif">.</p>
+
+<p>There''s one other useful thing to remember about editing your articles. If you have a lengthy post you might want to split it up with the <b><tt>&lt;!--readmore--&gt;</tt></b> tag. Anything that appears after this HTML comment will appear in the full article view, but will be hidden from your blog''s front page. Here comes one now...</p>
+
+<!--readmore-->
+
+<h3>Managing Articles</h3>
+
+<p>As mentioned above, new articles are saved as a draft. Click the <em>publish</em> <img align="absmiddle" src="/themes/default/images/play.gif"> button to see your post go live. You can make <em>edits</em> <img align="absmiddle" src="/themes/default/images/plus.gif"> to a live article, but the timestamp won''t be updated unless you re-draft and re-publish the story. If you decide that you really want to remove an article from the administrate view, you can <em>delete</em> <img align="absmiddle" src="/themes/default/images/delete.gif"> it.</p>
+
+<h3>Comments and Moderation</h3>
+
+<p>Article comments are moderated and must be accompanied with a successful Captcha challenge. All user input is encoded to avoid XSS issues. Click on the <em>moderate</em> view to <em>approve</em> <img align="absmiddle" src="/themes/default/images/check.gif"> or <em>deny</em> <img align="absmiddle" src="/themes/default/images/delete.gif"> a comment submission.</p>
+
+<h3>Using Tags</h3>
+
+<p>Tags are used liberally throughout Blogsum. Besides the tags defined in an article, Blogsum also uses the <tt>/Tags/</tt> path to search for authors. It also favors the use of tags as a conventional replacement to <em>categories</em>. Anyone can use the <tt>/Tags/</tt> path to search for articles in Blogsum (<a href="/Tags/jdixon">example</a>).</p>
+
+<h3>Themes</h3>
+
+<p>Blogsum includes a default theme (what you''re viewing now). If you wish to modify it according to your tastes, you should create your own theme. To create a theme, copy the <tt>themes/default</tt> directory to your own directory (e.g. <tt>themes/foobar</tt>) and modify accordingly. Changes can be made to any of the files in a theme, but the path and filenames should not change. When you are finished, edit the <tt>$blog_theme</tt> setting in <tt>Blogsum/Config.pm</tt> and restart your webserver.</p>
+
+<h3>Go Forth and Blog!</h3>
+
+<p>As you can see, Blogsum is a very simple application designed for <b><em>less maintenance, more writing</em></b>. We hope you enjoy publishing your works within Blogsum. If you create your own themes, please consider donating those back to the <a href="http://blogsum.obfuscurity.com/">project</a>. Enjoy!</p>
+','Blogsum,Welcome',1,'jdixon');
+CREATE TABLE comments (id integer primary key, article_id integer, date date, name text, email text, url text, comment text, enabled boolean);
+COMMIT;
diff --git a/examples/httpd-blogsum.conf b/examples/httpd-blogsum.conf
new file mode 100644
index 0000000..f7f669c
--- /dev/null
+++ b/examples/httpd-blogsum.conf
@@ -0,0 +1,50 @@
+<VirtualHost *:80>
+ ServerName www.example.com
+ DocumentRoot /var/www/blogsum
+ DirectoryIndex index.cgi
+
+ Options +FollowSymlinks
+ RewriteEngine On
+ RewriteRule ^/rss.xml$ /index.cgi?rss=1 [PT,QSA]
+ RewriteRule ^/rss2.xml$ /index.cgi?rss=2 [PT,QSA]
+ RewriteRule ^/Page/([^/]+)$ /index.cgi?page=$1 [PT,QSA]
+ RewriteRule ^/Tags/([^/]+)$ /index.cgi?search=$1 [PT,QSA]
+ RewriteRule ^/([0-9]{4})/([0-9]{2})/([^/]+)$ /index.cgi?view=article&year=$1&month=$2&uri=$3 [PT,QSA]
+ RewriteRule ^/([0-9]{4})/([0-9]{2})/?$ /index.cgi?view=article&year=$1&month=$2 [PT,QSA]
+ RewriteRule ^/([0-9]{4})/?$ /index.cgi?view=article&year=$1 [PT,QSA]
+
+ PerlModule Apache::PerlRun
+ <LocationMatch ^/index.cgi>
+ SetHandler perl-script
+ PerlHandler Apache::PerlRun
+ PerlRequire /var/www/blogsum/startup.pl
+ Options ExecCGI
+ Order deny,allow
+ Allow from all
+ </LocationMatch>
+ <LocationMatch ^/admin.cgi>
+ SetHandler perl-script
+ PerlHandler Apache::PerlRun
+ PerlRequire /var/www/blogsum/startup.pl
+ Options ExecCGI
+ Order deny,allow
+ Allow from all
+ AuthUserFile /var/www/conf/blogsum.htpasswd
+ AuthName "Blogsum Admin - example.com"
+ AuthType Basic
+ <limit GET POST>
+ require valid-user
+ </limit>
+ </LocationMatch>
+ <LocationMatch ^/Blogsum/>
+ SetHandler perl-script
+ PerlHandler Apache::PerlRun
+ Options -ExecCGI
+ Order deny,allow
+ Allow from all
+ </LocationMatch>
+ <LocationMatch ^/data/>
+ Order deny,allow
+ Deny from all
+ </LocationMatch>
+</VirtualHost>
diff --git a/examples/httpd2-blogsum.conf b/examples/httpd2-blogsum.conf
new file mode 100644
index 0000000..a887d0d
--- /dev/null
+++ b/examples/httpd2-blogsum.conf
@@ -0,0 +1,49 @@
+<VirtualHost *:80>
+ ServerName www.example.com
+ DocumentRoot /var/www/blogsum
+ DirectoryIndex index.cgi
+ PerlRequire /www/blogsum/startup.pl
+
+ Options +FollowSymlinks
+ RewriteEngine On
+ RewriteRule ^/rss.xml$ /index.cgi?rss=1 [PT,QSA]
+ RewriteRule ^/rss2.xml$ /index.cgi?rss=2 [PT,QSA]
+ RewriteRule ^/Page/([^/]+)$ /index.cgi?page=$1 [PT,QSA]
+ RewriteRule ^/Tags/([^/]+)$ /index.cgi?search=$1 [PT,QSA]
+ RewriteRule ^/([0-9]{4})/([0-9]{2})/([^/]+)$ /index.cgi?view=article&year=$1&month=$2&uri=$3 [PT,QSA]
+ RewriteRule ^/([0-9]{4})/([0-9]{2})/?$ /index.cgi?view=article&year=$1&month=$2 [PT,QSA]
+ RewriteRule ^/([0-9]{4})/?$ /index.cgi?view=article&year=$1 [PT,QSA]
+
+ PerlModule ModPerl::PerlRun
+ <LocationMatch ^/index.cgi>
+ SetHandler perl-script
+ PerlResponseHandler ModPerl::PerlRunPrefork
+ Options ExecCGI
+ Order deny,allow
+ Allow from all
+ </LocationMatch>
+ <LocationMatch ^/admin.cgi>
+ SetHandler perl-script
+ PerlResponseHandler ModPerl::PerlRunPrefork
+ Options ExecCGI
+ Order deny,allow
+ Allow from all
+ AuthUserFile /var/www/conf/blogsum.htpasswd
+ AuthName "Blogsum Admin - example.com"
+ AuthType Basic
+ <limit GET POST>
+ require valid-user
+ </limit>
+ </LocationMatch>
+ <LocationMatch ^/Blogsum/>
+ SetHandler perl-script
+ PerlResponseHandler ModPerl::PerlRunPrefork
+ Options -ExecCGI
+ Order deny,allow
+ Allow from all
+ </LocationMatch>
+ <LocationMatch ^/data/>
+ Order deny,allow
+ Deny from all
+ </LocationMatch>
+</VirtualHost>
diff --git a/examples/wp2blogsum.pl b/examples/wp2blogsum.pl
new file mode 100755
index 0000000..e11f1eb
--- /dev/null
+++ b/examples/wp2blogsum.pl
@@ -0,0 +1,75 @@
+#!/usr/bin/perl
+
+# Blogsum
+# Copyright (c) 2009 Jason Dixon <jason@dixongroup.net>
+# All rights reserved.
+
+use strict;
+use DBI;
+use XML::Simple;
+
+die "Usage: wp2blogsum.pl <file.xml> <file.db>\n\n" unless (@ARGV == 2);
+
+my $wpxml = $ARGV[0];
+my $database = $ARGV[1];
+my $xs = XML::Simple->new();
+my $ref = $xs->XMLin($wpxml);
+my $dbh = DBI->connect("DBI:SQLite:dbname=$database",'','', { RaiseError => 1 }) || die $DBI::errstr;
+my $stmt = "INSERT INTO articles VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)";
+my $sth = $dbh->prepare($stmt);
+my $stmt2 = "INSERT INTO comments VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)";
+my $sth2 = $dbh->prepare($stmt2);
+
+foreach my $item ( @{$ref->{'channel'}->{'item'}} ) {
+ next unless ($item->{'wp:post_type'} eq 'post');
+ my $title = $item->{'title'};
+ my $date = $item->{'wp:post_date'};
+ my $uri = $item->{'wp:post_name'};
+ my $author = $item->{'dc:creator'};
+ my $enabled = ($item->{'wp:status'} eq 'publish') ? 1 : 0;
+ my $content = $item->{'content:encoded'};
+ $content =~ s/ //g; # remove
+ unless (($content =~ /<pre>/) || ($content =~ <ul>) || ($content =~ <ol>)) {
+ $content =~ s/<\!\-\-more\-\->/<\!\-\-readmore\-\->/mg; # convert more to readmore
+ $content =~ s/^/<p>/mg; # add <p> to beginning of line
+ $content =~ s/\r\n/<\/p>\r\n/mg; # add </p> to end of line
+ $content =~ s/$/<\/p>/mg; # add </p> to end of story (no \r\n)
+ $content =~ s/^<p><\/p>$//mg; # remove <p></p> (empty lines)
+ $content =~ s/^<p>(<\!\-\-\w+\-\->)<\/p>/$1/mg; # remove <p></p> (comment lines)
+ $content =~ s/^<\/p>$//mg; # remove extra </p> from end of story
+ $content =~ s/<p><ul>/<ul>/mg; # remove <p> before <ul>
+ $content =~ s/<ul><\/p>/<ul>/mg; # remove </p> after <ul>
+ $content =~ s/<p><\/ul>/<\/ul>/mg; # remove <p> before </ul>
+ $content =~ s/<\/ul><\/p>/<\/ul>/mg; # remove </p> after </ul>
+ $content =~ s/<p><li>/<li>/mg; # remove <p> before <li>
+ $content =~ s/<li><\/p>/<li>/mg; # remove </p> after <li>
+ $content =~ s/<p><\/li>/<\/li>/mg; # remove <p> before </li>
+ $content =~ s/<\/li><\/p>/<\/li>/mg; # remove </p> after </li>
+ }
+ my @tags;
+ if ($item->{'category'}) {
+ for my $category (@{$item->{'category'}}) {
+ if (ref($category) eq 'HASH') {
+ if ($category->{'nicename'}) {
+ push(@tags, $category->{'content'});
+ }
+ }
+ }
+ }
+ $sth->execute($date, $title, $uri, $content, join(',', @tags), $enabled, $author) || die $dbh->errstr;
+ my $article_id = $dbh->func('last_insert_rowid');
+ if ($item->{'wp:comment'}) {
+ if (ref($item->{'wp:comment'}) eq 'ARRAY') {
+ for my $comment (@{$item->{'wp:comment'}}) {
+ $sth2->execute($article_id, $comment->{'wp:comment_date'}, $comment->{'wp:comment_author'}, $comment->{'wp:comment_author_email'}, $comment->{'wp:comment_author_url'}, $comment->{'wp:comment_content'}, $comment->{'wp:comment_approved'}) || die $dbh->errstr;
+ }
+ } else {
+ my $comment = $item->{'wp:comment'};
+ $sth2->execute($article_id, $comment->{'wp:comment_date'}, $comment->{'wp:comment_author'}, $comment->{'wp:comment_author_email'}, $comment->{'wp:comment_author_url'}, $comment->{'wp:comment_content'}, $comment->{'wp:comment_approved'}) || die $dbh->errstr;
+ }
+ }
+}
+
+$dbh->disconnect;
+
+