The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Acme::PM::Dresden::TWikiClient - A WWW::Mechanize client to access a TWiki.

SYNOPSIS

 use Acme::PM::Dresden::TWikiClient;
 
 my $client = new Acme::PM::Dresden::TWikiClient;
 
 $client->auth_user           ("TWikiUserName");
 $client->auth_passwd         ("secretpasswd");
 $client->override_locks      (0);  # default 0,
                                    # set to 1 if locked topics
                                    # should be "edited anyway"
 
 $client->bin_url             ('http://twiki.org/cgi-bin/');
 $client->current_default_web ('Sandbox'); # used if not contained in topic
 $client->current_topic       ('SandBox32');

 my $topic_content = $client->read_topic;
 $client->save_topic ($topic_content . "\n\n*TWikiClient was here.*\n\n");

ABOUT

This class is derived from WWW::Mechanize and extended for easy remote controlling a TWiki based webseite.

It was developed during the same time when WWW:Mechanize::TWiki version 0.06 was uploaded, so I didn't have a look at the new features there yet and don't want to throw away my class.

I currently only tested it with TWikis using the PatternSkin, e.g., http://twiki.org.

METHODS

edit_press_cancel

Cancels a current topic edit.

get_basic_credentials

Overwritten function to provide username and password, that were set via auth_user and auth_passwd.

htmlparse_extract_single_textarea

Auxiliary function to extract the nameless textarea in "raw text" view.

htmplparse_get_text

Auxiliary function within htmlparse_extract_single_textarea.

$url = $client->make_url ($cmd, $topic, $optional_tail);

Auxiliary function. Constructs URL from bin_url, $cmd (view, edit, ...) and topic name. If topic name doesn't contain a web prefix (eg., the "Main." in "Main.WebHome"), then current_default_web is used.

new

Constructor. Allows arguments:

bin_url

The base URL, where the twiki binaries are reached, e.g. "http://twiki.org/cgi-bin/".

current_default_web

The web that is used if topics are given without web prefix. Compare "Main.WebHome" vs. "WebHome"; set current_default_web("Main") for the latter case.

current_topic

The topic that is used if not given to functions. That makes it easier to set the topic and then call read_topic and save_topic with just content params.

auth_user

Set your TWiki username here.

auth_passwd

Set your TWiki password here.

override_locks

If the topic is locked during save_topic, this option decides whether the TWiki link "Edit anyway" is used and the lock is ignored.

Please note, that a lock means, that another user edits the topic just in this moment and his later save will throw away your changes.

pre_init

Called before params are taken over. I mostly use it for setting default values in derived clases.

post_init

Called after params are taken over. I mostly use it for forcing values (and ignoring params) in derived clases.

my $rawcontent = read_topic ($optional_topic_name);

Returns the raw topic content.

my $success = save_topic ($rawcontent, $optional_topic_name);

Writes the string $rawcontent into the topic. Old content is overwritten, so if you just want to append, use read_topic and concatenate.

skin_regex_authentication_failed

I sourced out some regexes that might be skin dependend. If you have another skin, you should only need to subclass and overwrite the skin_* methods.

This regex is for matching "authentication failed" page.

skin_regex_topic_locked

This regex is for matching "topic locked" page.

skin_regex_topic_locked_edit_anyway

This regex is for finding the "Edit anyway" link in the "topic locked" page.

AUTHOR

Steffen Schwigon <schwigon@cpan.org>

LICENSE

  Copyright (c) 2005. Steffen Schwigon
  All rights reserved.  You can redistribute and/or modify
  this bundle under the same terms as Perl itself.