Test post, please ignore.

rcaputo on 2009-07-13T06:17:14

BinGOs pointed out WWW::UsePerl::Journal and kindly pasted the code he uses to drive it. I've hacked it a little to embed the article title into a header block on the article. Since I'm writing these offline, I figure the title should be associated with the article for posterity.

Here's my hacked version of BinGOs' posting script:

#!/usr/bin/env perl

use warnings;
use strict;

use WWW::UsePerl::Journal;

my $user = 'rcaputo';
my $pass = '********';

# Headers.

my $title;
my $comments = 1;

while (<>) {
	chomp;
	last if /^\s*$/;

	unless (/^\s*([^:]+?)\s*:\s*(\S.*?)\s*$/) {
		die "Unknown header line ($_)\n";
	}

	my ($header, $value) = (lc($1), $2);

	# Avoid the lulz.
	$value =~ s/\Q$pass/********/g;

	if ($header eq "title") {
		$title = $value;
		next;
	}

	if ($header eq "comments") {
		if (lc($value) eq "yes") {
			$comments = 1;
		}
		elsif (lc($value) eq "no") {
			$comments = 0;
		}
		else {
			die "Comments header may only be yes or no.\n";
		}
	}
}

# Body HTML.

my $text = '';
while (<>) {
	# Only one per line.
	if (/^\s*\s*$/) {
		my $code = `/bin/cat $1`;
		$code =~ s/\n+$//;

		# Break up the ecode tags so this script can
		# present itself.
		$_ = "<" . "ecode>\n$code\n<" . "/ecode>";
	}

	$text .= $_;
}

# Avoid the lulz.
$text =~ s/\Q$pass/********/g;

die "Article needs a Title header.\n" unless $title;
die "Article needs body HTML.\n" unless $text;

# Post.

my $journal = WWW::UsePerl::Journal->new($user);
my $post = $journal->login($pass);

unless (
	$post->postentry(
		title    => $title,
		text     => $text,
		topic    => 34,         # user journal
		comments => $comments,  # allow comments?
		type     => 2,          # ???
		promote  => 'publish',  # ???
	)
) {
	 die "Failure.\n";
}

print "Success.\n";
exit;

Here's the source of this article:

Title: Test post, please ignore.

BinGOs pointed out WWW::UsePerl::Journal and kindly pasted the code he uses to drive it. I've hacked it a little to embed the article title into a header block on the article. Since I'm writing these offline, I figure the title should be associated with the article for posterity.

Here's my hacked version of BinGOs' posting script:

Here's the source of this article:

Thanks for reading anyway.

Thanks for reading anyway.