Attention

This document was written for an unsupported version of Plone, Plone 2.5.x, and was last updated 1565 days ago.

For more information, see the version support policy.

To learn how to upgrade to the current version of Plone, read the upgrade manual.

Embedding videos in kupu

by Malthe Borch last modified Feb 09, 2009 01:47 AM
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'

Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.