[kupu-checkins] r43355 - in kupu/trunk/kupu: common common/kupudrawers doc plone plone/kupu_plone_layer plone/kupu_plone_layer/plonekupuimages

duncan at codespeak.net duncan at codespeak.net
Mon May 14 12:15:38 CEST 2007


Author: duncan
Date: Mon May 14 12:15:37 2007
New Revision: 43355

Added:
   kupu/trunk/kupu/plone/kupu_plone_layer/plonekupuimages/flash-placeholder.png
      - copied unchanged from r42662, kupu/branch/duncan-flash/plone/kupu_plone_layer/plonekupuimages/flash-placeholder.png
Modified:
   kupu/trunk/kupu/common/kupubasetools.js
   kupu/trunk/kupu/common/kupudrawers.js
   kupu/trunk/kupu/common/kupudrawers/drawer.xsl
   kupu/trunk/kupu/common/kupuhelpers.js
   kupu/trunk/kupu/doc/CHANGES.txt
   kupu/trunk/kupu/doc/LIBRARIES.txt
   kupu/trunk/kupu/doc/PLONE2.txt
   kupu/trunk/kupu/plone/kupu_plone_layer/kupucollection.xml.pt
   kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml
   kupu/trunk/kupu/plone/librarytool.py
   kupu/trunk/kupu/plone/plonedrawers.py
   kupu/trunk/kupu/plone/plonelibrarytool.py
   kupu/trunk/kupu/plone/resource_types.pt
Log:
Added experimental support for Flash objects.
Media objects (flash + img) now have a customisable list of class names.

Modified: kupu/trunk/kupu/common/kupubasetools.js
==============================================================================
--- kupu/trunk/kupu/common/kupubasetools.js	(original)
+++ kupu/trunk/kupu/common/kupubasetools.js	Mon May 14 12:15:37 2007
@@ -1254,6 +1254,18 @@
         imageWindow.focus();
     };
 
+    this.newNode = function(name, obj) {
+        var ed = this.editor;
+        var currobj = ed.getNearestParentOfType(ed.getSelectedNode(), name);
+        if (currobj) {
+            var p = currobj.parentNode;
+            p.insertBefore(obj, currobj);
+            p.removeChild(currobj);
+            return obj;
+        } else {
+            return ed.insertNodeAtSelection(obj, 1);
+        }
+    }
     this.createImage = function(url, alttext, imgclass) {
         /* create an image */
         var img = this.editor.getInnerDocument().createElement('img');
@@ -1266,11 +1278,21 @@
         if (imgclass) {
             img.className = imgclass;
         };
-        img = this.editor.insertNodeAtSelection(img, 1);
+        this.newNode('IMG', img);
         this.editor.logMessage(_('Image inserted'));
         return img;
     };
 
+    this.create_flash = function(url, alttext, className, width, height) {
+        var ed = this.editor;
+        var obj = ed.newElement('object',
+            {src:url, alt:alttext, className:className, width:width, height:height, type:'application/x-shockwave-flash',
+            'data':url},
+            [ed.newElement('param', {name:'movie', value:url})]);
+        this.newNode('OBJECT', obj);
+        this.editor.logMessage(_('Flash inserted'));
+    }
+
     this.setImageClass = function(imgclass) {
         /* set the class of the selected image */
         var currnode = this.editor.getSelectedNode();

Modified: kupu/trunk/kupu/common/kupudrawers.js
==============================================================================
--- kupu/trunk/kupu/common/kupudrawers.js	(original)
+++ kupu/trunk/kupu/common/kupudrawers.js	Mon May 14 12:15:37 2007
@@ -1265,17 +1265,20 @@
     }
 
     this.createContent = function() {
-        var currnode = this.editor.getSelectedNode();
-        var currimg = this.editor.getNearestParentOfType(currnode, 'IMG');
-        this.selectedSrc = currimg?currimg.src:null;
+        var ed = this.editor;
+        var currnode = ed.getSelectedNode();
+        var currimg = ed.getNearestParentOfType(currnode, 'OBJECT') || ed.getNearestParentOfType(currnode, 'IMG');
+        this.selectedSrc = currimg.data||currimg.src||null;
         this.options = {};
         if (currimg) {
+            ed.getSelection().selectNodeContents(currimg);
             var className = currimg.className;
             var align = /\bimage-(left|right|inline)\b/.exec(className);
             if (align && align.length > 1) {
                 this.options['image-align'] = align[1];
             };
             this.options['image-caption'] = /\bcaptioned\b/.test(className);
+            this.options['image-class'] = className.replace(/\b(image-(left|right|inline)|captioned)\b/g,'').strip();
         }
         ImageLibraryDrawer.prototype.createContent.call(this);
     };
@@ -1354,8 +1357,18 @@
         if (caption && caption.length>0 && caption[0].checked) {
             imgclass += " captioned";
         };
-
-        this.tool.createImage(uri, alt, imgclass);
+        var classnames = document.getElementById('kupu-image-class');
+        if (classnames && classnames.selectedIndex >= 0) {
+            imgclass += " "+classnames.options[classnames.selectedIndex].value;
+        }
+        var media = document.getElementById('kupu-media').value;
+        var width = document.getElementById('kupu-width').value;
+        var height = document.getElementById('kupu-height').value;
+        if (this.tool['create_'+media]) {
+            this.tool['create_'+media](uri, alt, imgclass, width, height);
+        } else {
+            this.tool.createImage(uri, alt, imgclass);
+        }
         this.drawertool.closeDrawer();
     };
 };

Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl
==============================================================================
--- kupu/trunk/kupu/common/kupudrawers/drawer.xsl	(original)
+++ kupu/trunk/kupu/common/kupudrawers/drawer.xsl	Mon May 14 12:15:37 2007
@@ -51,6 +51,7 @@
     <xsl:param name="showanchors">yes</xsl:param>
     <xsl:param name="image-align">inline</xsl:param>
     <xsl:param name="image-caption">true</xsl:param>
+    <xsl:param name="image-class"></xsl:param>
     <xsl:param name="link_target"></xsl:param>
     <xsl:param name="link_name"></xsl:param>
     <xsl:variable name="titlelength" select="60"/>
@@ -286,14 +287,18 @@
      If a 'preview' tag is available then that one is used, otherwise 'uri'.
     -->
     <xsl:template match="resource|collection" mode="image-view">
-      <xsl:choose>
-        <xsl:when test="preview">
-          <img src="{preview}" title="{title}" onload="kupuFixImage(this);" width="1" height="1"/>
-        </xsl:when>
-        <xsl:otherwise>
-          <img onload="kupuFixImage(this);" width="1" height="1" src="{uri}" title="{title}"/>
-        </xsl:otherwise>
-      </xsl:choose>
+       <xsl:variable name="p" select="preview|uri"></xsl:variable>
+       <xsl:choose>
+          <xsl:when test="media='flash'">
+             <object src="{$p}" data="{$p}" type="application/x-shockwave-flash"
+                     width="100" height="100">
+                <param name="movie" value="{$p}" />
+             </object>
+          </xsl:when>
+          <xsl:otherwise>
+             <img src="{$p}" title="{title}" onload="kupuFixImage(this);" width="1" height="1"/>
+          </xsl:otherwise>
+       </xsl:choose>
     </xsl:template>
 
     <xsl:template match="resource|collection" mode="image-properties">
@@ -301,6 +306,9 @@
         <div>
            <!-- <form onsubmit="return false;"> -->
                 <div>
+                   <input id="kupu-media" type="hidden" value="{media}" />
+                   <input id="kupu-width" type="hidden" value="{width}" />
+                   <input id="kupu-height" type="hidden" value="{height}" />
                     <label style="display: block;margin-top: 1em;">Image alignment</label>
                     <input type="radio" name="image-align" id="image-align-left" value="image-left">
                        <xsl:attribute name="onkeypress">if(event.keyCode==13)return false;</xsl:attribute>
@@ -329,29 +337,46 @@
                         This is a browser-imposed limitation.
                     </div>
                 </div>
+                
                 <xsl:if test="$usecaptions='yes'">
-                    <div>
-                        <input type="checkbox" name="image-caption" id="image-caption">
-                           <xsl:attribute name="onkeypress">if(event.keyCode==13)return false;</xsl:attribute>
-                           <xsl:if test="$image-caption='true'">
-                              <xsl:attribute name="checked">checked</xsl:attribute>
-                           </xsl:if>
-                           <xsl:attribute name="onclick">document.getElementById('image_alt_div').style.display =
-                              this.checked?'none':'';</xsl:attribute>
-                        </input>
-                        <label for="image-caption" i18n:translate="imagedrawer_caption_label">Caption</label>
-                    </div>
+                   <xsl:choose>
+                      <xsl:when test="media='flash'" />
+                      <xsl:otherwise>
+                         <div>
+                            <input type="checkbox" name="image-caption" id="image-caption">
+                               <xsl:attribute name="onkeypress">if(event.keyCode==13)return false;</xsl:attribute>
+                               <xsl:if test="$image-caption='true'">
+                                  <xsl:attribute name="checked">checked</xsl:attribute>
+                               </xsl:if>
+                               <xsl:attribute name="onclick">document.getElementById('image_alt_div').style.display =
+                                  this.checked?'none':'';</xsl:attribute>
+                            </input>
+                            <label for="image-caption" i18n:translate="imagedrawer_caption_label">Caption</label>
+                         </div>
+                      </xsl:otherwise>
+                   </xsl:choose>
                 </xsl:if>
                 <xsl:if test="sizes">
+                   <div>
                     <label for="image-size-selector"
-                            style="display: block;margin-top: 1em;">Image size</label>
+                            style="margin-top: 1em;">Image size:</label>&#xa0;
                     <select name="image-size-selector">
                         <option name="image-size-option" value="{uri}">Original</option>
                         <xsl:apply-templates select="sizes/size" />
                     </select>
+                   </div>
+                </xsl:if>
+                <xsl:if test="class">
+                   <div>
+                      <label for="kupu-image-class-selector">Image style</label>&#xa0;
+                      <select name="kupu-image-class-selector" id="kupu-image-class">
+                         <xsl:apply-templates select="class"/>
+                      </select>
+                   </div>
                 </xsl:if>
                 <div id="image_alt_div">
-                    <xsl:if test="$usecaptions='yes'">
+                    <xsl:if
+                           test="$usecaptions='yes' and $image-caption='true'">
                         <xsl:attribute name="style">display:none;</xsl:attribute>
                      </xsl:if>   
                     <label for="image_alt" i18n:translate="imagedrawer_upload_alt_text">"alt" attribute text</label>
@@ -362,6 +387,13 @@
                 <!-- </form> -->
         </div>
     </xsl:template>
+    <xsl:template match="class">
+       <option value="{@name}">
+          <xsl:if test="$image-class=@name">
+             <xsl:attribute name="selected">selected</xsl:attribute>
+          </xsl:if>
+          <xsl:value-of select="@title" /></option>
+    </xsl:template>
     <xsl:template match="size">
       <xsl:choose>
         <xsl:when test="selected">

Modified: kupu/trunk/kupu/common/kupuhelpers.js
==============================================================================
--- kupu/trunk/kupu/common/kupuhelpers.js	(original)
+++ kupu/trunk/kupu/common/kupuhelpers.js	Mon May 14 12:15:37 2007
@@ -1011,7 +1011,7 @@
         // to just before the element instead of inside it, and since IE doesn't reserve
         // an index for the element itself as well the way to get it inside the element is
         // by moving the start one pos and then moving it back (yuck!)
-        var range = this.selection.createRange().duplicate();
+        var range = doc.body.createTextRange();
         range.moveToElementText(node);
         range.moveStart('character', 1);
         range.moveStart('character', -1);

Modified: kupu/trunk/kupu/doc/CHANGES.txt
==============================================================================
--- kupu/trunk/kupu/doc/CHANGES.txt	(original)
+++ kupu/trunk/kupu/doc/CHANGES.txt	Mon May 14 12:15:37 2007
@@ -2,6 +2,12 @@
 Kupu changes
 ============
 
+- Recent
+
+  - Added in some support for inserting Flash content.
+
+  - Media objects may now have a list of classes (specific to the portal type).
+
 - 1.4 Beta 6
 
   - Removed the getToolByName deprecation workround since

Modified: kupu/trunk/kupu/doc/LIBRARIES.txt
==============================================================================
--- kupu/trunk/kupu/doc/LIBRARIES.txt	(original)
+++ kupu/trunk/kupu/doc/LIBRARIES.txt	Mon May 14 12:15:37 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,18 @@
   - 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
+-------------
+
+See PLONE2.txt
+
 Futures
 -------
 

Modified: kupu/trunk/kupu/doc/PLONE2.txt
==============================================================================
--- kupu/trunk/kupu/doc/PLONE2.txt	(original)
+++ kupu/trunk/kupu/doc/PLONE2.txt	Mon May 14 12:15:37 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
 =================
 
@@ -645,6 +654,45 @@
        clear: both;
     }
 
+Flash
+-----
+Kupu has some support for embedding Flash objects using the
+ATFlashMovie content type, but requires some configuration. Other
+Flash content types may also work but have not been tested.
+
+  1. Install ATFlashMovie.
+
+  2. Got to the resource types tab of the configlet.
+
+  3. Under the resource ``mediaobject`` add Flash Movie to the
+     selection and save.
+
+  4. In the action urls table at the bottom of the page, add a new
+     entry for the type Flash Movie. The preview may be left blank
+     (kupu does not currently support previewing Flash), or you could
+     select a generic 'Flash' image. For 'normal image' you should
+     enter ``string:${object_url}/download``. Leave fieldname blank
+     and in the 'type' field select 'Flash'.
+
+Flash movies should now appear in the image drawer and be insertable
+into the document. Using IE the Flash movie will appear in the
+document and may be edited or moved as desired. Firefox will not play
+the movie while you are editing, so a 'flash placeholder' image is
+displayed instead: you cannot select it in Firefox so if you need to
+delete a Flash movie you will need to include the image in a slightly
+larger selection (e.g. spaces before and after) and delete that.
+
+Known problems
+==============
+When selecting a flash object in IE you need to be sure to get a
+selection only with sizing handles (by clicking exactly on the edge).
+If the selection box also shows cross-hatched then you have clicked
+inside the Flash object and kupu will not be able to determine the
+current selection.
+
+In IE the Flash object sometimes appears over the top of the drawer.
+Workaround: close the drawer and try again.
+
 References from HTML text
 -------------------------
 Kupu can be made to store archetypes references for any HTML field.

Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupucollection.xml.pt
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupucollection.xml.pt	(original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupucollection.xml.pt	Mon May 14 12:15:37 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/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml	(original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml	Mon May 14 12:15:37 2007
@@ -291,5 +291,12 @@
 .kupu-progresstext {
     text-align:center;position:absolute;top:0;width:100%;
 }
+/* Firefox makes Flash objects completely invisible.
+We need to force it to display something otherwise you cannot edit existing Flash. */
+.kupu-html object.image-inline {
+   display: block;
+   background-image: url(plonekupuimages/flash-placeholder.png);
+   border: 2px green solid;
+}
 /* </dtml-let></dtml-with> */
 

Modified: kupu/trunk/kupu/plone/librarytool.py
==============================================================================
--- kupu/trunk/kupu/plone/librarytool.py	(original)
+++ kupu/trunk/kupu/plone/librarytool.py	Mon May 14 12:15:37 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/trunk/kupu/plone/plonedrawers.py
==============================================================================
--- kupu/trunk/kupu/plone/plonedrawers.py	(original)
+++ kupu/trunk/kupu/plone/plonedrawers.py	Mon May 14 12:15:37 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/trunk/kupu/plone/plonelibrarytool.py
==============================================================================
--- kupu/trunk/kupu/plone/plonelibrarytool.py	(original)
+++ kupu/trunk/kupu/plone/plonelibrarytool.py	Mon May 14 12:15:37 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/trunk/kupu/plone/resource_types.pt
==============================================================================
--- kupu/trunk/kupu/plone/resource_types.pt	(original)
+++ kupu/trunk/kupu/plone/resource_types.pt	Mon May 14 12:15:37 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