>> Page-content plugins will need editor plugins, yeah (like our "include
>> page" plugin). But I think that's a good thing.
>>
> How do these plugin work when there is no XML "injection" into page
> content? How the final layout is being build?
We take the HTML5 that's stored and, before rendering it, transform
certain bits into functions. Right now we go HTML5 -> Django
template, and turn certain specially-registered HTML bits into Django
template tags (functions). We can then cache the Django template.
We're going to make registering a new page plugin easier (no HTML
traversal) soon.
Here's the docstring describing how we've got inside-page plugins working:
Conversion of HTML into template with dynamic parts.
We want to allow some dynamic content that gets inserted as the HTML is
rendered. This is done by converting certain HTML tags into template tags.
There are two mechanisms to do this: plugin handlers and tag handlers.
Plugins are meant for inserting bits of dynamic content at specific places on
the final rendered page marked by a placeholder element. The output can be
whatever you like: widgets, bits of JavaScript, anything. Tag handlers, on the
other hand, are meant for fixing up the HTML slightly and transparently, i.e.,
fixing links and adding helpful visual styles and the like. When in doubt, use
plugins.
Plugin handlers work with HTML elements that have the class "plugin". When
an element has the class "plugin", it will be passed to registered handlers
based on the other classes it has.
For example, the following element will be passed to the handler registered for
the "includepage" class:
<a href="Navigation" class="plugin includepage">Include Navigation</a>
which will convert it to this:
{% include_page "Navigation %}
to be rendered by the include_page template tag.
Tag handlers work similarly, but they are applied by element tag instead of by
class. They are best used for routine processing of content, such as styling.
For example, to mark links to non-existant pages with a different style, this:
<a href="My Page">My Page</a>
gets converted to this:
{% link "My Page" %}My Page{% endlink %}
and rendered as appropriate by the LinkNode class.
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l