diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/application_controller.rb | 16 | ||||
-rw-r--r-- | app/controllers/pages_controller.rb | 16 |
2 files changed, 31 insertions, 1 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 240df61..da6cf3e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -64,6 +64,22 @@ class ApplicationController < ActionController::Base end end + # + # same as render page, but returns the string + # + def page_body(page) + begin + render_to_string :template => page.template_path + rescue ActionView::MissingTemplate => exc + begin + render_to_string :template => page.template_path(DEFAULT_LOCALE) + rescue + raise exc + end + end + end + helper_method :page_body + ## ## INITIALIZATION ## diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index c86f313..d4fa09a 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -9,7 +9,10 @@ class PagesController < ApplicationController def show @page = StaticPage.find(params[:page]) if @page - render_page(@page) + respond_to do |format| + format.atom { render_atom_feed(@page) } + format.all { render_page(@page) } + end else raise PageNotFound.new end @@ -25,5 +28,16 @@ class PagesController < ApplicationController end end + def render_atom_feed(root) + if root + @pages = root.all_children.order_by(:posted_at, :direction => :desc).limit(PAGINATION_SIZE) + if @pages.any? + render :file => 'layouts/blog/feed', :layout => false, :content_type => 'application/atom+xml' + else + render_404 + end + end + end + end |