From 705a8ec6d14f104715a7f8d994de99c39ca92b9f Mon Sep 17 00:00:00 2001 From: Francisco Marcelo de Araújo Lima Júnior Date: Tue, 18 Feb 2014 19:29:16 -0300 Subject: [PATCH] add infra to embed feature --- app/controllers/application_controller.rb | 11 +++++++++++ app/controllers/embed_controller.rb | 9 +++++++++ app/helpers/boxes_helper.rb | 12 ++++++++++++ app/helpers/thickbox_helper.rb | 3 +++ app/views/embed/index.html.erb | 1 + config/routes.rb | 4 ++++ public/designs/icons/tango/style.css | 2 ++ public/javascripts/thickbox.js | 4 ++++ 8 files changed, 46 insertions(+), 0 deletions(-) create mode 100644 app/controllers/embed_controller.rb create mode 100644 app/views/embed/index.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6e1f0f8..389aeea 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -55,6 +55,17 @@ class ApplicationController < ActionController::Base !@no_design_blocks && self.class.uses_design_blocks? end + def self.no_design_theme + @no_design_theme + end + def self.uses_design_theme? + !@no_design_theme + end + def uses_design_theme + !@no_design_theme && self.class.uses_design_theme? + end + + # Be sure to include AuthenticationSystem in Application Controller instead include AuthenticatedSystem include PermissionCheck diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rb new file mode 100644 index 0000000..692243a --- /dev/null +++ b/app/controllers/embed_controller.rb @@ -0,0 +1,9 @@ +class EmbedController < ApplicationController + + #no_design_blocks + no_design_theme + + def index + end + +end diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb index 8045453..4ce343a 100644 --- a/app/helpers/boxes_helper.rb +++ b/app/helpers/boxes_helper.rb @@ -219,6 +219,18 @@ module BoxesHelper buttons << thickbox_inline_popup_icon(:help, _('Help on this block'), {}, "help-on-box-#{block.id}") << content_tag('div', content_tag('h2', _('Help')) + content_tag('div', block.help, :style => 'margin-bottom: 1em;') + thickbox_close_button(_('Close')), :style => 'display: none;', :id => "help-on-box-#{block.id}") end + #if block.respond_to?(:embedable) + if true + html = content_tag('div', + content_tag('h2', _('Embed code')) + + 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;') + + content_tag('textarea', '*This is the embed code for this block!*', :style => 'margin-bottom: 1em; width:100%; height:40%;') + + thickbox_copy_to_clipboard_button(_('Copy to clipboard')) + + thickbox_close_button(_('Close')), :style => 'display: none;', :id => "embed-code-box-#{block.id}") + + buttons << thickbox_inline_popup_icon(:embed, _('Embed code'), {}, "embed-code-box-#{block.id}") << html + end + content_tag('div', buttons.join("\n") + tag('br', :style => 'clear: left'), :class => 'button-bar') end diff --git a/app/helpers/thickbox_helper.rb b/app/helpers/thickbox_helper.rb index 376dd4f..d42b8fa 100644 --- a/app/helpers/thickbox_helper.rb +++ b/app/helpers/thickbox_helper.rb @@ -8,4 +8,7 @@ module ThickboxHelper def thickbox_close_button(title) button_to_function(:close, title, 'tb_remove();') end + def thickbox_copy_to_clipboard_button(title) + button_to_function(:'copy-to-clipboard', title, 'tb_copy_to_clipboard();') + end end diff --git a/app/views/embed/index.html.erb b/app/views/embed/index.html.erb new file mode 100644 index 0000000..057e033 --- /dev/null +++ b/app/views/embed/index.html.erb @@ -0,0 +1 @@ +<%= 'bli' %> diff --git a/config/routes.rb b/config/routes.rb index e4b4f2c..38db42f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,6 +31,10 @@ ActionController::Routing::Routes.draw do |map| map.connect 'thumbnails/*stuff', :controller => 'not_found', :action => 'nothing' 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' + # online documentation map.doc 'doc', :controller => 'doc', :action => 'index' map.doc_section 'doc/:section', :controller => 'doc', :action => 'section' diff --git a/public/designs/icons/tango/style.css b/public/designs/icons/tango/style.css index 48a1afe..9ae8f80 100644 --- a/public/designs/icons/tango/style.css +++ b/public/designs/icons/tango/style.css @@ -1,4 +1,6 @@ /******************SMALL ICONS********************/ +.icon-embed { background-image: url(Tango/16x16/apps/utilities-terminal.png) } +.icon-copy-to-clipboard { background-image: url(Tango/16x16/actions/gtk-copy.png) } .icon-edit { background-image: url(Tango/16x16/apps/text-editor.png) } .icon-home { background-image: url(Tango/16x16/actions/go-home.png) } .icon-home-not { background-image: url(mod/16x16/actions/go-home-not.png) } diff --git a/public/javascripts/thickbox.js b/public/javascripts/thickbox.js index 411e233..d5694df 100644 --- a/public/javascripts/thickbox.js +++ b/public/javascripts/thickbox.js @@ -265,6 +265,10 @@ function tb_showIframe(){ jQuery("#TB_window").css({display:"block"}); } +function tb_copy_to_clipboard() { + alert('Text copied to clipboard!'); +} + function tb_remove() { jQuery("#TB_imageOff").unbind("click"); jQuery("#TB_closeWindowButton").unbind("click"); -- libgit2 0.21.2