Move deck files to 'decks' subdirectory and ignore
This commit is contained in:
parent
0a8a5f9573
commit
35973af7e3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
.tern-port
|
.tern-port
|
||||||
/node_modules/
|
/node_modules/
|
||||||
|
/decks
|
||||||
|
12
server.js
12
server.js
@ -78,13 +78,13 @@ const server = http.createServer((req, res) => {
|
|||||||
sendFile(res, 'html/editor.html');
|
sendFile(res, 'html/editor.html');
|
||||||
break;
|
break;
|
||||||
case 'deck.png':
|
case 'deck.png':
|
||||||
sendFile(res, deckName + '.png', 'image/png');
|
sendFile(res, `decks/${deckName}.png`, 'image/png');
|
||||||
break;
|
break;
|
||||||
case 'deck.json':
|
case 'deck.json':
|
||||||
sendFileJSON(res, deckName);
|
sendFileJSON(res, deckName);
|
||||||
break;
|
break;
|
||||||
case 'deck.input.json':
|
case 'deck.input.json':
|
||||||
sendFile(res, deckName + ".input.json", 'application/json');
|
sendFile(res, `decks/${deckName}.input.json`, 'application/json');
|
||||||
break;
|
break;
|
||||||
case 'upload':
|
case 'upload':
|
||||||
handleUpload(res, req, deckName);
|
handleUpload(res, req, deckName);
|
||||||
@ -137,7 +137,7 @@ function sendDeckIndex(res, deckName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendFileJSON(res, deckName) {
|
function sendFileJSON(res, deckName) {
|
||||||
fs.readFile(deckName + '.json', (error, content) => {
|
fs.readFile(`decks/${deckName}.json`, (error, content) => {
|
||||||
console.log(JSON.parse(content));
|
console.log(JSON.parse(content));
|
||||||
res.writeHead(200, {'Content-type': 'application/json; charset=utf-8'});
|
res.writeHead(200, {'Content-type': 'application/json; charset=utf-8'});
|
||||||
res.end(JSON.stringify(JSON.parse(content).ObjectStates[0]), 'utf-8');
|
res.end(JSON.stringify(JSON.parse(content).ObjectStates[0]), 'utf-8');
|
||||||
@ -185,8 +185,8 @@ function handleUpload(res, req) {
|
|||||||
return cardOut;
|
return cardOut;
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.writeFileSync(deckJSON.name + '.json', JSON.stringify(deckOut));
|
fs.writeFileSync(`decks/${deckJSON.name}.json`, JSON.stringify(deckOut));
|
||||||
fs.writeFileSync(deckJSON.name + '.input.json', JSON.stringify(deckJSON));
|
fs.writeFileSync(`decks/${deckJSON.name}.input.json`, JSON.stringify(deckJSON));
|
||||||
|
|
||||||
console.log("making page");
|
console.log("making page");
|
||||||
phantom.create().then(
|
phantom.create().then(
|
||||||
@ -198,7 +198,7 @@ function handleUpload(res, req) {
|
|||||||
ph.exit(1);
|
ph.exit(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
page.render(deckJSON.name + ".png");
|
page.render(`decks/${deckJSON.name}.png`);
|
||||||
page.close().then(() => ph.exit());
|
page.close().then(() => ph.exit());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user