From c14f020ce2c245b6c5f54f418ca1c3b572c6683f Mon Sep 17 00:00:00 2001 From: albert Date: Wed, 8 Feb 2012 12:44:17 -0500 Subject: [PATCH] * Fix for Pixiv changes * Fix for artist/wiki pages for -names --- app/assets/stylesheets/mobile.css.scss | 3 -- app/logical/post_sets/artist.rb | 2 + app/logical/post_sets/post.rb | 2 + app/logical/sources/strategies/pixiv.rb | 2 +- app/models/artist.rb | 16 +++++--- app/models/post.rb | 2 + app/views/layouts/mobile.html.erb | 41 ------------------- config/routes.rb | 2 + test/functional/artists_controller_test.rb | 6 +++ test/functional/wiki_pages_controller_test.rb | 6 +++ 10 files changed, 31 insertions(+), 51 deletions(-) delete mode 100644 app/assets/stylesheets/mobile.css.scss delete mode 100644 app/views/layouts/mobile.html.erb diff --git a/app/assets/stylesheets/mobile.css.scss b/app/assets/stylesheets/mobile.css.scss deleted file mode 100644 index 4a785ec8f..000000000 --- a/app/assets/stylesheets/mobile.css.scss +++ /dev/null @@ -1,3 +0,0 @@ -/* - *= require_tree "./mobile" -*/ diff --git a/app/logical/post_sets/artist.rb b/app/logical/post_sets/artist.rb index d7dbb4903..4cbec68aa 100644 --- a/app/logical/post_sets/artist.rb +++ b/app/logical/post_sets/artist.rb @@ -9,6 +9,8 @@ module PostSets def posts ::Post.tag_match(@artist.name) + rescue ::Post::SearchError + ::Post.where("false") end def presenter diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 0f7e2c972..4534fc9dc 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -29,6 +29,8 @@ module PostSets end @posts ||= ::Post.tag_match(tag_string).paginate(page) + rescue ::Post::SearchError + @posts = ::Post.where("false") end def has_artist? diff --git a/app/logical/sources/strategies/pixiv.rb b/app/logical/sources/strategies/pixiv.rb index def6920a5..c9cd33c41 100644 --- a/app/logical/sources/strategies/pixiv.rb +++ b/app/logical/sources/strategies/pixiv.rb @@ -42,7 +42,7 @@ module Sources def get_image_url_from_page(page) meta = page.search("meta[property=\"og:image\"]").first if meta - meta.attr("content").sub(/_m\./, ".") + meta.attr("content").sub(/_[ms]\./, ".") else nil end diff --git a/app/models/artist.rb b/app/models/artist.rb index 0b1a302c2..7f99e256e 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -171,13 +171,17 @@ class Artist < ActiveRecord::Base def ban! Post.transaction do - Post.tag_match(name).each do |post| - begin - post.flag!("Artist requested removal") - rescue PostFlag::Error - # swallow + begin + Post.tag_match(name).each do |post| + begin + post.flag!("Artist requested removal") + rescue PostFlag::Error + # swallow + end + post.delete! end - post.delete! + rescue Post::SearchError + # swallow end # potential race condition but unlikely diff --git a/app/models/post.rb b/app/models/post.rb index f41e64c4b..3518db7eb 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -659,6 +659,8 @@ class Post < ActiveRecord::Base end end count + rescue SearchError + 0 end end diff --git a/app/views/layouts/mobile.html.erb b/app/views/layouts/mobile.html.erb deleted file mode 100644 index 33b14335a..000000000 --- a/app/views/layouts/mobile.html.erb +++ /dev/null @@ -1,41 +0,0 @@ - - - - <%= yield :page_title %> - <%= csrf_meta_tag %> - <%= stylesheet_link_tag "application", :media => "screen" %> - <%#= stylesheet_link_tag "mobile", :media => "only screen and (max-width: 480px), only screen and (max-device-width: 480px)" %> - <%= javascript_include_tag "application" %> - - <%= yield :html_header %> - - -
- <%= render "news_updates/listing" %> - -

<%= link_to Danbooru.config.app_name, "/" %>

- - - <%= render "layouts/more_links" %> -
- -
- <%- if flash[:notice] -%> -
<%= flash[:notice] %>
- <%- else -%> - - <%- end -%> - - <%= yield :layout %> -
- - - - <%= render "static/footer" %> - - diff --git a/config/routes.rb b/config/routes.rb index e3deae9fc..523dc2331 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -178,6 +178,8 @@ Danbooru::Application.routes.draw do namespace :mobile do resources :posts + resource :session + resources :favorites end # aliases diff --git a/test/functional/artists_controller_test.rb b/test/functional/artists_controller_test.rb index e5c5a5293..ee5f92a5f 100644 --- a/test/functional/artists_controller_test.rb +++ b/test/functional/artists_controller_test.rb @@ -29,6 +29,12 @@ class ArtistsControllerTest < ActionController::TestCase assert_response :success end + should "get the show page for a negated tag" do + @artist.update_attribute(:name, "-aaa") + get :show, {:id => @artist.id} + assert_response :success + end + should "get the index page" do get :index assert_response :success diff --git a/test/functional/wiki_pages_controller_test.rb b/test/functional/wiki_pages_controller_test.rb index 93c826c17..e8d32c91c 100644 --- a/test/functional/wiki_pages_controller_test.rb +++ b/test/functional/wiki_pages_controller_test.rb @@ -39,6 +39,12 @@ class WikiPagesControllerTest < ActionController::TestCase get :show, {:id => @wiki_page.id} assert_response :success end + + should "render for a negated tag" do + @wiki_page.update_attribute(:title, "-aaa") + get :show, {:id => @wiki_page.id} + assert_response :success + end end context "create action" do