From acb38afcd4780191569ee809f3e8bdb550a634bc Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 5 Sep 2012 18:34:48 +0000 Subject: blogsum --- examples/create_sqlite.sql | 36 +++++++++++++++++++++ examples/httpd-blogsum.conf | 50 +++++++++++++++++++++++++++++ examples/httpd2-blogsum.conf | 49 +++++++++++++++++++++++++++++ examples/wp2blogsum.pl | 75 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+) create mode 100644 examples/create_sqlite.sql create mode 100644 examples/httpd-blogsum.conf create mode 100644 examples/httpd2-blogsum.conf create mode 100755 examples/wp2blogsum.pl (limited to 'examples') 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','

Introduction

+ +

Blogsum is a very basic blogging application. It was written from scratch with a focus on simplicity and security, favoring practicality over feature bloat.

+ +

Writing Articles

+ +

The Administration interface is straightforward and bereft of unnecessary features. Three views allow you to create posts, moderate comments and administrate (manage posts). Blogsum uses HTML markup for article formatting. New articles are saved as a draft .

+ +

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 <!--readmore--> 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...

+ + + +

Managing Articles

+ +

As mentioned above, new articles are saved as a draft. Click the publish button to see your post go live. You can make edits 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 delete it.

+ +

Comments and Moderation

+ +

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 moderate view to approve or deny a comment submission.

+ +

Using Tags

+ +

Tags are used liberally throughout Blogsum. Besides the tags defined in an article, Blogsum also uses the /Tags/ path to search for authors. It also favors the use of tags as a conventional replacement to categories. Anyone can use the /Tags/ path to search for articles in Blogsum (example).

+ +

Themes

+ +

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 themes/default directory to your own directory (e.g. themes/foobar) 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 $blog_theme setting in Blogsum/Config.pm and restart your webserver.

+ +

Go Forth and Blog!

+ +

As you can see, Blogsum is a very simple application designed for less maintenance, more writing. We hope you enjoy publishing your works within Blogsum. If you create your own themes, please consider donating those back to the project. Enjoy!

+','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 @@ + + 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 + + SetHandler perl-script + PerlHandler Apache::PerlRun + PerlRequire /var/www/blogsum/startup.pl + Options ExecCGI + Order deny,allow + Allow from all + + + 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 + + require valid-user + + + + SetHandler perl-script + PerlHandler Apache::PerlRun + Options -ExecCGI + Order deny,allow + Allow from all + + + Order deny,allow + Deny from all + + 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 @@ + + 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 + + SetHandler perl-script + PerlResponseHandler ModPerl::PerlRunPrefork + Options ExecCGI + Order deny,allow + Allow from all + + + 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 + + require valid-user + + + + SetHandler perl-script + PerlResponseHandler ModPerl::PerlRunPrefork + Options -ExecCGI + Order deny,allow + Allow from all + + + Order deny,allow + Deny from all + + 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 +# All rights reserved. + +use strict; +use DBI; +use XML::Simple; + +die "Usage: wp2blogsum.pl \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 =~ /
/) || ($content =~ 
    ) || ($content =~
      )) { + $content =~ s/<\!\-\-more\-\->/<\!\-\-readmore\-\->/mg; # convert more to readmore + $content =~ s/^/

      /mg; # add

      to beginning of line + $content =~ s/\r\n/<\/p>\r\n/mg; # add

      to end of line + $content =~ s/$/<\/p>/mg; # add

      to end of story (no \r\n) + $content =~ s/^

      <\/p>$//mg; # remove

      (empty lines) + $content =~ s/^

      (<\!\-\-\w+\-\->)<\/p>/$1/mg; # remove

      (comment lines) + $content =~ s/^<\/p>$//mg; # remove extra

      from end of story + $content =~ s/

        /
          /mg; # remove

          before

            + $content =~ s/
              <\/p>/
                /mg; # remove

                after
                  + $content =~ s/

                  <\/ul>/<\/ul>/mg; # remove

                  before

                + $content =~ s/<\/ul><\/p>/<\/ul>/mg; # remove

                after
              + $content =~ s/

            • /
            • /mg; # remove

              before

            • + $content =~ s/
            • <\/p>/
            • /mg; # remove

              after
            • + $content =~ s/

              <\/li>/<\/li>/mg; # remove

              before

            • + $content =~ s/<\/li><\/p>/<\/li>/mg; # remove

              after + } + 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; + + -- cgit v1.2.3