enable blacklists in comments, wiki pages
This commit is contained in:
@@ -3,24 +3,30 @@
|
|||||||
|
|
||||||
Danbooru.Blacklist.blacklists = [];
|
Danbooru.Blacklist.blacklists = [];
|
||||||
|
|
||||||
|
Danbooru.Blacklist.parse_entry = function(string) {
|
||||||
|
var blacklist = {
|
||||||
|
"tags": string,
|
||||||
|
"require": [],
|
||||||
|
"exclude": [],
|
||||||
|
"disabled": false,
|
||||||
|
"hits": 0
|
||||||
|
};
|
||||||
|
var matches = string.match(/\S+/g) || [];
|
||||||
|
$.each(matches, function(i, tag) {
|
||||||
|
if (tag.charAt(0) === '-') {
|
||||||
|
blacklist.exclude.push(tag.slice(1));
|
||||||
|
} else {
|
||||||
|
blacklist.require.push(tag);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return blacklist;
|
||||||
|
}
|
||||||
|
|
||||||
Danbooru.Blacklist.parse_entries = function() {
|
Danbooru.Blacklist.parse_entries = function() {
|
||||||
var entries = (Danbooru.meta("blacklisted-tags") || "[]").replace(/(rating:[qes])\w+/, "$1").split(/,/);
|
var entries = (Danbooru.meta("blacklisted-tags") || "[]").replace(/(rating:[qes])\w+/, "$1").split(/,/);
|
||||||
|
|
||||||
$.each(entries, function(i, tags) {
|
$.each(entries, function(i, tags) {
|
||||||
var blacklist = {
|
var blacklist = Danbooru.Blacklist.parse_entry(tags);
|
||||||
"tags": tags,
|
|
||||||
"require": [],
|
|
||||||
"exclude": [],
|
|
||||||
"disabled": false,
|
|
||||||
"hits": 0
|
|
||||||
};
|
|
||||||
var matches = tags.match(/\S+/g) || [];
|
|
||||||
$.each(matches, function(i, tag) {
|
|
||||||
if (tag.charAt(0) === '-') {
|
|
||||||
blacklist.exclude.push(tag.slice(1));
|
|
||||||
} else {
|
|
||||||
blacklist.require.push(tag);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
Danbooru.Blacklist.blacklists.push(blacklist);
|
Danbooru.Blacklist.blacklists.push(blacklist);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -29,7 +35,12 @@
|
|||||||
$(".blacklisted").each(function(i, element) {
|
$(".blacklisted").each(function(i, element) {
|
||||||
var $element = $(element);
|
var $element = $(element);
|
||||||
if ($element.hasClass("blacklisted-active")) {
|
if ($element.hasClass("blacklisted-active")) {
|
||||||
$element.removeClass("blacklisted-active");
|
var tag = $(e.target).html();
|
||||||
|
var blacklist = Danbooru.Blacklist.parse_entry(tag);
|
||||||
|
|
||||||
|
if (Danbooru.Blacklist.post_match($element, blacklist)) {
|
||||||
|
$element.removeClass("blacklisted-active");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$element.addClass("blacklisted-active");
|
$element.addClass("blacklisted-active");
|
||||||
}
|
}
|
||||||
@@ -104,14 +115,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.Blacklist.initialize_all = function() {
|
Danbooru.Blacklist.initialize_all = function() {
|
||||||
if ($("#c-posts").length || $("#c-favorites").length || $("#c-pools").length) {
|
Danbooru.Blacklist.parse_entries();
|
||||||
Danbooru.Blacklist.parse_entries();
|
|
||||||
|
|
||||||
if (Danbooru.Blacklist.apply() > 0) {
|
if (Danbooru.Blacklist.apply() > 0) {
|
||||||
Danbooru.Blacklist.update_sidebar();
|
Danbooru.Blacklist.update_sidebar();
|
||||||
} else {
|
} else {
|
||||||
$("#blacklist-box").hide();
|
$("#blacklist-box").hide();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -45,6 +45,23 @@ div#page {
|
|||||||
margin-bottom: 1em;
|
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 {
|
section#content {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
float: left;
|
float: left;
|
||||||
|
|||||||
@@ -88,5 +88,9 @@ div#c-comments {
|
|||||||
width: 55em;
|
width: 55em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.post.blacklisted {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,23 +140,6 @@ div#c-posts {
|
|||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
aside#sidebar > section#blacklist-box ul {
|
|
||||||
margin-left: 1em;
|
|
||||||
|
|
||||||
li {
|
|
||||||
list-style-type: disc;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: $link_color;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
color: #AAA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: $h3_size;
|
font-size: $h3_size;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
def index_by_post
|
def index_by_post
|
||||||
@posts = Post.commented_before(Time.now).tag_match(params[:tags]).paginate(params[:page])
|
@posts = Post.commented_before(Time.now).tag_match(params[:tags]).paginate(params[:page], :limit => 5)
|
||||||
respond_with(@posts) do |format|
|
respond_with(@posts) do |format|
|
||||||
format.html {render :action => "index_by_post"}
|
format.html {render :action => "index_by_post"}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% @posts.each do |post| %>
|
<% @posts.each do |post| %>
|
||||||
<div class="post">
|
<div class="post post-preview" data-tags="<%= post.tag_string %>" data-uploader="<%= post.uploader_name %>" data-rating="<%= post.rating %>" data-flags="<%= post.status %>" data-score="<%= post.score %>">
|
||||||
<div class="preview">
|
<div class="preview">
|
||||||
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
|
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
<section id="blacklist-box">
|
<section id="blacklist-box">
|
||||||
<h1>Blacklisted</h1>
|
<h1>Blacklisted</h1>
|
||||||
<%= link_to "Hidden", "#" %>
|
<ul id="blacklist-list">
|
||||||
<ul>
|
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
@@ -7,4 +7,10 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<%= render "wiki_pages/recent_changes" %>
|
<%= render "wiki_pages/recent_changes" %>
|
||||||
|
|
||||||
|
<section id="blacklist-box">
|
||||||
|
<h1>Blacklisted</h1>
|
||||||
|
<ul id="blacklist-list">
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
Reference in New Issue
Block a user