Skip to content

Commit

Permalink
upgrade caldavzap with algoo caldavzap version
Browse files Browse the repository at this point in the history
  • Loading branch information
buxx committed Sep 6, 2016
1 parent dc07fbf commit 31aaacb
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 52 deletions.
5 changes: 4 additions & 1 deletion tracim/tracim/controllers/calendar.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

import re
import tg
from tg import tmpl_context

Expand Down Expand Up @@ -45,6 +45,8 @@ def index(self):
workspace_base_url = CalendarManager.get_workspace_base_url()
workspace_calendar_urls = CalendarManager\
.get_workspace_readable_calendars_urls_for_user(user)
base_href_url = \
re.sub(r"^http[s]?://", '', CalendarManager.get_base_url())

# Template will use User.auth_token, ensure it's validity
user.ensure_auth_token()
Expand All @@ -55,4 +57,5 @@ def index(self):
workspace_base_url=workspace_base_url,
workspace_clendar_urls=workspace_calendar_urls,
auth_token=user.auth_token,
base_href_url=base_href_url,
)
3 changes: 3 additions & 0 deletions tracim/tracim/public/caldavzap/.gitignore
@@ -0,0 +1,3 @@
*~
#*
.idea
2 changes: 1 addition & 1 deletion tracim/tracim/public/caldavzap/cache.manifest
@@ -1,5 +1,5 @@
CACHE MANIFEST
#V 20160728145557
#V 20160906103401

CACHE:
common.js
Expand Down
53 changes: 16 additions & 37 deletions tracim/tracim/public/caldavzap/config.js
Expand Up @@ -306,27 +306,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// }
//];

var globalAccountSettings=[
{
href: 'http://127.0.0.1:5232/user/3.ics/',
userAuth:
{
userName: 'bastien.sevajol@algoo.fr',
userPassword: 'bastien.sevajol@algoo.fr'
//userName: 'bastien',
//userPassword: 'bastien'
},
timeOut: 90000,
lockTimeOut: 10000,
checkContentType: true,
settingsAccount: true,
delegation: true,
hrefLabel: null,
forceReadOnly: null,
ignoreAlarms: false,
backgroundCalendars: []
}
];

// globalNetworkCheckSettings
// Use this option if you want to use standard login screen without
Expand All @@ -352,22 +331,22 @@ var globalAccountSettings=[
// Davical example which automatically detects the protocol, server name,
// port, ... (client installed into Davical "htdocs" subdirectory;
// works "out of the box", no additional setup required):
// var globalNetworkCheckSettings={
// href: location.protocol+'//'+location.hostname+
// (location.port ? ':'+location.port: '')+
// location.pathname.replace(RegExp('/+[^/]+/*(index\.html)?$'),'')+
// '/caldav.php/',
// timeOut: 90000,
// lockTimeOut: 10000,
// checkContentType: true,
// settingsAccount: true,
// delegation: true,
// additionalResources: [],
// hrefLabel: null,
// forceReadOnly: null,
// ignoreAlarms: false,
// backgroundCalendars: []
// }
var globalNetworkCheckSettings={
href: location.protocol+'//'+location.hostname+
(location.port ? ':'+location.port: '')+
location.pathname.replace(RegExp('/+[^/]+/*(index\.html)?$'),'')+
'/caldav.php/',
timeOut: 90000,
lockTimeOut: 10000,
checkContentType: true,
settingsAccount: true,
delegation: true,
additionalResources: [],
hrefLabel: null,
forceReadOnly: null,
ignoreAlarms: false,
backgroundCalendars: []
}


// globalNetworkAccountSettings
Expand Down
20 changes: 20 additions & 0 deletions tracim/tracim/public/caldavzap/main.js
Expand Up @@ -1936,3 +1936,23 @@ function setCalendarNumber(initSearch)
globalTodoCalendarNumber++;
}
}

function algoo_get_basehref_for_href(href, globalAccountSettings) {
for (config_key in globalAccountSettings) {
var config = globalAccountSettings[config_key];
if (config.href == href && config.basehref) {
return config.basehref;
}
}
}

function algoo_replace_regex(href, globalAccountSettings) {
var protocol_re = new RegExp('^(https?://)(.*)','i');

var base_href = algoo_get_basehref_for_href(href, globalAccountSettings);
var protocol_match = href.match(protocol_re);
var protocol = protocol_match[1];
var path = protocol_match[2].replace(base_href, '');

return [href, protocol, base_href, path]
}
16 changes: 6 additions & 10 deletions tracim/tracim/public/caldavzap/webdav_protocol.js
Expand Up @@ -490,8 +490,7 @@ function netSaveProperty(inputCollection, hrefProperty, inputProperty, inputValu
function DAVresourceDelegation(inputResource, index, lastIndex)
{
globalCalDAVResourceSync=false;
var re=new RegExp('^(https?://)([^/]+)(.*)', 'i');
var tmp=inputResource.href.match(re);
var tmp=algoo_replace_regex(inputResource.href, globalAccountSettings);

var baseHref=tmp[1]+tmp[2];
var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
Expand Down Expand Up @@ -1039,8 +1038,7 @@ function netFindResource(inputResource, inputResourceIndex, forceLoad, indexR, l
return false;
}

var re=new RegExp('^(https?://)([^/]+)(.*)','i');
var tmp=inputResource.href.match(re);
var tmp = algoo_replace_regex(inputResource.href, globalAccountSettings);
var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
var uidFull=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2]+tmp[3]; // for the error handler
var settingsXML='';
Expand Down Expand Up @@ -1221,15 +1219,14 @@ function netFindResource(inputResource, inputResourceIndex, forceLoad, indexR, l

function netLoadResource(inputResource, inputHref, hrefMode, inputResourceIndex, forceLoad, indexR, loadArray)
{
var re=new RegExp('^(https?://)([^/]+)(.*)','i');
if(!isAvaible('CardDavMATE') || !globalCardDAVInitLoad || (globalCardDAVInitLoad && typeof inputResource.addressbookNo == 'undefined'))
inputResource.addressbookNo=0;
if(!isAvaible('CalDavZAP') || !globalCalDAVInitLoad || (globalCalDAVInitLoad && typeof inputResource.calendarNo=='undefined' && typeof inputResource.todoNo=='undefined'))
{
inputResource.calendarNo=0;
inputResource.todoNo=0;
}
var tmp=inputResource.abhref.match(re);
var tmp = algoo_replace_regex(inputResource.abhref, globalAccountSettings);
var baseHref=tmp[1]+tmp[2];
var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
var uidFull=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2]+tmp[3]; // for the error handler
Expand Down Expand Up @@ -1482,7 +1479,7 @@ function netLoadResource(inputResource, inputHref, hrefMode, inputResourceIndex,
var href=$(element).children().filterNsNode('href').text();
if(href.match(RegExp('^https?://','i'))!=null)
{
var tmpH = href.match(RegExp('^(https?://)([^/]+)(.*)','i'))
var tmpH = algoo_replace_regex(href, globalAccountSettings);
if(tmpH!=null)
href = tmpH[3];
}
Expand Down Expand Up @@ -1708,7 +1705,7 @@ function netLoadResource(inputResource, inputHref, hrefMode, inputResourceIndex,
var href=$(element).children().filterNsNode('href').text();
if(href.match(RegExp('^https?://','i'))!=null)
{
var tmpH = href.match(RegExp('^(https?://)([^/]+)(.*)','i'))
var tmpH = algoo_replace_regex(href, globalAccountSettings);
if(tmpH!=null)
href = tmpH[3];
}
Expand Down Expand Up @@ -1898,8 +1895,7 @@ function netLoadResource(inputResource, inputHref, hrefMode, inputResourceIndex,
}// Save the client settings (stored as DAV property on server)
function netSaveSettings(inputResource, inputSettings, isFormSave, collectionLoad)
{
var re=new RegExp('^(https?://)([^/]+)(.*)', 'i');
var tmp=inputResource.href.match(re);
var tmp = algoo_replace_regex(inputResource.href, globalAccountSettings);
var baseHref=tmp[1]+tmp[2];
var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
var uidFull=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2]+tmp[3]; //for the error handler
Expand Down
6 changes: 4 additions & 2 deletions tracim/tracim/templates/calendar/config.mak
Expand Up @@ -15,7 +15,8 @@ var globalAccountSettings=[
delegation: false,
forceReadOnly: null,
ignoreAlarms: false,
backgroundCalendars: ['1.ics']
backgroundCalendars: [],
basehref: '${base_href_url}'
},
% if workspace_clendar_urls:
{
Expand All @@ -32,7 +33,8 @@ var globalAccountSettings=[
delegation: false,
forceReadOnly: null,
ignoreAlarms: false,
backgroundCalendars: []
backgroundCalendars: [],
basehref: '${base_href_url}'
},
% endif
] ;
Expand Down
2 changes: 1 addition & 1 deletion uppgrade_caldavzap.sh
Expand Up @@ -6,4 +6,4 @@ then
rm -r tracim/tracim/public/caldavzap
fi
git clone https://github.com/algoo/caldavzap.git tracim/tracim/public/caldavzap
rm -r tracim/tracim/public/caldavzap/.git
rm -rf tracim/tracim/public/caldavzap/.git

0 comments on commit 31aaacb

Please sign in to comment.