This commit is contained in:
Toks
2015-05-23 12:14:03 -04:00
18 changed files with 125 additions and 59 deletions

View File

@@ -46,7 +46,11 @@
Danbooru.Upload.initialize_info_bookmarklet = function() {
$("#source-info ul").hide();
$("#fetch-data-bookmarklet").click(function(e) {
$.get(e.target.href).success(Danbooru.Upload.fill_source_info);
var xhr = $.get(e.target.href);
xhr.success(Danbooru.Upload.fill_source_info);
xhr.fail(function(data) {
$("#source-info span#loading-data").html("Error: " + data.responseJSON["message"])
});
e.preventDefault();
});
$("#fetch-data-bookmarklet").trigger("click");
@@ -63,7 +67,11 @@
Danbooru.error("Error: Source is not a URL");
} else {
$("#source-info span#loading-data").show();
$.get("/source.json?url=" + encodeURIComponent(source)).success(Danbooru.Upload.fill_source_info);
var xhr = $.get("/source.json?url=" + encodeURIComponent(source));
xhr.success(Danbooru.Upload.fill_source_info);
xhr.fail(function(data) {
$("#source-info span#loading-data").html("Error: " + data.responseJSON["message"])
});
}
e.preventDefault();
});

View File

@@ -12,4 +12,14 @@ class SourcesController < ApplicationController
end
end
end
private
def rescue_exception(exception)
respond_with do |format|
format.json do
render :json => {:message => exception.to_s}, :status => :error
end
end
end
end

View File

@@ -20,6 +20,7 @@ class Post < ActiveRecord::Base
before_save :update_tag_post_counts
before_save :set_tag_counts
before_save :set_pool_category_pseudo_tags
before_create :autoban
before_validation :strip_source
before_validation :initialize_uploader, :on => :create
before_validation :parse_pixiv_id
@@ -290,6 +291,12 @@ class Post < ActiveRecord::Base
def disapproved_by?(user)
PostDisapproval.where(:user_id => user.id, :post_id => id).exists?
end
def autoban
if has_tag?("banned_artist")
self.is_banned = true
end
end
end
module PresenterMethods
@@ -1490,7 +1497,13 @@ class Post < ActiveRecord::Base
def update_iqdb_async
if Danbooru.config.iqdb_hostname_and_port && File.exists?(preview_file_path)
Danbooru.config.all_server_hosts.each do |host|
delay(:queue => host).update_iqdb
if has_tag?("ugoira")
run_at = 10.seconds.from_now
else
run_at = Time.from_now
end
delay(:queue => host, :run_at => run_at).update_iqdb
end
end
end
@@ -1558,6 +1571,7 @@ class Post < ActiveRecord::Base
def reload(options = nil)
super
reset_tag_array_cache
@pools = nil
@tag_categories = nil
@typed_tags = nil
self

View File

@@ -192,6 +192,11 @@ class Tag < ActiveRecord::Base
if category
category_id = categories.value_for(category)
# in case a category change hasn't propagated to this server yet,
# force an update the local cache. This may get overwritten in the
# next few lines if the category is changed.
tag.update_category_cache
if category_id != tag.category && !tag.is_locked? && (CurrentUser.is_builder? || tag.post_count <= 50)
tag.update_column(:category, category_id)
tag.update_category_cache_for_all

View File

@@ -198,11 +198,15 @@ class TagAlias < ActiveRecord::Base
def rename_wiki_and_artist
antecedent_wiki = WikiPage.titled(antecedent_name).first
if antecedent_wiki.present? && WikiPage.titled(consequent_name).blank?
CurrentUser.scoped(creator, creator_ip_addr) do
antecedent_wiki.update_attributes(
:title => consequent_name
)
if antecedent_wiki.present?
if WikiPage.titled(consequent_name).blank?
CurrentUser.scoped(creator, creator_ip_addr) do
antecedent_wiki.update_attributes(
:title => consequent_name
)
end
else
update_forum_topic_for_wiki_conflict
end
end
@@ -249,6 +253,16 @@ class TagAlias < ActiveRecord::Base
end
end
def update_forum_topic_for_wiki_conflict
if forum_topic
CurrentUser.scoped(User.admins.first, "127.0.0.1") do
forum_topic.posts.create(
:body => "The tag alias [[#{antecedent_name}]] -> [[#{consequent_name}]] has conflicting wiki pages. [[#{consequent_name}]] should be updated to include information from [[#{antecedent_name}]] if necessary."
)
end
end
end
def reject!
update_column(:status, "deleted")
clear_all_cache

View File

@@ -149,7 +149,7 @@
<meta name="always-resize-images" content="<%= CurrentUser.user.always_resize_images? %>">
<meta property="og:title" content="<%= @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>">
<meta property="og:description" content="<%= @post.presenter.humanized_tag_string %>">
<meta property="og:image" content="<%= @post.preview_file_url %>">
<meta property="og:image" content="http://<%= Danbooru.config.hostname %><%= @post.large_file_url %>">
<!-- Twitter properties -->
<% if @post.twitter_card_supported? %>