Commit d09f5528 authored by Ivan Tyagov's avatar Ivan Tyagov

Add script to generate proper URL for image conversion which can be reused in other UI parts.

parent f601ecc6
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>"""\n
A core method that will return default image conversion arguments as a dict.\n
"""\n
portal = context.getPortalObject()\n
portal_preferences = portal.portal_preferences\n
image_argument_dict = {\'format\': portal_preferences.getPreferredImageFormat(),\n
\'quality\': portal_preferences.getPreferredImageQuality()}\n
\n
pre_converted_only = portal_preferences.getPreferredPreConvertedOnly()\n
if pre_converted_only:\n
# only add if it\'s True as conversion machine assume that if it is missing\n
# then conversion should happen "on the fly"\n
image_argument_dict[\'pre_converted_only\'] = pre_converted_only\n
\n
if context.getPortalType() in (\'PDF\',):\n
# PDF support frames\n
image_argument_dict[\'frame\'] = 0\n
return image_argument_dict\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getImageArgumentDict</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -39,11 +39,12 @@ ...@@ -39,11 +39,12 @@
<tal:block \n <tal:block \n
tal:define="document_url here/absolute_url;\n tal:define="document_url here/absolute_url;\n
thumbnail_url here/Base_getThumbnailAbsoluteUrl;\n thumbnail_url here/Base_getThumbnailAbsoluteUrl;\n
display string:thumbnail;\n
icon here/getIconURL;\n icon here/getIconURL;\n
title here/getTitle;\n title here/getTitle;\n
modification_date python: here.Base_FormatDate(here.getModificationDate(),hour_minute=1);\n modification_date python: here.Base_FormatDate(here.getModificationDate(),hour_minute=1);\n
format python: here.getObject().portal_preferences.getPreference(\'preferred_image_format\', \'png\');\n image_conversion_dict here/Base_getImageArgumentDict;\n
dummy python: image_conversion_dict.update(**{\'display\':\'thumbnail\'});\n
image_conversion_arguments python: \'&\'.join([\'%s=%s\' % (k, v) for k, v in image_conversion_dict.items()]);\n
description python: here.getDescription();\n description python: here.getDescription();\n
box_relative_url python: request.get(\'box_relative_url\', \'\');\n box_relative_url python: request.get(\'box_relative_url\', \'\');\n
dom_id python: modules[\'base64\'].urlsafe_b64encode(\'%s-%s\' %(box_relative_url, here.getUid())).rstrip(\'=\')">\n dom_id python: modules[\'base64\'].urlsafe_b64encode(\'%s-%s\' %(box_relative_url, here.getUid())).rstrip(\'=\')">\n
...@@ -68,7 +69,7 @@ ...@@ -68,7 +69,7 @@
tal:attributes="href string:${document_url}/view">\n tal:attributes="href string:${document_url}/view">\n
<img alt="Thumbnail" class="document-thumbnail"\n <img alt="Thumbnail" class="document-thumbnail"\n
tal:condition="python: thumbnail_url is not None"\n tal:condition="python: thumbnail_url is not None"\n
tal:attributes="src string:${thumbnail_url}/index_html?display=${display}&format=${format}"/>\n tal:attributes="src string:${thumbnail_url}/index_html?${image_conversion_arguments}"/>\n
<br/>\n <br/>\n
<span class="description"\n <span class="description"\n
tal:content="description"/>\n tal:content="description"/>\n
......
1066 1067
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment