[kupu-checkins] r42487 - in kupu/branch/duncan-flash: common doc plone plone/kupu_plone_layer

duncan at codespeak.net duncan at codespeak.net
Mon Apr 30 16:22:35 CEST 2007


Author: duncan
Date: Mon Apr 30 16:22:35 2007
New Revision: 42487

Modified:
   kupu/branch/duncan-flash/common/kupubasetools.js
   kupu/branch/duncan-flash/doc/LIBRARIES.txt
   kupu/branch/duncan-flash/doc/PLONE2.txt
   kupu/branch/duncan-flash/plone/kupu_plone_layer/kupucollection.xml.pt
   kupu/branch/duncan-flash/plone/librarytool.py
   kupu/branch/duncan-flash/plone/plonedrawers.py
   kupu/branch/duncan-flash/plone/plonelibrarytool.py
   kupu/branch/duncan-flash/plone/resource_types.pt
Log:
Partially implemented support for Flash media.
So far: allows adding a Flash content type to resource library for media (probably just ATFlashMovie since that's what I'm using) and includes a new xml tag to distinguish flash from images.
To do: make xsl expose the media field to the javascript, fix up filtering to not remove the object tag.

Modified: kupu/branch/duncan-flash/common/kupubasetools.js
==============================================================================
--- kupu/branch/duncan-flash/common/kupubasetools.js	(original)
+++ kupu/branch/duncan-flash/common/kupubasetools.js	Mon Apr 30 16:22:35 2007
@@ -1271,6 +1271,13 @@
         return img;
     };
 
+    this.createObject = function(url, type, alttext, className, width, height) {
+        var ed = this.editor;
+        var obj = ed.newElement('object',
+            {src:url, alt:alttext, className:className, width:width, height:height, type:type}
+            [ed.newElement('param', {name:'movie', value:url})]);
+    }
+
     this.setImageClass = function(imgclass) {
         /* set the class of the selected image */
         var currnode = this.editor.getSelectedNode();

Modified: kupu/branch/duncan-flash/doc/LIBRARIES.txt
==============================================================================
--- kupu/branch/duncan-flash/doc/LIBRARIES.txt	(original)
+++ kupu/branch/duncan-flash/doc/LIBRARIES.txt	Mon Apr 30 16:22:35 2007
@@ -120,7 +120,10 @@
        & element label { text }?
        & 
          ## Icon to use in resource pane
-         element icon { xsd:anyURI }?)
+         element icon { xsd:anyURI }?
+       & 
+         ## Type of media to insert in document 
+         element media { text }?)
 
     ## A list of collections and resources with an optional upload button at the end.
     collectionItems =
@@ -405,13 +408,27 @@
   - Go to the kupu configlet/resource types tab. Scroll to the bottom
     of the page.
 
-  - Under 'preview URLs' select the type 'Image' and under URL enter:
+  - Under 'preview URLs' select the type 'Image' and under preview enter:
 
     string:${object_url}/image_thumb
 
   - Hit the 'Save' button.
 
 
+Flash support
+-------------
+
+To support Flash you need a separate content type (such as ATFlashMovie). 
+1. Add this content type to the mediaobject resource type.
+2. Add the type under the 'action urls' section at the bottom of the
+   resource types tab. Put in appropriate expressions for the urls (for
+   ATFlashMove the 'Normal Image' expression is:
+   'string:${object_url}/download'. Select type 'flash'.
+
+N.B. This function is not yet fully implemented, so when you've done
+that it still won't work. Watch this space...
+
+
 Futures
 -------
 

Modified: kupu/branch/duncan-flash/doc/PLONE2.txt
==============================================================================
--- kupu/branch/duncan-flash/doc/PLONE2.txt	(original)
+++ kupu/branch/duncan-flash/doc/PLONE2.txt	Mon Apr 30 16:22:35 2007
@@ -339,6 +339,15 @@
         Defaults to 'image'. N.B. This is a literal string, not a tal
         expression.
 
+    classes
+        An optional list of class names to be allowed for this media
+        type. The class names will be applied in addition to
+        left/inline/right and captioned class names.
+
+    type
+        This controls whether kupu inserts an img tag or an object
+        tag. Only images and flash objects are supported at this time.
+
 documentation tab
 =================
 

Modified: kupu/branch/duncan-flash/plone/kupu_plone_layer/kupucollection.xml.pt
==============================================================================
--- kupu/branch/duncan-flash/plone/kupu_plone_layer/kupucollection.xml.pt	(original)
+++ kupu/branch/duncan-flash/plone/kupu_plone_layer/kupucollection.xml.pt	Mon Apr 30 16:22:35 2007
@@ -37,6 +37,9 @@
                tal:content="info/url">URI</uri>
           <icon metal:define-slot="icon"
                 tal:content="info/icon">icon</icon>
+          <media tal:condition="info/media|nothing" tal:content="info/media">mime type</media>
+          <class tal:condition="info/classes|nothing" tal:repeat="c info/classes"
+                   tal:attributes="title c/title; name c/classname" />
           <size metal:define-slot="size"
                 tal:condition="info/size"
                 tal:content="info/size">size</size>

Modified: kupu/branch/duncan-flash/plone/librarytool.py
==============================================================================
--- kupu/branch/duncan-flash/plone/librarytool.py	(original)
+++ kupu/branch/duncan-flash/plone/librarytool.py	Mon Apr 30 16:22:35 2007
@@ -256,12 +256,17 @@
             if normal:
                 normal = Expression(normal)
             scalefield = a.get('scalefield', 'image')
+            classes = a.get('classes', '').split('\n')
+            mediatype = a.get('mediatype', 'image')
             if not portal_type:
                 continue
             action_map[portal_type] = {
                 'expression': Expression(preview),
                 'normal': normal,
-                'scalefield': scalefield, }
+                'scalefield': scalefield,
+                'classes': classes,
+                'mediatype': mediatype,
+            }
         self._preview_actions = action_map
 
     def deleteResourceTypes(self, resource_types):

Modified: kupu/branch/duncan-flash/plone/plonedrawers.py
==============================================================================
--- kupu/branch/duncan-flash/plone/plonedrawers.py	(original)
+++ kupu/branch/duncan-flash/plone/plonedrawers.py	Mon Apr 30 16:22:35 2007
@@ -207,7 +207,28 @@
         if type is None:
             return None
         return "%s/%s" % (self.base, type.getIcon())
-            
+
+    def media(self, portal_type):
+        """Get the media type to be included in the xml.
+        Since 'image' is the default we can omit it."""
+        media = self.tool.getMediaForType(portal_type)
+        if media=='image':
+            return None
+        return media
+
+    def classes(self, portal_type):
+        stored = self.tool.getClassesForType(portal_type)
+        classes = []
+        for c in stored:
+            c = c.strip()
+            if not c:
+                continue
+            if '|' in c:
+                title, classname = c.split('|', 1)
+                classes.append({'title': title, 'classname': classname})
+            else:
+                classes.append({'title': c, 'classname': c})
+        return classes
 
     def sizes(self, obj):
         """Returns size, width, height"""
@@ -312,6 +333,8 @@
                 normal = url
 
             sizes = self.get_image_sizes(obj, portal_type, url)
+            media = self.media(portal_type)
+            classes = self.classes(portal_type)
 
             icon = self.icon(portal_type)
             size, width, height = self.sizes(obj)
@@ -338,6 +361,8 @@
                 'height': height,
                 'preview': preview,
                 'sizes': sizes,
+                'media': media,
+                'classes': classes,
                 'title': title,
                 'description': description,
                 'linkable': linkable,
@@ -389,6 +414,8 @@
             normal = url
 
         sizes = self.get_image_sizes(brain, portal_type, url)
+        media = self.media(portal_type)
+        classes = self.classes(portal_type)
 
         icon = self.icon(portal_type)
         size, width, height = self.sizes(brain)
@@ -414,6 +441,8 @@
             'height': height,
             'preview': preview,
             'sizes': sizes,
+            'media': media,
+            'classes': classes,
             'title': title,
             'description': description,
             'linkable': linkable,

Modified: kupu/branch/duncan-flash/plone/plonelibrarytool.py
==============================================================================
--- kupu/branch/duncan-flash/plone/plonelibrarytool.py	(original)
+++ kupu/branch/duncan-flash/plone/plonelibrarytool.py	Mon Apr 30 16:22:35 2007
@@ -682,6 +682,17 @@
         value = action_map.get(portal_type, {}).get('scalefield', 'image')
         return value
 
+    security.declareProtected(permissions.ManageLibraries, "getClassesForType")
+    def getClassesForType(self, portal_type):
+        action_map = getattr(self, '_preview_actions', {})
+        return action_map.get(portal_type, {}).get('classes', ())
+
+    security.declareProtected(permissions.ManageLibraries, "getMediaForType")
+    def getMediaForType(self, portal_type):
+        action_map = getattr(self, '_preview_actions', {})
+        value = action_map.get(portal_type, {}).get('mediatype', 'image')
+        return value
+
     security.declareProtected(permissions.ManageLibraries, "set_html_exclusions")
     def set_html_exclusions(self, exclusions):
         """Set the html_exclusions.

Modified: kupu/branch/duncan-flash/plone/resource_types.pt
==============================================================================
--- kupu/branch/duncan-flash/plone/resource_types.pt	(original)
+++ kupu/branch/duncan-flash/plone/resource_types.pt	Mon Apr 30 16:22:35 2007
@@ -1,249 +1,285 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
-    lang="en"
-    metal:use-macro="here/kupu_config/macros/master"
-    i18n:domain="kupuconfig">
-
-<body>
-
-    <div class="documentContent" metal:fill-slot="kupu_content">
-<h1 class="documentFirstHeading"
-    i18n:translate="heading_kupu_resource_types">Kupu Resource Types</h1>
-<form action="" method="post" tal:attributes="action here/absolute_url">
-<p i18n:translate="text_resource_types">While libraries provide abstract locations for objects of any type,
-Kupu distinguishes objects by resource type. For example, a user might
-request a library showing objects to link to or a library showing
-objects to be inserted into a document. The abstract location
-(library) might be the same, but the former library would contain
-documents, the latter images.</p>
-
-<p i18n:translate="text_resource_types2">This management screen allows you to define resource types using a
-list of portal types. A special resource type, <code>collection</code>,
-identifies portal types that are to be treated as collections.
-The resource type <code>containsanchors</code> is used to list types which
-may contain HTML anchors.</p>
-
-<p i18n:translate="text_resource_types3">Also on this screen are urls
-for each type which can be previewed as an image. The expression may
-use <code>object_url</code> and <code>portal_type</code>, but should
-not attempt to access the object directly. The resulting URL should
-ideally return an image no larger than 128 pixels square.</p>
-
-<fieldset tal:define="typestool context/portal_types;
-                typeinfos typestool/listTypeInfo;">
-<legend i18n:translate="legend_map_resource_types">Map resource types</legend>
-
-<table summary="Resource definitions" class="listing nosort">
-<thead>
-  <tr>
-    <th colspan="3">Map resource types</th>
-  </tr>
-</thead>
-
- <tal:loop tal:repeat="resource here/zmi_get_resourcetypes">
-<tbody
-  tal:define="oddrow repeat/resource/odd;name resource/name; types resource/types;"
-  tal:attributes="class python:test(oddrow, 'even', 'odd');"
-  align="left"
-  style="margin-top: 1em !important;"
->
-  <tr><td colspan="3">&nbsp;</td></tr>
-  <tr tal:condition="repeat/resource/end"><td style="border-right:none;"></td><td colspan="2"><em>use this entry to add a new resource</em>
-</td></tr>
-  <tr>
-    <td>
-      <input type="hidden" name="type_info.old_type:records"
-             tal:attributes="value name" />
-      <input type="checkbox" name="resource_types:list"
-             tal:condition="name"
-             tal:attributes="value name" />
-    </td>
-    <th>Resource</th>
-    <td>
-      <input type="text" name="type_info.resource_type:records"
-             tal:attributes="value name" />
-    </td>
-  </tr>
-  <tr>
-    <td></td>
-    <th>Portal Types</th>
-    <td>
-      <select name="type_info.portal_types:list:records" size="5" multiple
-          tal:attributes="size python:max(5,len(types));">
-          <tal:block repeat="ti typeinfos">
-            <option tal:define="title python:path('string:${ti/Title}' + test(ti.Title()==ti.getId(),'',' (${ti/getId})'));
-                        id ti/getId;
-                        selected python:id in types;"
-                    tal:content="title"
-                    tal:condition="selected"
-                    tal:attributes="value ti/getId;" selected></option>
-
-          </tal:block>
-          <tal:block repeat="ti typeinfos">
-            <option tal:define="title python:path('string:${ti/Title}' + test(ti.Title()==ti.getId(),'',' (${ti/getId})'));
-                        id ti/getId;
-                        selected python:id in types;"
-                    tal:content="title"
-                    tal:condition="not:selected"
-                    tal:attributes="value ti/getId;"></option>
-
-          </tal:block>
-      </select>
-    </td>
-  </tr>
-  <tr><td></td><th>New types</th>
-    <td>
-      <select name="type_info.newtypes:int:records" size="1"
-              tal:define="newtype python:context.getNewTypeHandler(name)">
-        <option value="0" tal:attributes="selected python:test(newtype==0,True,None)">are not added to selection</option>
-        <option value="1" tal:attributes="selected python:test(newtype==1,True,None)">are added to selection</option>
-      </select>
-    </td>
-  <tr><td colspan="3">&nbsp;</td></tr>
-</tbody>
- </tal:loop>
-<tbody>
-  <tr>
-    <td style="border-right:none;"></td>
-    <td colspan="2"><em>specify a resource type to be used for reference fields with an empty list of allowed types</em>
-    </td>
-  </tr>
-  <tr>
-    <td> </td>
-    <th>Default resource</th>
-    <td>
-      <select name="default_resource" tal:define="current here/getDefaultResource">
-        <tal:block repeat="resource here/zmi_get_resourcetypes">
-          <option tal:define="name resource/name;"
-                  tal:attributes="value resource/name;selected python:current==name;"
-                  tal:content="resource/name" />
-        </tal:block>
-      </select>
-    </td>
-  </tr>
-  <tr>
-    <td  style="border-right: none;">&nbsp;</td>
-    <td colspan="2" style="padding-top:0.5em;">
-      <input class="context" type="submit" name="zmi_update_resource_types:method" value="Save" i18n:attributes="value" />
-      <input class="context" type="submit" name="zmi_delete_resource_types:method" value="Delete" i18n:attributes="value" />
-    </td>
-  </tr>
-</tbody>
-</table>
-
-<table summary="Preview actions" class="listing nosort" width="90%"
- tal:define="typestool context/portal_types;
-             typeinfos typestool/listTypeInfo;
-             previewable python:[t for t in typeinfos if context.getPreviewForType(t.getId())];">
-<thead>
-  <tr>
-    <th colspan="4">Action URLs</th>
-  </tr>
-  <tr><th width="1%"></th>
-    <th width="1%">Type</th>
-    <th colspan="2">URL</th>
-  </tr>
-</thead>
-
- <tal:loop tal:repeat="ti previewable">
-<tbody  tal:define="oddrow repeat/ti/odd;
-                portal_type ti/getId;
-                previewaction python:context.getPreviewForType(portal_type);
-                normalaction python:context.getNormalViewForType(portal_type);
-                scalefield python:context.getScaleFieldForType(portal_type);"
-       tal:condition="python:context.getPreviewForType(portal_type)"
-  tal:attributes="class python:test(oddrow, 'even', 'odd');">
-  <tr>
-    <td rowspan="3">
-      <input type="hidden" name="preview_action.marker:records" value="x" />
-      <input type="hidden" name="preview_action.portal_type:records" tal:attributes="value ti/getId" />
-      <input type="checkbox" name="preview_types:list"
-             tal:attributes="value ti/getId" />
-    </td>
-    <td rowspan="3" tal:define="title python:path('string:${ti/Title}' + test(ti.Title()==ti.getId(),'',' (${ti/getId})'));"
-        tal:content="title">type</td>
-    <td style="border-right: none;" width="1%">preview</td>
-    <td>
-      <input type="text" name="preview_action.expression:records"
-             style="width:90%"
-             tal:attributes="value previewaction" />
-    </td>
-  </tr>
-  <tr>
-    <td style="border-right: none;" width="1%">Normal&nbsp;mage</td>
-    <td>
-      <input type="text" name="preview_action.normal:records"
-             style="width:90%"
-             tal:attributes="value normalaction" />
-    </td>
-  </tr>
-  <tr>
-    <td style="border-right: none;" width="1%">fieldname</td>
-    <td>
-      <input type="text" name="preview_action.scalefield:records"
-             style="width:90%"
-             tal:attributes="value scalefield" />
-    </td>
-  </tr>
-</tbody>
- </tal:loop>
-<tbody  tal:define="oddrow python:len(previewable)%2;"
-        tal:attributes="class python:test(oddrow, 'even', 'odd');">
-  <tr>
-    <td rowspan="3">
-      <input type="hidden" name="preview_action.marker:records" value="-"/>
-    </td>
-    <td rowspan="3">
-      <select name="preview_action.portal_type:records">
-          <option i18n:translate="" value="">(select type)</option>
-          <tal:block repeat="ti typeinfos">
-            <option tal:define="title python:path('string:${ti/Title}' + test(ti.Title()==ti.getId(),'',' (${ti/getId})'));
-                        id ti/getId;"
-                    tal:content="title"
-                    tal:condition="not:python:context.getPreviewForType(id)"
-                    tal:attributes="value ti/getId;"></option>
-          </tal:block>
-      </select>
-    <td style="border-right: none;" width="1%">preview</td>
-    <td>
-      <input type="text" name="preview_action.expression:records"
-             style="width:90%" value="" />
-    </td>
-  </tr>
-  <tr>
-    <td style="border-right: none;" width="1%">Normal Image</td>
-    <td>
-      <input type="text" name="preview_action.normal:records"
-             style="width:90%" value="" />
-    </td>
-  </tr>
-  <tr>
-    <td style="border-right: none;" width="1%">fieldname</td>
-    <td>
-      <input type="text" name="preview_action.scalefield:records"
-             style="width:90%" value="image" />
-    </td>
-  </tr>
-</tbody>
-<tbody>
-  <tr>
-    <td style="border-right: none;">&nbsp;</td>
-    <td style="padding-top:0.5em;">
-      <input class="context" type="submit" name="zmi_update_resource_types:method" value="Save" i18n:attributes="value" />
-      <input class="context" type="submit" name="zmi_delete_resource_types:method" value="Delete" i18n:attributes="value" />
-    </td>
-    <td colspan="2"><em>Preview is an expression to use for the preview image in the drawer [default is no preview].
-      Normal image is an expression to use for the normal view of a mediaobject [string:$object_url].
-      Fieldname is the name of the field to use for scaled variants of the mediaobject [image].
-      </em>
-    </td>
-  </tr>
-</tbody>
-</table>
-
-</fieldset>
-</form>
-</div>
-</body>
+lang="en"
+metal:use-macro="here/kupu_config/macros/master"
+i18n:domain="kupuconfig">
+
+   <body>
+      <div class="documentContent" metal:fill-slot="kupu_content">
+         <h1 class="documentFirstHeading"
+             i18n:translate="heading_kupu_resource_types">Kupu Resource Types</h1>
+         <form action="" method="post" tal:attributes="action here/absolute_url"
+               tal:define="typestool context/portal_types;
+               typeinfos typestool/listTypeInfo;
+               typeinfos python:[(ti.Title(), ti.getId()) for ti in typeinfos];
+               dummy python:typeinfos.sort()">
+            <p i18n:translate="text_resource_types">While libraries provide abstract locations for objects of any type,
+               Kupu distinguishes objects by resource type. For example, a user might
+               request a library showing objects to link to or a library showing
+               objects to be inserted into a document. The abstract location
+               (library) might be the same, but the former library would contain
+               documents, the latter images.</p>
+            <p i18n:translate="text_resource_types2">This management screen allows you to define resource types using a
+               list of portal types. A special resource type, <code>collection</code>,
+               identifies portal types that are to be treated as collections.
+               The resource type <code>containsanchors</code> is used to list types which
+               may contain HTML anchors.</p>
+
+            <p i18n:translate="text_resource_types3">Also on this screen are urls
+               for each type which can be previewed as an image. The expression may
+               use <code>object_url</code> and <code>portal_type</code>, but should
+               not attempt to access the object directly. The resulting URL should
+               ideally return an image no larger than 128 pixels square.</p>
+
+            <fieldset>
+               <legend i18n:translate="legend_map_resource_types">Map resource types</legend>
+
+               <table summary="Resource definitions" class="listing nosort">
+                  <thead>
+                     <tr>
+                        <th colspan="3">Map resource types</th>
+                     </tr>
+                  </thead>
+
+                  <tal:loop tal:repeat="resource here/zmi_get_resourcetypes">
+                     <tbody
+                           tal:define="oddrow repeat/resource/odd;name resource/name; types resource/types;"
+                           tal:attributes="class python:test(oddrow, 'even', 'odd');"
+                           align="left"
+                           style="margin-top: 1em !important;"
+                           >
+                        <tr><td colspan="3">&nbsp;</td></tr>
+                        <tr tal:condition="repeat/resource/end"><td style="border-right:none;"></td><td colspan="2"><em>use this entry to add a new resource</em>
+                           </td></tr>
+                        <tr>
+                           <td>
+                              <input type="hidden" name="type_info.old_type:records"
+                                     tal:attributes="value name" />
+                              <input type="checkbox" name="resource_types:list"
+                                     tal:condition="name"
+                                     tal:attributes="value name" />
+                           </td>
+                           <th>Resource</th>
+                           <td>
+                              <input type="text" name="type_info.resource_type:records"
+                                     tal:attributes="value name" />
+                           </td>
+                        </tr>
+                        <tr>
+                           <td></td>
+                           <th>Portal Types</th>
+                           <td>
+                              <select name="type_info.portal_types:list:records" size="5" multiple
+                                      tal:attributes="size python:max(5,len(types));">
+                                 <tal:block repeat="ti typeinfos">
+                                    <option tal:define="title python:ti[0]; id python:ti[1];
+                                            fulltitle python:title + test(title==id,'',' (%s)'%id);
+                                            selected python:id in types;"
+                                            tal:content="fulltitle"
+                                            tal:condition="selected"
+                                            tal:attributes="value id;" selected></option>
+                                 </tal:block>
+                                 <tal:block repeat="ti typeinfos">
+                                    <option tal:define="title python:ti[0]; id python:ti[1];
+                                            fulltitle python:title + test(title==id,'',' (%s)'%id);
+                                            selected python:id in types;"
+                                            tal:content="fulltitle"
+                                            tal:condition="not:selected"
+                                            tal:attributes="value id;"></option>
+                                 </tal:block>
+                              </select>
+                           </td>
+                        </tr>
+                        <tr><td></td><th>New types</th>
+                           <td>
+                              <select name="type_info.newtypes:int:records" size="1"
+                                      tal:define="newtype python:context.getNewTypeHandler(name)">
+                                 <option value="0" tal:attributes="selected python:test(newtype==0,True,None)">are not added to selection</option>
+                                 <option value="1" tal:attributes="selected python:test(newtype==1,True,None)">are added to selection</option>
+                              </select>
+                           </td>
+                           <tr><td colspan="3">&nbsp;</td></tr>
+                     </tbody>
+                  </tal:loop>
+                  <tbody>
+                     <tr>
+                        <td style="border-right:none;"></td>
+                        <td colspan="2"><em>specify a resource type to be used for reference fields with an empty list of allowed types</em>
+                        </td>
+                     </tr>
+                     <tr>
+                        <td> </td>
+                        <th>Default resource</th>
+                        <td>
+                           <select name="default_resource" tal:define="current here/getDefaultResource">
+                              <tal:block repeat="resource here/zmi_get_resourcetypes">
+                                 <option tal:define="name resource/name;"
+                                         tal:attributes="value resource/name;selected python:current==name;"
+                                         tal:content="resource/name" />
+                              </tal:block>
+                           </select>
+                        </td>
+                     </tr>
+                     <tr>
+                        <td  style="border-right: none;">&nbsp;</td>
+                        <td colspan="2" style="padding-top:0.5em;">
+                           <input class="context" type="submit" name="zmi_update_resource_types:method" value="Save" i18n:attributes="value" />
+                           <input class="context" type="submit" name="zmi_delete_resource_types:method" value="Delete" i18n:attributes="value" />
+                        </td>
+                     </tr>
+                  </tbody>
+               </table>
+
+               <table summary="Preview actions" class="listing nosort" width="90%"
+                      tal:define="previewable python:[(title,id) for (title,id) in typeinfos if context.getPreviewForType(id)];">
+                  <thead>
+                     <tr>
+                        <th colspan="4">Action URLs</th>
+                     </tr>
+                     <tr><th width="1%"></th>
+                        <th width="1%">Type</th>
+                        <th colspan="2">URL</th>
+                     </tr>
+                  </thead>
+
+                  <tal:loop tal:repeat="ti previewable">
+                     <tbody  tal:define="title python:ti[0];id python:ti[1];oddrow repeat/ti/odd;
+                             fulltitle python:title + test(title==id,'',' (%s)'%id);
+                             portal_type id;
+                             previewaction python:context.getPreviewForType(portal_type);
+                             normalaction python:context.getNormalViewForType(portal_type);
+                             scalefield python:context.getScaleFieldForType(portal_type);
+                             classes python:context.getClassesForType(portal_type);
+                             mediatype python:context.getMediaForType(portal_type);"
+                             tal:condition="python:context.getPreviewForType(portal_type)"
+                             tal:attributes="class python:test(oddrow, 'even', 'odd');">
+                        <tr>
+                           <td rowspan="5">
+                              <input type="hidden" name="preview_action.marker:records" value="x" />
+                              <input type="hidden" name="preview_action.portal_type:records" tal:attributes="value id" />
+                              <input type="checkbox" name="preview_types:list"
+                                     tal:attributes="value id" />
+                           </td>
+                           <td rowspan="5" tal:content="fulltitle">type</td>
+                           <td style="border-right: none;" width="1%">preview</td>
+                           <td>
+                              <input type="text" name="preview_action.expression:records"
+                                     style="width:90%"
+                                     tal:attributes="value previewaction" />
+                           </td>
+                        </tr>
+                        <tr>
+                           <td style="border-right: none;" width="1%">Normal&nbsp;image</td>
+                           <td>
+                              <input type="text" name="preview_action.normal:records"
+                                     style="width:90%"
+                                     tal:attributes="value normalaction" />
+                           </td>
+                        </tr>
+                        <tr>
+                           <td style="border-right: none;" width="1%">fieldname</td>
+                           <td>
+                              <input type="text" name="preview_action.scalefield:records"
+                                     style="width:90%"
+                                     tal:attributes="value scalefield" />
+                           </td>
+                        </tr>
+                        <tr>
+                           <td style="border-right: none;" width="1%">classes</td>
+                           <td>
+                              <textarea name="preview_action.classes:records"
+                                     style="width:90%"
+                                     tal:content="python:'\n'.join(classes)" />
+                           </td>
+                        </tr>
+                        <tr>
+                           <td style="border-right: none;" width="1%">type</td>
+                           <td>
+                              <select name="preview_action.mediatype:records" size="1">
+                                 <option value="image" tal:attributes="selected python:mediatype=='image'">Image</option>
+                                 <option value="flash" tal:attributes="selected python:mediatype=='flash'">Flash</option>
+                              </select>
+                              <div style="height:1em;">&nbsp;</div>
+                           </td>
+                        </tr>
+                     </tbody>
+                  </tal:loop>
+                  <tbody  tal:define="oddrow python:len(previewable)%2;"
+                          tal:attributes="class python:test(oddrow, 'even', 'odd');">
+                     <tr>
+                        <td rowspan="5">
+                           <input type="hidden" name="preview_action.marker:records" value="-"/>
+                        </td>
+                        <td rowspan="5">
+                           <select name="preview_action.portal_type:records" style="width:15em">
+                              <option i18n:translate="" value="">(select type)</option>
+                              <tal:block repeat="ti typeinfos">
+                                    <option tal:define="title python:ti[0]; id python:ti[1];
+                                            fulltitle python:title + test(title==id,'',' (%s)'%id);"
+                                            tal:content="fulltitle"
+                                            tal:condition="not:python:context.getPreviewForType(id)"
+                                            tal:attributes="value id;"></option>
+                              </tal:block>
+                           </select>
+                           <td style="border-right: none;" width="1%">preview</td>
+                           <td>
+                              <input type="text" name="preview_action.expression:records"
+                                     style="width:90%" value="" />
+                           </td>
+                     </tr>
+                     <tr>
+                        <td style="border-right: none;" width="1%">Normal&nbsp;image</td>
+                        <td>
+                           <input type="text" name="preview_action.normal:records"
+                                  style="width:90%" value="" />
+                        </td>
+                     </tr>
+                     <tr>
+                        <td style="border-right: none;" width="1%">fieldname</td>
+                        <td>
+                           <input type="text" name="preview_action.scalefield:records"
+                                  style="width:90%" value="image" />
+                        </td>
+                     </tr>
+                        <tr>
+                           <td style="border-right: none;" width="1%">classes</td>
+                           <td>
+                              <textarea type="text" name="preview_action.classes:records"
+                                     style="width:90%"></textarea>
+                           </td>
+                        </tr>
+                        <tr>
+                           <td style="border-right: none;" width="1%">type</td>
+                           <td>
+                              <select name="preview_action.mediatype:records" size="1">
+                                 <option value="image" selected>Image</option>
+                                 <option value="flash">Flash</option>
+                              </select>
+                           </td>
+                        </tr>
+                  </tbody>
+                  <tbody>
+                     <tr>
+                        <td style="border-right: none;">&nbsp;</td>
+                        <td style="padding-top:0.5em;" colspan="3">
+                           <input class="context" type="submit" name="zmi_update_resource_types:method" value="Save" i18n:attributes="value" />
+                           <input class="context" type="submit" name="zmi_delete_resource_types:method" value="Delete" i18n:attributes="value" />
+                        </td>
+                     </tr>
+                     <tr>
+                        <td colspan="4">
+                           <em><code>Preview</code> is an expression to use for the preview image in the drawer [default is no preview].
+                           <code>Normal image</code> is an expression to use for the normal view of a mediaobject [string:$object_url].
+                           <code>Fieldname</code> is the name of the field to use for scaled variants of the mediaobject [image].
+                           <code>Classes</code> is a list of classnames which may be selected when inserting the object as media.
+                           <code>Type</code> controls whether kupu inserts an img tag or an object tag to embed flash.
+                           </em>
+                        </td>
+                     </tr>
+                  </tbody>
+               </table>
+
+            </fieldset>
+         </form>
+      </div>
+   </body>
 </html>
-
-


More information about the kupu-checkins mailing list