From e256440678be56dec70a372ffc8d277b877cf34c Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 19 Jun 2012 10:49:45 +0800 Subject: [PATCH] RSS first page --- app/controllers/application_controller.rb | 13 +++++++++++- .../front_end/bulletins/index.rss.builder | 21 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.rss.builder diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 109d4742..74274eeb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -101,7 +101,10 @@ class ApplicationController < ActionController::Base # Render the page def render_page if @item - render :text => parse_page_noko(@item), :layout => 'page_layout' + respond_to do |format| + format.html { render :text => parse_page_noko(@item), :layout => 'page_layout' } + format.rss { render_main_rss } + end else render :text => '404 Not Found' end @@ -187,4 +190,12 @@ class ApplicationController < ActionController::Base end end + def render_main_rss + ret = '' + ret << "/panel/#{@item.module_app.key}/front_end/#{@item.app_frontend_url}.rss" + ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(@item.id.to_s) + ret << "?inner=true&category_id=#{params[:category]}&tag_id=#{params[:tag]}&page_main=#{params[:page_main]}" + redirect_to ret + end + end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.rss.builder b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.rss.builder new file mode 100644 index 00000000..c0dd32e0 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.rss.builder @@ -0,0 +1,21 @@ +xml.instruct! :xml, :version => "1.0" +xml.rss :version => "2.0" do + xml.channel do + if @current_category + xml.title @current_category.i18n_variable[I18n.locale] + else + xml.title t('announcement.announcement') + end + xml.link panel_announcement_front_end_bulletins_path(:rss) + + for bulletin in @bulletins + xml.item do + xml.title bulletin.title[I18n.locale] + xml.description bulletin.subtitle[I18n.locale] + xml.pubDate bulletin.postdate.to_s(:rfc822) + xml.link panel_announcement_front_end_bulletin_path(bulletin, :rss) + xml.guid panel_announcement_front_end_bulletin_path(bulletin, :rss) + end + end + end +end \ No newline at end of file