Quellcode durchsuchen

upgrade caldavzap with algoo caldavzap version

Bastien Sevajol (Algoo) vor 7 Jahren
Ursprung
Commit
31aaacb8e6

+ 4 - 1
tracim/tracim/controllers/calendar.py Datei anzeigen

1
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
-
2
+import re
3
 import tg
3
 import tg
4
 from tg import tmpl_context
4
 from tg import tmpl_context
5
 
5
 
45
         workspace_base_url = CalendarManager.get_workspace_base_url()
45
         workspace_base_url = CalendarManager.get_workspace_base_url()
46
         workspace_calendar_urls = CalendarManager\
46
         workspace_calendar_urls = CalendarManager\
47
             .get_workspace_readable_calendars_urls_for_user(user)
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
         # Template will use User.auth_token, ensure it's validity
51
         # Template will use User.auth_token, ensure it's validity
50
         user.ensure_auth_token()
52
         user.ensure_auth_token()
55
             workspace_base_url=workspace_base_url,
57
             workspace_base_url=workspace_base_url,
56
             workspace_clendar_urls=workspace_calendar_urls,
58
             workspace_clendar_urls=workspace_calendar_urls,
57
             auth_token=user.auth_token,
59
             auth_token=user.auth_token,
60
+            base_href_url=base_href_url,
58
         )
61
         )

+ 3 - 0
tracim/tracim/public/caldavzap/.gitignore Datei anzeigen

1
+*~
2
+#*
3
+.idea

+ 1 - 1
tracim/tracim/public/caldavzap/cache.manifest Datei anzeigen

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

+ 16 - 37
tracim/tracim/public/caldavzap/config.js Datei anzeigen

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
 // globalNetworkCheckSettings
310
 // globalNetworkCheckSettings
332
 // Use this option if you want to use standard login screen without
311
 // Use this option if you want to use standard login screen without
352
 // Davical example which automatically detects the protocol, server name,
331
 // Davical example which automatically detects the protocol, server name,
353
 // port, ... (client installed into Davical "htdocs" subdirectory;
332
 // port, ... (client installed into Davical "htdocs" subdirectory;
354
 // works "out of the box", no additional setup required):
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
 // globalNetworkAccountSettings
352
 // globalNetworkAccountSettings

+ 20 - 0
tracim/tracim/public/caldavzap/main.js Datei anzeigen

1936
 			globalTodoCalendarNumber++;
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 Datei anzeigen

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

+ 4 - 2
tracim/tracim/templates/calendar/config.mak Datei anzeigen

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

+ 1 - 1
uppgrade_caldavzap.sh Datei anzeigen

6
     rm -r tracim/tracim/public/caldavzap
6
     rm -r tracim/tracim/public/caldavzap
7
 fi
7
 fi
8
 git clone https://github.com/algoo/caldavzap.git tracim/tracim/public/caldavzap
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