diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rb index 2e0b797..60755e9 100644 --- a/app/controllers/embed_controller.rb +++ b/app/controllers/embed_controller.rb @@ -1,18 +1,14 @@ class EmbedController < ApplicationController + layout 'embed' - def index - block = Block.find(params[:id]) - source = params[:source] - - if !block.embedable? || !block.visible? - render :template => 'shared/embed_unavailable.rhtml', :status => 403, :layout => "embed" - else - locals = {:source => source, :block => block} - render 'embed/index', :layout => 'embed', :locals => locals + def block + @block = Block.find(params[:id]) + @source = params[:source] + if !@block.embedable? || !@block.visible? + render :template => 'shared/embed_unavailable.rhtml', :status => 403 end - rescue ActiveRecord::RecordNotFound - render :template => 'shared/embed_not_found.rhtml', :status => 404, :layout => "embed" + render :template => 'shared/embed_not_found.rhtml', :status => 404 end end diff --git a/app/views/embed/block.html.erb b/app/views/embed/block.html.erb new file mode 100644 index 0000000..e0342ed --- /dev/null +++ b/app/views/embed/block.html.erb @@ -0,0 +1 @@ +<%= display_block(@block) %> diff --git a/app/views/embed/index.html.erb b/app/views/embed/index.html.erb deleted file mode 100644 index 324854f..0000000 --- a/app/views/embed/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= display_block(block) %> diff --git a/config/routes.rb b/config/routes.rb index 2098151..90b20fa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,7 +32,7 @@ ActionController::Routing::Routes.draw do |map| map.connect 'user_themes/*stuff', :controller => 'not_found', :action => 'nothing' # embed controller - map.embed_block 'embed/block/:id', :controller => 'embed', :action => 'index', :id => /\d+/ + map.embed 'embed/:action/:id', :controller => 'embed', :id => /\d+/ # online documentation map.doc 'doc', :controller => 'doc', :action => 'index' diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 8e9c690..2be6bf6 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -271,7 +271,7 @@ class RoutingTest < ActionController::IntegrationTest end should 'have route to get HTML code of Blocks to embed' do - assert_routing('/embed/block/12345', :controller => 'embed', :action => 'index', :id => '12345') + assert_routing('/embed/block/12345', :controller => 'embed', :action => 'block', :id => '12345') end end -- libgit2 0.21.2