############################################################################## # # Copyright (c) 2003-2005 Kupu Contributors. All rights reserved. # # This software is distributed under the terms of the Kupu # License. See LICENSE.txt for license text. For a list of Kupu # Contributors see CREDITS.txt. # ############################################################################## """Install kupu in CMF and, if available, Plone This is best executed using CMFQuickInstaller $Id$ """ import os.path import sys import re from StringIO import StringIO from App.Common import package_home from Products.CMFCore.utils import getToolByName from Products.kupu import kupu_globals from Products.kupu.plone.util import register_layer, unregister_layers from Products.kupu.plone import util from Products.kupu.config import TOOLNAME, PROJECTNAME, TOOLTITLE from zExceptions import BadRequest try: from Products.MimetypesRegistry import MimeTypeItem except ImportError: pass # Plone not available kupu_package_dir = package_home(kupu_globals) def install_plone(self, out): """Install with plone """ # register the plone skin layers register_layer(self, 'plone/kupu_plone_layer', 'kupu_plone', out) # By default, add the directory view but not the skin layer for the reference browser register_layer(self, 'plone/kupu_references', 'kupu_references', out, add=False) register_layer(self, 'tests', 'kupu_tests', out) # register as editor portal_props = getToolByName(self, 'portal_properties') site_props = getattr(portal_props,'site_properties', None) attrname = 'available_editors' if site_props is not None: editors = list(site_props.getProperty(attrname)) if 'Kupu' not in editors: editors.append('Kupu') site_props._updateProperty(attrname, editors) print >>out, "Added 'Kupu' to available editors in Plone." install_libraries(self, out) install_configlet(self, out) install_transform(self, out) install_resources(self, out) install_customisation(self, out) def _read_resources(): resourcefile = open(os.path.join(kupu_package_dir, 'plone', 'head.kupu'), 'r') try: data = resourcefile.read() return data finally: resourcefile.close() def css_files(resources): CSSPAT = re.compile(r'\]*rel="stylesheet"[^>]*\${portal_url}/([^"]*)"') for m in CSSPAT.finditer(resources): id = m.group(1) yield id def js_files(resources): JSPAT = re.compile(r'\