# HG changeset patch
# User sylvain.thenault@logilab.fr
# Date 1235138819 -3600
# Node ID 3530baff9120d84f4fced3c0290c502f1615813b
# Parent  609edca884066f6708eb65b806c511d8ad367572
make fckeditor actually optional, fix its config, avoid needs for a link to fckeditor.js

diff -r 609edca88406 -r 3530baff9120 debian/cubicweb-web.postinst
--- 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
diff -r 609edca88406 -r 3530baff9120 web/request.py
--- 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"""
diff -r 609edca88406 -r 3530baff9120 web/webconfig.py
--- 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'
diff -r 609edca88406 -r 3530baff9120 web/widgets.py
--- 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)