[Erp5-report] r20274 - in /experimental/Experimental: ./ Document/ Tool/ dtml/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Apr 2 16:38:13 CEST 2008


Author: bartek
Date: Wed Apr  2 16:38:12 2008
New Revision: 20274

URL: http://svn.erp5.org?rev=20274&view=rev
Log:
a proof-of-concept of a tool for managing css and js; can be used at development/experimental work, but generally it is a material for thinking about API

Added:
    experimental/Experimental/Document/
    experimental/Experimental/Document/__init__.py
    experimental/Experimental/Permissions.py
    experimental/Experimental/Tool/
    experimental/Experimental/Tool/HTMLIncludeTool.py
    experimental/Experimental/Tool/__init__.py
    experimental/Experimental/dtml/
    experimental/Experimental/dtml/explainHtmlIncludeTool.dtml
    experimental/Experimental/tool.png   (with props)
Modified:
    experimental/Experimental/__init__.py

Added: experimental/Experimental/Document/__init__.py
URL: http://svn.erp5.org/experimental/Experimental/Document/__init__.py?rev=20274&view=auto
==============================================================================
    (empty)

Added: experimental/Experimental/Permissions.py
URL: http://svn.erp5.org/experimental/Experimental/Permissions.py?rev=20274&view=auto
==============================================================================
    (empty)

Added: experimental/Experimental/Tool/HTMLIncludeTool.py
URL: http://svn.erp5.org/experimental/Experimental/Tool/HTMLIncludeTool.py?rev=20274&view=auto
==============================================================================
--- experimental/Experimental/Tool/HTMLIncludeTool.py (added)
+++ experimental/Experimental/Tool/HTMLIncludeTool.py Wed Apr  2 16:38:12 2008
@@ -1,0 +1,97 @@
+##############################################################################
+#
+# Copyright (c) 2007 Nexedi SARL and Contributors. All Rights Reserved.
+#                    Jean-Paul Smets <jp at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+
+from AccessControl import ClassSecurityInfo, getSecurityManager
+from Globals import InitializeClass, DTMLFile
+from Products.CMFCore.utils import getToolByName, _checkPermission
+from Products.ERP5Type.Tool.BaseTool import BaseTool
+from Products.ERP5Type import Permissions
+from Products.Experimental import _dtmldir
+
+
+from DateTime import DateTime
+from Acquisition import aq_base
+
+
+_marker = []  # Create a new marker object.
+
+class HTMLIncludeTool(BaseTool):
+  """
+    Manage JS and CSS includes
+  """
+  title = 'HTML Include Tool'
+  id = 'portal_html_includes'
+  meta_type = 'ERP5 HTML Include Tool'
+  portal_type = 'HTML Include Tool'
+
+  _properties = (
+      { 'id'            : 'javascript',
+        'description'   : 'a list of JS to be included',
+        'type'          : 'lines',
+        'mode'          : 'w'
+        },
+      { 'id'            : 'css',
+        'description'   : 'a list of css to be included',
+        'type'          : 'lines',
+        'mode'          : 'w'
+        },
+      )
+
+  # Declarative Security
+  security = ClassSecurityInfo()
+
+  security.declareProtected(Permissions.ManagePortal, 'manage_overview' )
+  manage_overview = DTMLFile( 'explainHtmlIncludeTool', _dtmldir )
+
+  security.declareProtected(Permissions.ManagePortal, 'addJavascript')
+  def addJavascript(self, name):
+    """
+      add javascript
+    """
+    js_list = self.getProperty('javascript')
+    if name not in js_list:
+      js_list.append(name)
+
+  security.declareProtected(Permissions.ManagePortal, 'addCSS')
+  def addCSS(self, name):
+    """
+      addd CSS
+    """
+    css_list = self.getProperty('css')
+    if name not in css_list:
+      css_list.append(name)
+
+  security.declareProtected(Permissions.ManagePortal, 'moveUp')
+  def moveUp(self, name):
+    pass
+
+  security.declareProtected(Permissions.ManagePortal, 'moveDown')
+  def moveDown(self, name):
+    pass
+
+InitializeClass(HTMLIncludeTool)

Added: experimental/Experimental/Tool/__init__.py
URL: http://svn.erp5.org/experimental/Experimental/Tool/__init__.py?rev=20274&view=auto
==============================================================================
    (empty)

Modified: experimental/Experimental/__init__.py
URL: http://svn.erp5.org/experimental/Experimental/__init__.py?rev=20274&r1=20273&r2=20274&view=diff
==============================================================================
--- experimental/Experimental/__init__.py (original)
+++ experimental/Experimental/__init__.py Wed Apr  2 16:38:12 2008
@@ -1,1 +1,65 @@
+##############################################################################
+#
+# Copyright (c) 2008 Nexedi SARL and Contributors. All Rights Reserved.
+#                    Bartek Gorny <bartek at erp5.pl>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+"""
+    ERP5 Free Software ERP
+"""
 import ZopePatch
+
+# Update ERP5 Globals
+from Products.ERP5Type.Utils import initializeProduct, updateGlobals
+import sys, Permissions
+from zLOG import LOG
+
+this_module = sys.modules[ __name__ ]
+document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
+
+from Tool import HTMLIncludeTool
+
+# Define object classes and tools
+object_classes = ()
+portal_tools = (HTMLIncludeTool.HTMLIncludeTool,)
+content_classes = ()
+content_constructors = ()
+
+# Finish installation
+def initialize( context ):
+  LOG('HTMLIncludeTool initialize', 0, 'initialize')
+  import Document
+  LOG('initialize', 0, Document)
+  initializeProduct(context, this_module, globals(),
+                         document_module = Document,
+                         document_classes = document_classes,
+                         object_classes = object_classes,
+                         portal_tools = portal_tools,
+                         content_constructors = content_constructors,
+                         content_classes = content_classes)
+
+from AccessControl.SecurityInfo import allow_module
+
+#allow_module('Products.ERP5Subversion.SubversionClient')
+

Added: experimental/Experimental/dtml/explainHtmlIncludeTool.dtml
URL: http://svn.erp5.org/experimental/Experimental/dtml/explainHtmlIncludeTool.dtml?rev=20274&view=auto
==============================================================================
--- experimental/Experimental/dtml/explainHtmlIncludeTool.dtml (added)
+++ experimental/Experimental/dtml/explainHtmlIncludeTool.dtml Wed Apr  2 16:38:12 2008
@@ -1,0 +1,27 @@
+<dtml-var manage_page_header>
+<dtml-var manage_tabs>
+
+<h3>Html IncludeTool</h3>
+
+<p>
+This is the main registry for JS and CSS files. They are (will be) stored here in a centralized way so that
+business templates and developers can add new ones without having to overwrite anything. The other role of the
+registry is to combine/compress css files (maybe js too) so that the upload is faster - more or less the way
+Plone's "CSS Registry" does.
+</p>
+
+<p>
+It will also store default includes (erp5.js, erp5.css, erp5_xhtml_appearance.js) and MochiKit.
+</p>
+
+<p>
+At the moment the only way to use it is to manually type extra js and css into the tool's properties. Defaults are
+included the old way, here you can add what you want.
+</p>
+
+<p>
+Another way of adding custom css and js files is overriding <pre>Widget.get_javascript_list</pre> and <pre>Widget.get_css_list</pre> methods,
+this can be done per field class in Products/ERP5Form/
+</p>
+
+<dtml-var manage_page_footer>

Added: experimental/Experimental/tool.png
URL: http://svn.erp5.org/experimental/Experimental/tool.png?rev=20274&view=auto
==============================================================================
Binary file - no diff available.

Propchange: experimental/Experimental/tool.png
------------------------------------------------------------------------------
    svn:mime-type = image/png




More information about the Erp5-report mailing list