Commit 417935cc972d1e6b3947441d67845ed980693251

Authored by Antonio Terceiro
1 parent 03101c7a

Add a Raw HTML block

(ActionItem1652)
app/controllers/admin/environment_design_controller.rb
... ... @@ -3,7 +3,7 @@ class EnvironmentDesignController < BoxOrganizerController
3 3 protect 'edit_environment_design', :environment
4 4  
5 5 def available_blocks
6   - @available_blocks ||= [ ArticleBlock, LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, PeopleBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock ]
  6 + @available_blocks ||= [ ArticleBlock, LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, PeopleBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock, RawHTMLBlock ]
7 7 end
8 8  
9 9 end
... ...
app/models/raw_html_block.rb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +class RawHTMLBlock < Block
  2 +
  3 + def self.description
  4 + _('Raw HTML')
  5 + end
  6 +
  7 + settings_items :html, :type => :text
  8 +
  9 + def content
  10 + (title.blank? ? '' : block_title(title)) + html.to_s
  11 + end
  12 +
  13 +end
... ...
app/views/box_organizer/_raw_html_block.rhtml 0 → 100644
... ... @@ -0,0 +1 @@
  1 +<%= labelled_form_field(_('HTML code'), text_area(:block, :html, :style => 'width: 100%', :rows => 15)) %>
... ...
test/unit/raw_html_block_test.rb 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +require File.dirname(__FILE__) + '/../test_helper'
  2 +
  3 +class RawHTMLBlockTest < ActiveSupport::TestCase
  4 +
  5 + should 'describe itself' do
  6 + assert_not_equal Block.description, RawHTMLBlock.description
  7 + end
  8 +
  9 + should 'store HTML' do
  10 + block = RawHTMLBlock.new(:html => '<strong>HTML!</strong>')
  11 + assert_equal '<strong>HTML!</strong>', block.html
  12 + end
  13 +
  14 + should 'not filter HTML' do
  15 + html = '<script type="text/javascript">alert("Hello, world")</script>"'
  16 + block = RawHTMLBlock.new(:html => html)
  17 + assert_equal html, block.html
  18 + end
  19 +
  20 + should 'return html as content' do
  21 + block = RawHTMLBlock.new(:html => "HTML")
  22 + assert_match(/HTML$/, block.content)
  23 + end
  24 +
  25 +end
... ...