Author: jmorliaguet Date: Sun Apr 9 18:11:38 2006 New Revision: 2797 Modified: cpsskins/branches/jmo-perspectives/ui/panels/io_section.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:
- reworked the export of snapshots Modified: cpsskins/branches/jmo-perspectives/ui/panels/io_section.pt ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/panels/io_section.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/panels/io_section.pt Sun Apr 9 18:11:38 2006 @@ -1,23 +1,46 @@ -<div class="sections" tal:define="section request/form/section|nothing"> +<div class="sections" + tal:define="section request/form/section|nothing; + snapshot request/form/snapshot|nothing"> <div tal:condition="section"> <div tal:condition="python: section == 'export'"> <h3>Export site</h3> - <a href="@@exportSite">Download site</a> + <a href="@@createSnapshot">Create a snapshot</a> + + <tal:block condition="snapshot"> + <h4>Download snapshot</h4> + <a tal:attributes="href string:@@downloadSnapshot?filename=$snapshot" + tal:content="snapshot" /> + </tal:block> </div> <div tal:condition="python: section == 'import'"> <h3>Import site</h3> + + <h4>Upload a snapshot</h4> <form action="@@importSite" method="post" enctype="multipart/form-data"> - <label for="snapshot">Snapshot</label> <input id="snapshot" type="file" name="file" /> <button type="submit">Upload</button> </form> + + <h4>Load an existing snapshot</h4> + <form> + <select name="snapshot"> + <option tal:repeat="snapshot view/@@listSnapshots" + tal:content="snapshot/title" /> + </select> + <button type="submit">Load</button> + </form> </div> <div tal:condition="python: section == 'snapshots'"> <h3>Snapshots</h3> - <a href="@@createSnapshot">Make a snapshot</a> + <ul> + <li tal:repeat="snapshot view/@@listSnapshots"> + <a tal:attributes="href string:@@downloadSnapshot?filename=$snapshot" + tal:content="snapshot" /> + </li> + </ul> </div> </div> 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 18:11:38 2006 @@ -72,6 +72,16 @@ attribute="createSnapshot" /> + <page + name="listSnapshots" + attribute="listSnapshots" + /> + + <page + name="downloadSnapshot" + attribute="downloadSnapshot" + /> + </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 18:11:38 2006 @@ -28,7 +28,11 @@ border-bottom: 1px solid #666; } -img { +h4 { + font-weight: bold; + color: #666; + padding-bottom: 0.1em; + margin-bottom: 0.2em; } .description { 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 18:11:38 2006 @@ -155,18 +155,31 @@ portlets = archive[u'portlets.xml'] relations = archive[u'relations.xml'] - # TODO + ################################################################### + # Snapshots + ################################################################### def createSnapshot(self): - mgr = getThemeManager() - - data = self.exportSite(False) - - snapshots = mgr.getSnapshotStorage() - - snapshot = Snapshot(data=data) + snapshots = getThemeManager().getSnapshotStorage() + snapshot = Snapshot(data=self.exportSite(False)) snapshots.add(snapshot, snapshot.filename) + self.request.response.setHeader('content-type', 'text/x-json') + return json.write({'url': + '@@io-section.html?section=export&snapshot=%s' % snapshot.filename}) + + def listSnapshots(self): + return list(getThemeManager().getSnapshotStorage()) + + def downloadSnapshot(self, filename): + snapshots = getThemeManager().getSnapshotStorage() + + response = self.request.response + response.setHeader('content-type', 'application/tgz') + response.setHeader('Content-disposition', + 'attachment; filename=%s' % filename) + return snapshots.get(filename).data + ################################################################### # Storage ################################################################### @@ -185,6 +198,9 @@ exporter = getMultiAdapter((storage, request), IDataExporter) return exporter() + def importStorage(self, xml): + print xml + ################################################################### # Themes ################################################################### -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins