Dave's Simple Weblogs.com and Greymatter Hack
version 0.1

Weblogs.com and greymatter, together at last

Here's how I did it:

Open up gm.cgi for editing. You will need to make two changes. At the top of the file, you will see two lines like this near the very top of the file:



use CGI::Carp qw(fatalsToBrowser);

require "gm-library.cgi";

Add the following two lines:



use LWP::UserAgent;
use URI::Escape;


between the two lines above.

OK, now it is ready for the main change.

Search for the line that looks like this (but without the weird spacing issues I'm having here):



$statusnote = qq(<B> <FONT COLOR="#0000FF">Your new entry has been added.</FONT></B>);

It should be around line 3410, according to my version of emacs, but I'm not sure how much you can trust line numbers these days. It is at the end of the gm_savenewentry method, if that helps.

Anyways, right before that line, insert the following lines:



# update weblogs.com to let them know we changed

$ua = new LWP::UserAgent;
$ua->agent("GM/0.1 " . $ua->agent);

#enter weblog info on the next two lines
$myweblogname = 'MyWeblog';
$myweblogurl = 'http://';

$myweblogname = uri_escape($myweblogname, "^A-Za-z");
$myweblogurl = uri_escape($myweblogurl, "^A-Za-z");

my $req = HTTP::Request->new(GET => "http://newhome.weblogs.com/pingSiteForm?na\
me=$myweblogname&url=$myweblogurl");

$req->content_type('application/x-www-form-urlencoded');

my $res = $ua->request($req);

Except, change the lines with $myweblogname and $myweblogurl to point to your weblog.

You are all set - every time you add an entry via greymatter, it will automatically ping Weblogs.com via the HTML form interface.

If you have suggestions for improving these instructions, or have trouble getting it to work, let me know.

If any real perl hackers want to improve upon this, please let me know.

An important note:
You need to have the LWP and URI Perl modules installed for this to work, otherwise your gm.cgi will be broken. I thought those were "standard" perl modules, but apparently not everyone has them. Remember, make a back-up copy of your gm.cgi file before trying this!

For Popup Posts:
You'll need to place the code above the location described above, before the IF statement checking to see whether it is a popup post. Thanks to Richard@rebuke.org for the fix. You can tell I don't ever use that feature, can't you?