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 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/controllers/nodes_controller.rb') 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 -- cgit v1.3 From 55bc7e53f260bda99fd007d3422b264e1f4f6124 Mon Sep 17 00:00:00 2001 From: hukl Date: Mon, 9 Mar 2009 00:01:33 +0100 Subject: after creating a node, edit it rather than showing it --- app/controllers/nodes_controller.rb | 2 +- test/functional/nodes_controller_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/controllers/nodes_controller.rb') diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index f82ab82..0c961b7 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -32,7 +32,7 @@ class NodesController < ApplicationController if parent and @node.save @node.move_to_child_of parent - redirect_to(@node) + redirect_to(edit_node_path(@node)) else @node.errors.add("Parent node") render :action => :new diff --git a/test/functional/nodes_controller_test.rb b/test/functional/nodes_controller_test.rb index fdeb6cb..edc49b6 100644 --- a/test/functional/nodes_controller_test.rb +++ b/test/functional/nodes_controller_test.rb @@ -19,7 +19,7 @@ class NodesControllerTest < ActionController::TestCase def test_create login_as :quentin post :create, :node => {:slug => 'foobar'}, :parent_id => Node.root.id - assert_redirected_to node_path(Node.last) + assert_redirected_to edit_node_path(Node.last) end def test_editing_a_node -- cgit v1.3