Skip to content

Commit 7610bcb

Browse files
committed
Merge pull request #519 from Martii/Issue-261DataList
Issue 261 data list Auto-merge ... no additional comments
2 parents 17b69b2 + 4f86b35 commit 7610bcb

File tree

7 files changed

+67
-3
lines changed

7 files changed

+67
-3
lines changed

controllers/remove.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ exports.rm = function (aReq, aRes, aNext) {
7474
return aNext();
7575
}
7676

77-
// Destory all the sessions belonging to the removed user
77+
// Destroy all the sessions belonging to the removed user
7878
destroySessions(aReq, aUser, function () {
7979
aRes.redirect('/');
8080
});

controllers/script.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var modelQuery = require('../libs/modelQuery');
2424
var modelParser = require('../libs/modelParser');
2525
var countTask = require('../libs/tasks').countTask;
2626
var pageMetadata = require('../libs/templateHelpers').pageMetadata;
27+
var removeReasons = require('../views/includes/scriptModals.json').removeReasons;
2728

2829
// Let controllers know this is a `new` route
2930
exports.new = function (aController) {
@@ -275,6 +276,14 @@ var setupScriptSidePanel = function (aOptions) {
275276
if (authedUser && authedUser.isMod) {
276277
//aOptions.authorTools = {}; // TODO: Support moderator edits on scripts?
277278
aOptions.modTools = {};
279+
280+
if (removeReasons) {
281+
aOptions.modTools.hasRemoveReasons = true;
282+
aOptions.modTools.removeReasons = [];
283+
removeReasons.forEach(function (aReason) {
284+
aOptions.modTools.removeReasons.push({ 'name' : aReason });
285+
});
286+
}
278287
}
279288

280289
// Admin

controllers/user.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var settings = require('../models/settings.json');
4040
var github = require('./../libs/githubClient');
4141
var pageMetadata = require('../libs/templateHelpers').pageMetadata;
4242
var orderDir = require('../libs/templateHelpers').orderDir;
43+
var removeReasons = require('../views/includes/userModals.json').removeReasons;
4344

4445
function caseInsensitive (aStr) {
4546
return new RegExp('^' + (aStr || '').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1")
@@ -127,6 +128,14 @@ var setupUserSidePanel = function (aOptions) {
127128
if (authedUser && authedUser.isMod && (authedUser.role < user.role || aOptions.isYou)) {
128129
//aOptions.userTools = {}; // TODO: Support moderator edits of user profiles?
129130
aOptions.modTools = {};
131+
132+
if (removeReasons) {
133+
aOptions.modTools.hasRemoveReasons = true;
134+
aOptions.modTools.removeReasons = [];
135+
removeReasons.forEach(function (aReason) {
136+
aOptions.modTools.removeReasons.push({ 'name' : aReason });
137+
});
138+
}
130139
}
131140

132141
// Admin

views/includes/scriptModals.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ <h4 class="modal-title">Remove {{script.fullName}}</h4>
3333
</div>
3434
<div class="modal-footer">
3535
<form action="{{{script.scriptRemovePageUrl}}}" method="post" enctype="multipart/form-data">
36-
<input type="text" class="form-control" name="reason" placeholder="Reason for removal.">
36+
<input type="text" class="form-control" name="reason" placeholder="Reason for removal."{{#modTools.removeReasons}} list="reasons"{{/modTools.removeReasons}}>
37+
{{#modTools.hasRemoveReasons}}
38+
<datalist id="reasons">
39+
{{#modTools.removeReasons}}<option value="{{{name}}}"></option>{{/modTools.removeReasons}}
40+
</datalist>
41+
{{/modTools.hasRemoveReasons}}
3742
<br />
3843
<button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-fw fa-close"></i> Close</button>
3944
<input type="hidden" name="remove" value="true">

views/includes/scriptModals.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"removeReasons" : [
3+
"Bad external script host ",
4+
"Cookie stealing ",
5+
"Incomplete metadata block ",
6+
"Licensing conflict ",
7+
"Malware ",
8+
"Obfuscated script ",
9+
"Obfuscated external script ",
10+
"Privacy stealing ",
11+
"Spamming ",
12+
"Unattributed script derivative ",
13+
"Undocumented auto-like ",
14+
"Vague description ",
15+
"Vague script ",
16+
"XSS attack "
17+
]
18+
}

views/includes/userModals.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ <h4 class="modal-title">Remove {{user.name}}</h4>
1111
</div>
1212
<div class="modal-footer">
1313
<form action="{{{user.userRemovePageUrl}}}" method="post" enctype="multipart/form-data">
14-
<input type="text" class="form-control" name="reason" placeholder="Reason for removal.">
14+
<input type="text" class="form-control" name="reason" placeholder="Reason for removal."{{#modTools.removeReasons}} list="reasons"{{/modTools.removeReasons}}>
15+
{{#modTools.hasRemoveReasons}}
16+
<datalist id="reasons">
17+
{{#modTools.removeReasons}}<option value="{{{name}}}"></option>{{/modTools.removeReasons}}
18+
</datalist>
19+
{{/modTools.hasRemoveReasons}}
1520
<br />
1621
<button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-fw fa-close"></i> Close</button>
1722
<input type="hidden" name="remove" value="true">

views/includes/userModals.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"removeReasons" : [
3+
"Bad external script hosts ",
4+
"Cookie stealings ",
5+
"Incomplete metadata blocks ",
6+
"Licensing conflicts ",
7+
"Malwares ",
8+
"Obfuscated scripts ",
9+
"Obfuscated external scripts ",
10+
"Privacy stealings ",
11+
"Spammings ",
12+
"Unattributed script derivatives ",
13+
"Undocumented auto-likes ",
14+
"Vague descriptions ",
15+
"Vague scripts ",
16+
"XSS attacks "
17+
]
18+
}

0 commit comments

Comments
 (0)