Commit 019bbf17426e83a2decf98d0fbf6b08e2b9df094

Authored by Francisco Marcelo de Araújo Lima Júnior
1 parent 91c78592

add infra to embed track block

app/controllers/embed_controller.rb
... ... @@ -5,13 +5,13 @@ class EmbedController < ApplicationController
5 5 source = params[:source]
6 6  
7 7 if !block.visible?
8   - render :template => 'shared/embed_denied.rhtml', :status => 403, :layout => "embed-block"
  8 + render :template => 'shared/embed_denied.rhtml', :status => 403, :layout => "embed"
9 9 else
10 10 locals = {:source => source, :block => block}
11   - render 'embed/index', :layout => 'embed-block', :locals => locals
  11 + render 'embed/index', :layout => 'embed', :locals => locals
12 12 end
13 13  
14 14 rescue ActiveRecord::RecordNotFound
15   - render :template => 'shared/embed_not_found.rhtml', :status => 404, :layout => "embed-block"
  15 + render :template => 'shared/embed_not_found.rhtml', :status => 404, :layout => "embed"
16 16 end
17 17 end
... ...
app/helpers/boxes_helper.rb
... ... @@ -221,11 +221,13 @@ module BoxesHelper
221 221  
222 222 #if block.respond_to?(:embedable)
223 223 if true
  224 +
  225 + url = url_for :controller => 'embed', :action => 'embed_block', :id => block.id, :only_path => false;
  226 +
224 227 html = content_tag('div',
225   - content_tag('h2', _('Embed code')) +
  228 + content_tag('h2', _('Embed block code')) +
226 229 content_tag('div', 'Below, you''ll see a field containing embed code for the block. Just copy the code and paste it into your website or blogging software.', :style => 'margin-bottom: 1em;') +
227   - content_tag('textarea', '*This is the embed code for this block!*', :style => 'margin-bottom: 1em; width:100%; height:40%;') +
228   - thickbox_copy_to_clipboard_button(_('Copy to clipboard')) +
  230 + content_tag('textarea', block.embed_code(url), :style => 'margin-bottom: 1em; width:100%; height:40%;') +
229 231 thickbox_close_button(_('Close')), :style => 'display: none;', :id => "embed-code-box-#{block.id}")
230 232  
231 233 buttons << thickbox_inline_popup_icon(:embed, _('Embed code'), {}, "embed-code-box-#{block.id}") << html
... ...
app/models/block.rb
... ... @@ -16,6 +16,10 @@ class Block &lt; ActiveRecord::Base
16 16  
17 17 named_scope :enabled, :conditions => { :enabled => true }
18 18  
  19 + def embed_code(url)
  20 + html = "<iframe src='#{url}?source=SOURCE_NAME' frameborder='0' allowfullscreen ></iframe>"
  21 + end
  22 +
19 23 # Determines whether a given block must be visible. Optionally a
20 24 # <tt>context</tt> must be specified. <tt>context</tt> must be a hash, and
21 25 # may contain the following keys:
... ...
app/views/layouts/embed-block.rhtml
... ... @@ -1,23 +0,0 @@
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>
app/views/layouts/embed.rhtml 0 → 100644
... ... @@ -0,0 +1,57 @@
  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 +
  7 + <%= noosfero_stylesheets %>
  8 + <%= noosfero_javascript %>
  9 +
  10 + <script type='text/javascript'>
  11 + DEFAULT_LOADING_MESSAGE = <%="'#{ _('loading...') }'" %>;
  12 + </script>
  13 +
  14 + </head>
  15 + <body class="<%= h body_classes %>">
  16 +
  17 + <%=
  18 + @plugins.dispatch(:body_beginning).collect do |content|
  19 + content.respond_to?(:call) ? content.call : content
  20 + end.join("\n")
  21 + %>
  22 +
  23 + <div id="wrap-1">
  24 + <div id="wrap-2">
  25 + <div id="content">
  26 + <div id="content-inner">
  27 + <%= yield %>
  28 + <br style="clear: both" />
  29 + </div>
  30 + </div>
  31 + </div>
  32 + </div>
  33 +
  34 + <script type="text/javascript">
  35 + jQuery(document).ready(function(){
  36 + jQuery('a').attr('target','_blank');
  37 + });
  38 + </script>
  39 +
  40 + <!-- Piwik -->
  41 + <script type="text/javascript">
  42 + var _paq = _paq || [];
  43 + _paq.push(["trackPageView"]);
  44 + _paq.push(["enableLinkTracking"]);
  45 +
  46 + (function() {
  47 + var u="http://estatisticas.presidencia.gov.br/";
  48 + _paq.push(["setTrackerUrl", u+"piwik.php"]);
  49 + _paq.push(["setSiteId", "14"]);
  50 + var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
  51 + g.defer=true; g.async=true; g.src="/javascripts/piwik.js"; s.parentNode.insertBefore(g,s);
  52 + })();
  53 + </script>
  54 + <!-- End Piwik Code -->
  55 +
  56 + </body>
  57 +</html>
... ...
public/designs/icons/tango/style.css
1 1 /******************SMALL ICONS********************/
2 2 .icon-embed { background-image: url(Tango/16x16/apps/utilities-terminal.png) }
3   -.icon-copy-to-clipboard { background-image: url(Tango/16x16/actions/gtk-copy.png) }
4 3 .icon-edit { background-image: url(Tango/16x16/apps/text-editor.png) }
5 4 .icon-home { background-image: url(Tango/16x16/actions/go-home.png) }
6 5 .icon-home-not { background-image: url(mod/16x16/actions/go-home-not.png) }
... ...
public/javascripts/thickbox.js
... ... @@ -265,10 +265,6 @@ function tb_showIframe(){
265 265 jQuery("#TB_window").css({display:"block"});
266 266 }
267 267  
268   -function tb_copy_to_clipboard() {
269   - alert('Text copied to clipboard!');
270   -}
271   -
272 268 function tb_remove() {
273 269 jQuery("#TB_imageOff").unbind("click");
274 270 jQuery("#TB_closeWindowButton").unbind("click");
... ...