2024-01-03 16:27:13 +00:00
|
|
|
/*\
|
2024-03-11 09:10:01 +00:00
|
|
|
title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/get-recipe-tiddlers-json.js
|
2024-01-03 16:27:13 +00:00
|
|
|
type: application/javascript
|
2024-03-18 08:44:45 +00:00
|
|
|
module-type: mws-route
|
2024-01-03 16:27:13 +00:00
|
|
|
|
2024-03-24 18:32:56 +00:00
|
|
|
GET /recipes/:recipe_name/tiddlers.json?last_known_tiddler_id=:last_known_tiddler_id&include_deleted=true|false
|
2024-01-03 16:27:13 +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 = /^\/recipes\/([^\/]+)\/tiddlers.json$/;
|
2024-01-03 16:27:13 +00:00
|
|
|
|
|
|
|
exports.handler = function(request,response,state) {
|
|
|
|
// Get the parameters
|
2024-03-20 15:13:50 +00:00
|
|
|
var recipe_name = $tw.utils.decodeURIComponentSafe(state.params[0]);
|
|
|
|
if(recipe_name) {
|
2024-03-23 09:27:54 +00:00
|
|
|
// Get the tiddlers in the recipe, optionally since the specified last known tiddler_id
|
|
|
|
var recipeTiddlers = $tw.mws.store.getRecipeTiddlers(recipe_name,{
|
2024-03-24 18:32:56 +00:00
|
|
|
include_deleted: state.queryParameters.include_deleted === "true",
|
2024-03-23 09:27:54 +00:00
|
|
|
last_known_tiddler_id: state.queryParameters.last_known_tiddler_id
|
2024-01-03 16:27:13 +00:00
|
|
|
});
|
2024-03-23 09:27:54 +00:00
|
|
|
if(recipeTiddlers) {
|
|
|
|
state.sendResponse(200,{"Content-Type": "application/json"},JSON.stringify(recipeTiddlers),"utf8");
|
|
|
|
return;
|
|
|
|
}
|
2024-01-03 16:27:13 +00:00
|
|
|
}
|
|
|
|
// Fail if something went wrong
|
|
|
|
response.writeHead(404);
|
|
|
|
response.end();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}());
|