[Cubicweb] annotating divs with rql and vid

Adrien Di Mascio adrien.dimascio at logilab.fr
Thu May 24 17:02:00 CEST 2012


Hi all,

On 24/05/2012 14:51, Nicolas Chauvat wrote:
> As you can see, it adds two data attributes to the main div:
> data-cw_rql and data-cw_vid.

> I contemplate making this the default behaviour. All the divs that are
> generated with rql+vid would be annotated with these two attributes
> and client-side js code could modify the values of these attributes
> before calling a js function similar to _loadDynamicFragment() that
> would take a div as an argument and replace it with the result of the
> query rql+vid.

_loadDynamicFragments() indeed achieves a similar purpose but back in 
the days when it was introduced, it was more to improve user experience 
by having the page displayed earlier and some parts loaded dynamically 
than to give a semantic structure to the page. It was quite convenient 
but when the xhtml fancy took us, it became necessary to introduce 
custom XML namespaces to annotate nodes thus not really encouraging 
custom annotations. Moreover some views (be it bad or good) require more 
than those two parameters.

I'm also still wondering if it's better to have a clean / pure HTML page 
with some javascript annotations as in :


   <div id="foo">something</div>
   ... and a javascript object :
   annotations = {foo: {rql: '...', vid: '...'}}

or to directly annotate HTML as you did in your example. The latter does 
not really feel right for me because it looks like it only tries to take 
advantage of HTML / browser laxity but is definitely simpler to read or 
wget + postprocess and HTML5 data attributes [1] somewhat encourages this.

[1] : 
http://dev.w3.org/html5/spec/global-attributes.html#custom-data-attribute

That being said, I like the whole idea, it will expose more clearly the 
selection / view mechanism and other tools such (e.g. the debug console) 
could benefit from a clean way to annotate page chunks.

> It would also allow new features like "zoom". Some overlay could
> appear when the mouse enters a div that has data-cw_rql/vid
> attributes. Clicking on the "zoom" icon shown by that overlay would
> make the value of cw_rql the new query.

This would indeed be a nice feature.

-- 
Adrien Di Mascio - LOGILAB, Paris (France).
Tél: 01.45.32.03.12
Formations - http://www.logilab.fr/formations
Développements - http://www.logilab.fr/services
Gestion de connaissances - http://www.cubicweb.org/


More information about the Cubicweb mailing list