Commit c02b7bca89968a1b693996685282464c8c0f2899

Authored by Rafael Reggiani Manzo
1 parent 723a6061

Remove HTML generation from community_block plugin

It now relies on BoxesHelper logic and thus the method got removed. As
it was the only subject of unit tests, The unit tests for this class
have been removed (most of the logic is tested through functional
tests).
plugins/community_block/lib/community_block.rb
@@ -7,13 +7,4 @@ class CommunityBlock < Block @@ -7,13 +7,4 @@ class CommunityBlock < Block
7 def help 7 def help
8 _("Help for Community Description Block.") 8 _("Help for Community Description Block.")
9 end 9 end
10 -  
11 - def content(arg={})  
12 - block = self  
13 -  
14 - proc do  
15 - render :file => 'community_block', :locals => { :block => block }  
16 - end  
17 - end  
18 -  
19 end 10 end
plugins/community_block/test/unit/commmunity_block_test.rb
@@ -1,11 +0,0 @@ @@ -1,11 +0,0 @@
1 -require_relative '../test_helper'  
2 -  
3 -class CommunityBlockTest < ActiveSupport::TestCase  
4 -  
5 - should "display community block" do  
6 - block = CommunityBlock.new  
7 - self.expects(:render).with(:file => 'community_block', :locals => { :block => block })  
8 - instance_eval(& block.content)  
9 - end  
10 -  
11 -end  
plugins/community_block/views/blocks/community.html.erb 0 → 100644
@@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
  1 +<div class="community-block">
  2 + <div class="community-block-logo">
  3 + <%= link_to profile_image(profile, :big), profile.url %>
  4 + </div>
  5 + <div class="community-block-info">
  6 + <div class="community-block-title">
  7 +
  8 + <%
  9 + links = []
  10 +
  11 + if logged_in?
  12 +
  13 + if profile.enable_contact?
  14 + links.push(c_('Send an e-mail') => {:href => url_for({:controller => 'contact', :action => 'new', :profile => profile.identifier})})
  15 + end
  16 +
  17 + links.push(c_('Report abuse') => {:href => url_for({:controller => 'profile', :action => 'report_abuse', :profile => profile.identifier})})
  18 +
  19 + if !user.nil? && user.has_permission?('edit_profile', profile)
  20 + links.push(c_('Control panel') => {:href => url_for({:controller => 'profile_editor', :profile => profile.identifier})})
  21 + end %>
  22 +
  23 + <%= link_to(
  24 + content_tag('span','',:class => 'community-block-button icon-arrow'),
  25 + '#',
  26 + :onclick => "toggleSubmenu(this,'',#{CGI::escapeHTML(links.to_json)}); return false;",
  27 + :class => 'simplemenu-trigger') %>
  28 +
  29 + <% end %>
  30 +
  31 + <% if logged_in? %>
  32 + <% if profile.members.include?(user) || profile.already_request_membership?(user) %>
  33 + <%= link_to(
  34 + content_tag('span', '', :class => 'community-block-button icon-remove'),
  35 + profile.leave_url, :class => 'join-community') %>
  36 + <% else %>
  37 + <%= link_to(
  38 + content_tag('span', '', :class => 'community-block-button icon-add'),
  39 + profile.join_url, :class => 'join-community') %>
  40 + <% end %>
  41 + <% else %>
  42 + <%= link_to(
  43 + content_tag('span', '', :class => 'community-block-button icon-add'),
  44 + profile.join_not_logged_url) %>
  45 + <% end %>
  46 +
  47 + <h1><%=profile.name%></h1>
  48 + </div>
  49 + <div class="community-block-description"><%= profile.description %></div>
  50 + </div>
  51 + <div style="clear:both"></div>
  52 +</div>
plugins/community_block/views/community_block.html.erb
@@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
1 -<div class="community-block">  
2 - <div class="community-block-logo">  
3 - <%= link_to profile_image(profile, :big), profile.url %>  
4 - </div>  
5 - <div class="community-block-info">  
6 - <div class="community-block-title">  
7 -  
8 - <%  
9 - links = []  
10 -  
11 - if logged_in?  
12 -  
13 - if profile.enable_contact?  
14 - links.push(c_('Send an e-mail') => {:href => url_for({:controller => 'contact', :action => 'new', :profile => profile.identifier})})  
15 - end  
16 -  
17 - links.push(c_('Report abuse') => {:href => url_for({:controller => 'profile', :action => 'report_abuse', :profile => profile.identifier})})  
18 -  
19 - if !user.nil? && user.has_permission?('edit_profile', profile)  
20 - links.push(c_('Control panel') => {:href => url_for({:controller => 'profile_editor', :profile => profile.identifier})})  
21 - end %>  
22 -  
23 - <%= link_to(  
24 - content_tag('span','',:class => 'community-block-button icon-arrow'),  
25 - '#',  
26 - :onclick => "toggleSubmenu(this,'',#{CGI::escapeHTML(links.to_json)}); return false;",  
27 - :class => 'simplemenu-trigger') %>  
28 -  
29 - <% end %>  
30 -  
31 - <% if logged_in? %>  
32 - <% if profile.members.include?(user) || profile.already_request_membership?(user) %>  
33 - <%= link_to(  
34 - content_tag('span', '', :class => 'community-block-button icon-remove'),  
35 - profile.leave_url, :class => 'join-community') %>  
36 - <% else %>  
37 - <%= link_to(  
38 - content_tag('span', '', :class => 'community-block-button icon-add'),  
39 - profile.join_url, :class => 'join-community') %>  
40 - <% end %>  
41 - <% else %>  
42 - <%= link_to(  
43 - content_tag('span', '', :class => 'community-block-button icon-add'),  
44 - profile.join_not_logged_url) %>  
45 - <% end %>  
46 -  
47 - <h1><%=profile.name%></h1>  
48 - </div>  
49 - <div class="community-block-description"><%= profile.description %></div>  
50 - </div>  
51 - <div style="clear:both"></div>  
52 -</div>