[Moin-devel] Macro that generates a dyamic png

Nick Trout nick at rockstarvancouver.com
Tue Apr 29 11:12:04 EDT 2003


måndagen den 28 april 2003 19.33 skrev Nick Trout:
> I haven't tried this but you could write the PNG to the page's 
> attachment directory and return the attachment name as a link (eg. 
> <img
> src="attachment-name">) from the macro. You could check the page
> timestamp and PNG timestamp to decide whether to recreate the PNG
after
> a page save.

K> I tried that, to put the png file in a temporary directory. It worked
once, 
but when the same thing was called twice on the same page it didn't
work.  
And then, if it would ever happen that the same page was called two
times at 
the same time, it would not work either.


The idea was that the macro creates a PNG and writes it to the
<wikiname>/data/pages/attachments directory. The macro then returns a
link to the attachment, just as the "attachment:<attachment name>"
markup works.

Alternatively you could place the macro in a page, and have it return a
blank string, which means it is invisible. You could then just reference
them as many times as you like using the attachment markup previously
described.

Doing it this way would mean you get the chance to update the PNG either
every time the page is rendered (and by comparing timestamps you might
choose to only updated on a page save). Using actions I believe you
would have to call the action explicitly to create the PNG attachment in
order to include it, ie. Actions are only called when the user calls
them. I don't think you can call actions from a page using mark up. You
could create content using processors however, but I don't think you can
pass parameters to them.

--Nick








More information about the Moin-devel mailing list