diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rb index 692243a..99258e1 100644 --- a/app/controllers/embed_controller.rb +++ b/app/controllers/embed_controller.rb @@ -1,9 +1,17 @@ class EmbedController < ApplicationController - #no_design_blocks - no_design_theme + def embed_block + block = Block.find(params[:id]) + source = params[:source] - def index - end + if !block.visible? + render :template => 'shared/embed_denied.rhtml', :status => 403, :layout => "embed-block" + else + locals = {:source => source, :block => block} + render 'embed/index', :layout => 'embed-block', :locals => locals + end + rescue ActiveRecord::RecordNotFound + render :template => 'shared/embed_not_found.rhtml', :status => 404, :layout => "embed-block" + end end diff --git a/app/views/embed/index.html.erb b/app/views/embed/index.html.erb index 057e033..324854f 100644 --- a/app/views/embed/index.html.erb +++ b/app/views/embed/index.html.erb @@ -1 +1 @@ -<%= 'bli' %> +<%= display_block(block) %> diff --git a/app/views/layouts/embed-block.rhtml b/app/views/layouts/embed-block.rhtml new file mode 100644 index 0000000..eac5f45 --- /dev/null +++ b/app/views/layouts/embed-block.rhtml @@ -0,0 +1,23 @@ + + + + Noosfero embed block + + <%= noosfero_stylesheets %> + <%= noosfero_javascript %> + + + +
+ <%= yield %> +
+ + + + + + diff --git a/app/views/shared/embed_denied.rhtml b/app/views/shared/embed_denied.rhtml new file mode 100644 index 0000000..1d113ce --- /dev/null +++ b/app/views/shared/embed_denied.rhtml @@ -0,0 +1,3 @@ +
+

<%= _('Embed denied. The requested embed is disable.') %>

+
diff --git a/app/views/shared/embed_not_found.rhtml b/app/views/shared/embed_not_found.rhtml new file mode 100644 index 0000000..49785b8 --- /dev/null +++ b/app/views/shared/embed_not_found.rhtml @@ -0,0 +1,6 @@ +
+

+ <%= _('You may have clicked an expired link or mistyped the address.') %> + <%= _('If you clicked a link that was in another site, or was given to you by someone else, it would be nice if you tell them that their link is not valid anymore.') %> +

+
diff --git a/config/routes.rb b/config/routes.rb index 38db42f..7d07dc8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,8 +32,7 @@ ActionController::Routing::Routes.draw do |map| map.connect 'user_themes/*stuff', :controller => 'not_found', :action => 'nothing' # embed controller - map.embed 'embed', :controller => 'embed', :action => 'index' - map.embed_block 'embed/:block/', :controller => 'embed', :action => 'block' + map.embed_block 'embed/block/:id', :controller => 'embed', :action => 'embed_block', :id => /.+/ # online documentation map.doc 'doc', :controller => 'doc', :action => 'index' -- libgit2 0.21.2