2
0
mirror of https://github.com/moebooru/moebooru synced 2025-08-31 14:05:14 +00:00

Move frame url generation to image stores.

This commit is contained in:
edogawaconan
2014-08-27 16:29:21 +09:00
parent 46f50c9f5f
commit 3c524a91a8
4 changed files with 28 additions and 5 deletions

View File

@@ -34,11 +34,8 @@ module Post::FrameMethods
frame[:preview_height] = size[:height]
filename = PostFrames.filename(frame)
server = Mirrors.select_image_server(frames_warehoused, created_at.to_i + i)
frame[:url] = server + "/data/frame/#{filename}"
thumb_server = Mirrors.select_image_server(frames_warehoused, created_at.to_i + i, :use_aliases => true)
frame[:preview_url] = thumb_server + "/data/frame-preview/#{filename}"
frame[:url] = frame_url(filename, i)
frame[:preview_url] = frame_preview_url(filename, i)
end
frames

View File

@@ -56,6 +56,14 @@ module Post::ImageStore
CONFIG["url_base"] + path
end
def frame_url(filename, _frame_number)
"#{CONFIG["url_base"]}/data/frame/#{filename}"
end
def frame_preview_url(filename, _frame_number)
"#{CONFIG["url_base"]}/data/frame-preview/#{filename}"
end
def delete_file
FileUtils.rm_f(file_path)
FileUtils.rm_f(preview_path) if image?

View File

@@ -58,6 +58,14 @@ module Post::ImageStore
end
end
def frame_url(filename, _frame_number)
"#{CONFIG["url_base"]}/data/frame/#{filename}"
end
def frame_preview_url(filename, _frame_number)
"#{CONFIG["url_base"]}/data/frame-preview/#{filename}"
end
def delete_file
FileUtils.rm_f(file_path)
FileUtils.rm_f(preview_path) if image?

View File

@@ -80,6 +80,16 @@ module Post::ImageStore
select_random_image_server + path
end
def frame_url(filename, frame_number)
frame_server = Mirrors.select_image_server(frames_warehoused, created_at.to_i + frame_number)
"#{frame_server}/data/frame/#{filename}"
end
def frame_preview_url(filename, frame_number)
frame_preview_server ||= Mirrors.select_image_server(frames_warehoused, created_at.to_i + frame_number, :use_aliases => true)
"#{frame_preview_server}/data/frame-preview/#{filename}"
end
def delete_file
FileUtils.rm_f(file_path)
FileUtils.rm_f(preview_path) if image?