Commit 91c785925dd2ca16d6f4c3014606a57c63c214ee
1 parent
705a8ec6
Exists in
master
and in
22 other branches
add infra to embed track block
Showing
6 changed files
with
46 additions
and
7 deletions
Show diff stats
app/controllers/embed_controller.rb
1 | 1 | class EmbedController < ApplicationController |
2 | 2 | |
3 | - #no_design_blocks | |
4 | - no_design_theme | |
3 | + def embed_block | |
4 | + block = Block.find(params[:id]) | |
5 | + source = params[:source] | |
5 | 6 | |
6 | - def index | |
7 | - end | |
7 | + if !block.visible? | |
8 | + render :template => 'shared/embed_denied.rhtml', :status => 403, :layout => "embed-block" | |
9 | + else | |
10 | + locals = {:source => source, :block => block} | |
11 | + render 'embed/index', :layout => 'embed-block', :locals => locals | |
12 | + end | |
8 | 13 | |
14 | + rescue ActiveRecord::RecordNotFound | |
15 | + render :template => 'shared/embed_not_found.rhtml', :status => 404, :layout => "embed-block" | |
16 | + end | |
9 | 17 | end | ... | ... |
app/views/embed/index.html.erb
... | ... | @@ -0,0 +1,23 @@ |
1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
2 | +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= html_language %>" lang="<%= html_language %>"> | |
3 | + <head> | |
4 | + <title>Noosfero embed block</title> | |
5 | + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
6 | + <%= noosfero_stylesheets %> | |
7 | + <%= noosfero_javascript %> | |
8 | + </head> | |
9 | + | |
10 | + <body id="embed-body"> | |
11 | + <div id="embed-content"> | |
12 | + <%= yield %> | |
13 | + </div> | |
14 | + | |
15 | + <script type="text/javascript"> | |
16 | + jQuery(document).ready(function(){ | |
17 | + jQuery('a').attr('target','_blank'); | |
18 | + }); | |
19 | + </script> | |
20 | + | |
21 | + </body> | |
22 | + | |
23 | +</html> | ... | ... |
... | ... | @@ -0,0 +1,6 @@ |
1 | +<div id='not-found'> | |
2 | + <p> | |
3 | + <%= _('You may have clicked an expired link or mistyped the address.') %> | |
4 | + <%= _('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.') %> | |
5 | + </p> | |
6 | +</div> | ... | ... |
config/routes.rb
... | ... | @@ -32,8 +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 'embed', :controller => 'embed', :action => 'index' | |
36 | - map.embed_block 'embed/:block/', :controller => 'embed', :action => 'block' | |
35 | + map.embed_block 'embed/block/:id', :controller => 'embed', :action => 'embed_block', :id => /.+/ | |
37 | 36 | |
38 | 37 | # online documentation |
39 | 38 | map.doc 'doc', :controller => 'doc', :action => 'index' | ... | ... |