RESTful wrapper for the MoinMoin wiki, included in Akara

MoinMoin is a very handy wiki implementation but it does not have a RESTful way of accessing or updating content. It's all designed around browser forms and browser rendering. Not very modern, from a Web point of view. Moinrest addresses this by providing an external wrapper to Moin instances (supporting Moin 1.7.x - 1.9.x). It requires Akara 2.x.

Once you have Akara set up, just put the moinrest.py file (you can find it in demo/modules) in the modules directory, configure it to wrap one or more Moin wiki instances, and restart the server. For more on settign up and configuring Akara, see Akara/Quick_start.

Configuration

You'll need to create a config section for moinrest, specifying one line for each wiki to be wrapped, mapping a local mount point to the destination wiki base URL. The syntax is as follows.

[moinrest]
target-mountpoint = wikiurl

For example, the following creates one wrapped wiki mounted at xml3k, wrapping the moin instance at http://wiki.xml3k.org.

[moinrest]
target-xml3k=http://wiki.xml3k.org

Sample client requests

Get the Wiki text content of the page:

curl http://localhost:8880/moin/xml3k/FrontPage

moin is the mount point for the entire moinrest module. Within this each wrapped wiki has its own mount point, as determined by the config described above.


Use HTTP content negotiation to get the page in different formats...

In Docbook form (if supported by the wrapped wiki):

curl -H Accept: application/docbook+xml" http://localhost:8880/moin/xml3k/FrontPage
curl -H "Accept: application/rdf+xml" http://localhost:8880/moin/xml3k/FrontPage
curl -H "Accept: application/x-moin-attachments+xml" http://localhost:8880/moin/xml3k/FrontPage

Get the history of the page as an RSS 1.0 (i.e. RDF) feed :

curl -H "Accept: application/rdf+xml" http://localhost:8880/moin/xml3k/FrontPage


Update the content of a page with wiki text from a file wikicontent.txt.

curl --request PUT --data-binary "@wikicontent.txt" --header "Content-Type: text/plain" "http://localhost:8880/moin/xml3k/FooTest"

Of course most wikis will require you to log in before updating a page. Mopinrest uses HTTP auth for this. Following is the same as above except that it logs in to the wiki using the user name JohnDoe and the password passwd.

curl -u JohnDoe:passwd -p --request PUT --data-binary "@wikicontent.txt" --header "Content-Type: text/plain" "http://localhost:8880/moin/xml3k/FooTest"


Moinrest supports attachments.

Get a list of attachments to the page, as a special, simple XML format:

curl -H "Accept: application/x-moin-attachments+xml" http://localhost:8880/moin/xml3k/FrontPage

Get an attached page. Notice the use of URL path parameters to specify an attachment associated with a page:

curl "http://localhost:8880/moin/xml3k/FooTest;attachment=somedoc.pdf"

Attach the file a.txt to the page wrapped at http://localhost:8880/moin/xml3k/FooTest

curl --request POST --data-binary "@/tmp/a.txt" --header "Content-Type: text/plain" "http://localhost:8880/moin/xml3k/FooTest;file=a.txt"

Use cases

Architecture

The following sequence diagram illustrates the process flow for a simple GET request for a Moin wiki page through moinrest, e.g. (to get the wiki front page)

curl http://akara/moin/wiki1/

This use case doesn't really emphasize the benefits of REST (except in the way, not illustrated, that content-negotiation is used to control the returned page representation), but it does show the basic pattern that's extended in more significant use-cases.

Akara-moin-simple-get.png

The following sequence diagram illustrates the process flow for a GET request using HTTP authentication.

curl -u username:passwd http://akara/moin/wiki1/

Akara-moin-auth-get.png

See also

Issues

Scalability

See also:

Akara/Modules/Moin (last edited 2010-08-09 03:44:40 by MarkBaker)