Skip to content

Commit

Permalink
Find/Replace 4spaces for Tab4, to make consistent with guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
well-noted committed Dec 18, 2024
1 parent e59eba9 commit f82425a
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 156 deletions.
62 changes: 31 additions & 31 deletions plugins/tiddlywiki/multiwikiserver/modules/mws-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
});
}
};

}());
Original file line number Diff line number Diff line change
Expand Up @@ -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"
});
}
};

}());
Original file line number Diff line number Diff line change
Expand Up @@ -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"
});
}
};

}());
Original file line number Diff line number Diff line change
Expand Up @@ -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"
});
}
};

}());
82 changes: 41 additions & 41 deletions plugins/tiddlywiki/multiwikiserver/templates/get-index.tid
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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>

0 comments on commit f82425a

Please sign in to comment.