Browse Source

Radicale client URL parameter: simplification

Bastien Sevajol (Algoo) 8 years ago
parent
commit
af692a810d
3 changed files with 24 additions and 10 deletions
  1. 1 1
      tracim/development.ini.base
  2. 22 4
      tracim/tracim/config/app_cfg.py
  3. 1 5
      tracim/tracim/lib/calendar.py

+ 1 - 1
tracim/development.ini.base View File

@@ -190,7 +190,7 @@ email.notification.smtp.password = your_smtp_password
190 190
 # radicale.server.port = 5232
191 191
 # radicale.server.ssl = false
192 192
 # radicale.server.filesystem.folder = ~/.config/radicale/collections
193
-# radicale.client.base_url = http://{server_name}:{radicale_port}
193
+# radicale.client.base_url = http://127.0.0.1:5232
194 194
 
195 195
 #####
196 196
 #

+ 22 - 4
tracim/tracim/config/app_cfg.py View File

@@ -182,6 +182,12 @@ class CFG(object):
182 182
 
183 183
         if not self.WEBSITE_SERVER_NAME:
184 184
             self.WEBSITE_SERVER_NAME = urlparse(self.WEBSITE_BASE_URL).hostname
185
+            logger.warning(
186
+                self,
187
+                'NOTE: Generated website.server_name parameter from '
188
+                'website.base_url parameter -> {0}'
189
+                .format(self.WEBSITE_SERVER_NAME)
190
+            )
185 191
 
186 192
         self.WEBSITE_HOME_TAG_LINE = tg.config.get('website.home.tag_line', '')
187 193
         self.WEBSITE_SUBTITLE = tg.config.get('website.home.subtitle', '')
@@ -232,10 +238,22 @@ class CFG(object):
232 238
             '~/.config/radicale/collections'
233 239
         )
234 240
 
235
-        self.RADICALE_CLIENT_BASE_URL_TEMPLATE = tg.config.get(
236
-            'radicale.client.base_url',
237
-            'http://{server_name}:{radicale_port}',
238
-        )
241
+        self.RADICALE_CLIENT_BASE_URL_TEMPLATE = \
242
+            tg.config.get('radicale.client.base_url', None)
243
+
244
+        if not self.RADICALE_CLIENT_BASE_URL_TEMPLATE:
245
+            self.RADICALE_CLIENT_BASE_URL_TEMPLATE = \
246
+                'http://{0}:{1}'.format(
247
+                    self.WEBSITE_SERVER_NAME,
248
+                    self.RADICALE_SERVER_PORT,
249
+                )
250
+            logger.warning(
251
+                self,
252
+                'NOTE: Generated radicale.client.base_url parameter with '
253
+                'followings parameters: website.server_name, '
254
+                'radicale.server.port -> {0}'
255
+                .format(self.RADICALE_CLIENT_BASE_URL_TEMPLATE)
256
+            )
239 257
 
240 258
     def get_tracker_js_content(self, js_tracker_file_path = None):
241 259
         js_tracker_file_path = tg.config.get('js_tracker_path', None)

+ 1 - 5
tracim/tracim/lib/calendar.py View File

@@ -35,11 +35,7 @@ class CalendarManager(object):
35 35
     def get_base_url(cls):
36 36
         from tracim.config.app_cfg import CFG
37 37
         cfg = CFG.get_instance()
38
-
39
-        return cfg.RADICALE_CLIENT_BASE_URL_TEMPLATE.format(
40
-            server_name=cfg.WEBSITE_SERVER_NAME,
41
-            radicale_port=cfg.RADICALE_SERVER_PORT,
42
-        )
38
+        return cfg.RADICALE_CLIENT_BASE_URL_TEMPLATE
43 39
 
44 40
     @classmethod
45 41
     def get_user_calendar_url(cls, user_id: int):