[Erp5-report] r36088 ivan - in /erp5/trunk/bt5/erp5_web: SkinTemplateItem/portal_skins/erp5...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Jun 8 14:04:19 CEST 2010


Author: ivan
Date: Tue Jun  8 14:04:18 2010
New Revision: 36088

URL: http://svn.erp5.org?rev=36088&view=rev
Log:
Make it possible to control breadcrumb string shortening through Web Site configuration.
Clean up scripts and add needed configuration ERP5 form field.

Added:
    erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_minimal_theme/WebSection_viewDefaultThemeConfiguration/my_layout_max_breadcrumb_length.xml
Modified:
    erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/Base_getTitle.xml
    erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getBreadcrumbItemList.xml
    erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_minimal_theme/WebSection_viewDefaultThemeConfiguration.xml
    erp5/trunk/bt5/erp5_web/bt/revision

Modified: erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/Base_getTitle.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/Base_getTitle.xml?rev=36088&r1=36087&r2=36088&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/Base_getTitle.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/Base_getTitle.xml [utf8] Tue Jun  8 14:04:18 2010
@@ -68,12 +68,11 @@
 \n
   XXX: move this script as an API of ERP5Type?\n
 """\n
-\n
 return context.getProperty(\'translated_short_title\', None) or \\\n
-       context.getProperty(\'short_title\', None) or \\\n
-       context.getProperty(\'translated_title_or_id\', None) or \\\n
-       context.getProperty(\'title_or_id\', None) or \\\n
-       context.title\n
+                   context.getProperty(\'short_title\', None) or \\\n
+                   context.getProperty(\'translated_title_or_id\', None) or \\\n
+                   context.getProperty(\'title_or_id\', None) or \\\n
+                   context.title\n
 </string> </value>
         </item>
         <item>

Modified: erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getBreadcrumbItemList.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getBreadcrumbItemList.xml?rev=36088&r1=36087&r2=36088&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getBreadcrumbItemList.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_getBreadcrumbItemList.xml [utf8] Tue Jun  8 14:04:18 2010
@@ -53,7 +53,9 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>"""\n
+            <value> <string encoding="cdata"><![CDATA[
+
+"""\n
  This script is part of ERP5 Web\n
 \n
  ERP5 Web is a business template of ERP5 which provides a way\n
@@ -112,24 +114,44 @@
 crumb_list = []\n
 \n
 # Implementation consists in browsing the aq_parent sequence\n
+web_site = context.getWebSiteValue()\n
 chain_list = document.Base_getAcquisitionParentValueList(upper_portal_type=\'Web Site\')\n
 chain_list.reverse()\n
-for i in xrange(0, len(chain_list)):\n
+\n
+last_breadcrumb_offset = 1\n
+max_breadcrumb_length = web_site.getLayoutProperty(\'layout_max_breadcrumb_length\', None)\n
+chain_list_length = len(chain_list)\n
+\n
+is_web_section_default_document = bool(context.REQUEST.get(\'is_web_section_default_document\', False))\n
+if is_web_section_default_document:\n
+  last_breadcrumb_offset = 2\n
+\n
+for chain_index in xrange(0, chain_list_length):\n
   try:\n
-    crumb = chain_list[i]\n
-    if i == 0:\n
+    crumb = chain_list[chain_index]\n
+    if chain_index == 0:\n
       title = context.Base_translateString(\'Home\')\n
     else:\n
       title = crumb.Base_getTitle()\n
-    crumb_list.append((title, crumb))\n
   except Unauthorized:\n
     # We should ignore any item in the chain which raises \n
     # a security exception. We use a catchall except here\n
     # because there is no way to import Unauthorized permission\n
-    pass\n
+    title = None\n
+\n
+  if title is not None:\n
+    # shorten it only if it exceeds maximum specified length or\n
+    # not last element in breadcrumb (include default Web Page which is not show but part of chain_list)\n
+    if max_breadcrumb_length is not None and \\\n
+       (chain_index + last_breadcrumb_offset < chain_list_length) and \\\n
+       (len(title) - 4 > max_breadcrumb_length):\n
+      title = \'%s ...\' %(title[:max_breadcrumb_length])\n
+    crumb_list.append((title, crumb))\n
 \n
 return crumb_list\n
-</string> </value>
+
+
+]]></string> </value>
         </item>
         <item>
             <key> <string>_code</string> </key>
@@ -178,11 +200,18 @@
                             <string>context</string>
                             <string>crumb_list</string>
                             <string>_getattr_</string>
+                            <string>web_site</string>
                             <string>chain_list</string>
+                            <string>last_breadcrumb_offset</string>
+                            <string>max_breadcrumb_length</string>
+                            <string>len</string>
+                            <string>chain_list_length</string>
+                            <string>bool</string>
+                            <string>False</string>
+                            <string>is_web_section_default_document</string>
                             <string>_getiter_</string>
                             <string>xrange</string>
-                            <string>len</string>
-                            <string>i</string>
+                            <string>chain_index</string>
                             <string>_getitem_</string>
                             <string>crumb</string>
                             <string>title</string>

Modified: erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_minimal_theme/WebSection_viewDefaultThemeConfiguration.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_minimal_theme/WebSection_viewDefaultThemeConfiguration.xml?rev=36088&r1=36087&r2=36088&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_minimal_theme/WebSection_viewDefaultThemeConfiguration.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_minimal_theme/WebSection_viewDefaultThemeConfiguration.xml [utf8] Tue Jun  8 14:04:18 2010
@@ -107,6 +107,7 @@
                         <string>my_layout_widget_legend_background</string>
                         <string>my_layout_widget_legend_color</string>
                         <string>my_layout_widget_border_color</string>
+                        <string>my_layout_max_breadcrumb_length</string>
                       </list>
                     </value>
                 </item>

Added: erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_minimal_theme/WebSection_viewDefaultThemeConfiguration/my_layout_max_breadcrumb_length.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_minimal_theme/WebSection_viewDefaultThemeConfiguration/my_layout_max_breadcrumb_length.xml?rev=36088&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_minimal_theme/WebSection_viewDefaultThemeConfiguration/my_layout_max_breadcrumb_length.xml (added)
+++ erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_minimal_theme/WebSection_viewDefaultThemeConfiguration/my_layout_max_breadcrumb_length.xml [utf8] Tue Jun  8 14:04:18 2010
@@ -1,0 +1,99 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>delegated_list</string> </key>
+            <value>
+              <list>
+                <string>title</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>my_layout_max_breadcrumb_length</string> </value>
+        </item>
+        <item>
+            <key> <string>message_values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>external_validator_failed</string> </key>
+                    <value> <string>The input failed the external validator.</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>overrides</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>tales</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string>my_integer_field</string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string>Base_viewFieldLibrary</string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string>Click to edit the target</string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string>Maximal Breadcrumb Item Length</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Modified: erp5/trunk/bt5/erp5_web/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web/bt/revision?rev=36088&r1=36087&r2=36088&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_web/bt/revision [utf8] Tue Jun  8 14:04:18 2010
@@ -1,1 +1,1 @@
-957
+959




More information about the Erp5-report mailing list