Merge pull request #3827 from evazion/fix-3709
Fix #3709: Provide OR capability for blacklist items
This commit is contained in:
@@ -10,6 +10,7 @@ Blacklist.parse_entry = function(string) {
|
||||
"tags": string,
|
||||
"require": [],
|
||||
"exclude": [],
|
||||
"optional": [],
|
||||
"disabled": false,
|
||||
"hits": 0,
|
||||
"min_score": null
|
||||
@@ -18,6 +19,8 @@ Blacklist.parse_entry = function(string) {
|
||||
$.each(matches, function(i, tag) {
|
||||
if (tag.charAt(0) === '-') {
|
||||
entry.exclude.push(tag.slice(1));
|
||||
} else if (tag.charAt(0) === '~') {
|
||||
entry.optional.push(tag.slice(1));
|
||||
} else if (tag.match(/^score:<.+/)) {
|
||||
var score = tag.match(/^score:<(.+)/)[1];
|
||||
entry.min_score = parseInt(score);
|
||||
@@ -30,6 +33,7 @@ Blacklist.parse_entry = function(string) {
|
||||
|
||||
Blacklist.parse_entries = function() {
|
||||
var entries = (Utility.meta("blacklisted-tags") || "nozomiisthebestlovelive").replace(/(rating:[qes])\w+/ig, "$1").toLowerCase().split(/,/);
|
||||
entries = entries.filter(e => e.trim() !== "");
|
||||
|
||||
$.each(entries, function(i, tags) {
|
||||
var entry = Blacklist.parse_entry(tags);
|
||||
@@ -51,6 +55,7 @@ Blacklist.toggle_entry = function(e) {
|
||||
}
|
||||
}
|
||||
Blacklist.apply();
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
Blacklist.update_sidebar = function() {
|
||||
@@ -64,6 +69,8 @@ Blacklist.update_sidebar = function() {
|
||||
var count = $("<span/>");
|
||||
|
||||
link.text(entry.tags);
|
||||
link.attr("href", `/posts?tags=${encodeURIComponent(entry.tags)}`);
|
||||
link.attr("title", entry.tags);
|
||||
link.click(Blacklist.toggle_entry);
|
||||
count.html(entry.hits);
|
||||
count.addClass("count");
|
||||
@@ -156,7 +163,10 @@ Blacklist.post_match = function(post, entry) {
|
||||
$.each(String($post.data("flags")).match(/\S+/g) || [], function(i, v) {
|
||||
tags.push("status:" + v);
|
||||
});
|
||||
return (entry.require.length > 0 || entry.exclude.length > 0) && Utility.is_subset(tags, entry.require) && !Utility.intersect(tags, entry.exclude).length;
|
||||
|
||||
return Utility.is_subset(tags, entry.require)
|
||||
&& (!entry.optional.length || Utility.intersect(tags, entry.optional).length)
|
||||
&& !Utility.intersect(tags, entry.exclude).length;
|
||||
}
|
||||
|
||||
Blacklist.post_hide = function(post) {
|
||||
|
||||
49
app/javascript/src/styles/common/blacklists.scss
Normal file
49
app/javascript/src/styles/common/blacklists.scss
Normal file
@@ -0,0 +1,49 @@
|
||||
@import "../base/000_vars.scss";
|
||||
|
||||
#blacklist-box {
|
||||
display: none;
|
||||
|
||||
#blacklist-list {
|
||||
a {
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
a.blacklisted-active {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
}
|
||||
|
||||
&.sidebar-blacklist ul li {
|
||||
list-style-type: disc;
|
||||
list-style-position: inside;
|
||||
|
||||
a {
|
||||
max-width: 75%;
|
||||
}
|
||||
}
|
||||
|
||||
&.inline-blacklist {
|
||||
margin-bottom: 1em;
|
||||
|
||||
#blacklist-list {
|
||||
display: inline;
|
||||
|
||||
li {
|
||||
display: inline;
|
||||
margin-right: 1em;
|
||||
|
||||
a {
|
||||
max-width: 25%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.post-preview.blacklisted-active, #image-container.blacklisted-active, #c-comments .post.blacklisted-active {
|
||||
display: none;
|
||||
}
|
||||
@@ -65,23 +65,6 @@ div#page {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
aside#sidebar > section#blacklist-box ul {
|
||||
margin-left: 1em;
|
||||
|
||||
li {
|
||||
list-style-type: disc;
|
||||
}
|
||||
|
||||
a {
|
||||
color: $link_color;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
span {
|
||||
color: #AAA;
|
||||
}
|
||||
}
|
||||
|
||||
section#content {
|
||||
overflow: visible;
|
||||
margin-left: 15em;
|
||||
|
||||
@@ -123,10 +123,6 @@ div#c-comments {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div.post.blacklisted.blacklisted-active {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,14 +51,6 @@ article.post-preview {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
a.blacklisted-active {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.post-preview.blacklisted-active, #image-container.blacklisted-active {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#excerpt p.links {
|
||||
margin-top: 1em;
|
||||
}
|
||||
@@ -499,33 +491,6 @@ div#c-explore-posts {
|
||||
}
|
||||
}
|
||||
|
||||
#blacklist-box {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#blacklist-box.inline-blacklist {
|
||||
margin-bottom: 1em;
|
||||
|
||||
#blacklist-list {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#blacklist-list li {
|
||||
display: inline;
|
||||
margin-right: 1em;
|
||||
|
||||
a {
|
||||
color: $link_color;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
span.count {
|
||||
color: #AAA;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div#unapprove-dialog {
|
||||
p {
|
||||
margin-bottom: 1em;
|
||||
|
||||
Reference in New Issue
Block a user