[Erp5-report] r31757 pierre.ducroquet - in /erp5/trunk/bt5/erp5_web_blog: SkinTemplateItem/...

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jan 14 17:33:25 CET 2010


Author: pierre.ducroquet
Date: Thu Jan 14 17:33:20 2010
New Revision: 31757

URL: http://svn.erp5.org?rev=31757&view=rev
Log:
As Jacques requested, make the first «paragraph» separator configurable.

Modified:
    erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getFirstParagraph.xml
    erp5/trunk/bt5/erp5_web_blog/bt/revision

Modified: erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getFirstParagraph.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getFirstParagraph.xml?rev=31757&r1=31756&r2=31757&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getFirstParagraph.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_web_blog/SkinTemplateItem/portal_skins/erp5_web_blog/WebSection_getFirstParagraph.xml [utf8] Thu Jan 14 17:33:20 2010
@@ -57,11 +57,25 @@
 
 """\n
   This simple script returns the first paragraph of an HTML or raw text.\n
+  The separator is specified through the layout property \n
+    layout_blog_first_part_separator.\n
   In the case of a raw text, the first line is returned, splitted by \\n.\n
 """\n
 content = context.getTextContent()\n
-if "</p>" in content:\n
-  return content.split("</p>")[0] + "</p>"\n
+separator = "</p>"\n
+if hasattr(context, \'REQUEST\'):\n
+  here = context.REQUEST.get(\'current_web_section\', None)\n
+  if here is not None:\n
+    separator = here.getLayoutProperty(\'layout_blog_first_part_separator\', separator)\n
+\n
+if context.text_format == "text/html":\n
+  # We must analyse the separator a bit.\n
+  # XXXX: this whole logic is too light for this problem, but I don\'t want to parse the whole HTML.\n
+  if "</" in separator:\n
+    # We will repeat the separator to be sure the content is approximately XHTML valid.\n
+    return content.split(separator)[0] + separator\n
+  else:\n
+    return content.split(separator)[0]\n
 else:\n
   return content.split("\\n")[0]\n
 
@@ -105,6 +119,10 @@
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>content</string>
+                            <string>separator</string>
+                            <string>hasattr</string>
+                            <string>None</string>
+                            <string>here</string>
                             <string>_getitem_</string>
                           </tuple>
                         </value>

Modified: erp5/trunk/bt5/erp5_web_blog/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web_blog/bt/revision?rev=31757&r1=31756&r2=31757&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web_blog/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_web_blog/bt/revision [utf8] Thu Jan 14 17:33:20 2010
@@ -1,1 +1,1 @@
-26
+27




More information about the Erp5-report mailing list