replace rss format with json in announcement
This commit is contained in:
parent
452b1525de
commit
114ca5493a
|
@ -1,6 +1,7 @@
|
||||||
class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendController
|
class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendController
|
||||||
include OrbitControllerLib::DivisionForDisable
|
include OrbitControllerLib::DivisionForDisable
|
||||||
before_filter :for_app_manager,:except => [:index,:get_categorys_json,:get_bulletins_json]
|
# if someone want to use json format replace with rss, please add :get_bulletins_json to below
|
||||||
|
before_filter :for_app_manager,:except => [:index,:get_categorys_json]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@bulletin_categorys = get_categories_for_index("BulletinCategory")
|
@bulletin_categorys = get_categories_for_index("BulletinCategory")
|
||||||
|
@ -22,7 +23,15 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
|
||||||
categorys.each do |c|
|
categorys.each do |c|
|
||||||
data << {
|
data << {
|
||||||
category: c.title,
|
category: c.title,
|
||||||
link: "http://#{request.host_with_port}#{panel_announcement_back_end_bulletin_category_get_bulletins_json_path(c)}"
|
# this is a json format
|
||||||
|
# link: "http://#{request.host_with_port}#{panel_announcement_back_end_bulletin_category_get_bulletins_json_path(c)}"
|
||||||
|
# remember to uncommand a rule in route.rb, too
|
||||||
|
link: "#{url_for( :action => "index",
|
||||||
|
:controller => "panel/announcement/front_end/bulletins",
|
||||||
|
:format => :rss,
|
||||||
|
:only_path => false,
|
||||||
|
:inner=>true,
|
||||||
|
:category_id => c )}"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super
|
super
|
||||||
@app_title = 'announcement'
|
@app_title = 'announcement'
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /bulletins
|
# GET /bulletins
|
||||||
# GET /bulletins.xml
|
# GET /bulletins.xml
|
||||||
def index_bulletins_by_unit
|
def index_bulletins_by_unit
|
||||||
|
@ -14,14 +14,15 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@item = Page.find(params[:page_id])
|
@item = Page.find(params[:page_id]) rescue nil
|
||||||
|
if @item
|
||||||
if @item.frontend_data_count
|
if @item.frontend_data_count
|
||||||
@page_num = @item.frontend_data_count
|
@page_num = @item.frontend_data_count
|
||||||
else
|
else
|
||||||
@page_num = 15
|
@page_num = 15
|
||||||
end
|
end
|
||||||
@frontend_style = @item.frontend_style
|
@frontend_style = @item.frontend_style
|
||||||
|
end
|
||||||
|
|
||||||
@page = Page.find(params[:page_id]) rescue nil
|
@page = Page.find(params[:page_id]) rescue nil
|
||||||
if !params[:search_query].blank?
|
if !params[:search_query].blank?
|
||||||
|
@ -54,9 +55,9 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
end
|
end
|
||||||
impressionist(@tag) if @tag
|
impressionist(@tag) if @tag
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@page = Page.find(params[:page_id]) rescue nil
|
@page = Page.find(params[:page_id]) rescue nil
|
||||||
if params[:preview] == "true"
|
if params[:preview] == "true"
|
||||||
|
@ -71,22 +72,22 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
|
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :nothing => true, :status => 403
|
render :nothing => true, :status => 403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def preview_content
|
def preview_content
|
||||||
@bulletin = Bulletin.find params[:id] rescue nil
|
@bulletin = Bulletin.find params[:id] rescue nil
|
||||||
@bulletin = Preview.find(params[:id]).get_virtual_object if @bulletin.nil?
|
@bulletin = Preview.find(params[:id]).get_virtual_object if @bulletin.nil?
|
||||||
get_categorys
|
get_categorys
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def get_categorys
|
def get_categorys
|
||||||
@bulletin_categorys = BulletinCategory.all
|
@bulletin_categorys = BulletinCategory.all
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
xml.instruct! :xml, :version => "1.0"
|
xml.instruct! :xml, :version => "1.0"
|
||||||
xml.rss :version => "2.0" do
|
xml.rss :version => "2.0" do
|
||||||
xml.channel do
|
xml.channel do
|
||||||
if @current_category
|
if @current_category
|
||||||
xml.title @current_category.title_translations[I18n.locale.to_s]
|
xml.title @current_category.title_translations[I18n.locale.to_s]
|
||||||
else
|
else
|
||||||
xml.title t('announcement.announcement')
|
xml.title t('announcement.announcement')
|
||||||
end
|
end
|
||||||
xml.link url_for(:action=>"index", :controller=>"panel/announcement/front_end/bulletins",:format=> :rss,:only_path=>false,:inner=>true)
|
xml.link url_for(:action=>"index", :controller=>"panel/announcement/front_end/bulletins",:format=> :rss,:only_path=>false,:inner=>true)
|
||||||
|
|
||||||
for bulletin in @bulletins
|
for bulletin in @bulletins
|
||||||
xml.item do
|
xml.item do
|
||||||
xml.title bulletin.title_translations[I18n.locale.to_s]
|
xml.title bulletin.title_translations[I18n.locale.to_s]
|
||||||
|
@ -18,4 +18,4 @@ xml.rss :version => "2.0" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ Rails.application.routes.draw do
|
||||||
match 'approval_setting' => "approvals#setting" ,:as => :approval_setting,:via => :get
|
match 'approval_setting' => "approvals#setting" ,:as => :approval_setting,:via => :get
|
||||||
match 'approval_setting' => "approvals#update_setting" ,:as => :approval_setting,:via => :post
|
match 'approval_setting' => "approvals#update_setting" ,:as => :approval_setting,:via => :post
|
||||||
match 'approval_setting' => "approvals#user_list" ,:as => :approval_user_list,:via => :put
|
match 'approval_setting' => "approvals#user_list" ,:as => :approval_user_list,:via => :put
|
||||||
#match 'get_bulletins_json' => "bulletins#get_bulletins_json" ,:as => :bulletins_json_list,:via => :get
|
|
||||||
resources :bulletins do
|
resources :bulletins do
|
||||||
match "approve/:bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put
|
match "approve/:bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put
|
||||||
match "approve/:bulletin_id" => "approvals#approve",:as => :approve,:via => :post
|
match "approve/:bulletin_id" => "approvals#approve",:as => :approve,:via => :post
|
||||||
|
@ -29,7 +29,9 @@ Rails.application.routes.draw do
|
||||||
collection do
|
collection do
|
||||||
get 'get_categorys_json'
|
get 'get_categorys_json'
|
||||||
end
|
end
|
||||||
match "get_bulletins_json/" => "bulletin_categorys#get_bulletins_json", :as => :get_bulletins_json
|
# if want to use json
|
||||||
|
# please uncommand below line
|
||||||
|
# match "get_bulletins_json/" => "bulletin_categorys#get_bulletins_json", :as => :get_bulletins_json
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :bulletin_links, :controller => 'bulletin_links' do
|
resources :bulletin_links, :controller => 'bulletin_links' do
|
||||||
|
|
Reference in New Issue