2024-03-10 17:45:33 +00:00
|
|
|
/*\
|
2024-03-11 09:10:01 +00:00
|
|
|
title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/get-bag-tiddler-blob.js
|
2024-03-10 17:45:33 +00:00
|
|
|
type: application/javascript
|
2024-03-18 08:44:45 +00:00
|
|
|
module-type: mws-route
|
2024-03-10 17:45:33 +00:00
|
|
|
|
2024-03-20 15:13:50 +00:00
|
|
|
GET /bags/:bag_name/tiddler/:title/blob
|
2024-03-10 17:45:33 +00:00
|
|
|
|
|
|
|
\*/
|
|
|
|
(function() {
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
exports.method = "GET";
|
|
|
|
|
2024-03-20 15:13:50 +00:00
|
|
|
exports.path = /^\/bags\/([^\/]+)\/tiddlers\/([^\/]+)\/blob$/;
|
2024-03-10 17:45:33 +00:00
|
|
|
|
|
|
|
exports.handler = function(request,response,state) {
|
|
|
|
// Get the parameters
|
|
|
|
const bag_name = $tw.utils.decodeURIComponentSafe(state.params[0]),
|
2024-03-20 15:13:50 +00:00
|
|
|
title = $tw.utils.decodeURIComponentSafe(state.params[1]);
|
|
|
|
if(bag_name) {
|
2024-03-10 17:45:33 +00:00
|
|
|
const result = $tw.mws.store.getBagTiddlerStream(title,bag_name);
|
|
|
|
if(result) {
|
|
|
|
response.writeHead(200, "OK",{
|
2024-03-20 17:56:47 +00:00
|
|
|
Etag: "\"tiddler_id:" + result.tiddler_id + "\"",
|
|
|
|
"Content-Type": result.type,
|
2024-03-10 17:45:33 +00:00
|
|
|
});
|
|
|
|
result.stream.pipe(response);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response.writeHead(404);
|
|
|
|
response.end();
|
|
|
|
};
|
|
|
|
|
|
|
|
}());
|