mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-21 19:59:42 +00:00
08649dd1eb
Thank you @PotOfCoffee2Go I ended up taking some of your code from #8101 to get this up and running. There's still some stuff missing (like the tests!) but it gets things moving.
39 lines
1010 B
JavaScript
39 lines
1010 B
JavaScript
/*\
|
|
title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/get-recipe-tiddlers-json.js
|
|
type: application/javascript
|
|
module-type: mws-route
|
|
|
|
GET /recipes/:recipe_name/tiddlers.json?filter=:filter
|
|
|
|
\*/
|
|
(function() {
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
exports.method = "GET";
|
|
|
|
exports.path = /^\/recipes\/([^\/]+)\/tiddlers.json$/;
|
|
|
|
exports.handler = function(request,response,state) {
|
|
// Get the parameters
|
|
var recipe_name = $tw.utils.decodeURIComponentSafe(state.params[0]);
|
|
if(recipe_name) {
|
|
// Get the tiddlers in the recipe, optionally since the specified last known tiddler_id
|
|
var recipeTiddlers = $tw.mws.store.getRecipeTiddlers(recipe_name,{
|
|
last_known_tiddler_id: state.queryParameters.last_known_tiddler_id
|
|
});
|
|
if(recipeTiddlers) {
|
|
state.sendResponse(200,{"Content-Type": "application/json"},JSON.stringify(recipeTiddlers),"utf8");
|
|
return;
|
|
}
|
|
}
|
|
// Fail if something went wrong
|
|
response.writeHead(404);
|
|
response.end();
|
|
|
|
};
|
|
|
|
}());
|