> I'd suggest we implement macros in "ductus-html5" like this:
>
> <ductusmacro data-name="page-search" data-tags="tag1,tag2" />
>
> This should work well with html parsers, and allow easy manipulation
> from aloha and with jquery.
Fiddling with aloha, I realised it's a lot easier to just store macro
calls using something like:
<div class="ductus-macro" data-macro-name="pagelist"
data-tags="tag1,tag2"></div>
This saves us from converting weird non-standard content upon
loading/saving in aloha (read: writing a lot more code). While editing,
a simple CSS definition (eg. using pseudo-elements) can act as a
placeholder. And we only deal with html5 compliant code, which is
probably a good idea.
> Input is pretty straightforward, click a button in aloha toolbar, set
> some params and aloha adds the code in the html blob.
> I suppose we can define some custom rendering html in editing mode, so
> that it shows something like "page-search macro (tags=xxx)" or so.
I took a shot at it based on another aloha plugin. It seems to work,
although I still need a simple UI to input the tags the user wants to
search for :)
> Then we have to run a parser that will turn <ductusmacro> tags into some
> form of html understandable by web browsers. This could be done on the
> client side using javascript, but I think it makes a lot more sense to
> do it server-side as it is now with creole macros. This way, results can
> be cached, crawled by search engines, etc...
it looks like using lxml works well. It parses the html and replaces
the placeholder above with actual content we want to see (in this case,
the list of pages).
As it stands, I have a bit of redundant code between the creole macro
and the html5 macro.
Considering that we only have a handful of actual pages that contain
macros, I'd be tempted to ignore the upgrade path. Currently, the
visual editor gets old pages via the creole parser, so that it receives
the output of macros. I'd say no big deal, we can just manually fix the
3 pages that need it. It will be easier than coding a converter! (if we
open an old page, the old macro still runs, so we don't break anything)
the take away: it works overall (I'll try to push a demo to devbox
tonight), except:
- removing the macro in the editor is weird/broken, I need to fix that
- your opinions on dealing with old creole macros, please :)
any other thoughts?