On Tuesday 26. August 2014 02.01.10 Lars Kruse wrote:
> 
> recently I upgraded the VisualSiteMap action [1] for moinmoin v1.9 and
> today I added the HoverCraft action [2].
> In both cases an external application is called in order to create one or
> more files locally:
> * VisualSiteMap: dot/neato/... creates an svg file
> * HoverCraft: a directory containing an html file and some more resource
> files is created
> 
> To be of any use, these files need to be accessible via a URL.

If these things really need to create actual files, or if it's easier for them 
to be made to create files instead of just producing data on demand, then you 
could potentially use either the attachment or caching APIs in Moin, and then 
Moin could be made to serve things from the attachment or cache areas in the 
filesystem.

I can think of two things I've had something to do with that uses these APIs:

https://moinmo.in/ParserMarket/graphviz (uses the attachment API)
https://moinmo.in/ActionMarket/ExportPDF (uses the caching API)

Both of these invoke other processes and collect output directly from those 
processes instead of letting them write to files. This is arguably more 
elegant because you don't have to clean up random files generated by tools and 
can choose whether to cache the output or to just send it to the browser 
directly.

> Thus both actions are currently configured with two pieces of information:
> 1) a local file path
> 2) a URL which is mapped to the above path (via a webserver?)

You can use URLs which invoke actions to get cached or attached content, but 
you'll need to make sure that any URLs embedded in any generated data are 
suitable for subsequently requesting things from Moin. I seem to recall Moin 
supporting a nicer way of requesting attachments than explicitly invoking the 
AttachFile action, so you might even have an easier job ahead of you if you 
use attachments.

> The actions call their respective external application and put their result
> into the above local directory. The URL of these files is
> delivered/embedded to the user.
> 
> This approach feels a bit clumsy, since the webserver requires manual
> configuration (mapping the directory to a URL) for each action separately,
> e.g.:
> 
>   AliasMatch /wikis/([^/]+)/_hovercraft-cache/(.*)$
> /var/cache/moin/HoverCraft/$1/$2
> 
> (suitable for the HoverCraft action and for multiple wikis via farmconfig)
> 
> Additionally the above approach ignores any ACL restrictions - but I could
> live wih that.

It's always worth remembering ACLs when developing actions to obtain data from 
the cache or associated with a page.

> Since at least the two above actions require this directory/URL mapping
> (separated for each wiki), I could imagine that maybe MoinMoin already
> includes something similar?
> Or is the preferred approach to turn the created files into attachments of
> the respective wiki page? This could work for VisualSiteMap but would be
> quite messy for HoverCraft since it creates multiple files.

I can't remember if there are any nice ways of creating cached bundles of 
files, presumably within their own subdirectories of a cache directory set up 
for this purpose, but even if the API isn't that helpful you could still write 
the necessary code to deal with creating such subdirectories: you'd only be 
getting the appropriate filesystem path from Moin and then appending the 
appropriate details in order to construct a specific path for any given 
purpose. Just be careful to sanitise paths in order to avoid data leakage from 
(or contamination of) the wider filesystem.

Hope this helps!

Paul

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Moin-user mailing list
Moin-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/moin-user

Reply via email to