2024-03-20 09:44:52 +00:00
|
|
|
/*\
|
|
|
|
title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/post-bag.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: mws-route
|
|
|
|
|
|
|
|
POST /bags
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
|
|
|
bag_name
|
|
|
|
description
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function() {
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
exports.method = "POST";
|
|
|
|
|
|
|
|
exports.path = /^\/bags$/;
|
|
|
|
|
|
|
|
exports.bodyFormat = "www-form-urlencoded";
|
|
|
|
|
|
|
|
exports.csrfDisable = true;
|
|
|
|
|
2024-10-30 17:59:44 +00:00
|
|
|
exports.useACL = true;
|
|
|
|
|
|
|
|
exports.entityName = "bag"
|
|
|
|
|
2024-03-20 09:44:52 +00:00
|
|
|
exports.handler = function(request,response,state) {
|
|
|
|
if(state.data.bag_name) {
|
|
|
|
const result = $tw.mws.store.createBag(state.data.bag_name,state.data.description);
|
|
|
|
if(!result) {
|
|
|
|
state.sendResponse(302,{
|
|
|
|
"Content-Type": "text/plain",
|
|
|
|
"Location": "/"
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
state.sendResponse(400,{
|
|
|
|
"Content-Type": "text/plain"
|
|
|
|
},
|
|
|
|
result.message,
|
|
|
|
"utf8");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
state.sendResponse(400,{
|
|
|
|
"Content-Type": "text/plain"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}());
|