mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-09-07 13:28:01 +00:00
POST /wiki/:bag_name/bags/:bag_name/tiddlers/ should also return JSON
This commit is contained in:
@@ -4,7 +4,6 @@ type: application/javascript
|
|||||||
module-type: route
|
module-type: route
|
||||||
|
|
||||||
POST /wiki/:bag_name/bags/:bag_name/tiddlers/
|
POST /wiki/:bag_name/bags/:bag_name/tiddlers/
|
||||||
POST /wiki/:bag_name/bags/:bag_name/tiddlers
|
|
||||||
|
|
||||||
NOTE: Urls currently include the bag name twice. This is temporary to minimise the changes to the TiddlyWeb plugin
|
NOTE: Urls currently include the bag name twice. This is temporary to minimise the changes to the TiddlyWeb plugin
|
||||||
|
|
||||||
@@ -42,29 +41,36 @@ console.log(`Got ${bag_name} and ${bag_name_2}`)
|
|||||||
response: response,
|
response: response,
|
||||||
bagname: bag_name,
|
bagname: bag_name,
|
||||||
callback: function(err,results) {
|
callback: function(err,results) {
|
||||||
response.writeHead(200, "OK",{
|
// If application/json is requested then this is an API request, and gets the response in JSON
|
||||||
"Content-Type": "text/html"
|
if(request.headers.accept && request.headers.accept.indexOf("application/json") !== -1) {
|
||||||
});
|
state.sendResponse(200,{"Content-Type": "application/json"},JSON.stringify({
|
||||||
response.write(`
|
"imported-tiddlers": results
|
||||||
<!doctype html>
|
}));
|
||||||
<head>
|
} else {
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
response.writeHead(200, "OK",{
|
||||||
</head>
|
"Content-Type": "text/html"
|
||||||
<body>
|
});
|
||||||
`);
|
response.write(`
|
||||||
// Render the html
|
<!doctype html>
|
||||||
var html = $tw.mws.store.adminWiki.renderTiddler("text/html","$:/plugins/tiddlywiki/multiwikiserver/templates/post-bag-tiddlers",{
|
<head>
|
||||||
variables: {
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||||
"bag-name": bag_name,
|
</head>
|
||||||
"imported-titles": JSON.stringify(results)
|
<body>
|
||||||
}
|
`);
|
||||||
});
|
// Render the html
|
||||||
response.write(html);
|
var html = $tw.mws.store.adminWiki.renderTiddler("text/html","$:/plugins/tiddlywiki/multiwikiserver/templates/post-bag-tiddlers",{
|
||||||
response.write(`
|
variables: {
|
||||||
</body>
|
"bag-name": bag_name,
|
||||||
</html>
|
"imported-titles": JSON.stringify(results)
|
||||||
`);
|
}
|
||||||
response.end();
|
});
|
||||||
|
response.write(html);
|
||||||
|
response.write(`
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`);
|
||||||
|
response.end();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user