[xwiki-devs] Annotation plugin
Now my objects are persistents. But i don't know how to access their properties. Should i create an annotation class through the XWiki class editor? It seems that in my database, none of the properties of my annotations are stored. I define an annotation for a document: $xwiki.annotation.addNewAnnotation($doc,"blablablaAnnotation",0,10,"blablaSelection","auteur") I retrieve all annotations of a document: #set($annots=$doc.getObjects("annotation")) And i try to get the selection field of my annotations: #foreach($annot in $annots) "$annot.get("selection")" #end But all i have is "". What should i do? -- Antoine SEILLES Doctorant (phd student) Pikko software Cap Omega - Rond Point Benjamin Franklin CS 39521 34960 Montpellier Cedex 2 FRANCE LIRMM CNRS UMR 5506 - 161 rue Ada 34392 Montpellier Cedex 5 FRANCE Tel: +33 (0)6 10 192 055 http://www.pikko-software.com http://www.lirmm.fr
Hi, Indeed you are lacking an AnnotationClass here You should use AnnotationClasses.AnnotationClass -> begin -> end -> selection -> author -> date Then you should make sure you persist your annotation using this object.. Once you have that you would get them by doing $doc.getObject("AnnotationClasses.AnnotationClass") or better $doc.use("AnnotationClasses.AnnotationClass") $doc.getValue("begin") Ludovic antoine SEILLES wrote:
Now my objects are persistents. But i don't know how to access their properties. Should i create an annotation class through the XWiki class editor? It seems that in my database, none of the properties of my annotations are stored.
I define an annotation for a document: $xwiki.annotation.addNewAnnotation($doc,"blablablaAnnotation",0,10,"blablaSelection","auteur")
I retrieve all annotations of a document: #set($annots=$doc.getObjects("annotation")) And i try to get the selection field of my annotations: #foreach($annot in $annots) "$annot.get("selection")" #end
But all i have is "".
What should i do?
------------------------------------------------------------------------
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Ludovic Dubost Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost
Hi, Thank for your help. So i have changed my class Annotation into AnnotationClass (and i changed debut into begin and fin into end). But what does AnnotationClasses represents? Should it be the name of my package? In AnnotationPlugin i have a method getName: public String getName() { return "annotation"; } What should it return instead of "annotation"? Ludovic Dubost a écrit :
Hi,
Indeed you are lacking an AnnotationClass here You should use
AnnotationClasses.AnnotationClass -> begin -> end -> selection -> author -> date
Then you should make sure you persist your annotation using this object.. Once you have that you would get them by doing
$doc.getObject("AnnotationClasses.AnnotationClass") or better $doc.use("AnnotationClasses.AnnotationClass") $doc.getValue("begin")
Ludovic
antoine SEILLES wrote:
Now my objects are persistents. But i don't know how to access their properties. Should i create an annotation class through the XWiki class editor? It seems that in my database, none of the properties of my annotations are stored.
I define an annotation for a document: $xwiki.annotation.addNewAnnotation($doc,"blablablaAnnotation",0,10,"blablaSelection","auteur")
I retrieve all annotations of a document: #set($annots=$doc.getObjects("annotation")) And i try to get the selection field of my annotations: #foreach($annot in $annots) "$annot.get("selection")" #end
But all i have is "".
What should i do?
------------------------------------------------------------------------
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Antoine SEILLES Doctorant (phd student) Pikko software Cap Omega - Rond Point Benjamin Franklin CS 39521 34960 Montpellier Cedex 2 FRANCE LIRMM CNRS UMR 5506 - 161 rue Ada 34392 Montpellier Cedex 5 FRANCE Tel: +33 (0)6 10 192 055 http://www.pikko-software.com http://www.lirmm.fr
AnnotationClass should be a wiki page describing your class.. Check the tutorial for FAQClass as an example http://www.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial Once you have a working XWiki Class storing data in your wiki, you can work on your plugin to create such objects programmatically. Ludovic antoine SEILLES wrote:
Hi, Thank for your help.
So i have changed my class Annotation into AnnotationClass (and i changed debut into begin and fin into end). But what does AnnotationClasses represents? Should it be the name of my package?
In AnnotationPlugin i have a method getName: public String getName() { return "annotation"; } What should it return instead of "annotation"?
Ludovic Dubost a écrit :
Hi,
Indeed you are lacking an AnnotationClass here You should use
AnnotationClasses.AnnotationClass -> begin -> end -> selection -> author -> date
Then you should make sure you persist your annotation using this object.. Once you have that you would get them by doing
$doc.getObject("AnnotationClasses.AnnotationClass") or better $doc.use("AnnotationClasses.AnnotationClass") $doc.getValue("begin")
Ludovic
antoine SEILLES wrote:
Now my objects are persistents. But i don't know how to access their properties. Should i create an annotation class through the XWiki class editor? It seems that in my database, none of the properties of my annotations are stored.
I define an annotation for a document: $xwiki.annotation.addNewAnnotation($doc,"blablablaAnnotation",0,10,"blablaSelection","auteur")
I retrieve all annotations of a document: #set($annots=$doc.getObjects("annotation")) And i try to get the selection field of my annotations: #foreach($annot in $annots) "$annot.get("selection")" #end
But all i have is "".
What should i do?
------------------------------------------------------------------------
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Ludovic Dubost Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost
Ok that's what i thought: i can't do without the XWiki class editor. So if i want to add my plugin to another XWiki installation, i'll have to create an AnnotationClass through the class editor. Thank you. Ludovic Dubost a écrit :
AnnotationClass should be a wiki page describing your class.. Check the tutorial for FAQClass as an example http://www.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial
Once you have a working XWiki Class storing data in your wiki, you can work on your plugin to create such objects programmatically.
Ludovic
antoine SEILLES wrote:
Hi, Thank for your help.
So i have changed my class Annotation into AnnotationClass (and i changed debut into begin and fin into end). But what does AnnotationClasses represents? Should it be the name of my package?
In AnnotationPlugin i have a method getName: public String getName() { return "annotation"; } What should it return instead of "annotation"?
Ludovic Dubost a écrit :
Hi,
Indeed you are lacking an AnnotationClass here You should use
AnnotationClasses.AnnotationClass -> begin -> end -> selection -> author -> date
Then you should make sure you persist your annotation using this object.. Once you have that you would get them by doing
$doc.getObject("AnnotationClasses.AnnotationClass") or better $doc.use("AnnotationClasses.AnnotationClass") $doc.getValue("begin")
Ludovic
antoine SEILLES wrote:
Now my objects are persistents. But i don't know how to access their properties. Should i create an annotation class through the XWiki class editor? It seems that in my database, none of the properties of my annotations are stored.
I define an annotation for a document: $xwiki.annotation.addNewAnnotation($doc,"blablablaAnnotation",0,10,"blablaSelection","auteur")
I retrieve all annotations of a document: #set($annots=$doc.getObjects("annotation")) And i try to get the selection field of my annotations: #foreach($annot in $annots) "$annot.get("selection")" #end
But all i have is "".
What should i do?
------------------------------------------------------------------------
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Antoine SEILLES Doctorant (phd student) Pikko software Cap Omega - Rond Point Benjamin Franklin CS 39521 34960 Montpellier Cedex 2 FRANCE LIRMM CNRS UMR 5506 - 161 rue Ada 34392 Montpellier Cedex 5 FRANCE Tel: +33 (0)6 10 192 055 http://www.pikko-software.com http://www.lirmm.fr
You plugin can create the class at initialization time.. Check the CalendarPlugin in the XWiki source https://svn.xwiki.org/svnroot/xwiki/xwiki-platform/core/trunk/xwiki-core/src... Ludovic antoine SEILLES wrote:
Ok that's what i thought: i can't do without the XWiki class editor. So if i want to add my plugin to another XWiki installation, i'll have to create an AnnotationClass through the class editor.
Thank you.
Ludovic Dubost a écrit :
AnnotationClass should be a wiki page describing your class.. Check the tutorial for FAQClass as an example http://www.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial
Once you have a working XWiki Class storing data in your wiki, you can work on your plugin to create such objects programmatically.
Ludovic
antoine SEILLES wrote:
Hi, Thank for your help.
So i have changed my class Annotation into AnnotationClass (and i changed debut into begin and fin into end). But what does AnnotationClasses represents? Should it be the name of my package?
In AnnotationPlugin i have a method getName: public String getName() { return "annotation"; } What should it return instead of "annotation"?
Ludovic Dubost a écrit :
Hi,
Indeed you are lacking an AnnotationClass here You should use
AnnotationClasses.AnnotationClass -> begin -> end -> selection -> author -> date
Then you should make sure you persist your annotation using this object.. Once you have that you would get them by doing
$doc.getObject("AnnotationClasses.AnnotationClass") or better $doc.use("AnnotationClasses.AnnotationClass") $doc.getValue("begin")
Ludovic
antoine SEILLES wrote:
Now my objects are persistents. But i don't know how to access their properties. Should i create an annotation class through the XWiki class editor? It seems that in my database, none of the properties of my annotations are stored.
I define an annotation for a document: $xwiki.annotation.addNewAnnotation($doc,"blablablaAnnotation",0,10,"blablaSelection","auteur")
I retrieve all annotations of a document: #set($annots=$doc.getObjects("annotation")) And i try to get the selection field of my annotations: #foreach($annot in $annots) "$annot.get("selection")" #end
But all i have is "".
What should i do?
------------------------------------------------------------------------
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Ludovic Dubost Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost
HI, now next step is to add an annotation using velocity template. I did an addannotation.vm template (view attached files). I'had like to do a form like in commentsinline.vm. But i have a problem: $doc.getURL("commentadd") How does it work? I can't find the URLFactory.java file. I had like to do $doc.getURL("annotationadd") that would add my annotation and, like than for comments, would return to the active doc. Thank you for your help. Ludovic Dubost a écrit :
You plugin can create the class at initialization time.. Check the CalendarPlugin in the XWiki source https://svn.xwiki.org/svnroot/xwiki/xwiki-platform/core/trunk/xwiki-core/src...
Ludovic
antoine SEILLES wrote:
Ok that's what i thought: i can't do without the XWiki class editor. So if i want to add my plugin to another XWiki installation, i'll have to create an AnnotationClass through the class editor.
Thank you.
Ludovic Dubost a écrit :
AnnotationClass should be a wiki page describing your class.. Check the tutorial for FAQClass as an example http://www.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial
Once you have a working XWiki Class storing data in your wiki, you can work on your plugin to create such objects programmatically.
Ludovic
antoine SEILLES wrote:
Hi, Thank for your help.
So i have changed my class Annotation into AnnotationClass (and i changed debut into begin and fin into end). But what does AnnotationClasses represents? Should it be the name of my package?
In AnnotationPlugin i have a method getName: public String getName() { return "annotation"; } What should it return instead of "annotation"?
Ludovic Dubost a écrit :
Hi,
Indeed you are lacking an AnnotationClass here You should use
AnnotationClasses.AnnotationClass -> begin -> end -> selection -> author -> date
Then you should make sure you persist your annotation using this object.. Once you have that you would get them by doing
$doc.getObject("AnnotationClasses.AnnotationClass") or better $doc.use("AnnotationClasses.AnnotationClass") $doc.getValue("begin")
Ludovic
antoine SEILLES wrote:
Now my objects are persistents. But i don't know how to access their properties. Should i create an annotation class through the XWiki class editor? It seems that in my database, none of the properties of my annotations are stored.
I define an annotation for a document: $xwiki.annotation.addNewAnnotation($doc,"blablablaAnnotation",0,10,"blablaSelection","auteur")
I retrieve all annotations of a document: #set($annots=$doc.getObjects("annotation")) And i try to get the selection field of my annotations: #foreach($annot in $annots) "$annot.get("selection")" #end
But all i have is "".
What should i do?
------------------------------------------------------------------------
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Antoine SEILLES Doctorant (phd student) Pikko software Cap Omega - Rond Point Benjamin Franklin CS 39521 34960 Montpellier Cedex 2 FRANCE LIRMM CNRS UMR 5506 - 161 rue Ada 34392 Montpellier Cedex 5 FRANCE Tel: +33 (0)6 10 192 055 http://www.pikko-software.com http://www.lirmm.fr #if($xwiki.hasAccessLevel("comment")) #set($cclass = $xwiki.getDocument("XWiki.AnnotationClass").getxWikiClass()) #set($comment = $cclass.newObject()) <form action="$doc.getURL("annotationadd")" method="post"> <fieldset class="expanded" id="commentform"> <legend onclick="toggleForm(this.form)">$msg.get("addcomment")<span class="expands">...</span></legend> <input type="hidden" name="xredirect" value="${doc.getURL("view")}" /> <input type="hidden" name="XWiki.AnnotationClass_author" value="$context.user"/> <input type="hidden" name="XWiki.AnnotationClass_begin" value="0"/> <input type="hidden" name="XWiki.AnnotationClass_end" value="10"/> <input type="hidden" name="XWiki.AnnotationClass_selection" value="blablabla pour le moment"/> <div><textarea id='XWiki.XWikiComments_comment' rows='5' cols="80" name='XWiki.Annotation_comment' style="width: 100%;"></textarea></div> <div> <span class="buttonwrapper"><input type="submit" value="$msg.get("addannotation")" class="button"/></span> <span class="buttonwrapper"><input type="reset" value="$msg.get("cancel")" onclick="hideForm(this.form);" class="button"/></span> </div> </fieldset> </form> #end </div> ## comments </div> ## commentscontent
Hi Antoine, antoine SEILLES wrote:
HI, now next step is to add an annotation using velocity template. I did an addannotation.vm template (view attached files). I'had like to do a form like in commentsinline.vm. But i have a problem: $doc.getURL("commentadd") How does it work? I can't find the URLFactory.java file. I had like to do $doc.getURL("annotationadd") that would add my annotation and, like than for comments, would return to the active doc.
If you want to code the annotation feature exactly as the comment feature, you need to have to look at the "commentadd" action in "WEB-INF/struts-config.xml" and at the related classes like "CommentAddAction" and the places where they show up, like XWikiRightServiceImpl.java, and then to introduce the same elements for the Annotation classes. That's not necessarily the simplest thing to do, though. Another option is to use Groovy or Velocity scripts directly in wiki pages for introducing the annotation feature. For example, for the help desk we're developing, the answers to questions asked are added as XWiki objects through Groovy scripts, even though the feature is similar to the XWikiComment feature as well. The main advantage I see in using scripts in wiki pages instead of external templates is that it's then easier to evolve those scripts collaboratively. You can see the way it's coded from [1], and the add "?viewer=code" at the end of the URLs for viewing the code. [1] http://club.mandriva.com/xwiki/bin/view/ITS/ Introducing annotation capabilities to XWiki is very relevant in various contexts. I would say we should think about the capabilities of the plugin a bit more before developing it. Here are some considerations: 1) do we want to have the possibility to annotate annotations? And also to tag annotations? If yes, having each annotation in a separate document would probably be a better design. Personally, I think that'd be a good feature to support tagging for annotations, letting users describe some annotations as "critique" for instance, or rating some annotations through the rating plugin when one will be available. 2) what about rights? That may be handy to have various access rights for annotations? Imagine a teacher and her students annotating a document. The teacher may wish to keep her annotation private while the students collaboratively annotate the same piece of document... 3) choosing a name would help packaging the plugin into a unique Space (not sure about the guidelines we chose there eventually, but having all the wiki pages for a given feature in a single space increases lisibility, I think) 4) how will we manage annotations on evolving documents? If the structure remains the same, that may be ok, but what will happen when a user moves an entire paragraph to a different position? Do you know if there has been some work on this? I propose we use the following page for refining the design of the feature: http://www.xwiki.org/xwiki/bin/view/Design/AnnotationFeature That may be easier to give input to the plugin development once we'll have a common view on what we aim at. Note that annotation capabilities also share some aspects with the PSEW prototype, that allows for external annotations of wiki pages (external in the sense that annotations are then stored in a completely distinct database): http://nepomuk-eclipse.semanticdesktop.org/xwiki/bin/view/Main/PSEW Cheers Stéphane
Thank you for your help.
Ludovic Dubost a écrit :
You plugin can create the class at initialization time.. Check the CalendarPlugin in the XWiki source https://svn.xwiki.org/svnroot/xwiki/xwiki-platform/core/trunk/xwiki-core/src...
Ludovic
antoine SEILLES wrote:
Ok that's what i thought: i can't do without the XWiki class editor. So if i want to add my plugin to another XWiki installation, i'll have to create an AnnotationClass through the class editor.
Thank you.
Ludovic Dubost a écrit :
AnnotationClass should be a wiki page describing your class.. Check the tutorial for FAQClass as an example http://www.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial
Once you have a working XWiki Class storing data in your wiki, you can work on your plugin to create such objects programmatically.
Ludovic
antoine SEILLES wrote:
Hi, Thank for your help.
So i have changed my class Annotation into AnnotationClass (and i changed debut into begin and fin into end). But what does AnnotationClasses represents? Should it be the name of my package?
In AnnotationPlugin i have a method getName: public String getName() { return "annotation"; } What should it return instead of "annotation"?
Ludovic Dubost a écrit :
Hi,
Indeed you are lacking an AnnotationClass here You should use
AnnotationClasses.AnnotationClass -> begin -> end -> selection -> author -> date
Then you should make sure you persist your annotation using this object.. Once you have that you would get them by doing
$doc.getObject("AnnotationClasses.AnnotationClass") or better $doc.use("AnnotationClasses.AnnotationClass") $doc.getValue("begin")
Ludovic
antoine SEILLES wrote:
> Now my objects are persistents. But i don't know how to access > their properties. > Should i create an annotation class through the XWiki class editor? > It seems that in my database, none of the properties of my > annotations are stored. > > I define an annotation for a document: > $xwiki.annotation.addNewAnnotation($doc,"blablablaAnnotation",0,10,"blablaSelection","auteur") > > I retrieve all annotations of a document: > #set($annots=$doc.getObjects("annotation")) > And i try to get the selection field of my annotations: > #foreach($annot in $annots) > "$annot.get("selection")" > #end > > But all i have is "". > > What should i do? > > ------------------------------------------------------------------------ > > > _______________________________________________ > devs mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/devs >
------------------------------------------------------------------------
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Stéphane Laurière [email protected] XWiki http://www.xwiki.com http://concerto.xwiki.com http://nepomuk.semanticdesktop.org
All these considerations are interesting. I agree we should think a bit more about capabilities of the plugin but i'had like to do a demo of what it could look like on wednesday 12 december. Timing is short. Well, i have new difficulties every day. I don't understand why but i have difficulties to include javascript. When i do <script language="javascript" type="text/javascript"> alert("toto");</script> no pbs. but when i do: <script language="javascript" type="text/javascript" src="getSelection.js"></script> <script language="javascript" type="text/javascript"> getSelection();</script> with getSelection.js : function getSelection(){ alert("toto"); } I have an error in my console: getSelection is not define. Another point is, how to get the values of a form in velocity? I have an addannotation.vm : #if($xwiki.hasAccessLevel("comment")) #set($cclass = $xwiki.getDocument("XWiki.AnnotationClass").getxWikiClass()) #set($annotation = $cclass.newObject()) <form action="XXXXXXXXX" method="post" id="myForm"> <fieldset class="expanded" id="commentform"> <legend onclick="toggleForm(this.form)">$msg.get("addannotationcomment")<span class="expands">...</span></legend> <input type="hidden" name="xredirect" value="${doc.getURL("view")}" /> <input type="hidden" name="AnnotationClass_author" value="$context.user"/> <input type="hidden" name="AnnotationClass_begin" value=0/> <input type="hidden" name="AnnotationClass_end" value=0/> <input type="hidden" name="AnnotationClass_selection" value="blablabla pour le moment"/> <div><textarea id='XWiki.XWikiComments_comment' rows='5' cols="80" name='XWiki.Annotation_comment' style="width: 100%;"></textarea></div> <div> <span class="buttonwrapper"><input type="submit" value="$msg.get("addannotation")" class="button"/></span> <span class="buttonwrapper"><input type="reset" value="$msg.get("cancel")" onclick="hideForm(this.form);" class="button"/></span> </div> </fieldset> </form> #end </div> ## comments </div> ## commentscontent I'd like to have a link to a page in "<form action=" that would print "your annotation has been added" and that would call my function $xwiki.annotation.addNewAnnotation($doc, $AnnotationClass_selection, $AnnotationClass_begin, $AnnotationClass_end, $AnnotationClass_selection, $AnnotationClass_author) (where $AnnotationClass_begin is the value of AnnotationClass_begin field). Stéphane Laurière a écrit :
If you want to code the annotation feature exactly as the comment feature, you need to have to look at the "commentadd" action in "WEB-INF/struts-config.xml" and at the related classes like "CommentAddAction" and the places where they show up, like XWikiRightServiceImpl.java, and then to introduce the same elements for the Annotation classes.
That's not necessarily the simplest thing to do, though. Another option is to use Groovy or Velocity scripts directly in wiki pages for introducing the annotation feature. For example, for the help desk we're developing, the answers to questions asked are added as XWiki objects through Groovy scripts, even though the feature is similar to the XWikiComment feature as well. The main advantage I see in using scripts in wiki pages instead of external templates is that it's then easier to evolve those scripts collaboratively. You can see the way it's coded from [1], and the add "?viewer=code" at the end of the URLs for viewing the code.
I agrre, it's a bit hard for a xwiki beginner.
[1] http://club.mandriva.com/xwiki/bin/view/ITS/
Introducing annotation capabilities to XWiki is very relevant in various contexts. I would say we should think about the capabilities of the plugin a bit more before developing it.
Here are some considerations:
1) do we want to have the possibility to annotate annotations? And also to tag annotations? If yes, having each annotation in a separate document would probably be a better design. Personally, I think that'd be a good feature to support tagging for annotations, letting users describe some annotations as "critique" for instance, or rating some annotations through the rating plugin when one will be available.
We want to have the possibility to tag and annotate annotations. But we want to have the possiblility to list for a doc all the annotations linked to.
2) what about rights? That may be handy to have various access rights for annotations? Imagine a teacher and her students annotating a document. The teacher may wish to keep her annotation private while the students collaboratively annotate the same piece of document...
OK
3) choosing a name would help packaging the plugin into a unique Space (not sure about the guidelines we chose there eventually, but having all the wiki pages for a given feature in a single space increases lisibility, I think)
I'm not sure to understand. I have named my plugin: annotation. And i want to be able to annotate any docs in any space.
4) how will we manage annotations on evolving documents? If the structure remains the same, that may be ok, but what will happen when a user moves an entire paragraph to a different position? Do you know if there has been some work on this?
Arf. I don't know. In this case, to localise annotation using tag should be better than using references.
I propose we use the following page for refining the design of the feature: http://www.xwiki.org/xwiki/bin/view/Design/AnnotationFeature
Great idea but i can't edit the page.
That may be easier to give input to the plugin development once we'll have a common view on what we aim at.
Of course.
Note that annotation capabilities also share some aspects with the PSEW prototype, that allows for external annotations of wiki pages (external in the sense that annotations are then stored in a completely distinct database): http://nepomuk-eclipse.semanticdesktop.org/xwiki/bin/view/Main/PSEW
Cheers
Stéphane
Thank you. And thank for your help. PS: my plugin and templates are attached. addannotation.vm doesn't work cause of the form action. -- Antoine SEILLES Doctorant (phd student) Pikko software Cap Omega - Rond Point Benjamin Franklin CS 39521 34960 Montpellier Cedex 2 FRANCE LIRMM CNRS UMR 5506 - 161 rue Ada 34392 Montpellier Cedex 5 FRANCE Tel: +33 (0)6 10 192 055 http://www.pikko-software.com http://www.lirmm.fr #if($xwiki.hasAccessLevel("comment")) #set($cclass = $xwiki.getDocument("XWiki.AnnotationClass").getxWikiClass()) #set($annotation = $cclass.newObject()) <form action=$xwiki.annotation.addNewAnnotation($doc, $AnnotationClass_selection, $AnnotationClass_begin, $AnnotationClass_end, $AnnotationClass_selection, $AnnotationClass_author) method="post" id="myForm"> <fieldset class="expanded" id="commentform"> <legend onclick="toggleForm(this.form)">$msg.get("addannotationcomment")<span class="expands">...</span></legend> <input type="hidden" name="xredirect" value="${doc.getURL("view")}" /> <input type="hidden" name="AnnotationClass_author" value="$context.user"/> <input type="hidden" name="AnnotationClass_begin" value=0/> <input type="hidden" name="AnnotationClass_end" value=0/> <input type="hidden" name="AnnotationClass_selection" value="blablabla pour le moment"/> <div><textarea id='XWiki.XWikiComments_comment' rows='5' cols="80" name='XWiki.Annotation_comment' style="width: 100%;"></textarea></div> <div> <span class="buttonwrapper"><input type="submit" value="$msg.get("addannotation")" class="button"/></span> <span class="buttonwrapper"><input type="reset" value="$msg.get("cancel")" onclick="hideForm(this.form);" class="button"/></span> </div> </fieldset> </form> #end </div> ## comments </div> ## commentscontent ### ### List document annotations ### ### TODO: web service? ### #if($xwiki.getWebPreferenceAsInt("commentsorder",1)==1) #set($annotations = $xwiki.annotation.getAnnotations($doc)) #end <div id="annotationscontent" class="xwikiintracontent"> #if($inline && ($inline == true)) <div class="xwikititlewrapper" onclick="toggleClass($('annotations'), 'hidden'); toggleClass($('annotationscontent'), 'exp')"><h3 class="xwikiintratitle">$msg.get("annotations")<span class="hidden">:</span> <span class="annotationsno"><span>$annotations.size()</span></span></h3></div>#end <div id="annotations"> #if($annotations.size()>0) #foreach($annotation in $annotations) #if($velocityCount > 1) <hr class="annotationspacer"/> #end <div id="xwikiannotation_${velocityCount}" class="xwikiannotation #if($velocityCount % 2 == 1) odd #else even #end"> ## <div class="annotationavatar">#useravatar($annotation.getAuthor())</div> <div class="annotationheader"><span class="annotationauthor">$!xwiki.getLocalUserName($doc.display('author','view', $annotation))</span> ## #set($date = $doc.display("date","view",$annotation)) #set($date = $doc.display("created","view",$annotation)) #if($date) | <span class="annotationdate">$date</span> #end #if($hasedit) <span class="annotationdelete"><a class="annotationremove" href="$doc.getURL("objectremove" , "classname=XWiki.AnnotationClass&classid=${annotation.number}&xredirect=${request.getRequestURL()}")" onclick="return confirm('$msg.get("confirmannotationremove")')">[$msg.get("removethisannotation")]</a></span>#end </div> <div class="annotationcontent"><b>$msg.get("annotationselection") :</b> $doc.getRenderedContent($doc.display("selection","view",$annotation)) <br> <b>$msg.get("annotationcommentaire") :</b> $doc.getRenderedContent($doc.display("comment","view",$annotation)) </div> </div> #end #else $msg.get("noannotations") #end </div> ## annotations </div> ## annotationscontent #if($inline && ($inline == true)) <script type="text/javascript"> //<!-- if(document.getElementById("annotationform")) { document.getElementById("annotationform").className = "collapsed"; } document.getElementById("annotations").className += " hidden"; //--> </script> #end
Antoine, antoine SEILLES wrote:
All these considerations are interesting. I agree we should think a bit more about capabilities of the plugin but i'had like to do a demo of what it could look like on wednesday 12 december. Timing is short.
Well, i have new difficulties every day.
I don't understand why but i have difficulties to include javascript. When i do <script language="javascript" type="text/javascript"> alert("toto");</script> no pbs. but when i do: <script language="javascript" type="text/javascript" src="getSelection.js"></script> <script language="javascript" type="text/javascript"> getSelection();</script> with getSelection.js : function getSelection(){ alert("toto"); } I have an error in my console: getSelection is not define.
that's because you don't specify the path where your javascript file is located. You need to use the following syntax: (see the file "javascript.vm"): <script type="text/javascript" src="$xwiki.getSkinFile("skin.js")"></script>
Another point is, how to get the values of a form in velocity? I have an addannotation.vm :
#if($xwiki.hasAccessLevel("comment")) #set($cclass = $xwiki.getDocument("XWiki.AnnotationClass").getxWikiClass()) #set($annotation = $cclass.newObject()) <form action="XXXXXXXXX" method="post" id="myForm"> <fieldset class="expanded" id="commentform"> <legend onclick="toggleForm(this.form)">$msg.get("addannotationcomment")<span class="expands">...</span></legend> <input type="hidden" name="xredirect" value="${doc.getURL("view")}" /> <input type="hidden" name="AnnotationClass_author" value="$context.user"/> <input type="hidden" name="AnnotationClass_begin" value=0/> <input type="hidden" name="AnnotationClass_end" value=0/> <input type="hidden" name="AnnotationClass_selection" value="blablabla pour le moment"/> <div><textarea id='XWiki.XWikiComments_comment' rows='5' cols="80" name='XWiki.Annotation_comment' style="width: 100%;"></textarea></div> <div> <span class="buttonwrapper"><input type="submit" value="$msg.get("addannotation")" class="button"/></span> <span class="buttonwrapper"><input type="reset" value="$msg.get("cancel")" onclick="hideForm(this.form);" class="button"/></span> </div> </fieldset> </form> #end </div> ## comments </div> ## commentscontent
I'd like to have a link to a page in "<form action=" that would print "your annotation has been added" and that would call my function $xwiki.annotation.addNewAnnotation($doc, $AnnotationClass_selection, $AnnotationClass_begin, $AnnotationClass_end, $AnnotationClass_selection, $AnnotationClass_author) (where $AnnotationClass_begin is the value of AnnotationClass_begin field).
the value of the attribute "action" in the form element of "addannotation.vm" is incorrect: you're trying to call a Java method directly ("$xwiki.annotation.addNewAnnotation"), whereas you should put a URL there, just like in the commentsinline.vm: something like "$doc.getURL("annotationadd")" (but then you have to define that action in struts-config.xml etc. as I said previously).
Stéphane Laurière a écrit :
If you want to code the annotation feature exactly as the comment feature, you need to have to look at the "commentadd" action in "WEB-INF/struts-config.xml" and at the related classes like "CommentAddAction" and the places where they show up, like XWikiRightServiceImpl.java, and then to introduce the same elements for the Annotation classes.
That's not necessarily the simplest thing to do, though. Another option is to use Groovy or Velocity scripts directly in wiki pages for introducing the annotation feature. For example, for the help desk we're developing, the answers to questions asked are added as XWiki objects through Groovy scripts, even though the feature is similar to the XWikiComment feature as well. The main advantage I see in using scripts in wiki pages instead of external templates is that it's then easier to evolve those scripts collaboratively. You can see the way it's coded from [1], and the add "?viewer=code" at the end of the URLs for viewing the code.
I agrre, it's a bit hard for a xwiki beginner.
[1] http://club.mandriva.com/xwiki/bin/view/ITS/
Introducing annotation capabilities to XWiki is very relevant in various contexts. I would say we should think about the capabilities of the plugin a bit more before developing it.
Here are some considerations:
1) do we want to have the possibility to annotate annotations? And also to tag annotations? If yes, having each annotation in a separate document would probably be a better design. Personally, I think that'd be a good feature to support tagging for annotations, letting users describe some annotations as "critique" for instance, or rating some annotations through the rating plugin when one will be available.
We want to have the possibility to tag and annotate annotations. But we want to have the possiblility to list for a doc all the annotations linked to.
ok. Putting annotations in documents that are distinct from the main one won't prevent you to link all annotations of each document: we can for instance use the "parent" attribute for that, or an attribute of the annotation class.
2) what about rights? That may be handy to have various access rights for annotations? Imagine a teacher and her students annotating a document. The teacher may wish to keep her annotation private while the students collaboratively annotate the same piece of document...
OK
3) choosing a name would help packaging the plugin into a unique Space (not sure about the guidelines we chose there eventually, but having all the wiki pages for a given feature in a single space increases lisibility, I think)
I'm not sure to understand. I have named my plugin: annotation. And i want to be able to annotate any docs in any space.
My point was just about packaging the documents that comprise the Annotation application itself. In case you use XWiki templates and sheets for manipulating annotations (instead of Velocity pages in the skin folder like you're doing currently, which is another possibility indeed), you will need to store those documents in a space. I was speaking about such a space.
4) how will we manage annotations on evolving documents? If the structure remains the same, that may be ok, but what will happen when a user moves an entire paragraph to a different position? Do you know if there has been some work on this?
Arf. I don't know. In this case, to localise annotation using tag should be better than using references.
I propose we use the following page for refining the design of the feature: http://www.xwiki.org/xwiki/bin/view/Design/AnnotationFeature
Great idea but i can't edit the page.
The platform is being upgraded currently. You should get edit rights again later on as soon as the upgrade process is entirely done.
That may be easier to give input to the plugin development once we'll have a common view on what we aim at.
Of course.
Note that annotation capabilities also share some aspects with the PSEW prototype, that allows for external annotations of wiki pages (external in the sense that annotations are then stored in a completely distinct database): http://nepomuk-eclipse.semanticdesktop.org/xwiki/bin/view/Main/PSEW
Cheers
Stéphane
Thank you. And thank for your help.
you're welcome Stéphane
PS: my plugin and templates are attached. addannotation.vm doesn't work cause of the form action.
------------------------------------------------------------------------
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Stéphane Laurière [email protected] XWiki http://www.xwiki.com http://concerto.xwiki.com http://nepomuk.semanticdesktop.org
Hi, My new problem: now javascript works but i need to have a global variable. So i need a velocity template that would be load only once. I've tried global.vm and menuview.vm but they seem to be load for all page. -- Antoine SEILLES Doctorant (phd student) Pikko software Cap Omega - Rond Point Benjamin Franklin CS 39521 34960 Montpellier Cedex 2 FRANCE LIRMM CNRS UMR 5506 - 161 rue Ada 34392 Montpellier Cedex 5 FRANCE Tel: +33 (0)6 10 192 055 http://www.pikko-software.com http://www.lirmm.fr
antoine SEILLES wrote:
Hi,
My new problem: now javascript works but i need to have a global variable. So i need a velocity template that would be load only once. I've tried global.vm and menuview.vm but they seem to be load for all page.
A set of variables are defined in "albatross/xwikivars.vm". They are reset for each page view/edit actions indeed. For a global variable, one possibily is to define it as an attribute of a class. Another option is to define it directly in your plugin. Cheers Stéphane -- Stéphane Laurière [email protected] XWiki http://www.xwiki.com http://concerto.xwiki.com http://nepomuk.semanticdesktop.org
participants (3)
-
antoine SEILLES -
Ludovic Dubost -
Stéphane Laurière