2006-09-11 Looking at Flock

Have you tried Flock? I’m giving it a try at the moment. It says that it can integrate blogging using “Wordpress, Movable Type, Typepad, LiveJournal, Typo, and Drupal and integrates with the Blogger, Meta Weblog, Typepad, and Atom APIs.”

Flock

Maybe I should write a complete Atom API for Oddmuse. Right now the Oddmuse:Atom Extension is a proof-of-concept extension that’s not really as flexible as the existing Oddmuse:Rss Action.

Oddmuse:Atom Extension

Oddmuse:Rss Action

At least exporting my subscriptions from BlogLines as an OPML feed, and subscribing to all of them in flock went smoothly. Yay for *open standards*! ❤ ❤ ❤

BlogLines

Actually the Bloglines searches did not work out of the box, because I hadn’t subscribed to them as RSS feed. Redoing the searches allowed me to subscribe to the RSS feeds, so that went well. Since I’m reading news from multiple machines, however, moving away from Bloglines is not an option. I was just “checking”... ;) I see that Flock is planning to look into the issue, however. ¹ I think they should just interface with Bloglines!!

¹

Logging into LiveJournal as a test automatically notified Flock that I signed into a site that it supported for blogging, and offered to do all the configuration automatically. It felt eerie, but it worked. Except that I don’t want to blog on LJ. — Or do I?

Anyway, I started working on *Atom*.

I downloaded XML::Atom, but it seemed complex. So I started to read the draft ² and started implementing: Return a simple “introspection document”.

XML::Atom

²

Alpinobombus:~ alex$ curl http://localhost/cgi-bin/wiki/atom
<?xml version="1.0" encoding='UTF-8'?>
<service xmlns="http://purl.org/atom/app#">
<workspace title="Oddmuse" >
<collection title="Wiki" href="http://localhost/cgi-bin/wiki/atom">
<accept>entry, image/jpeg, image/png</accept>
</collection>
</workspace>
</service>

I’m using the correct MIME type (application/atomserv+xml), and yet Flock keeps complaining that something’s wrong about it.

I guess I didn’t neet to go very far to realize I wouldn’t get far. 🙁

The meat of my Oddmuse extension:

push(@MyInitVariables, \&AtomInit);

sub AtomInit {
  SetParam('action', 'atom') if $q->path_info =~ m|/atom\b|;
}

$Action{atom} = \&DoAtom;

sub DoAtom {
  my $id = shift;
  DoAtomIntrospection();
}

1. from http://www.ietf.org/internet-drafts/draft-ietf-atompub-protocol-09.txt
sub DoAtomIntrospection {
  print GetHttpHeader('application/atomserv+xml');
  my @types = ('entry', );
  push(@types, @UploadTypes) if $UploadAllowed;
  my $upload = '<accept>' . join(', ', @types) . '</accept>';
  print <<EOT;
<?xml version="1.0" encoding='$HttpCharset'?>
<service xmlns="http://purl.org/atom/app#">
<workspace title="Oddmuse" >
<collection title="$SiteName" href="$ScriptName/atom/pub">
$upload
</collection>
</workspace>
</service>
EOT
}

Too bad Flock didn’t like it!

I’ve also installed RPC::XML, considering the implementation of the MetaWeblog API. But that, too, looks complicated. I really, really like simple code. 😄

MetaWeblog API

So now I wrote a simple skeleton for the MetaWeblog API:

use RPC::XML::Server;
require RPC::XML::Procedure;

$srv = RPC::XML::Server->new(port => 9000);

my $new = RPC::XML::Procedure->new({ name => 'metaWeblog.newPost',
				     code => sub { OddmuseNew(@_) },
				     signature => [ 'string', 'string',
						    'string', 'struct',
						    'boolean' ] });
my $edit = RPC::XML::Procedure->new({ name => 'metaWeblog.editPost',
				     code => sub { OddmuseEdit(@_) },
				     signature => [ 'string', 'string',
						    'string', 'struct',
						    'boolean' ] });
my $get = RPC::XML::Procedure->new({ name => 'metaWeblog.getPost',
				     code => sub { OddmuseGet(@_) },
				     signature => [ 'string', 'string',
						    'string' ] });

$srv->add_method($new);
$srv->add_method($edit);
$srv->add_method($get);

$srv->server_loop; # Never returns

1. metaWeblog.newPost (blogid, username, password, struct, publish)
1. returns string

sub OddmusePost {
  my ($blogid, $username, $password, $struct, $publish) = @_;
  return "foo";
}

1. metaWeblog.editPost (postid, username, password, struct, publish)
1. returns true

sub OddmuseEdit {
  my ($postid, $username, $password, $struct, $publish) = @_;
  return 1;
}

1. metaWeblog.getPost (postid, username, password) returns struct

sub OddmuseGet {
  my ($postid, $username, $password) = @_;
}

As you can see, no real code there.

I then created a file containing my request:

<?xml version="1.0"?>
<methodCall>
  <methodName>metaWeblog.newPost</methodName>
  <params>
    <param>
      <value><string>Wiki</string></value>
      <value><string>AlexSchroeder</string></value>
      <value><string>Hibiskus$Fresser</string></value>
      <value><struct>
	<title>Testing Meta</title>
	<description>This is my text!</description>
      </struct></value>
      <value><boolean>1</boolean></value>
    </param>
  </params>
</methodCall>

And ran the server and tested it using curl:

curl

Alpinobombus:~ alex$ curl --data @~/oddmuse/meta-new.xml localhost:9000
<title>403 Forbidden</title>
<h1>403 Forbidden</h1>

Didn’t get very far here, either!

Perhaps I should use Net::Blogger instead of Flock to test my implementation. ;)

Net::Blogger

Later, I returned to Atom! See 2006-09-16 Atom Revisited.

2006-09-16 Atom Revisited

​#Software ​#Web ​#Flock ​#Atom ​#Oddmuse