chg: don’t save site export as antville file anymore
This commit is contained in:
parent
704f80de75
commit
4c85e79dec
2 changed files with 13 additions and 30 deletions
|
@ -105,26 +105,17 @@ global.Exporter = (function() {
|
||||||
Exporter.saveSite = function(site, user) {
|
Exporter.saveSite = function(site, user) {
|
||||||
const sql = new Sql();
|
const sql = new Sql();
|
||||||
const zip = new helma.Zip();
|
const zip = new helma.Zip();
|
||||||
const fileName = 'antville-site-' + java.util.UUID.randomUUID() + '.zip';
|
|
||||||
|
|
||||||
try {
|
const dirName = app.appsProperties['static'] + '/export';
|
||||||
|
const fileName = 'antville-site-' + java.util.UUID.randomUUID() + '.zip';
|
||||||
|
const file = new java.io.File(dirName, fileName);
|
||||||
|
|
||||||
if (site.export) {
|
if (site.export) {
|
||||||
let file = File.getById(site.export);
|
const archive = new java.io.File(dirName, site.export.split('/').pop());
|
||||||
if (file) File.remove.call(file);
|
if (archive.exists()) archive['delete']();
|
||||||
}
|
}
|
||||||
|
|
||||||
const index = {
|
try {
|
||||||
comments: [],
|
|
||||||
files: [],
|
|
||||||
images: [],
|
|
||||||
members: [],
|
|
||||||
polls: [],
|
|
||||||
sites: [],
|
|
||||||
skins: [],
|
|
||||||
stories: [],
|
|
||||||
tags: []
|
|
||||||
};
|
|
||||||
|
|
||||||
const dir = new java.io.File(java.nio.file.Files.createTempDirectory(site.name));
|
const dir = new java.io.File(java.nio.file.Files.createTempDirectory(site.name));
|
||||||
const skinWriter = getJsonWriter(dir, 'skins.json');
|
const skinWriter = getJsonWriter(dir, 'skins.json');
|
||||||
let writer = getJsonWriter(dir, 'index.json');
|
let writer = getJsonWriter(dir, 'index.json');
|
||||||
|
@ -155,7 +146,6 @@ global.Exporter = (function() {
|
||||||
|
|
||||||
sql.traverse(function() {
|
sql.traverse(function() {
|
||||||
app.log('Exporting membership #' + this.creator_id);
|
app.log('Exporting membership #' + this.creator_id);
|
||||||
//index.members.push(this);
|
|
||||||
writer.push(this);
|
writer.push(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -245,24 +235,17 @@ global.Exporter = (function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
const xml = Exporter.getSiteXml(site);
|
const xml = Exporter.getSiteXml(site);
|
||||||
|
|
||||||
zip.addData(xml, 'export.xml');
|
zip.addData(xml, 'export.xml');
|
||||||
|
|
||||||
zip.add(dir);
|
zip.add(dir);
|
||||||
zip.close();
|
zip.save(file);
|
||||||
|
|
||||||
const mime = {
|
site.export = app.appsProperties.staticMountpoint + '/export/' + fileName;
|
||||||
file: new Packages.helma.util.MimePart(fileName, zip.getData(), 'application/zip'),
|
site.job = null;
|
||||||
file_origin: site.href('export')
|
|
||||||
};
|
|
||||||
|
|
||||||
const file = File.add(mime, site, user);
|
|
||||||
site.export = file._id;
|
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
app.log(ex.rhinoException);
|
app.log(ex.rhinoException);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the site’s export status
|
|
||||||
site.job = null;
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1197,7 +1197,7 @@ a.gs-title:hover {
|
||||||
<% #export %>
|
<% #export %>
|
||||||
<h1><% gettext "Export Site Data" %></h1>
|
<h1><% gettext "Export Site Data" %></h1>
|
||||||
<p>
|
<p>
|
||||||
<% if <% param.status %> is null then <% if <% site.export %> is null then '' else <% gettext "{0}Download the archive{1} or click “Export” to create a new one." <% file.href prefix="<a href='" suffix="'>" %> "</a>" %> %> else <% param.status %> %>
|
<% if <% param.status %> is null then <% if <% site.export %> is null then '' else <% gettext "{0}Download the archive{1} or click “Export” to create a new one." <% site.export prefix="<a href='" suffix="'>" %> "</a>" %> %> else <% param.status %> %>
|
||||||
</p>
|
</p>
|
||||||
<form action="<% site.href export %>" method="post">
|
<form action="<% site.href export %>" method="post">
|
||||||
<button type="submit" name="submit" value="<% if <% param.status %> is null then export else cancel %>" class='uk-button uk-button-primary'>
|
<button type="submit" name="submit" value="<% if <% param.status %> is null then export else cancel %>" class='uk-button uk-button-primary'>
|
||||||
|
|
Loading…
Add table
Reference in a new issue