Browse Source

upgrade caldavzap with algoo caldavzap version

Bastien Sevajol (Algoo) 7 years ago
parent
commit
31aaacb8e6

+ 4 - 1
tracim/tracim/controllers/calendar.py View File

@@ -1,5 +1,5 @@
1 1
 # -*- coding: utf-8 -*-
2
-
2
+import re
3 3
 import tg
4 4
 from tg import tmpl_context
5 5
 
@@ -45,6 +45,8 @@ class CalendarConfigController(BaseController):
45 45
         workspace_base_url = CalendarManager.get_workspace_base_url()
46 46
         workspace_calendar_urls = CalendarManager\
47 47
             .get_workspace_readable_calendars_urls_for_user(user)
48
+        base_href_url = \
49
+            re.sub(r"^http[s]?://", '', CalendarManager.get_base_url())
48 50
 
49 51
         # Template will use User.auth_token, ensure it's validity
50 52
         user.ensure_auth_token()
@@ -55,4 +57,5 @@ class CalendarConfigController(BaseController):
55 57
             workspace_base_url=workspace_base_url,
56 58
             workspace_clendar_urls=workspace_calendar_urls,
57 59
             auth_token=user.auth_token,
60
+            base_href_url=base_href_url,
58 61
         )

+ 3 - 0
tracim/tracim/public/caldavzap/.gitignore View File

@@ -0,0 +1,3 @@
1
+*~
2
+#*
3
+.idea

+ 1 - 1
tracim/tracim/public/caldavzap/cache.manifest View File

@@ -1,5 +1,5 @@
1 1
 CACHE MANIFEST
2
-#V 20160728145557
2
+#V 20160906103401
3 3
 
4 4
 CACHE:
5 5
 common.js

+ 16 - 37
tracim/tracim/public/caldavzap/config.js View File

@@ -306,27 +306,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
306 306
 //	}
307 307
 //];
308 308
 
309
-var globalAccountSettings=[
310
-	{
311
-		href: 'http://127.0.0.1:5232/user/3.ics/',
312
-		userAuth:
313
-		{
314
-			userName: 'bastien.sevajol@algoo.fr',
315
-			userPassword: 'bastien.sevajol@algoo.fr'
316
-			//userName: 'bastien',
317
-			//userPassword: 'bastien'
318
-		},
319
-		timeOut: 90000,
320
-		lockTimeOut: 10000,
321
-		checkContentType: true,
322
-		settingsAccount: true,
323
-		delegation: true,
324
-		hrefLabel: null,
325
-		forceReadOnly: null,
326
-		ignoreAlarms: false,
327
-		backgroundCalendars: []
328
-	}
329
-];
330 309
 
331 310
 // globalNetworkCheckSettings
332 311
 // Use this option if you want to use standard login screen without
@@ -352,22 +331,22 @@ var globalAccountSettings=[
352 331
 // Davical example which automatically detects the protocol, server name,
353 332
 // port, ... (client installed into Davical "htdocs" subdirectory;
354 333
 // works "out of the box", no additional setup required):
355
-// var globalNetworkCheckSettings={
356
-// 	href: location.protocol+'//'+location.hostname+
357
-// 		(location.port ? ':'+location.port: '')+
358
-// 		location.pathname.replace(RegExp('/+[^/]+/*(index\.html)?$'),'')+
359
-// 		'/caldav.php/',
360
-// 	timeOut: 90000,
361
-// 	lockTimeOut: 10000,
362
-//      checkContentType: true,
363
-// 	settingsAccount: true,
364
-//      delegation: true,
365
-// 	additionalResources: [],
366
-//      hrefLabel: null,
367
-// 	forceReadOnly: null,
368
-//      ignoreAlarms: false,
369
-// 	backgroundCalendars: []
370
-// }
334
+var globalNetworkCheckSettings={
335
+	href: location.protocol+'//'+location.hostname+
336
+		(location.port ? ':'+location.port: '')+
337
+		location.pathname.replace(RegExp('/+[^/]+/*(index\.html)?$'),'')+
338
+		'/caldav.php/',
339
+	timeOut: 90000,
340
+	lockTimeOut: 10000,
341
+	checkContentType: true,
342
+	settingsAccount: true,
343
+	delegation: true,
344
+	additionalResources: [],
345
+	hrefLabel: null,
346
+	forceReadOnly: null,
347
+	ignoreAlarms: false,
348
+	backgroundCalendars: []
349
+}
371 350
 
372 351
 
373 352
 // globalNetworkAccountSettings

+ 20 - 0
tracim/tracim/public/caldavzap/main.js View File

@@ -1936,3 +1936,23 @@ function setCalendarNumber(initSearch)
1936 1936
 			globalTodoCalendarNumber++;
1937 1937
 		}
1938 1938
 }
1939
+
1940
+function algoo_get_basehref_for_href(href, globalAccountSettings) {
1941
+	for (config_key in globalAccountSettings) {
1942
+		var config = globalAccountSettings[config_key];
1943
+		if (config.href == href && config.basehref) {
1944
+			return config.basehref;
1945
+		}
1946
+	}
1947
+}
1948
+
1949
+function algoo_replace_regex(href, globalAccountSettings) {
1950
+	var protocol_re = new RegExp('^(https?://)(.*)','i');
1951
+
1952
+	var base_href = algoo_get_basehref_for_href(href, globalAccountSettings);
1953
+	var protocol_match = href.match(protocol_re);
1954
+	var protocol = protocol_match[1];
1955
+	var path = protocol_match[2].replace(base_href, '');
1956
+
1957
+	return [href, protocol, base_href, path]
1958
+}

+ 6 - 10
tracim/tracim/public/caldavzap/webdav_protocol.js View File

@@ -490,8 +490,7 @@ function netSaveProperty(inputCollection, hrefProperty, inputProperty, inputValu
490 490
 function DAVresourceDelegation(inputResource, index, lastIndex)
491 491
 {
492 492
 	globalCalDAVResourceSync=false;
493
-	var re=new RegExp('^(https?://)([^/]+)(.*)', 'i');
494
-	var tmp=inputResource.href.match(re);
493
+	var tmp=algoo_replace_regex(inputResource.href, globalAccountSettings);
495 494
 
496 495
 	var baseHref=tmp[1]+tmp[2];
497 496
 	var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
@@ -1039,8 +1038,7 @@ function netFindResource(inputResource, inputResourceIndex, forceLoad, indexR, l
1039 1038
 		return false;
1040 1039
 	}
1041 1040
 
1042
-	var re=new RegExp('^(https?://)([^/]+)(.*)','i');
1043
-	var tmp=inputResource.href.match(re);
1041
+	var tmp = algoo_replace_regex(inputResource.href, globalAccountSettings);
1044 1042
 	var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
1045 1043
 	var uidFull=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2]+tmp[3];	// for the error handler
1046 1044
 	var settingsXML='';
@@ -1221,7 +1219,6 @@ function netFindResource(inputResource, inputResourceIndex, forceLoad, indexR, l
1221 1219
 
1222 1220
 function netLoadResource(inputResource, inputHref, hrefMode, inputResourceIndex, forceLoad, indexR, loadArray)
1223 1221
 {
1224
-	var re=new RegExp('^(https?://)([^/]+)(.*)','i');
1225 1222
 	if(!isAvaible('CardDavMATE') || !globalCardDAVInitLoad || (globalCardDAVInitLoad && typeof inputResource.addressbookNo == 'undefined'))
1226 1223
 		inputResource.addressbookNo=0;
1227 1224
 	if(!isAvaible('CalDavZAP') || !globalCalDAVInitLoad || (globalCalDAVInitLoad && typeof inputResource.calendarNo=='undefined' && typeof inputResource.todoNo=='undefined'))
@@ -1229,7 +1226,7 @@ function netLoadResource(inputResource, inputHref, hrefMode, inputResourceIndex,
1229 1226
 		inputResource.calendarNo=0;
1230 1227
 		inputResource.todoNo=0;
1231 1228
 	}
1232
-	var tmp=inputResource.abhref.match(re);
1229
+	var tmp = algoo_replace_regex(inputResource.abhref, globalAccountSettings);
1233 1230
 	var baseHref=tmp[1]+tmp[2];
1234 1231
 	var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
1235 1232
 	var uidFull=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2]+tmp[3];	// for the error handler
@@ -1482,7 +1479,7 @@ function netLoadResource(inputResource, inputHref, hrefMode, inputResourceIndex,
1482 1479
 						var href=$(element).children().filterNsNode('href').text();
1483 1480
 						if(href.match(RegExp('^https?://','i'))!=null)
1484 1481
 						{
1485
-							var tmpH = href.match(RegExp('^(https?://)([^/]+)(.*)','i'))
1482
+							var tmpH = algoo_replace_regex(href, globalAccountSettings);
1486 1483
 							if(tmpH!=null)
1487 1484
 								href = tmpH[3];
1488 1485
 						}
@@ -1708,7 +1705,7 @@ function netLoadResource(inputResource, inputHref, hrefMode, inputResourceIndex,
1708 1705
 							var href=$(element).children().filterNsNode('href').text();
1709 1706
 							if(href.match(RegExp('^https?://','i'))!=null)
1710 1707
 							{
1711
-								var tmpH = href.match(RegExp('^(https?://)([^/]+)(.*)','i'))
1708
+								var tmpH = algoo_replace_regex(href, globalAccountSettings);
1712 1709
 								if(tmpH!=null)
1713 1710
 									href = tmpH[3];
1714 1711
 							}
@@ -1898,8 +1895,7 @@ function netLoadResource(inputResource, inputHref, hrefMode, inputResourceIndex,
1898 1895
 }// Save the client settings (stored as DAV property on server)
1899 1896
 function netSaveSettings(inputResource, inputSettings, isFormSave, collectionLoad)
1900 1897
 {
1901
-	var re=new RegExp('^(https?://)([^/]+)(.*)', 'i');
1902
-	var tmp=inputResource.href.match(re);
1898
+	var tmp = algoo_replace_regex(inputResource.href, globalAccountSettings);
1903 1899
 	var baseHref=tmp[1]+tmp[2];
1904 1900
 	var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
1905 1901
 	var uidFull=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2]+tmp[3]; //for the error handler

+ 4 - 2
tracim/tracim/templates/calendar/config.mak View File

@@ -15,7 +15,8 @@ var globalAccountSettings=[
15 15
         delegation: false,
16 16
         forceReadOnly: null,
17 17
         ignoreAlarms: false,
18
-        backgroundCalendars: ['1.ics']
18
+        backgroundCalendars: [],
19
+        basehref: '${base_href_url}'
19 20
     },
20 21
 % if workspace_clendar_urls:
21 22
     {
@@ -32,7 +33,8 @@ var globalAccountSettings=[
32 33
         delegation: false,
33 34
         forceReadOnly: null,
34 35
         ignoreAlarms: false,
35
-        backgroundCalendars: []
36
+        backgroundCalendars: [],
37
+        basehref: '${base_href_url}'
36 38
     },
37 39
 % endif
38 40
 ] ;

+ 1 - 1
uppgrade_caldavzap.sh View File

@@ -6,4 +6,4 @@ then
6 6
     rm -r tracim/tracim/public/caldavzap
7 7
 fi
8 8
 git clone https://github.com/algoo/caldavzap.git tracim/tracim/public/caldavzap
9
-rm -r tracim/tracim/public/caldavzap/.git
9
+rm -rf tracim/tracim/public/caldavzap/.git