[Moin-user] Re: Re: Re: Image formatters and UTF8

Nir Soffer nirs at freeshell.org
Fri Feb 10 22:52:05 EST 2006


On 11 Feb, 2006, at 1:35, Jiba wrote:

>> Maybe you describe how your system works - why and how you use your
>> formatter to generate those files.
>
> I'm making a "free trading card game", with downloadable and printable 
> card editable using a wiki. The idea is to have a wiki page for each 
> card, and then to generate the card (in a PNG or JPEG image) using a 
> formatter. Here is a running example (in French) :
>
> http://nekeme.net/~jiba/cgi-bin/moin.cgi/Deichey
>
> When the wiki page is modified, the card image is regenerated (because 
> the cache is no longer valid) and updated to correspond to the contain 
> of the wiki page. The card image is also inserted at the top of the 
> page. You can also get it by using the action "RenderAsPNG" or 
> "RenderAsJpeg".
>
> It currently runs on a patched version of MoinMoin that supports a 
> per-request charset. The image is generated by a formatter, then 
> decoded in Unicode, then stored in the cache, add then (using the 
> patch) re-encoded in binary string and sent to the client.

Very interesting moin usage. Can you describe how you deploy this? in a 
school?

I would create a parser that:
  1. let the wiki parser render the page as wiki page using any format 
(wiki, rst etc.)
  2. check the attachment and generate an image from the wiki text if 
the attachment is older than the wiki page.

The page would look like:

#format card

## The card can have the same name, or maybe the name of the page
attachment:pagename.jpg

## or maybe the name is one of the keys
  name:: cardname
  key:: value
  key:: value

To create the parser I would reuse 
<http://moinmoin.wikiwikiweb.de/SectionParser>, because it already 
render a page as is. So the parser would be this:

from section import SectionParser

class CardParser(SectionParser):
	baseClass = 'card' # card pages may have unique style

	# Simplified format probably missing few arguments
	def format(self):
		# pseudo code...
		if page is newer then card attachment:
			generate new card
		SectionParser.format(self)	


Then add these css (and maybe more) rules to your wiki:
#card dl
#card dd
#card dt

This design does not need any patching of moin code,  and the page 
source is even simpler. You can even create more than one card on 
single page by using:

{{{
#!card

## XXX what is the card name in this case?
attachment:name.png

  key:: value
  key:: value
}}}


Best Regards,

Nir Soffer





More information about the Moin-user mailing list