[pmwiki-users] Update pmwiki using perl scripts ...
Joachim Durchholz
jo at durchholz.org
Fri Feb 24 03:52:42 CST 2006
Ginil Gharat schrieb:
>
> Pmwiki, I suppose is written in php, so is it possible to update using perl
> scripts ?
Sure. PHP or shell script would do as well.
> I was trying to use WWW-Mechanize-1.18 but was *not* very
> successful with my attempts.
I'm not sure what WWW-Mechanize does. It would help to hear what exactly
the problems were.
Anyway, here's how I'd approach that:
1) Get the previous contents of the page via wget or curl, with an URL
of http://server/path/pmwiki.php?n=Group.Page&action=source. The
relevant part here is the action=source bit, it will return the page's
wikitext as text/plain.
2) Modify the page (presumably by appending or prepending the new log
entries).
3) Write the result back using a POST request. (This might involve going
through a login dialog, or whatever authentication is installed on your
wiki.)
There's a danger here: You can't lock PmWiki pages against concurrent
access. To be really complete, the script would have to react to an
error message in a useful way (possibly by regetting the updated page
contents and trying again; or by saving the page including the conflict
markers and sending a mail to the administrator to clean up the mess
manually).
An alternative approach would be a recipe that implements a new action,
say ?action=update. Take a look at the Cookbook recipes, several of them
implement new actions. The advantage is that you can work "from the
inside" and don't have to worry about authorizing the access (but you'd
have to worry about adding authorization to the new action).
Or you could call PmWiki from the command line. Write a shell script
that unsets any of the usual CGI variables (say, REQUEST_URI), write a
code snippet in config.php that checks whether $_ENV ['REQUEST_URI'] is
set, and if it isn't, assume it's called from the command line and do
your updates.
Whichever of the two methods you chose, after that your code is inside
PmWiki and can access all the methods to update the page store.
Regards,
Jo
More information about the pmwiki-users
mailing list