From duncan at codespeak.net Tue May 1 11:15:07 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Tue, 1 May 2007 11:15:07 +0200 (CEST) Subject: [kupu-checkins] r42518 - kupu/trunk/kupu/doc Message-ID: <20070501091507.89B998075@code0.codespeak.net> Author: duncan Date: Tue May 1 11:15:07 2007 New Revision: 42518 Modified: kupu/trunk/kupu/doc/CHANGES.txt Log: Updated changes.txt Modified: kupu/trunk/kupu/doc/CHANGES.txt ============================================================================== --- kupu/trunk/kupu/doc/CHANGES.txt (original) +++ kupu/trunk/kupu/doc/CHANGES.txt Tue May 1 11:15:07 2007 @@ -2,6 +2,16 @@ Kupu changes ============ +- 1.4 Beta 6 + + - Removed the getToolByName deprecation workround since + getToolByName is now officially undeprecated again. + + - Removed most of the illegally nested forms produced by the xsl. + I hope this will stop IE6 crashing. The image upload form is still + there as it is going to take more major surgery to get rid of that + one. + - 1.4 Beta 5 - Adjusted some more Plone tests to work on Plone 3.0. From duncan at codespeak.net Tue May 1 17:38:18 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Tue, 1 May 2007 17:38:18 +0200 (CEST) Subject: [kupu-checkins] r42542 - in kupu/branch/duncan-flash: common common/kupudrawers plone/kupu_plone_layer/plonekupuimages Message-ID: <20070501153818.0A3A08076@code0.codespeak.net> Author: duncan Date: Tue May 1 17:38:18 2007 New Revision: 42542 Added: kupu/branch/duncan-flash/plone/kupu_plone_layer/plonekupuimages/flash-placeholder.png (contents, props changed) Modified: kupu/branch/duncan-flash/common/kupubasetools.js kupu/branch/duncan-flash/common/kupudrawers.js kupu/branch/duncan-flash/common/kupudrawers/drawer.xsl Log: Still work in progress, but basically working if anyone wants to try out Flash in kupu. Modified: kupu/branch/duncan-flash/common/kupubasetools.js ============================================================================== --- kupu/branch/duncan-flash/common/kupubasetools.js (original) +++ kupu/branch/duncan-flash/common/kupubasetools.js Tue May 1 17:38:18 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,16 +1278,20 @@ if (imgclass) { img.className = imgclass; }; - img = this.editor.insertNodeAtSelection(img, 1); + this.newNode('IMG', img); this.editor.logMessage(_('Image inserted')); return img; }; - this.createObject = function(url, type, alttext, className, width, height) { + 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:type} - [ed.newElement('param', {name:'movie', value:url})]); + {src:url, alt:alttext, className:className, width:width, height:height, type:'application/x-shockwave-flash', + 'data':url}, + [ed.newElement('param', {name:'movie', value:url}), + ed.newElement('img', {src:'plonekupuimages/flash-placeholder.png',width:width,height:height})]); + this.newNode('OBJECT', obj); + this.editor.logMessage(_('Flash inserted')); } this.setImageClass = function(imgclass) { Modified: kupu/branch/duncan-flash/common/kupudrawers.js ============================================================================== --- kupu/branch/duncan-flash/common/kupudrawers.js (original) +++ kupu/branch/duncan-flash/common/kupudrawers.js Tue May 1 17:38:18 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/branch/duncan-flash/common/kupudrawers/drawer.xsl ============================================================================== --- kupu/branch/duncan-flash/common/kupudrawers/drawer.xsl (original) +++ kupu/branch/duncan-flash/common/kupudrawers/drawer.xsl Tue May 1 17:38:18 2007 @@ -51,6 +51,7 @@ yes inline true + @@ -301,6 +302,9 @@
+ + + @@ -327,25 +331,32 @@
-
- - - checked - - document.getElementById('image_alt_div').style.display = +
+ + + checked + + document.getElementById('image_alt_div').style.display = this.checked?'none':''; - - -
+ + +
+ style="margin-top: 1em;">Image size:  + +
+   + +
display:none; @@ -357,6 +368,13 @@
+ + + Added: kupu/branch/duncan-flash/plone/kupu_plone_layer/plonekupuimages/flash-placeholder.png ============================================================================== Binary file. No diff available. From duncan at codespeak.net Fri May 4 10:53:31 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Fri, 4 May 2007 10:53:31 +0200 (CEST) Subject: [kupu-checkins] r42662 - kupu/branch/duncan-flash/plone/kupu_plone_layer Message-ID: <20070504085331.2F69E8062@code0.codespeak.net> Author: duncan Date: Fri May 4 10:53:29 2007 New Revision: 42662 Modified: kupu/branch/duncan-flash/plone/kupu_plone_layer/kupuplone.css.dtml Log: Workround to make it possible to edit flash with Firefox. Modified: kupu/branch/duncan-flash/plone/kupu_plone_layer/kupuplone.css.dtml ============================================================================== --- kupu/branch/duncan-flash/plone/kupu_plone_layer/kupuplone.css.dtml (original) +++ kupu/branch/duncan-flash/plone/kupu_plone_layer/kupuplone.css.dtml Fri May 4 10:53:29 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. */ +object.image-inline { + display: block; + background-image: url(plonekupuimages/flash-placeholder.png); + border: 2px green solid; +} /* */ From duncan at codespeak.net Mon May 14 12:15:38 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Mon, 14 May 2007 12:15:38 +0200 (CEST) Subject: [kupu-checkins] r43355 - in kupu/trunk/kupu: common common/kupudrawers doc plone plone/kupu_plone_layer plone/kupu_plone_layer/plonekupuimages Message-ID: <20070514101538.9C4A7807A@code0.codespeak.net> 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 @@ yes inline true + @@ -286,14 +287,18 @@ If a 'preview' tag is available then that one is used, otherwise 'uri'. --> - - - - - - - - + + + + + + + + + + + @@ -301,6 +306,9 @@
+ + + if(event.keyCode==13)return false; @@ -329,29 +337,46 @@ This is a browser-imposed limitation.
+ -
- - if(event.keyCode==13)return false; - - checked - - document.getElementById('image_alt_div').style.display = - this.checked?'none':''; - - -
+ + + +
+ + if(event.keyCode==13)return false; + + checked + + document.getElementById('image_alt_div').style.display = + this.checked?'none':''; + + +
+
+
+
+ style="margin-top: 1em;">Image size:  +
+
+ +
+   + +
- + display:none; @@ -362,6 +387,13 @@
+ + + 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 icon + mime type + 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; +} /* */ 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 @@ - - - -
-

Kupu 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.

- -

This management screen allows you to define resource types using a -list of portal types. A special resource type, collection, -identifies portal types that are to be treated as collections. -The resource type containsanchors is used to list types which -may contain HTML anchors.

- -

Also on this screen are urls -for each type which can be previewed as an image. The expression may -use object_url and portal_type, but should -not attempt to access the object directly. The resulting URL should -ideally return an image no larger than 128 pixels square.

- -
-Map resource types - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Map resource types
 
use this entry to add a new resource -
- - - Resource - -
Portal Types - -
New types - -
 
specify a resource type to be used for reference fields with an empty list of allowed types -
Default resource - -
  - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Action URLs
TypeURL
- - - - typepreview - -
Normal mage - -
fieldname - -
- - - - preview - -
Normal Image - -
fieldname - -
  - - - 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]. - -
- -
-
-
- +lang="en" +metal:use-macro="here/kupu_config/macros/master" +i18n:domain="kupuconfig"> + + +
+

Kupu 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.

+

This management screen allows you to define resource types using a + list of portal types. A special resource type, collection, + identifies portal types that are to be treated as collections. + The resource type containsanchors is used to list types which + may contain HTML anchors.

+ +

Also on this screen are urls + for each type which can be previewed as an image. The expression may + use object_url and portal_type, but should + not attempt to access the object directly. The resulting URL should + ideally return an image no larger than 128 pixels square.

+ +
+ Map resource types + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Map resource types
 
use this entry to add a new resource +
+ + + Resource + +
Portal Types + +
New types + +
 
specify a resource type to be used for reference fields with an empty list of allowed types +
Default resource + +
  + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Action URLs
TypeURL
+ + + + typepreview + +
Normal image + +
fieldname + +
classes + +
type + +
  + + +
+ 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]. + Classes is a list of classnames which may be selected when inserting the object as media. + Type controls whether kupu inserts an img tag or an object tag to embed flash. + +
+ +
+
+
+ - - From duncan at codespeak.net Mon May 14 12:20:54 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Mon, 14 May 2007 12:20:54 +0200 (CEST) Subject: [kupu-checkins] r43356 - kupu/trunk/kupu/doc Message-ID: <20070514102054.81D71807A@code0.codespeak.net> Author: duncan Date: Mon May 14 12:20:54 2007 New Revision: 43356 Modified: kupu/trunk/kupu/doc/PLONE2.txt Log: Update documentation. Modified: kupu/trunk/kupu/doc/PLONE2.txt ============================================================================== --- kupu/trunk/kupu/doc/PLONE2.txt (original) +++ kupu/trunk/kupu/doc/PLONE2.txt Mon May 14 12:20:54 2007 @@ -668,11 +668,10 @@ 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'. + entry for the type Flash Movie. The preview may be left blank or be + the same as the 'normal' 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 From duncan at codespeak.net Mon May 14 12:44:45 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Mon, 14 May 2007 12:44:45 +0200 (CEST) Subject: [kupu-checkins] r43357 - in kupu/trunk/kupu/plone: . kupu_plone_layer Message-ID: <20070514104445.302AC807A@code0.codespeak.net> Author: duncan Date: Mon May 14 12:44:44 2007 New Revision: 43357 Modified: kupu/trunk/kupu/plone/exportimport.py kupu/trunk/kupu/plone/kupu_plone_layer/sample-kupu-customisation-policy.py kupu/trunk/kupu/plone/librarytool.py kupu/trunk/kupu/plone/z3interfaces.py Log: GS support for image classes. Modified: kupu/trunk/kupu/plone/exportimport.py ============================================================================== --- kupu/trunk/kupu/plone/exportimport.py (original) +++ kupu/trunk/kupu/plone/exportimport.py Mon May 14 12:44:44 2007 @@ -171,10 +171,15 @@ previewaction = kupu.getPreviewForType(portal_type) normalaction = kupu.getNormalViewForType(portal_type) scalefield = kupu.getScaleFieldForType(portal_type) + classes = kupu.getClassesForType(portal_type) + mediatype = kupu.getMediaForType(portal_type) res.append(dict(portal_type=portal_type, previewaction=previewaction, normalaction=normalaction, - scalefield=scalefield)) + scalefield=scalefield, + classes=classes, + mediatype=mediatype, + )) return res security.declarePrivate('_getExportTemplate') @@ -247,7 +252,10 @@ 'preview': { KEY:'expression', DEFAULT: ''}, 'normal': { DEFAULT: ''}, 'scalefield': { DEFAULT: 'image' }, + 'previewclass': { KEY: 'classes', DEFAULT: ()}, + 'mediatype': { DEFAULT: ''}, }, + 'previewclass': { '#text': {KEY:None}, }, 'generatepreviews': {}, 'globaltoolbar': { '#text': { KEY:None }, }, 'toolbar': Modified: kupu/trunk/kupu/plone/kupu_plone_layer/sample-kupu-customisation-policy.py ============================================================================== --- kupu/trunk/kupu/plone/kupu_plone_layer/sample-kupu-customisation-policy.py (original) +++ kupu/trunk/kupu/plone/kupu_plone_layer/sample-kupu-customisation-policy.py Mon May 14 12:44:44 2007 @@ -101,6 +101,8 @@ 'expression': PREVIEW_EXPR % image, 'normal': None, 'scalefield': image.split('_',1)[0], + 'classes': '', + 'mediatype': 'image', } for (type, image) in tool.getPreviewable() ] # e.g. PREVIEW=[{'portal_type': 'Image', Modified: kupu/trunk/kupu/plone/librarytool.py ============================================================================== --- kupu/trunk/kupu/plone/librarytool.py (original) +++ kupu/trunk/kupu/plone/librarytool.py Mon May 14 12:44:44 2007 @@ -256,7 +256,10 @@ if normal: normal = Expression(normal) scalefield = a.get('scalefield', 'image') - classes = a.get('classes', '').split('\n') + classes = a.get('classes', '') + if isinstance(classes, basestring): + classes = classes.split('\n') + classes = tuple(classes) mediatype = a.get('mediatype', 'image') if not portal_type: continue Modified: kupu/trunk/kupu/plone/z3interfaces.py ============================================================================== --- kupu/trunk/kupu/plone/z3interfaces.py (original) +++ kupu/trunk/kupu/plone/z3interfaces.py Mon May 14 12:44:44 2007 @@ -83,15 +83,20 @@ def getCookedLibraries(context): """Return a list of libraries with our own parameters included""" - def getPreviewForType(self, portal_type): + def getPreviewForType(portal_type): """Get the preview url for a specific type""" - def getNormalViewForType(self, portal_type): + def getNormalViewForType(portal_type): """Get the normal view url for a specific type""" - def getScaleFieldForType(self, portal_type): + def getScaleFieldForType(portal_type): """Get the name of the field containing a scalable image""" + def getClassesForType(portal_type): + """Get a sequence of classes that may be applied""" + + def getMediaForType(portal_type): + """Gets the media type image/flash""" def configure_kupu( linkbyuid, table_classnames, html_exclusions, style_whitelist, class_blacklist, From duncan at codespeak.net Mon May 14 15:58:47 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Mon, 14 May 2007 15:58:47 +0200 (CEST) Subject: [kupu-checkins] r43369 - kupu/trunk/kupu/plone Message-ID: <20070514135847.428F28084@code0.codespeak.net> Author: duncan Date: Mon May 14 15:58:46 2007 New Revision: 43369 Modified: kupu/trunk/kupu/plone/html2captioned.py Log: Output transform fixes up Flash uid urls. Modified: kupu/trunk/kupu/plone/html2captioned.py ============================================================================== --- kupu/trunk/kupu/plone/html2captioned.py (original) +++ kupu/trunk/kupu/plone/html2captioned.py Mon May 14 15:58:46 2007 @@ -62,7 +62,7 @@ ''' -UID_PATTERN = re.compile('(?P<(?:a|img)\\s[^>]*(?:src|href)\s*=\s*")(?P[^"]*resolveuid/(?P[^/"#? ]*))', re.DOTALL | re.IGNORECASE) +UID_PATTERN = re.compile('(?P<(?:a|img|object|param)\\s[^>]*(?:src|href|data|value)\s*=\s*")(?P[^"]*resolveuid/(?P[^/"#? ]*))', re.DOTALL | re.IGNORECASE) class HTMLToCaptioned: """Transform which adds captions to images embedded in HTML""" From duncan at codespeak.net Tue May 15 12:10:59 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Tue, 15 May 2007 12:10:59 +0200 (CEST) Subject: [kupu-checkins] r43402 - kupu/trunk/kupu/common Message-ID: <20070515101059.EC248808F@code0.codespeak.net> Author: duncan Date: Tue May 15 12:10:58 2007 New Revision: 43402 Modified: kupu/trunk/kupu/common/kupubasetools.js Log: Danny asked "Can you please add the 'kupu-fulleditor-zoomed' class to the body inside the iframe when it's in zoomed mode? I cannot create a css rule to adjust margins and sizes otherwise." Modified: kupu/trunk/kupu/common/kupubasetools.js ============================================================================== --- kupu/trunk/kupu/common/kupubasetools.js (original) +++ kupu/trunk/kupu/common/kupubasetools.js Tue May 15 12:10:58 2007 @@ -1265,7 +1265,7 @@ } else { return ed.insertNodeAtSelection(obj, 1); } - } + }; this.createImage = function(url, alttext, imgclass) { /* create an image */ var img = this.editor.getInnerDocument().createElement('img'); @@ -1291,7 +1291,7 @@ [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 */ @@ -2821,17 +2821,20 @@ var body = document.body; var html = document.getElementsByTagName('html')[0]; + var doc = editor.getInnerDocument(); if (zoom) { html.style.overflow = 'hidden'; window.scrollTo(0, 0); editor.setClass(zoomClass); body.className += ' '+zoomClass; + doc.body.className += ' '+zoomClass; this.onresize(); } else { html.style.overflow = ''; var fulleditor = iframe.parentNode; fulleditor.style.width = ''; body.className = body.className.replace(/ *kupu-fulleditor-zoomed/, ''); + doc.body.className = doc.body.className.replace(/ *kupu-fulleditor-zoomed/, ''); editor.clearClass(zoomClass); iframe.style.width = ''; @@ -2844,7 +2847,6 @@ sourceArea.style.height = ''; }; } - var doc = editor.getInnerDocument(); // Mozilla needs this. Yes, really! doc.designMode=doc.designMode; From duncan at codespeak.net Tue May 15 13:41:46 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Tue, 15 May 2007 13:41:46 +0200 (CEST) Subject: [kupu-checkins] r43404 - in kupu/trunk/kupu/plone: . kupu_plone_layer profiles/default Message-ID: <20070515114146.219A18092@code0.codespeak.net> Author: duncan Date: Tue May 15 13:41:45 2007 New Revision: 43404 Modified: kupu/trunk/kupu/plone/kupu_plone_layer/sample-kupu-customisation-policy.py kupu/trunk/kupu/plone/plonelibrarytool.py kupu/trunk/kupu/plone/profiles/default/kupu.xml Log: Make the 'current folder' icon use the correct icon for the type of the 'folder'. Modified: kupu/trunk/kupu/plone/kupu_plone_layer/sample-kupu-customisation-policy.py ============================================================================== --- kupu/trunk/kupu/plone/kupu_plone_layer/sample-kupu-customisation-policy.py (original) +++ kupu/trunk/kupu/plone/kupu_plone_layer/sample-kupu-customisation-policy.py Tue May 15 13:41:45 2007 @@ -68,7 +68,7 @@ title="string:Current folder", uri="string:${folder_url}", src="string:${folder_url}/kupucollection.xml", - icon="string:${portal_url}/folder_icon.gif"), + icon="string:${folder/getIcon}"), dict(id="myitems", title="string:My recent items", uri="string:${portal_url}/kupumyitems.xml", Modified: kupu/trunk/kupu/plone/plonelibrarytool.py ============================================================================== --- kupu/trunk/kupu/plone/plonelibrarytool.py (original) +++ kupu/trunk/kupu/plone/plonelibrarytool.py Tue May 15 13:41:45 2007 @@ -59,7 +59,7 @@ title="string:Current folder", uri="string:${folder_url}", src="string:${folder_url}/kupucollection.xml", - icon="string:${portal_url}/folder_icon.gif"), + icon="string:${folder/getIcon}"), dict(id="myitems", title="string:My recent items", uri="string:${portal_url}/kupumyitems.xml", Modified: kupu/trunk/kupu/plone/profiles/default/kupu.xml ============================================================================== --- kupu/trunk/kupu/plone/profiles/default/kupu.xml (original) +++ kupu/trunk/kupu/plone/profiles/default/kupu.xml Tue May 15 13:41:45 2007 @@ -32,7 +32,7 @@ Author: duncan Date: Tue May 15 15:54:35 2007 New Revision: 43406 Modified: kupu/trunk/kupu/common/kupudrawers.js kupu/trunk/kupu/common/kupudrawers/drawer.xsl kupu/trunk/kupu/common/kupudrawerstyles.css kupu/trunk/kupu/plone/kupu_plone_layer/kupulibraries.xml.pt kupu/trunk/kupu/plone/kupu_plone_layer/kupumyitems.xml.pt kupu/trunk/kupu/plone/kupu_plone_layer/kupurecentitems.xml.pt kupu/trunk/kupu/plone/kupu_plone_layer/kupusearch.xml.pt kupu/trunk/kupu/plone/kupu_plone_layer/kupuselection.xml.pt Log: Changes to image drawer styling for a neater effect (I hope). Removed explicit styling and shuffled labels round a bit. 'Breadcrumbs' on search results changes to 'Locate'. Modified: kupu/trunk/kupu/common/kupudrawers.js ============================================================================== --- kupu/trunk/kupu/common/kupudrawers.js (original) +++ kupu/trunk/kupu/common/kupudrawers.js Tue May 15 15:54:35 2007 @@ -722,7 +722,7 @@ var divs = librariespanel.getElementsByTagName('div'); for (var i = 0; i < divs.length; i++) { var div = divs[i]; - div.className = div.className.replace(/ *selected/,''); + div.className = div.className.replace(/[ -]*selected/,''); } /* Deselect the currently active collection or library */ var selected; Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl ============================================================================== --- kupu/trunk/kupu/common/kupudrawers/drawer.xsl (original) +++ kupu/trunk/kupu/common/kupudrawers/drawer.xsl Tue May 15 15:54:35 2007 @@ -181,7 +181,7 @@ - +
@@ -309,33 +309,30 @@ - - - if(event.keyCode==13)return false; - + + + + if(event.keyCode==13)return false; + checked - - - - - if(event.keyCode==13)return false; - - checked - - - - - if(event.keyCode==13)return false; - - checked - - - -
- You have to select left/right alignment first, then - move the image up or down in the document afterwards. - This is a browser-imposed limitation. -
+
+ + + + if(event.keyCode==13)return false; + + checked + + + + + if(event.keyCode==13)return false; + + checked + + + + @@ -343,7 +340,9 @@
- + + if(event.keyCode==13)return false; checked @@ -351,16 +350,15 @@ document.getElementById('image_alt_div').style.display = this.checked?'none':''; -
-   - @@ -368,8 +366,9 @@
-   -
@@ -379,8 +378,10 @@ test="$usecaptions='yes' and $image-caption='true'"> display:none;
- - + + if(event.keyCode==13)return false;
Modified: kupu/trunk/kupu/common/kupudrawerstyles.css ============================================================================== --- kupu/trunk/kupu/common/kupudrawerstyles.css (original) +++ kupu/trunk/kupu/common/kupudrawerstyles.css Tue May 15 15:54:35 2007 @@ -64,7 +64,7 @@ .kupu-alt-row label { display: block; } - +#image_alt { width:17em; } div.kupu-linkdrawer-addlink td { border: 0; } @@ -190,10 +190,25 @@ vertical-align: text-bottom; white-space: nowrap; } +.kupu-libsource, .kupu-libsource-selected { margin-left: 20px; } +.library-icon-library { + margin-left: -20px; +} div.kupu-upload { text-align: right; font-style: italic; } +label.kupu-detail-label { + float:left;clear:left; + width:7em; + text-align:right; + margin: 0.2em; +} +.kupu-detail { + float:left; + margin: 0.2em; +} + /*div.kupu-libsource-selected { background-repeat: no-repeat; }*/ @@ -273,6 +288,7 @@ .kupu-drawer label { font-weight: bold; + vertical-align:middle; } #kupu-breadcrumbs { text-align: left; clear:left; @@ -297,4 +313,4 @@ background: transparent url(kupuimages/treeCollapsed.gif) 4px 6px no-repeat; padding: 1px 0px 1px 16px; font-style: italic; -} \ No newline at end of file +} Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupulibraries.xml.pt ============================================================================== --- kupu/trunk/kupu/plone/kupu_plone_layer/kupulibraries.xml.pt (original) +++ kupu/trunk/kupu/plone/kupu_plone_layer/kupulibraries.xml.pt Tue May 15 15:54:35 2007 @@ -6,6 +6,7 @@ @@ -13,12 +14,14 @@ getToolByName nocall:modules/Products.CMFCore.utils/getToolByName; kupu_tool python:getToolByName(context, 'kupu_library_tool'); libraries python:kupu_tool.getCookedLibraries(context); - "> + pss modules/Products/PythonScripts/standard; +"> URI - Title + Title Source Icon Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupumyitems.xml.pt ============================================================================== --- kupu/trunk/kupu/plone/kupu_plone_layer/kupumyitems.xml.pt (original) +++ kupu/trunk/kupu/plone/kupu_plone_layer/kupumyitems.xml.pt Tue May 15 15:54:35 2007 @@ -20,7 +20,7 @@ - Breadcrumbs + Locate Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupurecentitems.xml.pt ============================================================================== --- kupu/trunk/kupu/plone/kupu_plone_layer/kupurecentitems.xml.pt (original) +++ kupu/trunk/kupu/plone/kupu_plone_layer/kupurecentitems.xml.pt Tue May 15 15:54:35 2007 @@ -20,7 +20,7 @@ - Breadcrumbs + Locate Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupusearch.xml.pt ============================================================================== --- kupu/trunk/kupu/plone/kupu_plone_layer/kupusearch.xml.pt (original) +++ kupu/trunk/kupu/plone/kupu_plone_layer/kupusearch.xml.pt Tue May 15 15:54:35 2007 @@ -19,7 +19,7 @@ - Breadcrumbs + Locate Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupuselection.xml.pt ============================================================================== --- kupu/trunk/kupu/plone/kupu_plone_layer/kupuselection.xml.pt (original) +++ kupu/trunk/kupu/plone/kupu_plone_layer/kupuselection.xml.pt Tue May 15 15:54:35 2007 @@ -23,7 +23,7 @@ tal:define="url context/portal_url; resource_type request/resource_type | string:mediaobject;" tal:attributes="href string:${context/portal_url}/kupulocate.xml?resource_type=${resource_type}&src=$$src$$"> - Breadcrumbs + Locate From duncan at codespeak.net Tue May 15 15:55:16 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Tue, 15 May 2007 15:55:16 +0200 (CEST) Subject: [kupu-checkins] r43407 - in kupu/trunk/kupu: common tests Message-ID: <20070515135516.7E9DF8084@code0.codespeak.net> Author: duncan Date: Tue May 15 15:55:16 2007 New Revision: 43407 Modified: kupu/trunk/kupu/common/kupucontentfilters.js kupu/trunk/kupu/tests/test_xhtml.js Log: Improved filtering code:

tags can no longer contain tables, captioned images, or other things which make the html go horribly wrong. Modified: kupu/trunk/kupu/common/kupucontentfilters.js ============================================================================== --- kupu/trunk/kupu/common/kupucontentfilters.js (original) +++ kupu/trunk/kupu/common/kupucontentfilters.js Tue May 15 15:55:16 2007 @@ -312,7 +312,7 @@ this.misc = ['noscript'].concat(this.misc_inline); this.inline = ['a'].concat(this.special, this.fontstyle, this.phrase, this.inline_forms); - this.Inline = ['#PCDATA'].concat(this.inline, this.misc_inline); + this.Inline = ['#text'].concat(this.inline, this.misc_inline); this.heading = ['h1','h2','h3','h4','h5','h6']; this.lists = ['ul','ol','dl','menu','dir']; @@ -320,7 +320,7 @@ this.block = ['p','div','isindex','fieldset','table'].concat( this.heading, this.lists, this.blocktext); - this.Flow = ['#PCDATA','form'].concat(this.block, this.inline, this.misc); + this.Flow = ['#text','form'].concat(this.block, this.inline, this.misc); }(this); this._commonsetting = function(self, names, value) { @@ -415,7 +415,7 @@ 'base', 'meta', 'link', 'hr', 'param', 'img', 'area', 'input', 'br', 'basefont', 'isindex', 'col'], []); - setStates(['title','style','script','option','textarea'], ['#PCDATA']); + setStates(['title','style','script','option','textarea'], ['#text']); setStates([ 'noscript', 'iframe', 'noframes', 'body', 'div', 'li', 'dd', 'blockquote', 'center', 'ins', 'del', 'td', 'th'], el.Flow); @@ -430,12 +430,12 @@ setStates(['dl'], ['dt','dd']); setStates(['pre'], validation._exclude(el.Inline, "img|object|embed|applet|big|small|sub|sup|font|basefont")); setStates(['a'], validation._exclude(el.Inline, "a")); - setStates(['applet', 'object','embed'], ['#PCDATA', 'param','form'].concat(el.block, el.inline, el.misc)); + setStates(['applet', 'object','embed'], ['#text', 'param','form'].concat(el.block, el.inline, el.misc)); setStates(['map'], ['form', 'area'].concat(el.block, el.misc)); setStates(['form'], validation._exclude(el.Flow, ['form'])); setStates(['select'], ['optgroup','option']); setStates(['optgroup'], ['option']); - setStates(['fieldset'], ['#PCDATA','legend','form'].concat(el.block,el.inline,el.misc)); + setStates(['fieldset'], ['#text','legend','form'].concat(el.block,el.inline,el.misc)); setStates(['button'], validation._exclude(el.Flow, ['a','form','iframe'].concat(el.inline_forms))); setStates(['table'], ['caption','col','colgroup','thead','tfoot','tbody','tr']); setStates(['thead', 'tfoot', 'tbody'], ['tr']); @@ -542,26 +542,6 @@ }; }(this, editor); - // Node filtering. May modify html node or xhtml parentNode. - // Return true to continue processing html node, false to skip it. - this.nodefilters = new function(editor) { - // Strip
at end of paragraph. - // Top level
: enclose preceding text (if any) in

and - // drop the
- this['br'] = function(node, parentNode) { - if (parentNode.tagName=='body') { - var p = parentNode.ownerDocument.createElement('p'); - if (parentNode.lastChild && parentNode.lastChild.nodeType==3) { - p.appendChild(parentNode.lastChild); - } - parentNode.appendChild(p); - return false; - } - if (!node.nextSibling && /p|div/i.test(parentNode.nodeName)) return false; - return true; - }; - } - // Exclude unwanted tags. this.excludeTags(['center']); @@ -610,9 +590,101 @@ if (filter) filter(name, htmlnode, xhtmlnode); } }; + this._xmlCopyAttr = function(srcnode, target) { + var valid = this.tagAttributes[srcnode.nodeName]; + for (var i = 0; i < valid.length; i++) { + var val = srcnode.getAttribute(valid[i]); + if (val) { + target.setAttribute(valid[i], val); + } + }; + } + + this._convertToSarissaNode = function(ownerdoc, htmlnode) { + var root = this._convertNodes(ownerdoc, htmlnode, null, new this.Set(['html'])); + this._cleanupBr(ownerdoc, root); + this._cleanupParas(ownerdoc, root); + return root; + }; + + // Clean up a paragraph. Any direct child which is not allowed in + // the paragraph is moved to the parent. This may involved + // splitting the paragraph, or if it is at the beginning or end it + // may simply mean moving it out of the paragraph. + this._cleanupPara = function(ownerdoc, para) { + var permitted = this.States.p; + var nodes = [[]]; + var idx = 0; + for (var child = para.firstChild; child; child = child.nextSibling) { + var nn = child.nodeName.toLowerCase(); + if (permitted[nn] && (nn != 'img' || !(/\bcaptioned\b/i.test(child.getAttribute('class'))))) { + nodes[idx].push(child); + } else { + if (nodes[idx].length) { + nodes.push(child); + } else { + nodes[idx] = child; + } + nodes.push([]); + idx = nodes.length-1; + } + } + if (!nodes[idx].length) { + nodes.splice(idx,1); + }; + if (nodes.length > 0 && nodes[0] instanceof Array && !nodes[0].length) { + nodes.splice(0,1); + } + if (nodes.length==0 || (nodes.length==1 && nodes[0] instanceof Array)) { + return; /* No change */ + } + /* Need to cleanup this paragraph */ + var parentnode = para.parentNode; + for (var idx = 0; idx < nodes.length; idx++) { + var n = nodes[idx]; + if (n instanceof Array) { + var newp = ownerdoc.createElement('p'); + this._xmlCopyAttr(para, newp); + var ln = n.length-1; + if (/br/i.test(n[ln].nodeName)) { + n.splice(ln,1); + } + for (var j = 0; j < n.length; j++) { + newp.appendChild(n[j]); + } + n = newp; + } + parentnode.insertBefore(n,para); + } + parentnode.removeChild(para); + }; - this._convertToSarissaNode = function(ownerdoc, htmlnode, xhtmlparent) { - return this._convertNodes(ownerdoc, htmlnode, xhtmlparent, new this.Set(['html'])); + this._cleanupParas = function(ownerdoc, root) { + var paras = root.getElementsByTagName('p'); + for (var i = 0; i < paras.length; i++) { + this._cleanupPara(ownerdoc, paras[i]); + } + }; + /* Cleanup br tags: br at top level is replaced by a paragraph, + * br at end of p|div is dropped. + */ + this._cleanupBr = function(ownerdoc, root) { + var breaks = root.getElementsByTagName('br'); + for (var i = 0; i < breaks.length; i++) { + var node = breaks[i]; + var parentNode = node.parentNode; + if (parentNode.tagName=='body') { + var p = ownerdoc.createElement('p'); + var prev = node.previousSibling; + if (prev && prev.nodeType==3) { + p.appendChild(prev); + } + parentNode.insertBefore(p,node); + parentNode.removeChild(node); + } else if (!node.nextSibling && (/p|div/i.test(parentNode.nodeName))) { + parentNode.removeChild(node); + } + } }; this._convertNodes = function(ownerdoc, htmlnode, xhtmlparent, permitted) { @@ -620,12 +692,6 @@ var nodename = this._getTagName(htmlnode); var nostructure = !this.filterstructure; - var filter = this.nodefilters[nodename]; - if (filter) { - if (!filter(htmlnode, xhtmlparent)) { - return; - } - } // TODO: This permits valid tags anywhere. it should use the state // table in xhtmlvalid to only permit tags where the XHTML DTD // says they are valid. @@ -646,7 +712,7 @@ if (kids.length == 0) { if (htmlnode.text && htmlnode.text != "" && - (nostructure || permittedChildren['#PCDATA'])) { + (nostructure || permittedChildren['#text'])) { var text = htmlnode.text; var tnode = ownerdoc.createTextNode(text); parentnode.appendChild(tnode); @@ -669,11 +735,11 @@ parentnode.appendChild(newkid); }; } else if (kid.nodeType == 3) { - if (nostructure || permittedChildren['#PCDATA']) { + if (nostructure || permittedChildren['#text']) { parentnode.appendChild(ownerdoc.createTextNode(kid.nodeValue)); } } else if (kid.nodeType == 4) { - if (nostructure || permittedChildren['#PCDATA']) { + if (nostructure || permittedChildren['#text']) { parentnode.appendChild(ownerdoc.createCDATASection(kid.nodeValue)); } } Modified: kupu/trunk/kupu/tests/test_xhtml.js ============================================================================== --- kupu/trunk/kupu/tests/test_xhtml.js (original) +++ kupu/trunk/kupu/tests/test_xhtml.js Tue May 15 15:55:16 2007 @@ -256,8 +256,45 @@ ''; this.editor.xhtmlvalid.filterstructure = true; this.conversionTest(data, data); + } + + // Some tests to ensure that we don't put anything in a

tag + // which isn't allowed in a

tag. + // Can't test with

x

as Firefox DOM fixes that + // for us (but not as we want it fixed) so we use something FF doesn't already fix. + this.testPcleanup = function() { + var data = '

oops

'; + var expected = '
oops
'; + this.conversionTest(data, expected); + }; + + this.testPcleanup2 = function() { + var data = '

some text
oops
more text

'; + var expected = '

some text

oops

more text

'; + this.conversionTest(data, expected); + }; + + this.testPWithCaptionedImg = function() { + // Captioned images are converted to block tags so they must + // not be inside a paragraph. + var data = '

some text
xyzzyblah

'; + var expected = '

some text

xyzzy

blah

'; + this.conversionTest(data, expected); + // If there is no surrounding text we don't want empty paras. + var data = '

xyzzy

'; + var expected = 'xyzzy'; + this.conversionTest(data, expected); + // But ordinary images are fine. + var data = '

some text
xyzzyblah

'; + var expected = '

some text
xyzzyblah

'; + this.conversionTest(data, expected); }; + // Firefox is broken wrt to
tags and newlines inside
.
+    // It thinks that 
\n is two newlines but in fact the HTML spec + // says it should ignore any whitespace following a
. + this.testBrInsidePre = function() { + } this.tearDown = function() { this.body.innerHTML = ''; }; From duncan at codespeak.net Tue May 15 16:15:42 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Tue, 15 May 2007 16:15:42 +0200 (CEST) Subject: [kupu-checkins] r43408 - kupu/trunk/kupu/common/kupudrawers Message-ID: <20070515141542.6B1B08084@code0.codespeak.net> Author: duncan Date: Tue May 15 16:15:42 2007 New Revision: 43408 Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl Log: Description should be inside

tags. Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl ============================================================================== --- kupu/trunk/kupu/common/kupudrawers/drawer.xsl (original) +++ kupu/trunk/kupu/common/kupudrawers/drawer.xsl Tue May 15 16:15:42 2007 @@ -252,7 +252,8 @@

- +

 
@@ -276,7 +277,8 @@
- +

From duncan at codespeak.net Tue May 15 17:10:55 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Tue, 15 May 2007 17:10:55 +0200 (CEST) Subject: [kupu-checkins] r43413 - in kupu/trunk/kupu/common: . kupudrawers Message-ID: <20070515151055.38A598084@code0.codespeak.net> Author: duncan Date: Tue May 15 17:10:54 2007 New Revision: 43413 Modified: kupu/trunk/kupu/common/kupudrawers.js kupu/trunk/kupu/common/kupudrawers/drawer.xsl kupu/trunk/kupu/common/kupudrawerstyles.css Log: Fixup race condition on loading preview. Moved preview image under the title Fixed up styles for IE Modified: kupu/trunk/kupu/common/kupudrawers.js ============================================================================== --- kupu/trunk/kupu/common/kupudrawers.js (original) +++ kupu/trunk/kupu/common/kupudrawers.js Tue May 15 17:10:54 2007 @@ -692,7 +692,10 @@ if (!this.focussed) { this.focusElement(); } - + var el = targetnode.getElementsByTagName('img')[0]; + if (el) { + kupuFixImage(el); + } // Mark drawer as having a selection or not var el = this.element; el.className = el.className.replace(' kupu-has-selection', ''); Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl ============================================================================== --- kupu/trunk/kupu/common/kupudrawers/drawer.xsl (original) +++ kupu/trunk/kupu/common/kupudrawers/drawer.xsl Tue May 15 17:10:54 2007 @@ -244,12 +244,12 @@
-
- -

+
+ +

+

+ +

@@ -272,9 +275,6 @@ )
-

- -

  + for="image-size-selector">Size: Modified: kupu/trunk/kupu/common/kupudrawerstyles.css ============================================================================== --- kupu/trunk/kupu/common/kupudrawerstyles.css (original) +++ kupu/trunk/kupu/common/kupudrawerstyles.css Tue May 15 17:10:54 2007 @@ -97,6 +97,7 @@ clear: none; height: auto; line-height: 1.1em; } +.kupu-description-row p { height: auto !IMPORTANT; } h1.kupu-title-row { font-size: 136%; } From hannosch at codespeak.net Wed May 16 05:53:50 2007 From: hannosch at codespeak.net (hannosch at codespeak.net) Date: Wed, 16 May 2007 05:53:50 +0200 (CEST) Subject: [kupu-checkins] r43425 - kupu/trunk/kupu/common Message-ID: <20070516035350.133D98084@code0.codespeak.net> Author: hannosch Date: Wed May 16 05:53:49 2007 New Revision: 43425 Modified: kupu/trunk/kupu/common/fulldoc.html Log: Make ZChecker happy and add missing summary attribute to a table. Modified: kupu/trunk/kupu/common/fulldoc.html ============================================================================== --- kupu/trunk/kupu/common/fulldoc.html (original) +++ kupu/trunk/kupu/common/fulldoc.html Wed May 16 05:53:49 2007 @@ -51,7 +51,8 @@ us a chance to test table editing in Kupu:

Comparing Data- and Document-Centric

- +
From duncan at codespeak.net Wed May 16 11:29:38 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Wed, 16 May 2007 11:29:38 +0200 (CEST) Subject: [kupu-checkins] r43427 - kupu/trunk/kupu/plone Message-ID: <20070516092938.2AE14808D@code0.codespeak.net> Author: duncan Date: Wed May 16 11:29:37 2007 New Revision: 43427 Modified: kupu/trunk/kupu/plone/plonedrawers.py Log: Protect against corrupted catalog Modified: kupu/trunk/kupu/plone/plonedrawers.py ============================================================================== --- kupu/trunk/kupu/plone/plonedrawers.py (original) +++ kupu/trunk/kupu/plone/plonedrawers.py Wed May 16 11:29:37 2007 @@ -234,9 +234,9 @@ """Returns size, width, height""" if not self.showimagesize: return None, None, None - if not callable(obj.getId): - obj = obj.getObject() # Must be a brain try: + if not callable(obj.getId): + obj = obj.getObject() # Must be a brain size = self.tool.getObjSize(obj) except: size = None From duncan at codespeak.net Wed May 16 14:29:32 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Wed, 16 May 2007 14:29:32 +0200 (CEST) Subject: [kupu-checkins] r43429 - kupu/trunk/kupu/common/kupudrawers Message-ID: <20070516122932.47D9A808F@code0.codespeak.net> Author: duncan Date: Wed May 16 14:29:29 2007 New Revision: 43429 Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl Log: Removed some spurious
tags. Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl ============================================================================== --- kupu/trunk/kupu/common/kupudrawers/drawer.xsl (original) +++ kupu/trunk/kupu/common/kupudrawers/drawer.xsl Wed May 16 14:29:29 2007 @@ -304,91 +304,79 @@ - -
- -
- - - - - - - if(event.keyCode==13)return false; - - checked - - - - - if(event.keyCode==13)return false; - - checked - - - - - if(event.keyCode==13)return false; - - checked - - - - -
- - - - - -
- - - if(event.keyCode==13)return false; - - checked - - document.getElementById('image_alt_div').style.display = - this.checked?'none':''; - -
-
-
+ +
+ + + + + + + if(event.keyCode==13)return false; + + checked - -
- - -
+ + + + if(event.keyCode==13)return false; + + checked - -
- - -
+ + + + if(event.keyCode==13)return false; + + checked -
- - display:none; - - - - if(event.keyCode==13)return false; - -
- -
+ + + + + + + + + + if(event.keyCode==13)return false; + + checked + + document.getElementById('image_alt_div').style.display = + this.checked?'none':''; + + + + + + + + + + + + +
+ + display:none; + + + + if(event.keyCode==13)return false; + +
+
-
+
+ Upload image here... +
{../title} Modified: kupu/trunk/kupu/common/kupudrawerstyles.css ============================================================================== --- kupu/trunk/kupu/common/kupudrawerstyles.css (original) +++ kupu/trunk/kupu/common/kupudrawerstyles.css Wed May 16 14:44:48 2007 @@ -185,7 +185,7 @@ } div.kupu-libsource, div.kupu-libsource-selected, -div.kupu-resource, div.kupu-collection, div.kupu-upload { +div.kupu-resource, div.kupu-collection { cursor: pointer; margin-bottom: 2px; vertical-align: text-bottom; @@ -195,8 +195,8 @@ .library-icon-library { margin-left: -20px; } -div.kupu-upload { - text-align: right; font-style: italic; +.kupu-upload { + margin-top: 1em; float:right; } label.kupu-detail-label { From duncan at codespeak.net Wed May 16 15:41:54 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Wed, 16 May 2007 15:41:54 +0200 (CEST) Subject: [kupu-checkins] r43434 - in kupu/trunk/kupu/common: . kupudrawers Message-ID: <20070516134154.1F3198092@code0.codespeak.net> Author: duncan Date: Wed May 16 15:41:53 2007 New Revision: 43434 Modified: kupu/trunk/kupu/common/kupudrawers.js kupu/trunk/kupu/common/kupudrawers/drawer.xsl kupu/trunk/kupu/common/kupudrawerstyles.css Log: Upload button moved to the bottom of the panel. selected-item class is now applied to the containing div instead of the span. Modified: kupu/trunk/kupu/common/kupudrawers.js ============================================================================== --- kupu/trunk/kupu/common/kupudrawers.js (original) +++ kupu/trunk/kupu/common/kupudrawers.js Wed May 16 15:41:53 2007 @@ -1003,7 +1003,8 @@ if (item) { var spans = item.getElementsByTagName('span'); for (var j = 0; j < spans.length; j++) { - spans[j].className = spans[j].className.replace(' selected-item', ''); + var p = spans[j].parentNode; + p.className = p.className.replace(/(\s+|^)selected-item/, ''); } } } @@ -1070,8 +1071,9 @@ var span = item.getElementsByTagName('span'); if (span.length > 0) { span = span[0]; - span.className += ' selected-item'; - var inp = span.parentNode.getElementsByTagName('input'); + var p = span.parentNode; + p.className += ' selected-item'; + var inp = p.getElementsByTagName('input'); if (inp) inp[0].checked = check; } Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl ============================================================================== --- kupu/trunk/kupu/common/kupudrawers/drawer.xsl (original) +++ kupu/trunk/kupu/common/kupudrawers/drawer.xsl Wed May 16 15:41:53 2007 @@ -119,6 +119,8 @@ +
 
@@ -186,10 +188,17 @@
- + -
+
+ + + kupu- + + selected-item + + drawertool.current_drawer.selectCollection(this); @@ -229,9 +238,6 @@ - - drawer-item-title selected-item - ... Modified: kupu/trunk/kupu/common/kupudrawerstyles.css ============================================================================== --- kupu/trunk/kupu/common/kupudrawerstyles.css (original) +++ kupu/trunk/kupu/common/kupudrawerstyles.css Wed May 16 15:41:53 2007 @@ -195,9 +195,6 @@ .library-icon-library { margin-left: -20px; } -.kupu-upload { - margin-top: 1em; float:right; -} label.kupu-detail-label { float:left;clear:left; @@ -240,7 +237,7 @@ padding-top: 2px; } -span.drawer-item-title.selected-item { +.selected-item span.drawer-item-title { background-color:#C0C0C0; } From duncan at codespeak.net Wed May 16 17:18:24 2007 From: duncan at codespeak.net (duncan at codespeak.net) Date: Wed, 16 May 2007 17:18:24 +0200 (CEST) Subject: [kupu-checkins] r43435 - in kupu/trunk/kupu: common common/kupudrawers plone/kupu_plone_layer Message-ID: <20070516151824.8F7F88092@code0.codespeak.net> Author: duncan Date: Wed May 16 17:18:23 2007 New Revision: 43435 Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl kupu/trunk/kupu/common/kupudrawerstyles.css kupu/trunk/kupu/plone/kupu_plone_layer/kupuplone.css.dtml Log: More style changes Modified: kupu/trunk/kupu/common/kupudrawers/drawer.xsl ============================================================================== --- kupu/trunk/kupu/common/kupudrawers/drawer.xsl (original) +++ kupu/trunk/kupu/common/kupudrawers/drawer.xsl Wed May 16 17:18:23 2007 @@ -85,8 +85,7 @@ Search + class="kupu-searchbox-input nofocus"> if(event.keyCode==13)return false; if(event.keyCode == 13){drawertool.current_drawer.search();return false;} @@ -116,6 +115,9 @@
+ + overflow overflow-with-button +
@@ -226,8 +228,7 @@ @@ -272,8 +273,7 @@
-
- +
( by Modified: kupu/trunk/kupu/common/kupudrawerstyles.css ============================================================================== --- kupu/trunk/kupu/common/kupudrawerstyles.css (original) +++ kupu/trunk/kupu/common/kupudrawerstyles.css Wed May 16 17:18:23 2007 @@ -109,10 +109,6 @@ width: 640px; /* Mozilla bug */