DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:tofromdoku

This is an old revision of the document!


ToFromDoku - A dokuwiki command line utility

:!: The XMLRPC interface has changed since this tip was posted, so this tip might need some adjustments. In any case you don't have to apply the darcs patch! :!:

Introduction

Using dokuwiki for automatic documentations (i.e. for sys2wiki.sh etc.) can be a bit complex. The following is a command line utility to get and post pages from/into dokuwiki using dokuwiki's HIGHLY EXPERIMENTAL XMLRPC-functionalities.

Note: an alternative method, if dokuwiki lies directly on your server or you'd like to do this all using a ssh-setup, would be to use the dwpage.php command line utility provided with DokuWiki which does not rely on XMLRPC communication.

Warning!

Looking at the xmlrpc-Servercode I found it in a very experimental state. So be warned not to do this unless you're certain, that you know what you doing! I'm serious, using the cli can result in an empty dokuwiki, a blank server or a collapsed universe.

Seriously, BE CAREFUL !!!

A bit patching

Dokuwiki has already got a small XMLRPC-server under /lib/exe/xmlrpc.php. It is disabled, tough, because the xmlrpc-functionality is currently in an experimental state. I've sent in a patch to enable a “putPage”-method to the xmlrpc-Server to enable posting pages into dokuwiki.

The darcs patch is available here:

http://dieploegers.de/files/xmlrpc_putpage.darcs

After applying that, enable the xmlrpc-server by uncommenting or removing the “die”-line somewhere at it's start.

The CLI

Now, install a PHP-CLI on your server and don't forget PHP's curl extension, than grab the CLI here:

http://dieploegers.de/files/tofromdoku.tar.gz

and put it somewhere you like.

Ways

The most important thing you'll have to specify is a way. The way says, if you gather sites from Dokuwiki (way=from) or put sites into Dokuwiki (way=to).

Configuring

You can configure the cli using commandline arguments or a configuration file. Let's start the cli using

php tofromdoku.php --help

This gives you the valid commandline arguments:

Usage: tofromdoku.php [-wupfc]  

-c --config=<value>    Path of the configuration file (tofromdoku.ini)
-f --filename=<value>  Filename to retrieve text from a file rather than from
                       STDIN or to write text into rather than to STDOUT ()
-p --pagename=<value>  The pagename (with namespaces) for the dokuwiki-page ()
-u --url=<value>       The URL to dokuwiki ()
-w --way=<value>       Get pages from Dokuwiki or send them to dokuwiki (from,
                       to) (from)

The single options are:

  • filename: Normally, pages retrieved (way=from) are put out to STDOUT, pages send (way=to) are read from STDIN. Alternatively you can specify a file here to be used instead.
  • pagename: The page (including namespaces) in Dokuwiki
  • url: The URL to Dokuwiki's xmlrpc-Server. You can use HTTP's default schema to supply a username and password (http:<username>:<password>@…) You need http-auth-functionality for this. * way: The default way to use. (It's “from”, if not specified) You can configure this options using the commandline arguments above or put the options in a configuration file. The script tries to read a tofromdoku.ini as a default config file, but you can specify a different file using the “–config”-argument. That's all you need. Configure the script and run it to retrieve or send pages. Again, please be advised, that this is dangerous. Don't blame anyone of the Dokuwiki developers or me for data loss or other bad things. ====== Discussion ======
tips/tofromdoku.1261323412.txt.gz · Last modified: 2009-12-20 16:36 by 79.203.121.26

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki