Embedding videos in kupu

Kupu 1.4+ supports embedding videos. Here's how to make Plone play nicely, too.

You'll need to disable or subdue Plone's safe_html transform.

The easy way is the go to the portal_transforms-tool in the ZMI, then safe_html, and remove the 'embed' and 'object' rows from nasty_tags and add them to the list of valid tags with a '1' indicating that these tags consists of an open and close part.

Another way is to do this programatically, in an install-script (it's a bit ugly, but it works):

def setupTransforms(portal, out):
    from Products.CMFDefault.utils import VALID_TAGS
    from Products.CMFDefault.utils import NASTY_TAGS

    valid_tags = VALID_TAGS.copy()
    nasty_tags = NASTY_TAGS.copy()

    nasty_tags.pop('embed')
    nasty_tags.pop('object')

    valid_tags['embed'] = 1
    valid_tags['object'] = 1

    kwargs = {'nasty_tags': nasty_tags,
              'valid_tags': valid_tags}
    
    transform = getattr(getToolByName(portal, 'portal_transforms'), 'safe_html')
            
    for k in list(kwargs):
        if isinstance(kwargs[k], dict):
            v = kwargs[k]
            kwargs[k+'_key'] = v.keys()
            kwargs[k+'_value'] = [str(s) for s in v.values()]
            del kwargs[k]

    transform.set_parameters(**kwargs)

    print >> out, "Transforms updated."

Finally, you could also patch ATDocument to use a more relaxed transform. Only do this if you trust the people who have permissions to edit documents. The following patch should be called from an __init__.py-script in a product on the filesystem:

def apply_allow_unsafe_html_patch():
    from Products.ATContentTypes.content import document as atdocument
    atdocument.ATDocumentSchema['text'].default_output_type = 'text/x-html-captioned'

dont' forget <param>!

Posted by Jon Stahl at Jan 04, 2008 02:52 AM
the param tag is also frequently used by embeddable media players, and should be enabled, too! Perhaps you can merge in the directions from http://plone.org/[…]/how-to-embed-content-flickr-youtube-or-myspace ?