mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-04 14:30:28 +00:00
Find/Replace 4spaces for Tab4, to make consistent with guidelines
This commit is contained in:
parent
e59eba9086
commit
f82425a20d
@ -317,37 +317,37 @@ Server.prototype.addAuthenticator = function(AuthenticatorClass) {
|
||||
};
|
||||
|
||||
Server.prototype.findMatchingRoute = function(request,state) {
|
||||
for(var t=0; t<this.routes.length; t++) {
|
||||
var potentialRoute = this.routes[t],
|
||||
pathRegExp = potentialRoute.path,
|
||||
pathname = state.urlInfo.pathname,
|
||||
match;
|
||||
if(state.pathPrefix) {
|
||||
if(pathname.substr(0,state.pathPrefix.length) === state.pathPrefix) {
|
||||
pathname = pathname.substr(state.pathPrefix.length) || "/";
|
||||
match = potentialRoute.path.exec(pathname);
|
||||
} else {
|
||||
match = false;
|
||||
}
|
||||
} else {
|
||||
match = potentialRoute.path.exec(pathname);
|
||||
}
|
||||
// Allow POST as a synonym for PUT and DELETE because HTML doesn't allow these methods in forms
|
||||
if(match && (
|
||||
request.method === potentialRoute.method ||
|
||||
(request.method === "POST" && (
|
||||
potentialRoute.method === "PUT" ||
|
||||
potentialRoute.method === "DELETE"
|
||||
))
|
||||
)) {
|
||||
state.params = [];
|
||||
for(var p=1; p<match.length; p++) {
|
||||
state.params.push(match[p]);
|
||||
}
|
||||
return potentialRoute;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
for(var t=0; t<this.routes.length; t++) {
|
||||
var potentialRoute = this.routes[t],
|
||||
pathRegExp = potentialRoute.path,
|
||||
pathname = state.urlInfo.pathname,
|
||||
match;
|
||||
if(state.pathPrefix) {
|
||||
if(pathname.substr(0,state.pathPrefix.length) === state.pathPrefix) {
|
||||
pathname = pathname.substr(state.pathPrefix.length) || "/";
|
||||
match = potentialRoute.path.exec(pathname);
|
||||
} else {
|
||||
match = false;
|
||||
}
|
||||
} else {
|
||||
match = potentialRoute.path.exec(pathname);
|
||||
}
|
||||
// Allow POST as a synonym for PUT and DELETE because HTML doesn't allow these methods in forms
|
||||
if(match && (
|
||||
request.method === potentialRoute.method ||
|
||||
(request.method === "POST" && (
|
||||
potentialRoute.method === "PUT" ||
|
||||
potentialRoute.method === "DELETE"
|
||||
))
|
||||
)) {
|
||||
state.params = [];
|
||||
for(var p=1; p<match.length; p++) {
|
||||
state.params.push(match[p]);
|
||||
}
|
||||
return potentialRoute;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
Server.prototype.methodMappings = {
|
||||
|
@ -23,26 +23,26 @@ exports.useACL = true;
|
||||
exports.entityName = "bag"
|
||||
|
||||
exports.handler = function(request,response,state) {
|
||||
const bagName = state.params[0];
|
||||
if(bagName) {
|
||||
const result = $tw.mws.store.deleteBag(bagName);
|
||||
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"
|
||||
});
|
||||
}
|
||||
const bagName = state.params[0];
|
||||
if(bagName) {
|
||||
const result = $tw.mws.store.deleteBag(bagName);
|
||||
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"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}());
|
@ -23,26 +23,26 @@ exports.useACL = true;
|
||||
exports.entityName = "recipe"
|
||||
|
||||
exports.handler = function(request,response,state) {
|
||||
const recipeName = state.params[0];
|
||||
if(recipeName) {
|
||||
const result = $tw.mws.store.deleteRecipe(recipeName);
|
||||
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"
|
||||
});
|
||||
}
|
||||
const recipeName = state.params[0];
|
||||
if(recipeName) {
|
||||
const result = $tw.mws.store.deleteRecipe(recipeName);
|
||||
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"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}());
|
@ -30,25 +30,25 @@ exports.useACL = true;
|
||||
exports.entityName = "bag"
|
||||
|
||||
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"
|
||||
});
|
||||
}
|
||||
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"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}());
|
@ -30,31 +30,31 @@ exports.useACL = true;
|
||||
exports.entityName = "recipe"
|
||||
|
||||
exports.handler = function(request,response,state) {
|
||||
var server = state.server,
|
||||
sqlTiddlerDatabase = server.sqlTiddlerDatabase;
|
||||
|
||||
if(state.data.recipe_name && state.data.bag_names) {
|
||||
const result = $tw.mws.store.createRecipe(state.data.recipe_name,$tw.utils.parseStringArray(state.data.bag_names),state.data.description);
|
||||
if(!result) {
|
||||
if(state.authenticatedUser) {
|
||||
sqlTiddlerDatabase.assignRecipeToUser(state.data.recipe_name,state.authenticatedUser.user_id);
|
||||
}
|
||||
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"
|
||||
});
|
||||
}
|
||||
var server = state.server,
|
||||
sqlTiddlerDatabase = server.sqlTiddlerDatabase;
|
||||
|
||||
if(state.data.recipe_name && state.data.bag_names) {
|
||||
const result = $tw.mws.store.createRecipe(state.data.recipe_name,$tw.utils.parseStringArray(state.data.bag_names),state.data.description);
|
||||
if(!result) {
|
||||
if(state.authenticatedUser) {
|
||||
sqlTiddlerDatabase.assignRecipeToUser(state.data.recipe_name,state.authenticatedUser.user_id);
|
||||
}
|
||||
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"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}());
|
@ -88,10 +88,10 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/get-index
|
||||
<$text text={{{ [<recipe-info>jsonget[description]] }}}/>
|
||||
</div>
|
||||
<div class="mws-wiki-card-actions">
|
||||
<form action={{{ [<recipe-info>jsonget[recipe_name]addprefix[/recipes/]] }}} method="post" onsubmit="return confirmRecipeDelete(this)">
|
||||
<input type="hidden" name="_method" value="DELETE"/>
|
||||
<button type="submit" class="mws-delete-button">Delete Recipe</button>
|
||||
</form>
|
||||
<form action={{{ [<recipe-info>jsonget[recipe_name]addprefix[/recipes/]] }}} method="post" onsubmit="return confirmRecipeDelete(this)">
|
||||
<input type="hidden" name="_method" value="DELETE"/>
|
||||
<button type="submit" class="mws-delete-button">Delete Recipe</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -133,19 +133,19 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/get-index
|
||||
<ul class="mws-vertical-list">
|
||||
<$list filter="[<bag-list>jsonindexes[]] :filter[<bag-list>jsonget<currentTiddler>,[bag_name].hide.system[]] :sort[<bag-list>jsonget<currentTiddler>,[bag_name]]" variable="bag-index" counter="counter">
|
||||
<li class="mws-wiki-card">
|
||||
<$let
|
||||
bag-info={{{ [<bag-list>jsonextract<bag-index>] }}}
|
||||
bag-name={{{ [<bag-info>jsonget[bag_name]] }}}
|
||||
>
|
||||
<$transclude $variable="bagPill"/>
|
||||
<$text text={{{ [<bag-info>jsonget[description]] }}}/>
|
||||
<div class="mws-wiki-card-actions">
|
||||
<form action={{{ [<bag-info>jsonget[bag_name]addprefix[/bags/]] }}} method="post" onsubmit="return confirmBagDelete(this)">
|
||||
<input type="hidden" name="_method" value="DELETE"/>
|
||||
<button type="submit" class="mws-delete-button">Delete Bag</button>
|
||||
</form>
|
||||
<$let
|
||||
bag-info={{{ [<bag-list>jsonextract<bag-index>] }}}
|
||||
bag-name={{{ [<bag-info>jsonget[bag_name]] }}}
|
||||
>
|
||||
<$transclude $variable="bagPill"/>
|
||||
<$text text={{{ [<bag-info>jsonget[description]] }}}/>
|
||||
<div class="mws-wiki-card-actions">
|
||||
<form action={{{ [<bag-info>jsonget[bag_name]addprefix[/bags/]] }}} method="post" onsubmit="return confirmBagDelete(this)">
|
||||
<input type="hidden" name="_method" value="DELETE"/>
|
||||
<button type="submit" class="mws-delete-button">Delete Bag</button>
|
||||
</form>
|
||||
</div>
|
||||
</$let>
|
||||
</$let>
|
||||
</li>
|
||||
</$list>
|
||||
</ul>
|
||||
@ -254,23 +254,23 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/get-index
|
||||
}
|
||||
|
||||
.mws-delete-button {
|
||||
background-color: #f44336;
|
||||
color: white;
|
||||
padding: 5px 10px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin-left: 10px;
|
||||
background-color: #f44336;
|
||||
color: white;
|
||||
padding: 5px 10px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.mws-delete-button:hover {
|
||||
background-color: #d32f2f;
|
||||
background-color: #d32f2f;
|
||||
}
|
||||
|
||||
.mws-wiki-card-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 10px;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
@ -353,34 +353,34 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/get-index
|
||||
}
|
||||
|
||||
.mws-config-button:hover {
|
||||
background-color: #45a049;
|
||||
background-color: #45a049;
|
||||
}
|
||||
|
||||
.mws-modal-content {
|
||||
padding: 20px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.mws-modal-section {
|
||||
margin-bottom: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.mws-modal-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.mws-modal-button-primary {
|
||||
background-color: #4CAF50;
|
||||
color: white;
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
background-color: #4CAF50;
|
||||
color: white;
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.mws-modal-button-primary:hover {
|
||||
background-color: #45a049;
|
||||
background-color: #45a049;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user