Because I forget stuff. Part of norcimo.com
Note: It appears you must have reached this page by a deep level URL. In general this site is currently down and unmaintained. See here
Originally posted December 18 2006 at 13:12 under Blogging. 3 Comments. Trackbacks Disabled. Last modified: 18 December 2006 at 14:06
What the bloody hell’s going on with all these dum de dum posts? That was me playing
around, trying to get something to work. I think I have now.
If you’d really like to know what (it involves email, and posting, and
moveabletype), then read on…
The first thing I think I should point out is I’m writing this entire
post in GMail, because I’m going to email it and have MT import it as
a post. I think I now have control over setting everything at this
point.
I could have sworn I’ve talked about emailing to moveabletype before,
but I’m damned if I can find any mention now. I know I have attempted
it before, and never really got it to work in a way I could live with.
The only solution I really got to publish is
meow (Mail enotes on weblog, apparently. Judging by the
spaminess of the comments on the posts there and last update date it’s
not under active development). Meow is actually just a script to
periodically poll an email box and use the emails there to post to MT
via the XML-RPC API. Part of the problem is that I really need the
extended entry (more text) field to hang entries together neatly (I
use it to contain lots of metadata like location, etc and, especially,
tags as well as the more text). It’s also nice to be able to set
the keywords field, and control whether comments and trackbacks are
allowed, and everything else. While MT does extend the XML_RPC API to allow such things logically enough not a lot actually makes
use of that, including for some reason Meow. The other problem I’ve
always had is that setting a category on a post would never show up on
the live site (even though the post itself would, and the category
would be set in the back end interface). Having looked at the code it
seems that just setting a category doesn’t publish the post, so in
general the sequence of events was going make post->publish->set
category->nothing…
My first thought was to simply make Meow rebuild the entry by calling
mt-rebuild, which would at least get the category to
show up. That didn’t solve the problem of getting things posted into
the extended entry field though. I considered doing that within Meow
somehow but the only obvious way is to parse something out the message
body. As that message body just gets passed on as the main text of the
entry I realised I might as well do the parsing a step further along,
which would give more versatility (for using things like Flickr’s posting to blog . And if I was going to parse
extended entry text out, I could do the same with keywords and
comments permission etc.
The XML-RPC API is provided by a perl module
(/path-to-mt/lib/mt/XMLRPCServer.pm). I don’t really speak perl (which
was already a little problem given that’s the language Meow is in). It
seems I do just about speak enough to hack together a solution (if I
actually understood perl properly then the solution would probably be
nicer and wouldn’t have required so much whisky to reach).
So now the newPost method will parse the main body of the post for
things which look like {{:foo: bar :foo:}} and use bar to do
something, depending on what foo is. This includes setting the
categories after the entry is saved but before it is
published, which means they show up (getting the categories bit to
work took me the longest).
In case you want this wonderful pile of coded functionality yourself
you can find the modified XMLRPCServer module and modified Meow (which
now doesn’t do category setting itself—it will just parse any
category in the subject line and add it to the body to be parsed) can
be downloaded in this zip file later. Usual disclaimers
apply; if it eats your blog and sets the server on fire don’t come
blaming me, you’re using it at your own risk. There are some obvious
limitations. This only hangs together on new posts, not ones
which are being edited. That’s all I want, though you could probably
sort it properly if you felt like it. For Meow to be useful you
obviously need to be able to set up something like a cron job to run
it every now and then (and if someone knew the secret address you’re
polling and fakes the from header in a message to it, they can post to
your blog, though that’s not very likely. Still, I’m tempted to have
Meow parse for a password in the message body as an extra security
level). Oh, and if you have a category hierarchy with some categories
named the same I’ve no idea what will happen.
Hmmm: Well, it works, though the fact GMail threw line breaks all over the place caused some problems (not good to have a line break in the middle of your anchor tag). Still, it’s probably not actually going to be much of a problem, and I can always remember to turn of convert line breaks :-)
Name and email address are required. Email address is never shown. If you enter a URL your name will be linked to it (this and other links will have the rel attribute set to contain nofollow). Markup allowed: <a href="" title="" rel=""> <em> <strong> <abbr title=""> <acronym title=""> <p> <br />. Anything else is stripped; please be valid. Single linebreaks automatically convert to <br />, double to <p>'s. Additionally anything that looks like a bare URL should get automagically linked. Many acronyms and abbreviations are also automagically handled.
Please note this blog's comment policy
© Ian Scott. Powered by Movable Type 3.2. This blog uses valid XHTML 1.0 Strict and valid CSS. All times are local UK time. For further details see the IMS_Blog about page.. All my feeds in one.
1
I just want to check comments subscription
Made by Ian Scott on Jul 21, 2008 at 21:06