Skip to content

Instantly share code, notes, and snippets.

@dblevins
Created July 14, 2009 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dblevins/147299 to your computer and use it in GitHub Desktop.
Save dblevins/147299 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use LWP;
my $user = 'test';
my $site = 'http://blogs.apache.org';
open(C, "< .$user") or die "Unable to open handle to .$user: $!\n";
my $pass = <C>;
chomp $pass;
close C;
print "Content-Type: text/html\n\n";
my $browser = LWP::UserAgent->new;
$browser->cookie_jar( {} );
$browser->post("$site/roller_j_security_check", [ j_username => $user, j_password => $pass]);
# gotta be a way to avoid the $_ usage
$_ = $ENV{REQUEST_URI};
my ($blog, $entry) = m,.*/preview.cgi/([^/]+)/.previewEntry=(.+)$,;
my $res = $browser->get("$site/roller-ui/authoring/preview/$blog/?previewEntry=$entry");
my $content = $res->content();
# munge the links and url paths
$content =~ s,href="/,href="$site/,g;
$content =~ s,/roller-ui/authoring/preview/([^ ]+.css),/$1,;
print $content;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment