adbanner-test/config/routes.rb

27 lines
959 B
Ruby

Rails.application.routes.draw do
require 'fileutils'
get 'ad_banners/widget'
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
Thread.new do
ad_images = AdImage.where(:video_file.ne=>nil,:video_snapshot=>nil).to_a
ad_images.each do |ad_image|
ad_image[:video_snapshot] = File.basename(ad_image.video_file.file.path).split(/\.[^.]+$/)[0] + ".jpg"
FileUtils.mkdir_p(File.dirname(ad_image.video_snapshot.file.path))
system("tmp/ffmpeg/ffmpeg -i #{ad_image.video_file.file.path} -vframes 1 #{ad_image.video_snapshot.file.path}")
ad_image.save
end
end
end
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
post "/ad_banner/save_image_order", to: "ad_banners#save_image_order"
resources :ad_banners
resources :ad_images
end
end
end