mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 13:29:56 +00:00
Basic support for creating bags and recipes
Cannot yet specify the bags for the new recipe
This commit is contained in:
parent
9767e7d3b7
commit
4b0df1a7ae
@ -1,5 +1,51 @@
|
||||
title: MultiWikiServer Administration
|
||||
|
||||
\procedure createBag(name)
|
||||
|
||||
\procedure completion-createBag()
|
||||
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||
<$action-log msg="In completion-createBag"/>
|
||||
<$action-log/>
|
||||
\end completion-createBag
|
||||
|
||||
<$action-sendmessage
|
||||
$message="tm-http-request"
|
||||
url=`/wiki/$(name)$/bags/$(name)$`
|
||||
method="PUT"
|
||||
oncompletion=<<completion-createBag>>
|
||||
/>
|
||||
\end createBag
|
||||
|
||||
\procedure createBagButton(name)
|
||||
<$button class="">
|
||||
<$transclude $variable="createBag" name={{$:/state/NewBagName}}/>
|
||||
{{$:/core/images/new-button}}
|
||||
</$button><span class="tc-btn-text"><$text text="Create a new bag:"/></span><$edit-text tiddler="$:/state/NewBagName" tag="input"/>
|
||||
\end createBagButton
|
||||
|
||||
\procedure createRecipe(name)
|
||||
|
||||
\procedure completion-createRecipe()
|
||||
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||
<$action-log msg="In completion-createRecipe"/>
|
||||
<$action-log/>
|
||||
\end completion-createRecipe
|
||||
|
||||
<$action-sendmessage
|
||||
$message="tm-http-request"
|
||||
url=`/wiki/$(name)$/recipes/$(name)$`
|
||||
method="PUT"
|
||||
oncompletion=<<completion-createRecipe>>
|
||||
/>
|
||||
\end createRecipe
|
||||
|
||||
\procedure createRecipeButton(name)
|
||||
<$button class="">
|
||||
<$transclude $variable="createRecipe" name={{$:/state/NewRecipeName}}/>
|
||||
{{$:/core/images/new-button}}
|
||||
</$button><span class="tc-btn-text"><$text text="Create a new recipe:"/></span><$edit-text tiddler="$:/state/NewRecipeName" tag="input"/>
|
||||
\end createRecipeButton
|
||||
|
||||
<div class="mws-admin-container">
|
||||
<h1>Recipes</h1>
|
||||
<ul>
|
||||
@ -19,6 +65,9 @@ title: MultiWikiServer Administration
|
||||
</$list>
|
||||
</ul>
|
||||
<div>
|
||||
<<createRecipeButton>>
|
||||
</div>
|
||||
<div>
|
||||
Higher numbered bags take priority if a tiddler with the same title is in more than one bag
|
||||
</div>
|
||||
<h1>Bags</h1>
|
||||
@ -29,4 +78,7 @@ Higher numbered bags take priority if a tiddler with the same title is in more t
|
||||
</li>
|
||||
</$list>
|
||||
</ul>
|
||||
<div>
|
||||
<<createBagButton>>
|
||||
</div>
|
||||
</div>
|
36
plugins/tiddlywiki/multiwikiserver/modules/route-put-bag.js
Normal file
36
plugins/tiddlywiki/multiwikiserver/modules/route-put-bag.js
Normal file
@ -0,0 +1,36 @@
|
||||
/*\
|
||||
title: $:/plugins/tiddlywiki/multiwikiserver/route-put-bag.js
|
||||
type: application/javascript
|
||||
module-type: route
|
||||
|
||||
PUT /wikis/:bag_name/bags/:bag_name
|
||||
|
||||
NOTE: Urls currently include the bag name twice. This is temporary to minimise the changes to the TiddlyWeb plugin
|
||||
|
||||
\*/
|
||||
(function() {
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports.method = "PUT";
|
||||
|
||||
exports.path = /^\/wiki\/([^\/]+)\/bags\/([^\/]+)$/;
|
||||
|
||||
exports.handler = function(request,response,state) {
|
||||
// Get the parameters
|
||||
var bag_name = $tw.utils.decodeURIComponentSafe(state.params[0]),
|
||||
bag_name_2 = $tw.utils.decodeURIComponentSafe(state.params[1]);
|
||||
if(bag_name === bag_name_2) {
|
||||
$tw.sqlTiddlerStore.createBag(bag_name);
|
||||
state.sendResponse(204,{
|
||||
"Content-Type": "text/plain"
|
||||
});
|
||||
} else {
|
||||
response.writeHead(404);
|
||||
response.end();
|
||||
}
|
||||
};
|
||||
|
||||
}());
|
@ -0,0 +1,36 @@
|
||||
/*\
|
||||
title: $:/plugins/tiddlywiki/multiwikiserver/route-put-recipe.js
|
||||
type: application/javascript
|
||||
module-type: route
|
||||
|
||||
PUT /wikis/:recipe_name/recipes/:recipe_name
|
||||
|
||||
NOTE: Urls currently include the recipe name twice. This is temporary to minimise the changes to the TiddlyWeb plugin
|
||||
|
||||
\*/
|
||||
(function() {
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports.method = "PUT";
|
||||
|
||||
exports.path = /^\/wiki\/([^\/]+)\/recipes\/([^\/]+)$/;
|
||||
|
||||
exports.handler = function(request,response,state) {
|
||||
// Get the parameters
|
||||
var recipe_name = $tw.utils.decodeURIComponentSafe(state.params[0]),
|
||||
recipe_name_2 = $tw.utils.decodeURIComponentSafe(state.params[1]);
|
||||
if(recipe_name === recipe_name_2) {
|
||||
$tw.sqlTiddlerStore.createRecipe(recipe_name);
|
||||
state.sendResponse(204,{
|
||||
"Content-Type": "text/plain"
|
||||
});
|
||||
} else {
|
||||
response.writeHead(404);
|
||||
response.end();
|
||||
}
|
||||
};
|
||||
|
||||
}());
|
Loading…
Reference in New Issue
Block a user