package Bric::Mech; require 5.006001; our $VERSION = '0.04'; use strict; use warnings; use Carp; # (can also require HTML::TokeParser::Simple) =head1 NAME Bric::Mech - browse Bricolage using WWW::Mechanize =head1 SYNOPSIS use Bric::Mech; # Login my $mech = Bric::Mech->new(); $mech->login(server => 'http://example.com'); # Open the 'Story' workflow $mech->open_workflow_menu(name => 'Story'); # Click on 'New Story' in that workflow $mech->follow_action_link(action => 'new'); ... $mech->logout(); =head1 DESCRIPTION This class subclasses L to provide convenience methods for navigating the Bricolage browser interface. =head1 CLASS METHODS =head2 new my $self = Bric::Mech->new(); Constructs a new Bric::Mech object. The object's attributes are described in the L section. =head3 Args: =over 4 =item version (optional) Indicate which version of Bricolage the server you're connecting to is. You can either give the exact version (e.g. '1.10.2') or the "series" (e.g. '1.10'). Defaults to '1.10', which is nominally the earliest supported version (though I hope to make it work with 1.8, too; I know that currently it doesn't with some methods). =item base (optional) Set this object's base class, which should have an interface compatible with L, which is the default base class. You might use another subclass of WWW::Mechanize or even L (not tried yet). =back All other arguments are passed directly to $self->SUPER::new. =cut sub new { my $class = shift; my %args = @_; my $version = delete($args{version}); my $base = delete($args{base}) || 'WWW::Mechanize'; our @ISA = ($base); eval "require $base"; croak("new failed: requiring base class, ERROR = $@") if $@; my $self = $class->SUPER::new(%args); bless $self, $class; $self->{bric_version} = $version || '1.10'; $self->{_base} = $base; foreach my $attr (qw(server username password lang_key)) { $self->{$attr} = ''; } foreach my $attr (qw(logged_in workflow site debug)) { $self->{$attr} = 0; } foreach my $attr (qw(_double_lists)) { $self->{$attr} = {}; } return $self; } =head1 OBJECT METHODS Something to keep in mind with these methods is that the Bricolage UI is divided into two parts: the left nav and the main content. The left nav is included through an