Commit 5acb61dd0b15aedb4d94497d0a009a4de0e4a543
1 parent
ce0d03ab
Exists in
master
and in
22 other branches
adding community block plugin
Showing
8 changed files
with
238 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -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 @@ |
| 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,43 @@ |
| 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 { | |
| 24 | + //border: 1px solid #00F; | |
| 25 | + font-variant: small-caps; | |
| 26 | + color: #555753; | |
| 27 | + text-align: left; | |
| 28 | + padding-left: 10px; | |
| 29 | + margin: 0px; | |
| 30 | +} | |
| 31 | + | |
| 32 | +#content .box-1 .community-block .community-block-description { | |
| 33 | + //border: 1px solid #0F0; | |
| 34 | + font-style: italic; | |
| 35 | + color: black; | |
| 36 | + padding: 10px; | |
| 37 | +} | |
| 38 | + | |
| 39 | +#content .box-1 .community-block .community-block-buttons { | |
| 40 | + //border: 1px solid #F00; | |
| 41 | + text-align: right; | |
| 42 | +} | |
| 43 | + | ... | ... |
plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb
0 → 100644
| ... | ... | @@ -0,0 +1,66 @@ |
| 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') | |
| 19 | + #login_as(user.login) | |
| 20 | + | |
| 21 | + @community = fast_create(Community, :environment_id => Environment.default) | |
| 22 | + | |
| 23 | + @environment = @community.environment | |
| 24 | + @environment.enabled_plugins = ['CommunityBlock'] | |
| 25 | + @environment.save! | |
| 26 | + | |
| 27 | + CommunityBlock.delete_all | |
| 28 | + @box1 = Box.create!(:owner => @community) | |
| 29 | + @community.boxes = [@box1] | |
| 30 | + | |
| 31 | + @block = CommunityBlock.new | |
| 32 | + @block.box = @box1 | |
| 33 | + @block.save! | |
| 34 | + | |
| 35 | + @community.blocks<<@block | |
| 36 | + @community.save! | |
| 37 | + end | |
| 38 | + | |
| 39 | + attr_accessor :profile, :block, :community | |
| 40 | + | |
| 41 | + should 'display community-block-logo class in community block' do | |
| 42 | + get :index, :profile => community.identifier | |
| 43 | + assert_tag :div, :attributes => {:class => 'community-block-logo'} | |
| 44 | + end | |
| 45 | + | |
| 46 | + should 'display community-block-info class in community block' do | |
| 47 | + get :index, :profile => community.identifier | |
| 48 | + assert_tag :div, :attributes => {:class => 'community-block-info'} | |
| 49 | + end | |
| 50 | + | |
| 51 | + should 'display community-block-title class in community block' do | |
| 52 | + get :index, :profile => community.identifier | |
| 53 | + assert_tag :h1, :attributes => {:class => 'community-block-title'} | |
| 54 | + end | |
| 55 | + | |
| 56 | + should 'display community-block-description class in community block' do | |
| 57 | + get :index, :profile => community.identifier | |
| 58 | + assert_tag :div, :attributes => {:class => 'community-block-description'} | |
| 59 | + end | |
| 60 | + | |
| 61 | + should 'display community-block-buttons class in community block' do | |
| 62 | + get :index, :profile => community.identifier | |
| 63 | + assert_tag :div, :attributes => {:class => 'community-block-buttons'} | |
| 64 | + end | |
| 65 | + | |
| 66 | +end | ... | ... |
| ... | ... | @@ -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 @@ |
| 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 @@ |
| 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,38 @@ |
| 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 | + <h1 class="community-block-title"><%=profile.name%></h1> | |
| 7 | + <div class="community-block-description"><%= profile.description %></div> | |
| 8 | + <div class="community-block-buttons"> | |
| 9 | + <% if logged_in? %> | |
| 10 | + <% if profile.members.include?(user) %> | |
| 11 | + <%= button(:delete, content_tag('span', __('Leave community')), profile.leave_url, | |
| 12 | + :class => 'leave-community', | |
| 13 | + :title => _("Leave community"), | |
| 14 | + :style => 'position: relative;') %> | |
| 15 | + <%= button(:add, content_tag('span', __('Join')), profile.join_url, | |
| 16 | + :class => 'join-community', | |
| 17 | + :title => _("Join community"), | |
| 18 | + :style => 'position: relative; display: none;') %> | |
| 19 | + <% else %> | |
| 20 | + <% unless profile.already_request_membership?(user) %> | |
| 21 | + <%= button(:delete, content_tag('span', __('Leave community')), profile.leave_url, | |
| 22 | + :class => 'leave-community', | |
| 23 | + :title => _("Leave community"), | |
| 24 | + :style => 'position: relative; display: none;') %> | |
| 25 | + <%= button(:add, content_tag('span', __('Join')), profile.join_url, | |
| 26 | + :class => 'join-community', | |
| 27 | + :title => _("Join community"), | |
| 28 | + :style => 'position: relative;') %> | |
| 29 | + <% end %> | |
| 30 | + <% end %> | |
| 31 | + | |
| 32 | + <% else %> | |
| 33 | + <%= link_to content_tag('span', _('Join')), profile.join_not_logged_url, :class => 'button with-text icon-add', :title => _("Join comunity") %> | |
| 34 | + <% end %> | |
| 35 | + </div> | |
| 36 | + </div> | |
| 37 | + <div style="clear:both"></div> | |
| 38 | +</div> | ... | ... |