Author: jmorliaguet Date: Sun Apr 9 12:00:08 2006 New Revision: 2794 Added: cpsskins/branches/jmo-perspectives/ui/panels/io_section.pt (contents, props changed) Modified: cpsskins/branches/jmo-perspectives/setup/utils.py cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py cpsskins/branches/jmo-perspectives/ui/panels/configure.zcml cpsskins/branches/jmo-perspectives/ui/panels/io.pt cpsskins/branches/jmo-perspectives/ui/panels/negotiation.pt cpsskins/branches/jmo-perspectives/ui/panels/settings.pt cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/configure.zcml cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/site_manager.css cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/views.py Log:
- updated import / export panels Modified: cpsskins/branches/jmo-perspectives/setup/utils.py ============================================================================== --- cpsskins/branches/jmo-perspectives/setup/utils.py (original) +++ cpsskins/branches/jmo-perspectives/setup/utils.py Sun Apr 9 12:00:08 2006 @@ -17,6 +17,12 @@ """ __docformat__ = "reStructuredText" +import time + +from StringIO import StringIO +from tarfile import TarFile +from tarfile import TarInfo + from zope.component import queryUtility, getUtility from cpsskins.utils import getThemeManager @@ -27,3 +33,21 @@ resources = getUtility(IResourceManager) return resources.lookup(name, context=mgr) +class TarArchive: + + def __init__(self, filename=u''): + self.stream = StringIO() + self.archive = TarFile.open(str(filename), 'w:gz', self.stream) + + def __setitem__(self, k, v): + stream = StringIO(v) + info = TarInfo(k) + info.size = len(v) + info.mtime = time.time() + self.archive.addfile(info, stream) + + def __call__(self): + self.archive.close() + return self.stream.getvalue() + + Modified: cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py (original) +++ cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py Sun Apr 9 12:00:08 2006 @@ -107,6 +107,13 @@ } }, + 'io-section': { + 'id': 'io-section', + 'data': { + 'url': '@@io-section.html', + } + }, + 'negotiation': { 'id': 'negotiation', 'data': { @@ -288,6 +295,15 @@ 'controllers': ['site-manager-perspectives'], }, + 'io-section': { + 'id': 'io-section', + 'widget': { + 'type': 'panel' + }, + 'model': 'io-section', + 'perspectives': ['io'], + 'controllers': ['site-manager-perspectives', 'io-actions'], + }, # Bottom area 'portlet-factory': { 'id': 'portlet-factory', @@ -443,6 +459,10 @@ 'id': 'settings-actions', 'type': 'remote scripting', }, + 'io-actions': { + 'id': 'io-actions', + 'type': 'remote scripting', + }, 'layout-designer-actions': { 'id': 'layout-designer-actions', 'type': 'remote scripting', Modified: cpsskins/branches/jmo-perspectives/ui/panels/configure.zcml ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/panels/configure.zcml (original) +++ cpsskins/branches/jmo-perspectives/ui/panels/configure.zcml Sun Apr 9 12:00:08 2006 @@ -59,6 +59,11 @@ template="io.pt" /> + <page + name="io-section.html" + template="io_section.pt" + /> + </pages> <pages Modified: cpsskins/branches/jmo-perspectives/ui/panels/io.pt ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/panels/io.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/panels/io.pt Sun Apr 9 12:00:08 2006 @@ -1,20 +1,27 @@ -<div class="sections"> - <img class="icon" - src="/++skin++cpsskins/@@/++resource++io-48.png" /> - <span class="description">export, import themes and settings ...</span> - - <ul> - <li><a href="@@exportSite">Export site</a></li> - <li><a href="@@exportThemes">Export themes</a></li> - <li><a href="@@exportSettings">Export settings</a></li> - <li><a href="@@exportStorage?name=relations">Export relations</a></li> - <li><a href="@@exportStorage?name=portlets">Export portlets</a></li> - <li><a href="@@exportStorage?name=formats">Export formats</a></li> - <li><a href="@@exportStorage?name=displays">Export displays</a></li> - </ul> - - <br style="clear:both"/> - -</div> - +<table class="panel" cellpadding="0" cellspacing="0" + tal:define="info context/@@getSettingInfo"> + <tr> + <td class="icon"> + <img src="/++skin++cpsskins/@@/++resource++io-48.png" /> + </td> + <td class="section"> + <div class="sections"> + <span class="description">export, import themes and settings ...</span> + <ul> + <li tal:repeat="section python: ['export', 'import', 'snapshots']"> + <a class="section" + tal:attributes="href string:javascript:CPSSkins.getModelById('io-section').setData({'url': '@@io-section.html?section=$section'})" + tal:content="section">SECTION</a> + </li> + </ul> + <br style="clear:both"/> + </div> + </td> + <td class="subsection"> + <ins class="model" cite="@@getModel?id=io-section"></ins> + <ins class="view" cite="@@getView?id=io-section"></ins> + <ins class="controller" cite="@@getController?id=io-actions"></ins> + </td> + </tr> +</table> Added: cpsskins/branches/jmo-perspectives/ui/panels/io_section.pt ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/panels/io_section.pt Sun Apr 9 12:00:08 2006 @@ -0,0 +1,26 @@ +<div class="sections" tal:define="section request/form/section|nothing"> + <div tal:condition="section"> + + <div tal:condition="python: section == 'export'"> + <h3>Export site</h3> + <a href="@@exportSite">Download site</a> + </div> + + <div tal:condition="python: section == 'import'"> + <h3>Import site</h3> + <form action="@@importSite" method="post"> + <label for="snapshot">Snapshot</label> + <input id="snapshot" type="file" name="file" /> + <button type="submit">Upload</button> + </form> + </div> + + <div tal:condition="python: section == 'snapshots'"> + <h3>Snapshots</h3> + Make a snapshot + </div> + + </div> + <div tal:condition="not:section"> + </div> +</div> Modified: cpsskins/branches/jmo-perspectives/ui/panels/negotiation.pt ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/panels/negotiation.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/panels/negotiation.pt Sun Apr 9 12:00:08 2006 @@ -1,8 +1,17 @@ +<table class="panel" cellpadding="0" cellspacing="0" + tal:define="info context/@@getSettingInfo"> + <tr> + <td class="icon"> + <img src="/++skin++cpsskins/@@/++resource++negotiation-48.png" /> + </td> + <td class="section"> + <div class="sections"> + <span class="description">local themes, perspectives ...</span> - <div class="sections"> - <img class="icon" - src="/++skin++cpsskins/@@/++resource++negotiation-48.png" /> - <span class="description">local themes, perspectives ...</span> - <br style="clear:both"/> - </div> + </div> + </td> + <td class="subsection"> + </td> + </tr> +</table> Modified: cpsskins/branches/jmo-perspectives/ui/panels/settings.pt ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/panels/settings.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/panels/settings.pt Sun Apr 9 12:00:08 2006 @@ -2,10 +2,11 @@ <table class="panel" cellpadding="0" cellspacing="0" tal:define="info context/@@getSettingInfo"> <tr> - <td class="first"> + <td class="icon"> + <img src="/++skin++cpsskins/@@/++resource++settings-48.png" /> + </td> + <td class="section"> <div class="sections"> - <img class="icon" - src="/++skin++cpsskins/@@/++resource++settings-48.png" /> <span class="description">manage settings ...</span> <ul> <li tal:repeat="section python: ['perspective', 'style', 'color']"> Modified: cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/configure.zcml ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/configure.zcml (original) +++ cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/configure.zcml Sun Apr 9 12:00:08 2006 @@ -77,6 +77,11 @@ attribute="exportSite" /> + <page + name="importSite" + attribute="importSite" + /> + </pages> </configure> Modified: cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/site_manager.css ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/site_manager.css (original) +++ cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/site_manager.css Sun Apr 9 12:00:08 2006 @@ -20,6 +20,17 @@ cursor: pointer; } +h3 { + margin-top: 0; + font-size: 110%; + font-weight: bold; + color: #000; + border-bottom: 1px solid #666; +} + +img { +} + .description { color: #333; padding-right: 1.5em; @@ -35,11 +46,6 @@ font: 13px Arial, sans-serif; } -.icon { - padding-right: 1.5em; - padding-left: 1em; - float: left; -} a, a:visited, a:hover { color: #204a87; @@ -47,7 +53,7 @@ ul { margin: 0; - padding-left: 2em; + padding: 0; list-style: square; } @@ -61,6 +67,7 @@ table.panel td { vertical-align:top; + padding-top: 0.2em; } table.panel td.section { @@ -71,3 +78,6 @@ width: 70%; } +table.panel td.icon { + padding: 1em; +} Modified: cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/views.py ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/views.py (original) +++ cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/views.py Sun Apr 9 12:00:08 2006 @@ -17,12 +17,6 @@ """ __docformat__ = "reStructuredText" -import time - -from StringIO import StringIO -from tarfile import TarFile -from tarfile import TarInfo - from zope.app.interface import queryType from zope.app.publisher.browser import BrowserView from zope.component import getUtilitiesFor, getUtility, getMultiAdapter @@ -34,6 +28,7 @@ from cpsskins.setup.interfaces import IGlobalSetting, IDataExporter from cpsskins.setup.interfaces import IResourceType, IResourceManager, IResource from cpsskins.setup.registration import reloadSetting, refreshSettings +from cpsskins.setup.utils import TarArchive from cpsskins.utils import getThemeManager themes_xml = """<?xml version="1.0"?> @@ -44,12 +39,6 @@ class SiteDesignerView(BrowserView): - def _setAttachment(self, filename=u'', content_type=u''): - response = self.request.response - response.setHeader('content-type', content_type) - response.setHeader('Content-disposition', - 'attachment; filename=%s' % filename) - ################################################################### # Settings ################################################################### @@ -91,7 +80,7 @@ resources = getUtility(IResourceManager) resources.unregister(name=name, context=self.context) - def exportSetting(self, name=u'', interactive=True): + def exportSetting(self, name=u''): """Export the setting as an XML file. """ context = self.context @@ -103,8 +92,6 @@ resource = IResource(setting).getResource() resource_type = queryType(resource, IResourceType) - if interactive: - self._setAttachment(u'%s.xml' % name.replace(' ', '_'), 'text/xml') exporter = getMultiAdapter((setting, request), IDataExporter) return exporter() @@ -118,38 +105,51 @@ """ refreshSettings() - def exportSettings(self, interactive=True): + def exportSettings(self): """Export the settings as an XML file. """ context = self.context request = self.request - if interactive: - self._setAttachment(u'settings.xml', u'text/xml') - settings = getUtility(ISettings, context=context) exporter = getMultiAdapter((settings, request), IDataExporter) return exporter() + ################################################################### + # Site + ################################################################### + def exportSite(self): """Export the entire site an XML file. """ + filename = 'site.tgz' + + response = self.request.response + response.setHeader('content-type', 'application/gz') + response.setHeader('Content-disposition', + 'attachment; filename=%s' % filename) + archive = TarArchive('site.tgz') - archive[u'themes.xml'] = self.exportThemes(False) - archive[u'settings.xml'] = self.exportSettings(False) + archive[u'themes.xml'] = self.exportThemes() + archive[u'settings.xml'] = self.exportSettings() for storage in u'formats', u'displays', u'relations', u'portlets': - archive['%s.xml' % storage] = self.exportStorage(storage, False) + archive['%s.xml' % storage] = self.exportStorage(storage) - self._setAttachment(u'site.tgz', 'application/gz') return archive() + def importSite(self, file=None): + + mgr = getThemeManager() + print file + + ################################################################### # Storage ################################################################### - def exportStorage(self, name=u'', interactive=True): + def exportStorage(self, name=u''): """Export the storage as an XML file. """ context = self.context @@ -160,9 +160,6 @@ mgr = getThemeManager() storage = mgr[name] - if interactive: - self._setAttachment(u'%s.xml' % name.replace(' ', '_'), 'text/xml') - exporter = getMultiAdapter((storage, request), IDataExporter) return exporter() @@ -170,15 +167,12 @@ # Themes ################################################################### - def exportThemes(self, interactive=True): + def exportThemes(self): """Export the themes """ context = self.context request = self.request - if interactive: - self._setAttachment(u'themes.xml', 'text/xml') - xml = u'' for theme in getThemeManager().getThemes(): exporter = getMultiAdapter((theme, request), IDataExporter) @@ -187,19 +181,3 @@ return themes_xml % {'content': xml} -class TarArchive: - - def __init__(self, filename=u''): - self.stream = StringIO() - self.archive = TarFile.open(str(filename), 'w:gz', self.stream) - - def __setitem__(self, k, v): - stream = StringIO(v) - info = TarInfo(k) - info.size = len(v) - info.mtime = time.time() - self.archive.addfile(info, stream) - - def __call__(self): - self.archive.close() - return self.stream.getvalue() -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins