maintain current directory structure for images
This commit is contained in:
@@ -90,12 +90,12 @@ class Post < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def file_path
|
def file_path
|
||||||
"#{Rails.root}/public/data/original/#{file_path_prefix}#{md5}.#{file_ext}"
|
"#{Rails.root}/public/data/#{file_path_prefix}#{md5}.#{file_ext}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def large_file_path
|
def large_file_path
|
||||||
if has_large?
|
if has_large?
|
||||||
"#{Rails.root}/public/data/large/#{file_path_prefix}#{md5}.jpg"
|
"#{Rails.root}/public/data/sample/#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.jpg"
|
||||||
else
|
else
|
||||||
file_path
|
file_path
|
||||||
end
|
end
|
||||||
@@ -118,12 +118,12 @@ class Post < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def file_url
|
def file_url
|
||||||
"/data/original/#{file_path_prefix}#{md5}.#{file_ext}"
|
"/data/#{file_path_prefix}#{md5}.#{file_ext}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def large_file_url
|
def large_file_url
|
||||||
if has_large?
|
if has_large?
|
||||||
"/data/large/#{file_path_prefix}#{md5}.jpg"
|
"/data/sample/#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.jpg"
|
||||||
else
|
else
|
||||||
file_url
|
file_url
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ class Upload < ActiveRecord::Base
|
|||||||
module FilePathMethods
|
module FilePathMethods
|
||||||
def md5_file_path
|
def md5_file_path
|
||||||
prefix = Rails.env == "test" ? "test." : ""
|
prefix = Rails.env == "test" ? "test." : ""
|
||||||
"#{Rails.root}/public/data/original/#{prefix}#{md5}.#{file_ext}"
|
"#{Rails.root}/public/data/#{prefix}#{md5}.#{file_ext}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def resized_file_path_for(width)
|
def resized_file_path_for(width)
|
||||||
@@ -220,7 +220,7 @@ class Upload < ActiveRecord::Base
|
|||||||
"#{Rails.root}/public/data/preview/#{prefix}#{md5}.jpg"
|
"#{Rails.root}/public/data/preview/#{prefix}#{md5}.jpg"
|
||||||
|
|
||||||
when Danbooru.config.large_image_width
|
when Danbooru.config.large_image_width
|
||||||
"#{Rails.root}/public/data/large/#{prefix}#{md5}.jpg"
|
"#{Rails.root}/public/data/sample/#{prefix}#{md5}.jpg"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ module Danbooru
|
|||||||
900
|
900
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def large_image_prefix
|
||||||
|
"sample-"
|
||||||
|
end
|
||||||
|
|
||||||
# When calculating statistics based on the posts table, gather this many posts to sample from.
|
# When calculating statistics based on the posts table, gather this many posts to sample from.
|
||||||
def post_sample_size
|
def post_sample_size
|
||||||
300
|
300
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ namespace :data do
|
|||||||
task :setup_directories do
|
task :setup_directories do
|
||||||
run "mkdir -p #{deploy_to}/shared/data"
|
run "mkdir -p #{deploy_to}/shared/data"
|
||||||
run "mkdir #{deploy_to}/shared/data/preview"
|
run "mkdir #{deploy_to}/shared/data/preview"
|
||||||
run "mkdir #{deploy_to}/shared/data/large"
|
run "mkdir #{deploy_to}/shared/data/sample"
|
||||||
run "mkdir #{deploy_to}/shared/data/original"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
task :link_directories do
|
task :link_directories do
|
||||||
|
|||||||
1024
db/structure.sql
1024
db/structure.sql
File diff suppressed because it is too large
Load Diff
@@ -110,8 +110,8 @@ class UploadTest < ActiveSupport::TestCase
|
|||||||
context "resizer" do
|
context "resizer" do
|
||||||
teardown do
|
teardown do
|
||||||
FileUtils.rm_f(Dir.glob("#{Rails.root}/public/data/preview/test.*.jpg"))
|
FileUtils.rm_f(Dir.glob("#{Rails.root}/public/data/preview/test.*.jpg"))
|
||||||
FileUtils.rm_f(Dir.glob("#{Rails.root}/public/data/large/test.*.jpg"))
|
FileUtils.rm_f(Dir.glob("#{Rails.root}/public/data/sample/test.*.jpg"))
|
||||||
FileUtils.rm_f(Dir.glob("#{Rails.root}/public/data/original/test.*.jpg"))
|
FileUtils.rm_f(Dir.glob("#{Rails.root}/public/data/test.*.jpg"))
|
||||||
end
|
end
|
||||||
|
|
||||||
should "generate several resized versions of the image" do
|
should "generate several resized versions of the image" do
|
||||||
|
|||||||
Reference in New Issue
Block a user