On 12/14/2009 11:50 PM, Jerome Velociter wrote:
> On 12/14/09 6:38 PM, lucaa (SVN) wrote:
>> Author: lucaa
>> Date: 2009-12-14 18:38:53 +0100 (Mon, 14 Dec 2009)
>> New Revision: 25793
>>
>> Modified:
>>      
>> contrib/sandbox/xwiki-annotation-parent/xwiki-annotation-application/src/main/resources/Panels/AnnotationManager.xml
>> Log:
>> Fixed js client to work in multiwiki mode.
>>
>>
>> Modified: 
>> contrib/sandbox/xwiki-annotation-parent/xwiki-annotation-application/src/main/resources/Panels/AnnotationManager.xml
>> ===================================================================
>> --- 
>> contrib/sandbox/xwiki-annotation-parent/xwiki-annotation-application/src/main/resources/Panels/AnnotationManager.xml
>>      2009-12-14 17:27:26 UTC (rev 25792)
>> +++ 
>> contrib/sandbox/xwiki-annotation-parent/xwiki-annotation-application/src/main/resources/Panels/AnnotationManager.xml
>>      2009-12-14 17:38:53 UTC (rev 25793)
>> @@ -12,8 +12,8 @@
>>    <customClass></customClass>
>>    <contentAuthor>XWiki.Admin</contentAuthor>
>>    <creationDate>1240502446000</creationDate>
>> -<date>1259676301000</date>
>> -<contentUpdateDate>1259676301000</contentUpdateDate>
>> +<date>1260811068000</date>
>> +<contentUpdateDate>1260811068000</contentUpdateDate>
>>    <version>1.0</version>
>>    <title></title>
>>    <template></template>
>> @@ -277,6 +277,7 @@
>>    XWiki.Annotation.prototype = {
>>        /* Utils */
>>        getDocumentInfos : function() {
>> +        // TODO: get these from the XWiki object or meta tags
>>            var space = '';
>>            var page = '';
>>            window.location.pathname.toString().scan(/\/[^\/]+/, 
>> function(match) {
>> @@ -295,6 +296,7 @@
>>            page = page.replace('/', '');
>>            return {
>>                host : location.host,
>> +            'wiki' :  XWiki.currentWiki,
>>                'space' : space,
>>                'page' : page
>>            };
>> @@ -463,11 +465,18 @@
>>                  
>> XWiki.Annotation.getInstance().updateAnnotationResumeAux(items);
>>                  return;
>>                }
>> -            var space = anno.author.split('.')[0];
>> -            var page = anno.author.split('.')[1];
>> +            var wiki = anno.author.split(':')[0];
>> +            var localAuthor = anno.author.split(':')[1];
>> +            // if there is no wiki in the username (user is already local), 
>> use XWiki.currentWiki for wiki and wiki for localAuthor
>> +            if (!localAuthor) {
>> +              localAuthor = wiki;
>> +              wiki = XWiki.currentWiki;
>> +            }
>> +            var space = localAuthor.split('.')[0];
>> +            var page = localAuthor.split('.')[1];
>>                var url = 'http://'
>>                        + location.host
>> -                    + '/xwiki/rest/wikis/xwiki/spaces/'
>> +                    + '/xwiki/rest/wikis/' + wiki + '/spaces/'
>>                        + space
>>                        + '/pages/'
>>                        + page
>> @@ -537,7 +546,7 @@
>>            }
>>            XWiki.Annotation.getInstance().annotatedDocumentFlag = 1;
>>            var infos = XWiki.Annotation.getInstance().getDocumentInfos();
>> -        var url = 'http://' + infos.host + '/xwiki/rest/wikis/xwiki/spaces/'
>> +        var url = 'http://' + infos.host + '/xwiki/rest/wikis/' + 
>> infos.wiki + '/spaces/'
>>                    + infos.space + '/pages/' + infos.page
>>                    + '/annotation?media=json';
>>            new Ajax.Request(url, {
>> @@ -549,7 +558,7 @@
>>
>>        removeAnnotation : function(id) {
>>            var infos = XWiki.Annotation.getInstance().getDocumentInfos();
>> -        var url = 'http://' + infos.host + '/xwiki/rest/wikis/xwiki/spaces/'
>> +        var url = 'http://' + infos.host + '/xwiki/rest/wikis/' + 
>> infos.wiki + '/spaces/'
>>
>
> To be on the safe side you should use XWiki.contextPath in place of
> "/xwiki".

Hi Jerome,

thanks for the review. This js is so far from being final, I just did this fix 
so that we can use it on the incubator. Otherwise there is still cleaning to 
do, 
I haven't even started with it.


>
> We really need to add some helper methods in the XWiki object, to create
> URLs...

+1

Thanks,
Anca

>
> Jerome.
>>                    + infos.space + '/pages/' + infos.page + '/annotation/' + 
>> id
>>                    + '?method=DELETE&amp;media=json';
>>            new Ajax.Request(url, {
>> @@ -561,7 +570,7 @@
>>
>>        addAnnotation : function() {
>>            var infos = XWiki.Annotation.getInstance().getDocumentInfos();
>> -        var url = 'http://' + infos.host + '/xwiki/rest/wikis/xwiki/spaces/'
>> +        var url = 'http://' + infos.host + '/xwiki/rest/wikis/' + 
>> infos.wiki + '/spaces/'
>>                    + infos.space + '/pages/' + infos.page
>>                    + '/annotation?method=PUT&amp;media=json';
>>            new Ajax.Request(url, {
>>
>> _______________________________________________
>> notifications mailing list
>> [email protected]
>> http://lists.xwiki.org/mailman/listinfo/notifications
>>
>
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to