[Cubicweb] annotating divs with rql and vid

Sylvain Thénault sylvain.thenault at logilab.fr
Thu May 24 17:33:16 CEST 2012


On 24 mai 17:02, Adrien Di Mascio wrote:
> 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.

What I dislike the most in the _loadDynamicFragments and related div
is its reliance on document loaded event, where magic occurs to find
those div, and then make relevant ajax call to replace them.

I would rather have explicit javascript call.

> 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.

The latter == <div id=foo rql=...> ?

If there is some clean way to decorate html tags with desired information,
I would rather go for it than for a separated-annotation-in-js mecanism.
IMO it makes things clearer to read (and probably to generate).

Anayway let's drop XHTML support quickly so we can think to something else! :)
-- 
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (09.54.03.55.76)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org


More information about the Cubicweb mailing list