Commit d5cce900998ddf80f8e6000da90face3243eb6af
1 parent
91938c6e
Exists in
master
and in
29 other branches
Change routes from embed controller
(ActionItem3031)
Showing
5 changed files
with
10 additions
and
14 deletions
Show diff stats
app/controllers/embed_controller.rb
| 1 | 1 | class EmbedController < ApplicationController |
| 2 | + layout 'embed' | |
| 2 | 3 | |
| 3 | - def index | |
| 4 | - block = Block.find(params[:id]) | |
| 5 | - source = params[:source] | |
| 6 | - | |
| 7 | - if !block.embedable? || !block.visible? | |
| 8 | - render :template => 'shared/embed_unavailable.rhtml', :status => 403, :layout => "embed" | |
| 9 | - else | |
| 10 | - locals = {:source => source, :block => block} | |
| 11 | - render 'embed/index', :layout => 'embed', :locals => locals | |
| 4 | + def block | |
| 5 | + @block = Block.find(params[:id]) | |
| 6 | + @source = params[:source] | |
| 7 | + if !@block.embedable? || !@block.visible? | |
| 8 | + render :template => 'shared/embed_unavailable.rhtml', :status => 403 | |
| 12 | 9 | end |
| 13 | - | |
| 14 | 10 | rescue ActiveRecord::RecordNotFound |
| 15 | - render :template => 'shared/embed_not_found.rhtml', :status => 404, :layout => "embed" | |
| 11 | + render :template => 'shared/embed_not_found.rhtml', :status => 404 | |
| 16 | 12 | end |
| 17 | 13 | |
| 18 | 14 | end | ... | ... |
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +<%= display_block(@block) %> | ... | ... |
app/views/embed/index.html.erb
| ... | ... | @@ -1 +0,0 @@ |
| 1 | -<%= display_block(block) %> |
config/routes.rb
| ... | ... | @@ -32,7 +32,7 @@ ActionController::Routing::Routes.draw do |map| |
| 32 | 32 | map.connect 'user_themes/*stuff', :controller => 'not_found', :action => 'nothing' |
| 33 | 33 | |
| 34 | 34 | # embed controller |
| 35 | - map.embed_block 'embed/block/:id', :controller => 'embed', :action => 'index', :id => /\d+/ | |
| 35 | + map.embed 'embed/:action/:id', :controller => 'embed', :id => /\d+/ | |
| 36 | 36 | |
| 37 | 37 | # online documentation |
| 38 | 38 | map.doc 'doc', :controller => 'doc', :action => 'index' | ... | ... |
test/integration/routing_test.rb
| ... | ... | @@ -271,7 +271,7 @@ class RoutingTest < ActionController::IntegrationTest |
| 271 | 271 | end |
| 272 | 272 | |
| 273 | 273 | should 'have route to get HTML code of Blocks to embed' do |
| 274 | - assert_routing('/embed/block/12345', :controller => 'embed', :action => 'index', :id => '12345') | |
| 274 | + assert_routing('/embed/block/12345', :controller => 'embed', :action => 'block', :id => '12345') | |
| 275 | 275 | end |
| 276 | 276 | |
| 277 | 277 | end | ... | ... |