diff --git a/app/controllers/bulk_update_requests_controller.rb b/app/controllers/bulk_update_requests_controller.rb index d3b11fa7c..c7b2ccbf9 100644 --- a/app/controllers/bulk_update_requests_controller.rb +++ b/app/controllers/bulk_update_requests_controller.rb @@ -35,7 +35,7 @@ class BulkUpdateRequestsController < ApplicationController def destroy if @bulk_update_request.editable?(CurrentUser.user) - @bulk_update_request.destroy + @bulk_update_request.reject! flash[:notice] = "Bulk update request deleted" respond_with(@bulk_update_request, :location => bulk_update_requests_path) else diff --git a/app/controllers/tag_aliases_controller.rb b/app/controllers/tag_aliases_controller.rb index 263ccc2d6..bfbb0d690 100644 --- a/app/controllers/tag_aliases_controller.rb +++ b/app/controllers/tag_aliases_controller.rb @@ -7,11 +7,6 @@ class TagAliasesController < ApplicationController respond_with(@tag_alias) end - def new - @tag_alias = TagAlias.new(params[:tag_alias]) - respond_with(@tag_alias) - end - def edit @tag_alias = TagAlias.find(params[:id]) end @@ -36,11 +31,6 @@ class TagAliasesController < ApplicationController end end - def create - @tag_alias = TagAlias.create(params[:tag_alias]) - respond_with(@tag_alias, :location => tag_aliases_path(:search => {:id => @tag_alias.id})) - end - def destroy @tag_alias = TagAlias.find(params[:id]) if @tag_alias.deletable_by?(CurrentUser.user) diff --git a/app/controllers/tag_implications_controller.rb b/app/controllers/tag_implications_controller.rb index 84e4fe181..167d4aef2 100644 --- a/app/controllers/tag_implications_controller.rb +++ b/app/controllers/tag_implications_controller.rb @@ -7,11 +7,6 @@ class TagImplicationsController < ApplicationController respond_with(@tag_implication) end - def new - @tag_implication = TagImplication.new - respond_with(@tag_implication) - end - def edit @tag_implication = TagImplication.find(params[:id]) end @@ -36,11 +31,6 @@ class TagImplicationsController < ApplicationController end end - def create - @tag_implication = TagImplication.create(params[:tag_implication]) - respond_with(@tag_implication, :location => tag_implications_path(:search => {:id => @tag_implication.id})) - end - def destroy @tag_implication = TagImplication.find(params[:id]) if @tag_implication.deletable_by?(CurrentUser.user) diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 62e089454..6213fc8aa 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -16,7 +16,11 @@ class UploadsController < ApplicationController @normalized_url, headers = strategy.new(@normalized_url).rewrite(@normalized_url, headers) end - @post = Post.where(source: [params[:url], @normalized_url]).first + if @normalized_url.nil? + @post = Post.where(source: params[:url]).first + else + @post = Post.where(source: [params[:url], @normalized_url]).first + end begin @source = Sources::Site.new(params[:url]) diff --git a/app/logical/alias_and_implication_importer.rb b/app/logical/alias_and_implication_importer.rb index 7da0e7763..ee5556dfe 100644 --- a/app/logical/alias_and_implication_importer.rb +++ b/app/logical/alias_and_implication_importer.rb @@ -48,12 +48,18 @@ private case token[0] when :create_alias tag_alias = TagAlias.create(:forum_topic_id => forum_id, :status => "pending", :antecedent_name => token[1], :consequent_name => token[2]) + unless tag_alias.valid? + raise "Error: #{tag_alias.errors.full_messages.join("; ")} (create alias #{tag_alias.antecedent_name} -> #{tag_alias.consequent_name})" + end tag_alias.rename_wiki_and_artist if rename_aliased_pages? - tag_alias.delay(:queue => "default").process! + tag_alias.delay(:queue => "default").process!(false) when :create_implication tag_implication = TagImplication.create(:forum_topic_id => forum_id, :status => "pending", :antecedent_name => token[1], :consequent_name => token[2]) - tag_implication.delay(:queue => "default").process! + unless tag_implication.valid? + raise "Error: #{tag_implication.errors.full_messages.join("; ")} (create implication #{tag_implication.antecedent_name} -> #{tag_implication.consequent_name})" + end + tag_implication.delay(:queue => "default").process!(false) when :remove_alias tag_alias = TagAlias.where("antecedent_name = ?", token[1]).first diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index e5232b0e5..b5b285c3a 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -47,12 +47,18 @@ module Sources end def get_image_url_from_page(page) - download_link = page.link_with(:class => /dev-page-download/) + image = page.search("div.dev-view-deviation img.dev-content-full") - if download_link - download_link.click.uri.to_s # need to follow the redirect now to get the full size url, following it later seems to not work. + if image.any? + image[0]["src"] else - nil + download_link = page.link_with(:class => /dev-page-download/) + + if download_link + download_link.click.uri.to_s # need to follow the redirect now to get the full size url, following it later seems to not work. + else + nil + end end end diff --git a/app/models/bulk_update_request.rb b/app/models/bulk_update_request.rb index e64f34afc..37c79661a 100644 --- a/app/models/bulk_update_request.rb +++ b/app/models/bulk_update_request.rb @@ -31,8 +31,8 @@ class BulkUpdateRequest < ActiveRecord::Base extend SearchMethods def approve! - update_forum_topic_for_approve AliasAndImplicationImporter.new(script, forum_topic_id, "1").process! + update_forum_topic_for_approve update_attribute(:status, "approved") end diff --git a/app/models/post.rb b/app/models/post.rb index 32a802910..d6ea04b19 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -668,7 +668,7 @@ class Post < ActiveRecord::Base end def has_tag?(tag) - !!(tag_string =~ /(?:^| )#{tag}(?:$| )/) + !!(tag_string =~ /(?:^| )(?:#{tag})(?:$| )/) end def has_dup_tag? diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb index 6598fd494..f59e05483 100644 --- a/app/models/tag_alias.rb +++ b/app/models/tag_alias.rb @@ -77,7 +77,7 @@ class TagAlias < ActiveRecord::Base end.uniq end - def process! + def process!(update_topic=true) unless valid? raise errors.full_messages.join("; ") end @@ -86,7 +86,7 @@ class TagAlias < ActiveRecord::Base clear_all_cache ensure_category_consistency update_posts - update_forum_topic_for_approve + update_forum_topic_for_approve if update_topic update_column(:post_count, consequent_tag.post_count) update_column(:status, "active") rescue Exception => e diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index 22288d609..ac032d966 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -120,7 +120,7 @@ class TagImplication < ActiveRecord::Base self.creator_ip_addr = CurrentUser.ip_addr end - def process! + def process!(update_topic=true) unless valid? raise errors.full_messages.join("; ") end @@ -128,7 +128,7 @@ class TagImplication < ActiveRecord::Base update_posts update_column(:status, "active") update_descendant_names_for_parents - update_forum_topic_for_approve + update_forum_topic_for_approve if update_topic rescue Exception => e update_column(:status, "error: #{e}") end diff --git a/app/views/tag_aliases/_secondary_links.html.erb b/app/views/tag_aliases/_secondary_links.html.erb index f72861d32..ba769bd27 100644 --- a/app/views/tag_aliases/_secondary_links.html.erb +++ b/app/views/tag_aliases/_secondary_links.html.erb @@ -2,11 +2,7 @@
  • <%= link_to "Listing", tag_aliases_path %>
  • <%= link_to "MetaSearch", meta_searches_tags_path %>
  • - <% if CurrentUser.is_admin? %> -
  • <%= link_to "New", new_tag_alias_path %>
  • - <% else %> -
  • <%= link_to "Request alias", new_tag_alias_request_path %>
  • - <% end %> +
  • <%= link_to "Request alias", new_tag_alias_request_path %>
  • <%= link_to "Request bulk update", new_bulk_update_request_path %>
  • <%= link_to "Help", wiki_pages_path(:title => "help:tag_aliases") %>
  • diff --git a/app/views/tag_aliases/new.html.erb b/app/views/tag_aliases/new.html.erb deleted file mode 100644 index 7c48afc0a..000000000 --- a/app/views/tag_aliases/new.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -
    -
    -

    New Tag Alias

    - - <%= error_messages_for :tag_alias %> - - <%= simple_form_for(@tag_alias) do |f| %> - <%= f.input :status, :value => "pending", :as => :hidden %> - <%= f.input :antecedent_name, :as => :string, :label => "From" %> - <%= f.input :consequent_name, :label => "To" %> - <%= f.input :forum_topic_id, :label => "Forum" %> - <%= f.button :submit %> - <% end %> -
    -
    - -<%= render "secondary_links" %> - -<% content_for(:page_title) do %> - New Tag Alias - <%= Danbooru.config.app_name %> -<% end %> diff --git a/app/views/tag_implications/_secondary_links.html.erb b/app/views/tag_implications/_secondary_links.html.erb index 3bc0b464b..1a1d65472 100644 --- a/app/views/tag_implications/_secondary_links.html.erb +++ b/app/views/tag_implications/_secondary_links.html.erb @@ -2,11 +2,7 @@
  • <%= link_to "Listing", tag_implications_path %>
  • <%= link_to "MetaSearch", meta_searches_tags_path %>
  • - <% if CurrentUser.is_admin? %> -
  • <%= link_to "New", new_tag_implication_path %>
  • - <% else %> -
  • <%= link_to "Request implication", new_tag_implication_request_path %>
  • - <% end %> +
  • <%= link_to "Request implication", new_tag_implication_request_path %>
  • <%= link_to "Request bulk update", new_bulk_update_request_path %>
  • <%= link_to "Help", wiki_pages_path(:title => "help:tag_implications") %>
  • diff --git a/app/views/tag_implications/new.html.erb b/app/views/tag_implications/new.html.erb deleted file mode 100644 index 5e4d1952e..000000000 --- a/app/views/tag_implications/new.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -
    -
    -

    New Tag Implication

    - - <%= error_messages_for :tag_implication %> - - <%= simple_form_for(@tag_implication) do |f| %> - <%= f.input :status, :value => "pending", :as => :hidden %> - <%= f.input :antecedent_name, :label => "From" %> - <%= f.input :consequent_name, :label => "To" %> - <%= f.input :forum_topic_id, :label => "Forum" %> - <%= f.button :submit %> - <% end %> -
    -
    - -<%= render "secondary_links" %> - -<% content_for(:page_title) do %> - New Tag Implication - <%= Danbooru.config.app_name %> -<% end %> diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index 6060cd004..12b728c3c 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -4,7 +4,7 @@ module Danbooru class Configuration # The version of this Danbooru. def version - "2.75.3" + "2.76.0" end # The name of this Danbooru.