On 11/17/2010 09:24 AM, Ricardo Rodriguez [eBioTIC.] wrote:
Marius Dumitru Florea wrote:
On 11/16/2010 01:24 AM, Ricardo Rodriguez [eBioTIC.] wrote:
Marius Dumitru Florea wrote:
On 11/15/2010 03:05 PM, Sergiu Dumitriu wrote:
On 11/15/2010 09:18 AM, Raluca Stavro wrote:
Hello Ricardo,
Yes, you can use velocity code inside SSX and JSX objects. What you need to do is to set the 'Parse content' property to 'Yes'. You can take a look at the SSX documentation: http://code.xwiki.org/xwiki/bin/view/Plugins/SkinExtensionsPlugin#HTip:Howto... .
Example of usage: #if(!$hasEdit) #body{ background-color: red; } #end
This is problematic, since the extension is cached on the clientside (browser cache). So if a user visits the wiki once unauthenticated, after he logs in the same CSS file (already parsed) is used, so nothing will change in the UI.
To load the re-parsed CSS, either refresh the browser cache, or you can set the Cache property of the extension to "Forbid", which is bad for performance.
In this particular case changing the JavaScript code that loads the annotation feature is better IMO.
I tried but failed to do that.
Ricardo, did you check AnnotationCode.Script ? I can see these lines at the end of the second JSX (named "Annotation Javascript -- Annotation application"):
// if the action on the current document is not view, don't load annotations if (XWiki.contextaction != "view") { return; }
I'm sure you can extend the test for your needs.
Hope this helps, Marius
I think I get the point. Even though I'm not able to understand this script now or how to tweak it, I understand that this option blocks the loading process of the annotation feature. It is "cheaper" to do that as it stops a process not required for a given type of users.
But, please, one more question. When is this script executed? Each time a document is loaded or even reloaded?
The JavaScript code of this extension is evaluated (loaded into browser's memory) for each wiki page, and the code at the end of the second JSX object is executed after a wiki page finished loading (in the browser):
document.observe('xwiki:dom:loaded', function() { ... // code executed after the page finished loading. });
Does this match your needs:
document.observe('xwiki:dom:loaded', function() { // if the action on the current document is not view, don't load annotations if (XWiki.contextaction != "view" || !XWiki.hasEdit) { return; } ...// the rest of the code that loads the annotation feature. });
It works without a glitch (XE 2.7-SNAPSHOT.32908). I think it is more elegant than tweaking CSS and doesn't compromise performance. Thanks!
Note that XWiki.hasEdit is defined in javascript.vm .
And this is the reason why I'm not forced to include xwikivars.vm in the modified JSX. Please, am I right? I could use !$hasEdit, but then I must include #template('xwikivars.vm'). I've tried and it seems to work fine.
Exactly.
Please, why don't directly use !$xwiki.hasAccessLevel('edit')?
To avoid (re)evaluating/recomputing the edit right multiple times (it may be costly). The value returned by $xwiki.hasAccessLevel('edit') is cached in $hasEdit to speed up the page loading time. $hasEdit (velocity, server-side) is also send to the client side in the value of the "hasEdit" property of XWiki JavaScript object. Hope this helps, Marius
Thanks!
Hope this helps, Marius
Thanks!
Raluca.
On Mon, Nov 15, 2010 at 12:36 AM, Ricardo Rodriguez [eBioTIC.] <[email protected]> wrote:
> Ricardo Rodriguez [eBioTIC.] wrote: > > >> Hi, >> >> I see how to control edit, export, action and watch appearance in >> contentmenu div by tweaking contentmenu.vm. But, please, how could I get >> the same control over Annotations entry in the same are? >> >> I want to show annotations only to users with edit rights in a given doc. >> >> Thanks! >> >> Ricardo >> >> >> >> > The object of type XWiki.StyleSheetExtension in AnnotationCode.Style > holds the code that seems to control how the action menu entry is shown. > > Currently, to hide the annotation icon on this menu will be enough for me. > > I can add visibility:hidden; to the concerned .actionmenu elements, but > this also hides them for users with edit rights. > > Please, is it possible to add ##if($hasEdit)...#else...#end structures > in a SSE? My bet is that this is not possible: this extensions holds CSS > code, not a script. So, please, how could I introduce conditional > structures to control how page elements are show? > > I guess I must tweak AnnotationCode.Script but, please, how? > > Any help will be welcome! Thanks. > > Best, > > Ricardo > > -- > Ricardo RodrÃguez > CTO > eBioTIC. > Life Sciences, Data Modeling and Information Management Systems > > _______________________________________________ > users mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/users > > > _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users