From e055502fe81469d1f96f41e3dbf70d2ed9ac33fe Mon Sep 17 00:00:00 2001 From: hukl Date: Sun, 8 Mar 2009 23:45:52 +0100 Subject: added basic preview feature. If a draft exists, the show action renders a proper preview. If not the default show template is rendered. --- app/controllers/nodes_controller.rb | 10 +++++++++- app/views/layouts/application.html.erb | 3 ++- app/views/nodes/_preview.html.erb | 5 +++++ app/views/nodes/show.html.erb | 6 +++--- public/stylesheets/styled.css | 13 +++++++++++++ 5 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 app/views/nodes/_preview.html.erb diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 81ead62..f82ab82 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -40,7 +40,15 @@ class NodesController < ApplicationController end def show - @nodes = Node.find(params[:id]).children + @page = Node.find(params[:id]).draft + + if @page + template = @page.valid_template + render( + :file => template, + :layout => "application" + ) + end end def edit diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1446e14..e6317fd 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -12,10 +12,11 @@ + <%= render :partial => 'nodes/preview' if params[:action] == "show" %> - +