diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getNewsItemSummary.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getNewsItemSummary.xml new file mode 100644 index 0000000000000000000000000000000000000000..35eb68a326719c0c9ef6182e4f1d9189ea10b780 --- /dev/null +++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSite_getNewsItemSummary.xml @@ -0,0 +1,203 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <tuple> + <string>Products.PythonScripts.PythonScript</string> + <string>PythonScript</string> + </tuple> + <none/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Python_magic</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>__ac_local_roles__</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_body</string> </key> + <value> <string encoding="cdata"><![CDATA[ + +no_summary_message = "News vide !"\n +\n +if news_full_text in [None, \'\']:\n + return no_summary_message\n +\n +# XXX ! Big Security issue here !!!\n +# Must be replaced by http://www.zope.org/Members/itamar/striphtml ? \n +\n +# Other Alternative:\n +# from stripogram import html2text\n +# return html2text(news_full_text)\n +\n +def StripTags(text):\n + finished = 0\n + while not finished:\n + finished = 1\n + # check if there is an open tag left\n + start = text.find("<")\n + if start >= 0:\n + # if there is, check if the tag gets closed\n + stop = text[start:].find(">")\n + if stop >= 0:\n + # if it does, strip it, and continue loop\n + text = text[:start] + text[start+stop+1:]\n + finished = 0\n + return text\n +\n +# End of bad HTML tag stripping\n +\n +word_list = StripTags(news_full_text).split(\' \')\n +\n +# Get the first 30 words of the news\n +word_count = 30\n +summary = \'\'\n +for word in word_list:\n + if len(word) > 0:\n + summary += word + \' \'\n + word_count -= 1\n + if word_count == 0:\n + break\n + \n +return summary\n + + +]]></string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_filepath</string> </key> + <value> <string>Script (Python):/nexedi/portal_skins/erp5_web/WebSite_getNewsItemSummary</string> </value> + </item> + <item> + <key> <string>_owner</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>news_full_text=None</string> </value> + </item> + <item> + <key> <string>errors</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>func_code</string> </key> + <value> + <object> + <klass> + <global name="FuncCode" module="Shared.DC.Scripts.Signature"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>co_argcount</string> </key> + <value> <int>1</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>news_full_text</string> + <string>no_summary_message</string> + <string>None</string> + <string>StripTags</string> + <string>_getattr_</string> + <string>word_list</string> + <string>word_count</string> + <string>summary</string> + <string>_getiter_</string> + <string>word</string> + <string>len</string> + </tuple> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>func_defaults</string> </key> + <value> + <tuple> + <none/> + </tuple> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>WebSite_getNewsItemSummary</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData>