make fckeditor actually optional, fix its config, avoid needs for a link to fckeditor.js tls-sprint
authorsylvain.thenault@logilab.fr
Fri, 20 Feb 2009 15:06:59 +0100
branchtls-sprint
changeset 890 3530baff9120
parent 889 609edca88406
child 891 dbc4b1de49b5
make fckeditor actually optional, fix its config, avoid needs for a link to fckeditor.js
debian/cubicweb-web.postinst
web/request.py
web/webconfig.py
web/widgets.py
--- a/debian/cubicweb-web.postinst	Fri Feb 20 10:38:41 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#! /bin/sh -e
-
-ln -sf /usr/share/fckeditor/fckeditor.js /usr/share/cubicweb/cubes/shared/data
- 
-#DEBHELPER#
- 
-exit 0
--- a/web/request.py	Fri Feb 20 10:38:41 2009 +0100
+++ b/web/request.py	Fri Feb 20 15:06:59 2009 +0100
@@ -265,9 +265,10 @@
     
     @cached # so it's writed only once
     def fckeditor_config(self):
+        self.add_js('fckeditor/fckeditor.js')
         self.html_headers.define_var('fcklang', self.lang)
         self.html_headers.define_var('fckconfigpath',
-                                     self.build_url('data/fckcwconfig.js'))
+                                     self.build_url('data/cubicweb.fckcwconfig.js'))
 
     def edited_eids(self, withtype=False):
         """return a list of edited eids"""
--- a/web/webconfig.py	Fri Feb 20 10:38:41 2009 +0100
+++ b/web/webconfig.py	Fri Feb 20 15:06:59 2009 +0100
@@ -199,6 +199,15 @@
             return 'http://intranet.logilab.fr/jpl/view?__linkto=concerns:%s:subject&etype=Ticket&type=bug&vid=creation' % cubeeid
         return None
 
+    def fckeditor_installed(self):
+        return exists(self.ext_resources['FCKEDITOR_PATH'])
+    
+    def eproperty_definitions(self):
+        for key, pdef in super(WebConfiguration, self).eproperty_definitions(self):
+            if key == 'ui.fckeditor' and not self.fckeditor_installed():
+                continue
+            yield key, pdef
+                
     # method used to connect to the repository: 'inmemory' / 'pyro'
     # Pyro repository by default
     repo_method = 'pyro'
--- a/web/widgets.py	Fri Feb 20 10:38:41 2009 +0100
+++ b/web/widgets.py	Fri Feb 20 15:06:59 2009 +0100
@@ -391,11 +391,7 @@
         if not entity.has_eid():
             return u''
         return entity.printable_value(self.name)
-    
-    def add_fckeditor_info(self, req):
-        req.add_js('fckeditor.js')
-        req.fckeditor_config()
-    
+        
     def _edit_render(self, entity, with_format=True):
         req = entity.req
         editor = self._edit_render_textarea(entity, with_format)
@@ -411,7 +407,7 @@
         if isinstance(dvalue, basestring):
             dvalue = html_escape(dvalue)
         if entity.use_fckeditor(self.name):
-            self.add_fckeditor_info(entity.req)
+            entity.req.fckeditor_config()
             if with_format:
                 if entity.has_eid():
                     format = entity.format(self.name)