Flag of Earth Peter Halasz (talk) ?

Subpages: /dia | /missing | /org | /pages | /photo | /quotes

Ideas: /rants | /ite | /R | /teletaxo

Subjects: /bot | /comp | /ee | /eco | /fringe | /micro | /sd | /zoo

Incubator: /ownimg | /teletaxotest | /self


Image Templating Engine (ITE)

edit
 
[[Image:Pengo_test.svg|150px]]

There's a huge amount of power ready to be unlocked in templatable SVG.

Here's how I see the interface working

edit
  • Uploads an image like the one on the left.
  • Using the image tag normally as following, it will appear like it does on the right.
[[Image:Pengo_test.svg]] 
  • Running the image name through special ITE template like so:
[[{{ITE|Image:Pengo_test.svg|Hello, world}}|150px]]

...and you can guess what happens! (or just see the image below)

Uses

edit
 
[[{{ITE|Image:Pengo_test.svg|Hello, world}}]]
  • Easy translating of diagrams
  • Maps: Regional colours could be changed, or country hi-lite toggled.
  • Cladistics: see my horrible attempt at drawing simple diagrams without ITE: User:Pengo/clad
  • Unexpected cool things you wouldn't expect until it happens

Further usage notes

edit

To simplify the usage of ITE, it could also be wrapped in a normal template. For the above example I could make a template called Template:Hello with the following contents:

[[{{ITE|Image:Pengo_test.svg|{{{1|Hi everyone}}}}}|150px]]

(bold added just for readability)

And to use it you could just insert {{Hello|a star!}}

How ITE works

edit
  1. MediaWiki sees an ITE template so handles it specially.
  2. The first parameter of the ITE template is the name of the source svg
  3. All subsequent parameters are then shifted up by one, so the the second parameter becomes {{{1}}}
  4. SVG file is run through the normal template mechanism (as a template), with the shifted parameters
  5. Generated SVG is given a new name based on a hash of its parameters (the hashname)
  6. The generated image may also be cached (with the hashname as a key). Note that svg's can be very small.
  7. ITE returns the hashname and it is inserted, as the "output" of the template
  8. The name is treated like any other image name
  9. After an hour of the hash not being referenced (or when the cache fills, or whatever) the image is dumped from cache.

Example expansion

edit

Example template expansion:

[[{{ITE|Image:Pengo_test.svg|Hello, world}}|150px]]

becomes:

[[Image:Pengo_test_52E84A3822.svg|150px]] 

notes for above example:

  • Image:Pengo_test_52E84A3822.svg now contains the new image
  • 52E84A3822 is a hash of "1=Hello, world"
  • the generated image gets deleted again eventually, so using subst might be a bad idea.
  • We'd also probably actually give ite output its own namespace or something so it didn't accidently step on anything, but this way makes the example easier

Notes

edit

Note (1): There's nothing special about the SVG files here. Any other file type could be used just as well. The only thing that the template mechanism is looking for is {{{these}}} things anyway, just like when it runs against a normal wikipage.

Note (2): We can't make the syntax simply [[{{Image:Pengo_test.svg|Hello, world}}|150px]], because that syntax is already used to include the Image Description Page.

Note (3): For the morbidly curious, the source code of the SVG that draws the text for the above image looks like this (generated by inkscape 0.43). See the full source also.

    <tspan
        sodipodi:role="line"
        id="tspan1311"
        x="143.57103"
        y="148.60481">{{{1|yay}}}</tspan>



Please leave comments on the talk page or at mediawiki bugzilla

More ideas and other thoughts like this at my rants page.


search A, search B