feeds/config/routes.rb

64 lines
2.4 KiB
Ruby
Raw Normal View History

2015-07-07 11:51:56 +00:00
Rails.application.routes.draw do
locales = Site.first.in_use_locales rescue I18n.available_locales
2021-11-17 14:05:08 +00:00
Thread.new do
begin
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
trans = {}
locales.each do |locale|
locale = locale.to_s
trans[locale] = {}
I18n.with_locale(locale) do
trans[locale]['top'] = I18n.t(:top)
trans[locale]['hot'] = I18n.t(:hot)
trans[locale]['more_plus'] = I18n.t(:more_plus)
end
end
2021-11-18 05:33:25 +00:00
SiteFeedAnnc.where(:feed_id.nin=>SiteFeed.all.pluck(:id)).destroy
2021-11-17 14:05:08 +00:00
SiteFeed.each do |site_feed|
2021-11-18 05:59:37 +00:00
count = SiteFeedAnnc.where(feed_id: site_feed.id).count
if count>1
SiteFeedAnnc.where(feed_id: site_feed.id).limit(count-1).destroy
end
2021-11-17 14:05:08 +00:00
tmp = SiteFeedAnnc.where(feed_id: site_feed.id).first
if site_feed.disabled != true
if tmp.nil?
tmp = SiteFeedAnnc.new(feed_id: site_feed.id)
end
tmp[:feed_name] = site_feed[:feed_name]
tmp.merge_with_category = site_feed.merge_with_category
tmp.channel_key = site_feed.channel_key
tmp.category_title = site_feed.category[:title] rescue {}
tmp.remote_site_url = site_feed.remote_site_url
tmp.channel_title = site_feed.channel_title_for_cache
tmp.all_contents_for_feed = tmp.cache_annc(false,locales,trans)
tmp.save
elsif !tmp.nil?
tmp.destroy
end
end
SiteFeedAnnc.create_indexes
end
rescue => e
puts ['feed_routes',e]
end
end
2015-07-07 11:51:56 +00:00
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
get "/feeds/get_channel_list", to: 'feeds#get_channel_list'
get "/feeds/get_feed_list", to: 'feeds#get_feed_list'
get "/feeds/get_category_list", to: 'feeds#get_category_list'
post "/feeds/subscribe", to: 'feeds#subscribe'
post "/feeds/unsubscribe", to: 'feeds#unsubscribe'
post "/feeds/disable", to: 'feeds#disable'
2015-11-09 17:38:30 +00:00
post "/feeds/channel_title", to: 'feeds#channel_title'
resources :feeds,only: ['new','index']
get '/feeds/announcements' => 'feeds#announcements'
post '/feeds/process_annc' => 'feeds#process_annc'
get '/feeds/annc_content' => 'feeds#annc_content'
2021-09-15 08:43:19 +00:00
post "/feeds/force_refresh", to: 'feeds#force_refresh'
2015-07-07 11:51:56 +00:00
end
end
end