Commit b1a971dbb60cc78d0c47a17eeb6f359a8989ad41
Exists in
master
and in
29 other branches
Merge commit 'refs/merge-requests/423' of git://gitorious.org/noosfero/noosfero …
…into merge-requests/423
Showing
8 changed files
with
339 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
1 | +class CommunityBlock < Block | ||
2 | + | ||
3 | + def self.description | ||
4 | + "Community block" | ||
5 | + end | ||
6 | + | ||
7 | + def help | ||
8 | + "Help for Community Description Block." | ||
9 | + end | ||
10 | + | ||
11 | + def content(arg={}) | ||
12 | + block = self | ||
13 | + | ||
14 | + lambda do | ||
15 | + render :file => 'community_block', :locals => { :block => block } | ||
16 | + end | ||
17 | + end | ||
18 | + | ||
19 | +end |
@@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
1 | +require_dependency File.dirname(__FILE__) + '/community_block' | ||
2 | + | ||
3 | +class CommunityBlockPlugin < Noosfero::Plugin | ||
4 | + | ||
5 | + def self.plugin_name | ||
6 | + "Community Block Plugin" | ||
7 | + end | ||
8 | + | ||
9 | + def self.plugin_description | ||
10 | + "A plugin that adds a block to show community description" | ||
11 | + end | ||
12 | + | ||
13 | + def self.extra_blocks | ||
14 | + { | ||
15 | + CommunityBlock => {:type => Community} | ||
16 | + } | ||
17 | + end | ||
18 | + | ||
19 | + def self.has_admin_url? | ||
20 | + false | ||
21 | + end | ||
22 | + | ||
23 | + def stylesheet? | ||
24 | + true | ||
25 | + end | ||
26 | + | ||
27 | +end |
@@ -0,0 +1,109 @@ | @@ -0,0 +1,109 @@ | ||
1 | +#content .box-1 .community-block { | ||
2 | + //border: 1px solid #F00; | ||
3 | + display: table; | ||
4 | + width: 100%; | ||
5 | +} | ||
6 | + | ||
7 | +#content .box-1 .community-block .community-block-logo { | ||
8 | + //border: 1px solid #00F; | ||
9 | + float: left; | ||
10 | + width: 150px; | ||
11 | + height: 150px; | ||
12 | + padding: 5px; | ||
13 | +} | ||
14 | + | ||
15 | +#content .box-1 .community-block-info { | ||
16 | + //border: 1px solid #000; | ||
17 | + float: left; | ||
18 | + padding: 5px; | ||
19 | + width: 360px; | ||
20 | + margin-left: 2px; | ||
21 | +} | ||
22 | + | ||
23 | +#content .box-1 .community-block .community-block-title .menu-submenu { | ||
24 | + bottom: 154px; | ||
25 | + right: -120px; | ||
26 | +} | ||
27 | + | ||
28 | +#content .box-1 .community-block .community-block-title .menu-submenu-header { | ||
29 | + display: none; | ||
30 | +} | ||
31 | + | ||
32 | +#content .box-1 .community-block .community-block-title .menu-submenu-content { | ||
33 | + border: 1px solid #888a85; | ||
34 | + border-radius: 4px; | ||
35 | + background-color: #efefef; | ||
36 | + background-image: none; | ||
37 | +} | ||
38 | + | ||
39 | +#content .box-1 .community-block .community-block-title .menu-submenu-content h4 { | ||
40 | + display: none; | ||
41 | +} | ||
42 | + | ||
43 | +#content .box-1 .community-block .community-block-title .menu-submenu-content ul { | ||
44 | + list-style: none; | ||
45 | +} | ||
46 | + | ||
47 | +#content .box-1 .community-block .community-block-title .menu-submenu-content li { | ||
48 | + padding: 7px; | ||
49 | + font-size: 10px; | ||
50 | +} | ||
51 | + | ||
52 | +#content .box-1 .community-block .community-block-title .menu-submenu-content a { | ||
53 | + color: #000; | ||
54 | +} | ||
55 | + | ||
56 | +#content .box-1 .community-block .community-block-title .menu-submenu-footer { | ||
57 | + display: none; | ||
58 | +} | ||
59 | + | ||
60 | +#content .box-1 .community-block .community-block-title h1 { | ||
61 | + //border: 1px solid #00F; | ||
62 | + font-variant: small-caps; | ||
63 | + color: #555753; | ||
64 | + text-align: left; | ||
65 | + padding-left: 10px; | ||
66 | + margin: 0px 0px 2px 0px; | ||
67 | +} | ||
68 | + | ||
69 | +#content .box-1 .community-block .community-block-button { | ||
70 | + border: 1px solid #CCCCCC; | ||
71 | + border-radius: 4px; | ||
72 | + float: right; | ||
73 | + height: 22px; | ||
74 | + line-height: 22px; | ||
75 | + margin-top: 1px; | ||
76 | + margin-right: 1px; | ||
77 | + background-color: #F4F4F4; | ||
78 | + background-position: center center; | ||
79 | + background-repeat: no-repeat; | ||
80 | + cursor: pointer; | ||
81 | +} | ||
82 | + | ||
83 | +#content .box-1 .community-block .community-block-button.icon-add { | ||
84 | + width: 20px; | ||
85 | + background-image: url('/designs/icons/default/Tango/16x16/actions/add.png'); | ||
86 | +} | ||
87 | + | ||
88 | +#content .box-1 .community-block .community-block-button.icon-remove { | ||
89 | + width: 20px; | ||
90 | + background-image: url('/designs/icons/default/Tango/16x16/actions/remove.png'); | ||
91 | +} | ||
92 | + | ||
93 | +#content .box-1 .community-block .community-block-button.icon-arrow { | ||
94 | + width: 16px; | ||
95 | + background-image: url('/images/top-arrow.png'); | ||
96 | +} | ||
97 | + | ||
98 | +#content .box-1 .community-block .community-block-button:hover { | ||
99 | + background-color: #DDDDDD; | ||
100 | +} | ||
101 | + | ||
102 | + | ||
103 | +#content .box-1 .community-block .community-block-description { | ||
104 | + //border: 1px solid #0F0; | ||
105 | + font-style: italic; | ||
106 | + color: black; | ||
107 | + padding: 10px; | ||
108 | +} | ||
109 | + |
plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb
0 → 100644
@@ -0,0 +1,87 @@ | @@ -0,0 +1,87 @@ | ||
1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
2 | + | ||
3 | +# Re-raise errors caught by the controller. | ||
4 | +class ProfileController | ||
5 | + append_view_path File.join(File.dirname(__FILE__) + '/../../views') | ||
6 | + def rescue_action(e) | ||
7 | + raise e | ||
8 | + end | ||
9 | +end | ||
10 | + | ||
11 | +class ProfileControllerTest < ActionController::TestCase | ||
12 | + | ||
13 | + def setup | ||
14 | + @controller = ProfileController.new | ||
15 | + @request = ActionController::TestRequest.new | ||
16 | + @response = ActionController::TestResponse.new | ||
17 | + | ||
18 | + @user = create_user('testinguser').person | ||
19 | + login_as(@user.identifier) | ||
20 | + | ||
21 | + @community = fast_create(Community, :environment_id => Environment.default) | ||
22 | + @community.add_member @user | ||
23 | + @community.add_admin @user | ||
24 | + | ||
25 | + @environment = @community.environment | ||
26 | + @environment.enabled_plugins = ['CommunityBlock'] | ||
27 | + @environment.save! | ||
28 | + | ||
29 | + CommunityBlock.delete_all | ||
30 | + @box1 = Box.create!(:owner => @community) | ||
31 | + @community.boxes = [@box1] | ||
32 | + | ||
33 | + @block = CommunityBlock.new | ||
34 | + @block.box = @box1 | ||
35 | + @block.save! | ||
36 | + | ||
37 | + @community.blocks<<@block | ||
38 | + @community.save! | ||
39 | + end | ||
40 | + | ||
41 | + should 'display community-block' do | ||
42 | + get :index, :profile => @community.identifier | ||
43 | + assert_tag :div, :attributes => {:class => 'community-block-logo'} | ||
44 | + assert_tag :div, :attributes => {:class => 'community-block-info'} | ||
45 | + assert_tag :div, :attributes => {:class => 'community-block-title'} | ||
46 | + assert_tag :div, :attributes => {:class => 'community-block-description'} | ||
47 | + end | ||
48 | + | ||
49 | + should 'display *leave* button when the user is logged in and is a member of the community' do | ||
50 | + get :index, :profile => @community.identifier | ||
51 | + assert_tag :span, :attributes => {:class => 'community-block-button icon-remove'} | ||
52 | + end | ||
53 | + | ||
54 | + should 'display *send email to administrators* button when the user is logged in and is a member of the community' do | ||
55 | + get :index, :profile => @community.identifier | ||
56 | + assert_match /\{"Send an e-mail":\{"href":"\/contact\/#{@community.identifier}\/new"\}\}/, @response.body | ||
57 | + end | ||
58 | + | ||
59 | + should 'display *report* button when the user is logged in and is a member of the community' do | ||
60 | + get :index, :profile => @community.identifier | ||
61 | + assert_match /\{"Report abuse":\{"href":"\/profile\/#{@community.identifier}\/report_abuse"\}\}/, @response.body | ||
62 | + end | ||
63 | + | ||
64 | + should 'display *join* button when the user is logged in and is not a member of the community' do | ||
65 | + @community.remove_member @user | ||
66 | + get :index, :profile => @community.identifier | ||
67 | + assert_tag :span, :attributes => {:class => 'community-block-button icon-add'} | ||
68 | + end | ||
69 | + | ||
70 | + should 'display *control panel* link option when the user is logged in and is community admin' do | ||
71 | + get :index, :profile => @community.identifier | ||
72 | + assert_match /\{"Control panel":\{"href":"\/myprofile\/#{@community.identifier}"\}\}/, @response.body | ||
73 | + end | ||
74 | + | ||
75 | + should 'display *join* button when the user is not logged in' do | ||
76 | + logout | ||
77 | + get :index, :profile => @community.identifier | ||
78 | + assert_tag :span, :attributes => {:class => 'community-block-button icon-add'} | ||
79 | + end | ||
80 | + | ||
81 | + should 'not display *arrow* button when the user is not logged in' do | ||
82 | + logout | ||
83 | + get :index, :profile => @community.identifier | ||
84 | + assert_no_tag :span, :attributes => {:class => 'community-block-button icon-arrow'} | ||
85 | + end | ||
86 | + | ||
87 | +end |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../test/test_helper' |
plugins/community_block/test/unit/commmunity_block_plugin_test.rb
0 → 100644
@@ -0,0 +1,33 @@ | @@ -0,0 +1,33 @@ | ||
1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
2 | + | ||
3 | +class CommunityBlockPluginTest < ActiveSupport::TestCase | ||
4 | + | ||
5 | + def setup | ||
6 | + @plugin = CommunityBlockPlugin.new | ||
7 | + end | ||
8 | + | ||
9 | + should 'be a noosfero plugin' do | ||
10 | + assert_kind_of Noosfero::Plugin, @plugin | ||
11 | + end | ||
12 | + | ||
13 | + should 'have name' do | ||
14 | + assert_equal 'Community Block Plugin', CommunityBlockPlugin.plugin_name | ||
15 | + end | ||
16 | + | ||
17 | + should 'have description' do | ||
18 | + assert_equal "A plugin that adds a block to show community description", CommunityBlockPlugin.plugin_description | ||
19 | + end | ||
20 | + | ||
21 | + should 'have stylesheet' do | ||
22 | + assert @plugin.stylesheet? | ||
23 | + end | ||
24 | + | ||
25 | + should "return CommunityBlock in extra_blocks class method" do | ||
26 | + assert CommunityBlockPlugin.extra_blocks.keys.include?(CommunityBlock) | ||
27 | + end | ||
28 | + | ||
29 | + should "return false for class method has_admin_url?" do | ||
30 | + assert !CommunityBlockPlugin.has_admin_url? | ||
31 | + end | ||
32 | + | ||
33 | +end |
plugins/community_block/test/unit/commmunity_block_test.rb
0 → 100644
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +require File.dirname(__FILE__) + '/../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 |
@@ -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(_('Send an e-mail') => {:href => url_for({:controller => 'contact', :action => 'new', :profile => profile.identifier})}) | ||
15 | + end | ||
16 | + | ||
17 | + links.push(_('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(_('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,'',#{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) %> | ||
36 | + <% else %> | ||
37 | + <%= link_to( | ||
38 | + content_tag('span', '', :class => 'community-block-button icon-add'), | ||
39 | + profile.join_url) %> | ||
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> |