diff --git a/Gemfile b/Gemfile index 9e8d66ac8..c003a994c 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ group :test do end group :assets do - gem "sass-rails", "~> 3.2.3" + gem "sass-rails" gem "uglifier", ">= 1.0.3" gem "therubyracer" end @@ -24,7 +24,6 @@ gem "simple_form" gem "mechanize", git: 'git://github.com/caribio/mechanize.git' gem "nokogiri" gem "meta_search", :git => "git://github.com/ernie/meta_search.git" -gem "silent-postgres" gem "whenever", :require => false gem "sanitize", :git => "git://github.com/rgrove/sanitize.git" gem 'rmagick', :require => "RMagick" diff --git a/Gemfile.lock b/Gemfile.lock index c92e4c63a..0e3bfb96f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -145,7 +145,6 @@ GEM shoulda-matchers (~> 1.0.0) shoulda-context (1.0.0) shoulda-matchers (1.0.0) - silent-postgres (0.1.1) simple_form (2.0.1) actionpack (~> 3.0) activemodel (~> 3.0) @@ -200,9 +199,8 @@ DEPENDENCIES rails (= 3.2.2) rmagick sanitize! - sass-rails (~> 3.2.3) + sass-rails shoulda - silent-postgres simple_form simplecov super_exception_notifier diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index ee06dc320..f24a8a8af 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -96,12 +96,9 @@ Danbooru.Post.initialize_image_resize = function() { var default_image_size = Danbooru.meta("default-image-size"); var original_width = parseInt($("#image").data("original-width")); - var medium_width = parseInt(Danbooru.meta("config-medium-width")); var large_width = parseInt(Danbooru.meta("config-large-width")); - if ((default_image_size === "medium") && (original_width > medium_width)) { - $("#medium-file-link").trigger("click"); - } else if ((default_image_size === "large") && (original_width > large_width)) { + if ((default_image_size === "large") && (original_width > large_width)) { $("#large-file-link").trigger("click"); } else { $("#original-file-link").trigger("click"); @@ -113,7 +110,6 @@ Danbooru.Note.Box.descale_all(); var $link = $(e.target); var $image = $("#image"); - $("#medium-file-link").removeClass("active"); $("#large-file-link").removeClass("active"); $("#original-file-link").removeClass("active"); $link.addClass("active"); @@ -126,7 +122,6 @@ } Danbooru.Post.initialize_post_image_resize_links = function() { - $("#medium-file-link").click(Danbooru.Post.build_resize_function("medium")); $("#large-file-link").click(Danbooru.Post.build_resize_function("large")); $("#original-file-link").click(Danbooru.Post.build_resize_function("original")); } diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index f0123d0a7..7963f1e93 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -2,15 +2,11 @@ module PostsHelper def resize_image_links(post, user) links = [] - if post.has_medium? - links << link_to("M", post.medium_file_url, :id => "medium-file-link") - end - if post.has_large? links << link_to("L", post.large_file_url, :id => "large-file-link") end - if post.has_medium? || post.has_large? + if post.has_large? links << link_to("O", post.file_url, :id => "original-file-link") end diff --git a/app/logical/anonymous_user.rb b/app/logical/anonymous_user.rb index 78e0be9ae..ae04f0546 100644 --- a/app/logical/anonymous_user.rb +++ b/app/logical/anonymous_user.rb @@ -105,7 +105,7 @@ class AnonymousUser end def default_image_size - "medium" + "large" end def blacklisted_tags diff --git a/app/logical/popular_post_explorer.rb b/app/logical/popular_post_explorer.rb deleted file mode 100644 index 4f2350fc1..000000000 --- a/app/logical/popular_post_explorer.rb +++ /dev/null @@ -1,29 +0,0 @@ -class PopularPostExplorer - attr_reader :col1, :col2, :posts - - def initialize - load_posts - sort_posts - end - -private - - def load_posts - Post.tag_match("order:rank").where("image_width >= ?", Danbooru.config.medium_image_width).limit(5).offset(offset) - end - - def sort_posts - height1, height2 = 0, 0 - @col1, @col2 = [], [] - - posts.each do |post| - if height1 > height2 - @col2 << post - height2 += post.medium_image_height - else - @col1 << post - height1 += post.medium_image_height - end - end - end -end diff --git a/app/models/amazon_backup.rb b/app/models/amazon_backup.rb index e29c2d373..2c33383e4 100644 --- a/app/models/amazon_backup.rb +++ b/app/models/amazon_backup.rb @@ -28,10 +28,6 @@ class AmazonBackup < ActiveRecord::Base AWS::S3::S3Object.store("preview/#{post.md5}.jpg", open(post.preview_file_path, "rb"), Danbooru.config.amazon_s3_bucket_name) end - if File.exists?(post.medium_file_path) - AWS::S3::S3Object.store("medium/#{post.md5}.jpg", open(post.medium_file_path, "rb"), Danbooru.config.amazon_s3_bucket_name) - end - if File.exists?(post.large_file_path) AWS::S3::S3Object.store("large/#{post.md5}.jpg", open(post.large_file_path, "rb"), Danbooru.config.amazon_s3_bucket_name) end diff --git a/app/models/forum_topic.rb b/app/models/forum_topic.rb index fd1e14707..533cbf3f7 100644 --- a/app/models/forum_topic.rb +++ b/app/models/forum_topic.rb @@ -1,6 +1,6 @@ class ForumTopic < ActiveRecord::Base attr_accessible :title, :original_post_attributes, :as => [:member, :privileged, :contributor, :janitor, :moderator, :admin, :default] - attr_accessible :is_sticky, :is_locked, :is_deleted, :as => [:admin, :moderator] + attr_accessible :is_sticky, :is_locked, :is_deleted, :as => [:janitor, :admin, :moderator] belongs_to :creator, :class_name => "User" belongs_to :updater, :class_name => "User" has_many :posts, :class_name => "ForumPost", :order => "forum_posts.id asc", :foreign_key => "topic_id", :dependent => :destroy diff --git a/app/models/pool.rb b/app/models/pool.rb index 548f10b49..34ec378af 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -12,7 +12,8 @@ class Pool < ActiveRecord::Base before_validation :initialize_creator, :on => :create after_save :create_version before_destroy :create_mod_action_for_destroy - attr_accessible :name, :description, :post_ids, :post_id_array, :is_active, :post_count + attr_accessible :name, :description, :post_ids, :post_id_array, :post_count, :as => [:member, :privileged, :contributor, :janitor, :moderator, :admin, :default] + attr_accessible :is_active, :as => [:janitor, :moderator, :admin] scope :active, where("is_active = true") def self.name_to_id(name) diff --git a/app/models/post.rb b/app/models/post.rb index c5b672d7e..09e96f2e3 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -68,7 +68,6 @@ class Post < ActiveRecord::Base RemoteFileManager.new(file_path).distribute RemoteFileManager.new(real_preview_file_path).distribute RemoteFileManager.new(ssd_preview_file_path).distribute if Danbooru.config.ssd_path - RemoteFileManager.new(medium_file_path).distribute if has_medium? RemoteFileManager.new(large_file_path).distribute if has_large? end @@ -76,13 +75,11 @@ class Post < ActiveRecord::Base RemoteFileManager.new(file_path).delete RemoteFileManager.new(real_preview_file_path).delete RemoteFileManager.new(ssd_preview_file_path).delete if Danbooru.config.ssd_path - RemoteFileManager.new(medium_file_path).delete if has_medium? RemoteFileManager.new(large_file_path).delete if has_large? end def delete_files FileUtils.rm_f(file_path) - FileUtils.rm_f(medium_file_path) FileUtils.rm_f(large_file_path) FileUtils.rm_f(ssd_preview_file_path) if Danbooru.config.ssd_path FileUtils.rm_f(real_preview_file_path) @@ -96,14 +93,6 @@ class Post < ActiveRecord::Base "#{Rails.root}/public/data/original/#{file_path_prefix}#{md5}.#{file_ext}" end - def medium_file_path - if has_medium? - "#{Rails.root}/public/data/medium/#{file_path_prefix}#{md5}.jpg" - else - file_path - end - end - def large_file_path if has_large? "#{Rails.root}/public/data/large/#{file_path_prefix}#{md5}.jpg" @@ -132,23 +121,11 @@ class Post < ActiveRecord::Base "/data/original/#{file_path_prefix}#{md5}.#{file_ext}" end - def medium_file_url - if has_medium? - if is_flash? - "/data/preview/480x200-flash.png" - else - "/data/medium/#{file_path_prefix}#{md5}.jpg" - end - else - file_url - end - end - def large_file_url if has_large? "/data/large/#{file_path_prefix}#{md5}.jpg" else - medium_file_url + file_url end end @@ -166,13 +143,6 @@ class Post < ActiveRecord::Base def file_url_for(user) case user.default_image_size - when "medium" - if image_width > Danbooru.config.medium_image_width - medium_file_url - else - file_url - end - when "large" if image_width > Danbooru.config.large_image_width large_file_url @@ -187,13 +157,6 @@ class Post < ActiveRecord::Base def file_path_for(user) case user.default_image_size - when "medium" - if image_width > Danbooru.config.medium_image_width - medium_file_path - else - file_path - end - when "large" if image_width > Danbooru.config.large_image_width large_file_path @@ -216,35 +179,14 @@ class Post < ActiveRecord::Base end module ImageMethods - def has_medium? - image_width > Danbooru.config.medium_image_width - end - def has_large? image_width > Danbooru.config.large_image_width end - def medium_image_width - [Danbooru.config.medium_image_width, image_width].min - end - def large_image_width [Danbooru.config.large_image_width, image_width].min end - def medium_image_height - if is_flash? - return 200 - end - - ratio = Danbooru.config.medium_image_width.to_f / image_width.to_f - if ratio < 1 - (image_height * ratio).to_i - else - image_height - end - end - def large_image_height ratio = Danbooru.config.large_image_width.to_f / image_width.to_f if ratio < 1 @@ -256,9 +198,6 @@ class Post < ActiveRecord::Base def image_width_for(user) case user.default_image_size - when "medium" - medium_image_width - when "large" large_image_width @@ -269,9 +208,6 @@ class Post < ActiveRecord::Base def image_height_for(user) case user.default_image_size - when "medium" - medium_image_height - when "large" large_image_height diff --git a/app/models/upload.rb b/app/models/upload.rb index b5f9f17d2..3a1cedea3 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -134,7 +134,6 @@ class Upload < ActiveRecord::Base def generate_resizes(source_path) if is_image? generate_resize_for(Danbooru.config.small_image_width, Danbooru.config.small_image_width, source_path, 85) - generate_resize_for(Danbooru.config.medium_image_width, nil, source_path) if image_width > Danbooru.config.medium_image_width generate_resize_for(Danbooru.config.large_image_width, nil, source_path) if image_width > Danbooru.config.large_image_width end end @@ -220,9 +219,6 @@ class Upload < ActiveRecord::Base when Danbooru.config.small_image_width "#{Rails.root}/public/data/preview/#{prefix}#{md5}.jpg" - when Danbooru.config.medium_image_width - "#{Rails.root}/public/data/medium/#{prefix}#{md5}.jpg" - when Danbooru.config.large_image_width "#{Rails.root}/public/data/large/#{prefix}#{md5}.jpg" end diff --git a/app/models/user.rb b/app/models/user.rb index c3d083a17..a2f5f14b9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -21,7 +21,7 @@ class User < ActiveRecord::Base validates_uniqueness_of :name, :case_sensitive => false validates_uniqueness_of :email, :case_sensitive => false, :if => lambda {|rec| rec.email.present?} validates_length_of :password, :minimum => 5, :if => lambda {|rec| rec.new_record? || rec.password.present?} - validates_inclusion_of :default_image_size, :in => %w(medium large original) + validates_inclusion_of :default_image_size, :in => %w(large original) validates_confirmation_of :password validates_presence_of :email, :if => lambda {|rec| rec.new_record? && Danbooru.config.enable_email_verification?} validates_presence_of :comment_threshold @@ -432,7 +432,7 @@ class User < ActiveRecord::Base include ApiMethods def initialize_default_image_size - self.default_image_size = "Medium" + self.default_image_size = "large" end def can_update?(object, foreign_key = :user_id) diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 5c5b9c69b..bcf7f737f 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -47,13 +47,6 @@ class PostPresenter < Presenter PostPresenter.preview(@post) end - def medium_image_html(template, options = {}) - return "" if @post.is_deleted? && !CurrentUser.user.is_janitor? - return "" if !Danbooru.config.can_user_see_post?(CurrentUser.user, @post) - - template.render("posts/partials/show/medium_image", :post => @post) - end - def image_html(template) return template.content_tag("p", "This image was deleted.") if @post.is_deleted? && !CurrentUser.user.is_janitor? return template.content_tag("p", "You need a privileged account to see this image.") if !Danbooru.config.can_user_see_post?(CurrentUser.user, @post) diff --git a/app/views/landings/_image.html.erb b/app/views/landings/_image.html.erb deleted file mode 100644 index 22aefa1cb..000000000 --- a/app/views/landings/_image.html.erb +++ /dev/null @@ -1 +0,0 @@ -

<%= post.essential_tag_string.tr("_", " ") %>

\ No newline at end of file diff --git a/app/views/landings/_tag.html.erb b/app/views/landings/_tag.html.erb deleted file mode 100644 index 288d029eb..000000000 --- a/app/views/landings/_tag.html.erb +++ /dev/null @@ -1,8 +0,0 @@ - -
- <% @explorer.search(tag, 300).each do |post| %> - <%= post.presenter.medium_image_html(self, :max_height => 300) %> - <% end %> -
\ No newline at end of file diff --git a/app/views/landings/show.html.erb b/app/views/landings/show.html.erb deleted file mode 100644 index 3fcb1935f..000000000 --- a/app/views/landings/show.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -<% cache(:expires_in => 1.hour) do %> -
-
-

<%= link_to Danbooru.config.app_name, posts_path %>

-

Find good art fast

- -
- <% @explorer.col1.each do |post| %> - <%= render "image", :post => post %> - <% end %> -
- -
- <% @explorer.col2.each do |post| %> - <%= render "image", :post => post %> - <% end %> -
-
-
-<% end %> - -<% content_for(:page_title) do %> - <%= Danbooru.config.app_name %> -<% end %> diff --git a/app/views/moderator/post/queues/show.html.erb b/app/views/moderator/post/queues/show.html.erb index d6b22dc48..46e6e5eab 100644 --- a/app/views/moderator/post/queues/show.html.erb +++ b/app/views/moderator/post/queues/show.html.erb @@ -27,13 +27,7 @@ <% @posts.each do |post| %>
diff --git a/app/views/posts/partials/show/_image.html.erb b/app/views/posts/partials/show/_image.html.erb index 2c7129dd0..40c0b609a 100644 --- a/app/views/posts/partials/show/_image.html.erb +++ b/app/views/posts/partials/show/_image.html.erb @@ -1 +1 @@ -<%= image_tag(post.file_url_for(CurrentUser.user), :width => post.image_width_for(CurrentUser.user), :height => post.image_height_for(CurrentUser.user), :id => "image", "data-original-width" => post.image_width, "data-original-height" => post.image_height, "data-medium-width" => post.medium_image_width, "data-medium-height" => post.medium_image_height, "data-large-width" => post.large_image_width, "data-large-height" => post.large_image_height) %> +<%= image_tag(post.file_url_for(CurrentUser.user), :width => post.image_width_for(CurrentUser.user), :height => post.image_height_for(CurrentUser.user), :id => "image", "data-original-width" => post.image_width, "data-original-height" => post.image_height, "data-large-width" => post.large_image_width, "data-large-height" => post.large_image_height) %> diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index bcdea7d83..85e8f3a26 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -87,7 +87,6 @@ - <% end %> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index de20d01cd..7a2d2a2ff 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -12,7 +12,7 @@ <%= f.input :time_zone %> <%= f.input :receive_email_notifications %> <%= f.input :comment_threshold, :hint => "Comments below this score will be hidden by default" %> - <%= f.input :default_image_size, :hint => "Medium shows images resized to #{Danbooru.config.medium_image_width} pixels wide, large is #{Danbooru.config.large_image_width} pixels wide, and original is whatever the original image is", :collection => %w(medium large original), :include_blank => false %> + <%= f.input :default_image_size, :hint => "Large is #{Danbooru.config.large_image_width} pixels wide, and original is whatever the original image is", :collection => %w(large original), :include_blank => false %> <%= f.input :favorite_tags, :hint => "A list of whitespace delimited tags that show up in your profile", :input_html => {:size => "40x5"} %> <%= f.input :blacklisted_tags, :hint => "A list of newline delimited tags that you never want to see", :input_html => {:size => "40x5"} %> diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index e2ebbbe8d..e0de682cd 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -68,11 +68,6 @@ module Danbooru 150 end - # Medium resize image width. Set to nil to disable. - def medium_image_width - 480 - end - # Large resize image width. Set to nil to disable. def large_image_width 960 diff --git a/config/deploy.rb b/config/deploy.rb index 03e56b02b..1e5b39c0d 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -44,7 +44,6 @@ namespace :data do task :setup_directories do run "mkdir -p #{deploy_to}/shared/data" run "mkdir #{deploy_to}/shared/data/preview" - run "mkdir #{deploy_to}/shared/data/medium" run "mkdir #{deploy_to}/shared/data/large" run "mkdir #{deploy_to}/shared/data/original" end diff --git a/db/test_structure.sql b/db/test_structure.sql index abde90fb6..f916be439 100644 --- a/db/test_structure.sql +++ b/db/test_structure.sql @@ -1450,7 +1450,7 @@ CREATE TABLE users ( receive_email_notifications boolean DEFAULT false NOT NULL, comment_threshold integer DEFAULT (-1) NOT NULL, always_resize_images boolean DEFAULT false NOT NULL, - default_image_size character varying(255) DEFAULT 'medium'::character varying NOT NULL, + default_image_size character varying(255) DEFAULT 'large'::character varying NOT NULL, favorite_tags text, blacklisted_tags text, time_zone character varying(255) DEFAULT 'Eastern Time (US & Canada)'::character varying NOT NULL diff --git a/lib/tasks/images.rake b/lib/tasks/images.rake index 406c5621d..67cc6127a 100644 --- a/lib/tasks/images.rake +++ b/lib/tasks/images.rake @@ -11,16 +11,6 @@ namespace :images do end end - desc "Generate medium-sized images of posts" - task :generate_medium => :environment do - Post.where("image_width > ?", Danbooru.config.medium_image_width).find_each do |post| - if post.is_image? - puts "resizing medium #{post.id}" - Danbooru.resize(post.file_path, post.medium_file_path, Danbooru.config.medium_image_width, nil, 90) - end - end - end - desc "Generate large-sized images of posts" task :generate_large => :environment do Post.where("image_width > ?", Danbooru.config.large_image_width).find_each do |post| @@ -31,16 +21,6 @@ namespace :images do end end - desc "Distribute medium posts to other servers" - task :distribute_medium => :environment do - Post.where("image_width > ?", Danbooru.config.medium_image_width).find_each do |post| - if post.is_image? - puts "distributing medium #{post.id}" - RemoteFileManager.new(post.medium_file_path).distribute - end - end - end - desc "Distribute large posts to other servers" task :distribute_large => :environment do Post.where("image_width > ?", Danbooru.config.large_image_width).find_each do |post| diff --git a/script/upgrade_schema.sql b/script/upgrade_schema.sql index ba65401d4..59bf52551 100755 --- a/script/upgrade_schema.sql +++ b/script/upgrade_schema.sql @@ -3150,7 +3150,7 @@ alter table users rename column invited_by to inviter_id; alter table users rename column last_forum_topic_read_at to last_forum_read_at; alter table users rename column receive_dmails to receive_email_notifications; alter table users add column is_banned boolean not null default false; -alter table users add column default_image_size varchar(255) not null default 'medium'; +alter table users add column default_image_size varchar(255) not null default 'large'; alter table users add column favorite_tags text; alter table users add column blacklisted_tags text; alter table users add column time_zone varchar(255) not null default 'Eastern Time (US & Canada)'; diff --git a/test/factories/user.rb b/test/factories/user.rb index 01f1b73e4..ea5979b45 100644 --- a/test/factories/user.rb +++ b/test/factories/user.rb @@ -3,7 +3,7 @@ Factory.define(:user) do |f| f.password "password" f.password_hash {User.sha1("password")} f.email {Faker::Internet.email} - f.default_image_size "medium" + f.default_image_size "large" f.base_upload_limit 10 f.level 20 f.last_logged_in_at {Time.now} diff --git a/test/unit/upload_test.rb b/test/unit/upload_test.rb index 3106271a3..41f089ecd 100644 --- a/test/unit/upload_test.rb +++ b/test/unit/upload_test.rb @@ -110,7 +110,6 @@ class UploadTest < ActiveSupport::TestCase context "resizer" do teardown do FileUtils.rm_f(Dir.glob("#{Rails.root}/public/data/preview/test.*.jpg")) - FileUtils.rm_f(Dir.glob("#{Rails.root}/public/data/medium/test.*.jpg")) FileUtils.rm_f(Dir.glob("#{Rails.root}/public/data/large/test.*.jpg")) FileUtils.rm_f(Dir.glob("#{Rails.root}/public/data/original/test.*.jpg")) end @@ -122,8 +121,6 @@ class UploadTest < ActiveSupport::TestCase assert_nothing_raised {@upload.generate_resizes(@upload.file_path)} assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.small_image_width))) assert_equal(10639, File.size(@upload.resized_file_path_for(Danbooru.config.small_image_width))) - assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.medium_image_width))) - assert_equal(43470, File.size(@upload.resized_file_path_for(Danbooru.config.medium_image_width))) assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.large_image_width))) assert_equal(129472, File.size(@upload.resized_file_path_for(Danbooru.config.large_image_width))) end