Commit 7b79be121b66cfb807bf82121a18213f0e0b4b5f

Authored by Daniela Feitosa
Committed by Joenio Costa
1 parent 3d76539d

Some changes to add a new theme

* Adding div's on blocks, blog, footer and home/index
* Adding separator as argument on language chooser
* Adding slideshowblock on available blocks of Environment

(ActionItem1398)
app/controllers/admin/environment_design_controller.rb
@@ -3,7 +3,7 @@ class EnvironmentDesignController < BoxOrganizerController @@ -3,7 +3,7 @@ class EnvironmentDesignController < BoxOrganizerController
3 protect 'edit_environment_design', :environment 3 protect 'edit_environment_design', :environment
4 4
5 def available_blocks 5 def available_blocks
6 - @available_blocks ||= [ LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, PeopleBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock ] 6 + @available_blocks ||= [ LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, PeopleBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock ]
7 end 7 end
8 8
9 end 9 end
app/helpers/blog_helper.rb
@@ -24,14 +24,18 @@ module BlogHelper @@ -24,14 +24,18 @@ module BlogHelper
24 artic_len = articles.length 24 artic_len = articles.length
25 articles.each_with_index{ |art,i| 25 articles.each_with_index{ |art,i|
26 css_add = [ 'position-'+(i+1).to_s() ] 26 css_add = [ 'position-'+(i+1).to_s() ]
  27 + position = (i%2 == 0) ? 'odd-post' : 'even-post'
27 if art.published? || (user==art.profile) 28 if art.published? || (user==art.profile)
28 css_add << 'first' if i == 0 29 css_add << 'first' if i == 0
29 css_add << 'last' if i == (artic_len-1) 30 css_add << 'last' if i == (artic_len-1)
30 css_add << 'not-published' if !art.published? 31 css_add << 'not-published' if !art.published?
  32 + css_add << position + '-inner'
31 content << content_tag('div', 33 content << content_tag('div',
  34 + content_tag('div',
32 display_post(art) + '<br style="clear:both"/>', 35 display_post(art) + '<br style="clear:both"/>',
33 :class => 'blog-post ' + css_add.join(' '), 36 :class => 'blog-post ' + css_add.join(' '),
34 - :id => "post-#{art.id}") 37 + :id => "post-#{art.id}"), :class => position
  38 + )
35 end 39 end
36 } 40 }
37 content.join("\n<hr class='sep-posts'/>\n") + (pagination or '') 41 content.join("\n<hr class='sep-posts'/>\n") + (pagination or '')
app/helpers/boxes_helper.rb
@@ -8,7 +8,13 @@ module BoxesHelper @@ -8,7 +8,13 @@ module BoxesHelper
8 if @controller.send(:uses_design_blocks?) 8 if @controller.send(:uses_design_blocks?)
9 display_boxes(@controller.boxes_holder, content) 9 display_boxes(@controller.boxes_holder, content)
10 else 10 else
11 - content_tag('div', content, :class => 'no-boxes') 11 + content_tag('div',
  12 + content_tag('div',
  13 + content_tag('div', content, :class => 'no-boxes-inner-2'),
  14 + :class => 'no-boxes-inner-1'
  15 + ),
  16 + :class => 'no-boxes'
  17 + )
12 end + 18 end +
13 maybe_display_custom_element(@controller.boxes_holder, :custom_footer_expanded, :id => 'profile-footer') 19 maybe_display_custom_element(@controller.boxes_holder, :custom_footer_expanded, :id => 'profile-footer')
14 end 20 end
@@ -95,8 +101,13 @@ module BoxesHelper @@ -95,8 +101,13 @@ module BoxesHelper
95 end 101 end
96 102
97 box_decorator.block_target(block.box, block) + 103 box_decorator.block_target(block.box, block) +
98 - content_tag('div', result + footer_content + box_decorator.block_edit_buttons(block),  
99 - options) + 104 + content_tag('div',
  105 + content_tag('div',
  106 + content_tag('div',
  107 + result + footer_content + box_decorator.block_edit_buttons(block),
  108 + :class => 'block-inner-2'),
  109 + :class => 'block-inner-1'),
  110 + options) +
100 box_decorator.block_handle(block) 111 box_decorator.block_handle(block)
101 end 112 end
102 113
app/helpers/language_helper.rb
@@ -20,6 +20,7 @@ module LanguageHelper @@ -20,6 +20,7 @@ module LanguageHelper
20 20
21 def language_chooser(options = {}) 21 def language_chooser(options = {})
22 current = language 22 current = language
  23 + separator = options[:separator] || ' &mdash; '
23 24
24 if options[:element] == 'dropdown' 25 if options[:element] == 'dropdown'
25 select_tag('lang', 26 select_tag('lang',
@@ -34,7 +35,7 @@ module LanguageHelper @@ -34,7 +35,7 @@ module LanguageHelper
34 else 35 else
35 link_to(name, params.merge(:lang => code), :rel => 'nofollow') 36 link_to(name, params.merge(:lang => code), :rel => 'nofollow')
36 end 37 end
37 - end.join(' &mdash; ') 38 + end.join(separator)
38 content_tag('div', languages, :id => 'language-chooser', :help => _('The language you choose here is the language used for options, buttons, etc. It does not affect the language of the content created by other users.')) 39 content_tag('div', languages, :id => 'language-chooser', :help => _('The language you choose here is the language used for options, buttons, etc. It does not affect the language of the content created by other users.'))
39 end 40 end
40 end 41 end
app/views/home/index.rhtml
@@ -8,15 +8,17 @@ @@ -8,15 +8,17 @@
8 <div id='highlighted-news'> 8 <div id='highlighted-news'>
9 <% @highlighted_news.each_with_index do |highlighted, index| %> 9 <% @highlighted_news.each_with_index do |highlighted, index| %>
10 <div class='highlighted-news-item post-<%= index + 1 %>'> 10 <div class='highlighted-news-item post-<%= index + 1 %>'>
11 - <h2><%= link_to(highlighted.title, highlighted.url, :class => 'post-title') %></h2>  
12 - <span class="post-date"><%= show_date(highlighted.published_at, true) %> </span></p>  
13 - <p class='headline'><%= highlighted.first_paragraph %></p>  
14 - <p class='highlighted-news-read-more'>  
15 - <%= link_to(_('Read more'), highlighted.url) %>  
16 - </p>  
17 - <br style='clear:both' /> 11 + <div class='highlighted-news-item post-<%= index + 1 %>-inner'>
  12 + <h2><%= link_to(highlighted.title, highlighted.url, :class => 'post-title') %></h2>
  13 + <span class="post-date"><%= show_date(highlighted.published_at, true) %> </span></p>
  14 + <p class='headline'><%= highlighted.first_paragraph %></p>
  15 + <p class='highlighted-news-read-more'>
  16 + <%= link_to(_('Read more'), highlighted.url) %>
  17 + </p>
  18 + <br style='clear:both' />
  19 + </div>
18 </div> 20 </div>
19 - <% end%> 21 + <% end %>
20 </div> 22 </div>
21 23
22 <div class='sep'></div> 24 <div class='sep'></div>
@@ -28,7 +30,7 @@ @@ -28,7 +30,7 @@
28 <span class="post-date"><%= show_date(news.published_at, true) %> </span> 30 <span class="post-date"><%= show_date(news.published_at, true) %> </span>
29 <%= link_to(news.title, news.url, :class => 'post-title' ) %> 31 <%= link_to(news.title, news.url, :class => 'post-title' ) %>
30 </li> 32 </li>
31 - <% end%> 33 + <% end %>
32 </ul> 34 </ul>
33 </div> 35 </div>
34 36
@@ -36,14 +38,18 @@ @@ -36,14 +38,18 @@
36 38
37 <% @area_news.each_with_index do |folder, i| %> 39 <% @area_news.each_with_index do |folder, i| %>
38 <% content_tag(:div, :class => ["news-area", ['even', 'odd'][i%2]].join(' ')) do %> 40 <% content_tag(:div, :class => ["news-area", ['even', 'odd'][i%2]].join(' ')) do %>
39 - <h3><%= link_to folder.title, folder.url %></h3>  
40 - <ul>  
41 - <% folder.news(environment.news_amount_by_folder).each do |news| %>  
42 - <li> <%= link_to(news.title, news.url) %></li>  
43 - <% end%>  
44 - </ul>  
45 - <%= link_to _('View more'), folder.url, :class => 'news-see-more' %>  
46 - <%end %> 41 + <% content_tag(:div, :class => 'news-area-inner-1') do %>
  42 + <% content_tag(:div, :class => 'news-area-inner-2') do %>
  43 + <h3><%= link_to folder.title, folder.url %></h3>
  44 + <ul>
  45 + <% folder.news(environment.news_amount_by_folder).each do |news| %>
  46 + <li> <%= link_to(news.title, news.url) %></li>
  47 + <% end%>
  48 + </ul>
  49 + <%= link_to _('View more'), folder.url, :class => 'news-see-more' %>
  50 + <% end %>
  51 + <% end %>
  52 + <% end %>
47 <% end %> 53 <% end %>
48 <% end %> 54 <% end %>
49 <% else %> 55 <% else %>
test/functional/environment_design_controller_test.rb
@@ -27,6 +27,10 @@ class EnvironmentDesignControllerTest &lt; Test::Unit::TestCase @@ -27,6 +27,10 @@ class EnvironmentDesignControllerTest &lt; Test::Unit::TestCase
27 assert_includes @controller.available_blocks, LinkListBlock 27 assert_includes @controller.available_blocks, LinkListBlock
28 end 28 end
29 29
  30 + should 'SlideshowBlock be available' do
  31 + assert_includes @controller.available_blocks, SlideshowBlock
  32 + end
  33 +
30 should 'be able to edit LinkListBlock' do 34 should 'be able to edit LinkListBlock' do
31 login_as(create_admin_user(Environment.default)) 35 login_as(create_admin_user(Environment.default))
32 l = LinkListBlock.create!(:links => [{:name => 'link 1', :address => '/address_1'}]) 36 l = LinkListBlock.create!(:links => [{:name => 'link 1', :address => '/address_1'}])
test/unit/blog_helper_test.rb
@@ -21,7 +21,8 @@ class BlogHelperTest &lt; Test::Unit::TestCase @@ -21,7 +21,8 @@ class BlogHelperTest &lt; Test::Unit::TestCase
21 blog.children << published_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => true) 21 blog.children << published_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => true)
22 22
23 expects(:display_post).with(anything).returns('POST') 23 expects(:display_post).with(anything).returns('POST')
24 - expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-1 first last', :id => "post-#{published_post.id}").returns('RESULT') 24 + expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-1 first last odd-post-inner', :id => "post-#{published_post.id}").returns('POST')
  25 + expects(:content_tag).with('div', 'POST', {:class => 'odd-post'}).returns('RESULT')
25 26
26 assert_equal 'RESULT', list_posts(profile, blog.posts) 27 assert_equal 'RESULT', list_posts(profile, blog.posts)
27 end 28 end
@@ -30,8 +31,8 @@ class BlogHelperTest &lt; Test::Unit::TestCase @@ -30,8 +31,8 @@ class BlogHelperTest &lt; Test::Unit::TestCase
30 blog.children << unpublished_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false) 31 blog.children << unpublished_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false)
31 32
32 expects(:display_post).with(anything).returns('POST') 33 expects(:display_post).with(anything).returns('POST')
33 - expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-1 first last not-published', :id => "post-#{unpublished_post.id}").returns('RESULT')  
34 - 34 + expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-1 first last not-published odd-post-inner', :id => "post-#{unpublished_post.id}").returns('POST')
  35 + expects(:content_tag).with('div', 'POST', {:class => 'odd-post'}).returns('RESULT')
35 assert_equal 'RESULT', list_posts(profile, blog.posts) 36 assert_equal 'RESULT', list_posts(profile, blog.posts)
36 end 37 end
37 38
@@ -41,12 +42,29 @@ class BlogHelperTest &lt; Test::Unit::TestCase @@ -41,12 +42,29 @@ class BlogHelperTest &lt; Test::Unit::TestCase
41 blog.children << published_post = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true) 42 blog.children << published_post = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true)
42 43
43 expects(:display_post).with(anything).returns('POST') 44 expects(:display_post).with(anything).returns('POST')
44 - expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", has_entries(:id => "post-#{published_post.id}")).returns('RESULT')  
45 expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", has_entries(:id => "post-#{unpublished_post.id}")).never 45 expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", has_entries(:id => "post-#{unpublished_post.id}")).never
46 - 46 + expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", has_entries(:id => "post-#{published_post.id}")).returns('POST')
  47 + expects(:content_tag).with('div', 'POST', {:class => 'odd-post'}).returns('RESULT')
47 assert_equal 'RESULT', list_posts(nil, blog.posts) 48 assert_equal 'RESULT', list_posts(nil, blog.posts)
48 end 49 end
49 50
  51 + should 'list even/odd posts with a different class' do
  52 + blog.children << older_post = TextileArticle.create!(:name => 'First post', :profile => profile, :parent => blog, :published => true)
  53 +
  54 + blog.children << newer_post = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true)
  55 +
  56 + expects(:display_post).with(anything).returns('POST').times(2)
  57 +
  58 + expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-1 first odd-post-inner', :id => "post-#{newer_post.id}").returns('POST 1')
  59 + expects(:content_tag).with('div', "POST 1", :class => 'odd-post').returns('ODD-POST')
  60 +
  61 + expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-2 last even-post-inner', :id => "post-#{older_post.id}").returns('POST 2')
  62 + expects(:content_tag).with('div', "POST 2", :class => 'even-post').returns('EVEN-POST')
  63 +
  64 + assert_equal "ODD-POST\n<hr class='sep-posts'/>\nEVEN-POST", list_posts(nil, blog.posts)
  65 + end
  66 +
  67 +
50 should 'display post' do 68 should 'display post' do
51 blog.children << article = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true) 69 blog.children << article = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true)
52 expects(:article_title).with(article).returns('TITLE') 70 expects(:article_title).with(article).returns('TITLE')