diff --git a/app/models/advertisement.rb b/app/models/advertisement.rb index ed00e8c77..b95c69716 100644 --- a/app/models/advertisement.rb +++ b/app/models/advertisement.rb @@ -25,11 +25,15 @@ class Advertisement < ActiveRecord::Base end def image_url - "/images/advertisements/#{file_name}" + "/images/advertisements/ads-#{date_prefix}/#{file_name}" + end + + def date_prefix + created_at.strftime("%Y%m%d") end def image_path - "#{Rails.root}/public/images/advertisements/#{file_name}" + "#{Danbooru.config.advertisement_path}/ads-#{date-prefix}/#{file_name}" end def file diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index b88fb43d6..70c32c49d 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -87,6 +87,11 @@ module Danbooru nil end + # Where the ad banners are stored in the file system + def advertisement_path + nil + end + # List of memcached servers def memcached_servers %w(localhost:11211) diff --git a/config/deploy.rb b/config/deploy.rb index 6ff3e45d3..bb8a15035 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -50,6 +50,12 @@ namespace :data do task :link_directories do run "rm -f #{release_path}/public/data" run "ln -s #{deploy_to}/shared/data #{release_path}/public/data" + + run "rm -f #{release_path}/public/ssd" + run "ln -s /mnt/ssd#{release_path}/public #{release_path}/public/ssd" + + run "rm -f #{release_path}/public/images/advertisements" + run "ln -s #{deploy_to}/shared/advertisements #{release_path}/public/images/advertisements" end end