diff --git a/app/controllers/admin/feeds_controller.rb b/app/controllers/admin/feeds_controller.rb
index dccfaa9..e8ff430 100644
--- a/app/controllers/admin/feeds_controller.rb
+++ b/app/controllers/admin/feeds_controller.rb
@@ -185,6 +185,15 @@ class Admin::FeedsController < OrbitAdminController
end
render :json => {"success" => true}.to_json
end
+
+ def force_refresh
+ sf = SiteFeed.find_by(:feed_uid => params[:feed_uid]) rescue nil
+ if !sf.nil?
+ sf.get_annc(true)
+ end
+ render :json => {"success" => true}.to_json
+ end
+
def search_all_words(target, word)
target = target.upcase
words = word.upcase.split(' ')
diff --git a/app/models/site_feed.rb b/app/models/site_feed.rb
index 62fce13..4c93cc6 100644
--- a/app/models/site_feed.rb
+++ b/app/models/site_feed.rb
@@ -31,10 +31,10 @@ class SiteFeed
end
end
scope :enabled, ->{where(:disabled => false)}
- def get_annc
+ def get_annc(force_refresh=false)
main_directory = File.join("#{Rails.root}","public","site_feeds")
feed_directory = File.join(main_directory.to_s, self.id.to_s)
- if File.exists?(feed_directory)
+ if !force_refresh && File.exists?(feed_directory)
anns = JSON.parse(File.read(File.join(feed_directory.to_s, self.feed_uid + ".json")))[self.channel_key.pluralize] rescue []
else
uri = URI(self.feed_url)
diff --git a/app/views/admin/feeds/index.html.erb b/app/views/admin/feeds/index.html.erb
index 06ff99c..3a728aa 100644
--- a/app/views/admin/feeds/index.html.erb
+++ b/app/views/admin/feeds/index.html.erb
@@ -53,8 +53,9 @@
<%= channel.feed_name %>
<%= channel.category.title rescue "" %>
-
-
+
+
+
@@ -129,7 +130,18 @@
el.parent().remove();
})
}
- })
+ });
+ $(".force-refresh-btn").on("click",function(){
+ var el = $(this);
+ $.ajax({
+ url : "/admin/feeds/force_refresh",
+ data : {"feed_uid": el.data("feed-uid")},
+ dataType : "json",
+ type : "post"
+ }).done(function(){
+ alert("<%= t("feed.successful") %>")
+ });
+ });
diff --git a/config/locales/en.yml b/config/locales/en.yml
index c96fa67..4708f80 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -8,4 +8,9 @@ en:
all_announcements: All Announcements
display: Display
all_feeds_announcments: All feeds announcments
- feed_name: Channel name
\ No newline at end of file
+ feed_name: Channel name
+ enable: Enable
+ disable: Disable
+ force_refresh: Force Refresh
+ unsubscribe: Unsubscribe
+ successful: Successful!
\ No newline at end of file
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index 5aca003..27e0cc4 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -9,3 +9,8 @@ zh_tw:
display: 顯示
all_feeds_announcments: 全部訂閱公告
feed_name: 訂閱名稱
+ enable: 開啟
+ disable: 關閉
+ force_refresh: 強制刷新
+ unsubscribe: 解除訂閱
+ successful: 刷新成功
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index eb2199f..be470df 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -15,6 +15,7 @@ Rails.application.routes.draw do
get '/feeds/announcements' => 'feeds#announcements'
post '/feeds/process_annc' => 'feeds#process_annc'
get '/feeds/annc_content' => 'feeds#annc_content'
+ post "/feeds/force_refresh", to: 'feeds#force_refresh'
end
end