From 6e1fdc22d213139462598e736b6e77b917dcc2eb Mon Sep 17 00:00:00 2001 From: Francisco Marcelo A. Lima JĂșnior Date: Wed, 6 Nov 2013 17:47:29 -0300 Subject: [PATCH] improved stylesheet and functional tests in community block plugin --- app/helpers/application_helper.rb | 14 +++----------- plugins/community_block/public/style.css | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb | 55 ++++++++++++------------------------------------------- plugins/community_block/views/community_block.rhtml | 90 ++++++++++++++++++++++++++++++++++++++++-------------------------------------------------- 4 files changed, 128 insertions(+), 113 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 160da6d..d193b73 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1250,19 +1250,11 @@ module ApplicationHelper already_reported_message = _('You already reported this profile.') report_profile_message = _('Report this profile for abusive behaviour') - if type == :button || type == :button_without_text + if type == :button if user.already_reported?(profile) - if type == :button - button(:alert, text, url, :class => klass+' disabled', :disabled => true, :title => already_reported_message) - elsif type == :button_without_text - button_without_text(:alert, text, url, :class => klass+' disabled', :disabled => true, :title => already_reported_message) - end + button(:alert, text, url, :class => klass+' disabled', :disabled => true, :title => already_reported_message) else - if type == :button - button(:alert, text, url, :class => klass, :title => report_profile_message) - elsif type == :button_without_text - button_without_text(:alert, text, url, :class => klass, :title => report_profile_message) - end + button(:alert, text, url, :class => klass, :title => report_profile_message) end elsif type == :link if user.already_reported?(profile) diff --git a/plugins/community_block/public/style.css b/plugins/community_block/public/style.css index 60df06f..e2d3a46 100644 --- a/plugins/community_block/public/style.css +++ b/plugins/community_block/public/style.css @@ -20,15 +20,86 @@ margin-left: 2px; } -#content .box-1 .community-block .community-block-title { +#content .box-1 .community-block .community-block-title .menu-submenu { + bottom: 154px; + right: -120px; +} + +#content .box-1 .community-block .community-block-title .menu-submenu-header { + display: none; +} + +#content .box-1 .community-block .community-block-title .menu-submenu-content { + border: 1px solid #888a85; + border-radius: 4px; + background-color: #efefef; + background-image: none; +} + +#content .box-1 .community-block .community-block-title .menu-submenu-content h4 { + display: none; +} + +#content .box-1 .community-block .community-block-title .menu-submenu-content ul { + list-style: none; +} + +#content .box-1 .community-block .community-block-title .menu-submenu-content li { + padding: 7px; + font-size: 10px; +} + +#content .box-1 .community-block .community-block-title .menu-submenu-content a { + color: #000; +} + +#content .box-1 .community-block .community-block-title .menu-submenu-footer { + display: none; +} + +#content .box-1 .community-block .community-block-title h1 { //border: 1px solid #00F; font-variant: small-caps; color: #555753; text-align: left; padding-left: 10px; - margin: 0px; + margin: 0px 0px 2px 0px; +} + +#content .box-1 .community-block .community-block-button { + border: 1px solid #CCCCCC; + border-radius: 4px; + float: right; + height: 22px; + line-height: 22px; + margin-top: 1px; + margin-right: 1px; + background-color: #F4F4F4; + background-position: center center; + background-repeat: no-repeat; + cursor: pointer; +} + +#content .box-1 .community-block .community-block-button.icon-add { + width: 20px; + background-image: url('/designs/icons/default/Tango/16x16/actions/add.png'); +} + +#content .box-1 .community-block .community-block-button.icon-remove { + width: 20px; + background-image: url('/designs/icons/default/Tango/16x16/actions/remove.png'); +} + +#content .box-1 .community-block .community-block-button.icon-arrow { + width: 16px; + background-image: url('/images/top-arrow.png'); +} + +#content .box-1 .community-block .community-block-button:hover { + background-color: #DDDDDD; } + #content .box-1 .community-block .community-block-description { //border: 1px solid #0F0; font-style: italic; @@ -36,10 +107,3 @@ padding: 10px; } -#content .box-1 .community-block .community-block-buttons { - //border: 1px solid #F00; - text-align: left; - margin-top: 3px; - margin-left: 22px; -} - diff --git a/plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb b/plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb index 8ecb1e5..bf36148 100644 --- a/plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb +++ b/plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb @@ -42,77 +42,46 @@ class ProfileControllerTest < ActionController::TestCase get :index, :profile => @community.identifier assert_tag :div, :attributes => {:class => 'community-block-logo'} assert_tag :div, :attributes => {:class => 'community-block-info'} - assert_tag :h1, :attributes => {:class => 'community-block-title'} + assert_tag :div, :attributes => {:class => 'community-block-title'} assert_tag :div, :attributes => {:class => 'community-block-description'} - assert_tag :div, :attributes => {:class => 'community-block-buttons'} end - - # USER LOGGED IN AND COMMUNITY MEMBER # - should 'display *leave* button when the user is logged in and is a member of the community' do get :index, :profile => @community.identifier - assert_tag :a, :attributes => {:class => 'button icon-remove'} + assert_tag :span, :attributes => {:class => 'community-block-button icon-remove'} end should 'display *send email to administrators* button when the user is logged in and is a member of the community' do get :index, :profile => @community.identifier - assert_tag :a, :attributes => {:class => 'button icon-menu-mail'} + assert_match /\{"Send an e-mail":\{"href":"\/contact\/#{@community.identifier}\/new"\}\}/, @response.body end should 'display *report* button when the user is logged in and is a member of the community' do get :index, :profile => @community.identifier - assert_tag :a, :attributes => {:class => 'button icon-alert report-abuse-action'} + assert_match /\{"Report abuse":\{"href":"\/profile\/#{@community.identifier}\/report_abuse"\}\}/, @response.body end - - # USER LOGGED IN AND NOT MEMBER OF THE COMMUNITY - should 'display *join* button when the user is logged in and is not a member of the community' do @community.remove_member @user get :index, :profile => @community.identifier - assert_tag :a, :attributes => {:class => 'button icon-add'} - end - - should 'display *send email to administrators* button when the user is logged in and is not a member of the community' do - @community.remove_member @user - get :index, :profile => @community.identifier - assert_tag :a, :attributes => {:class => 'button icon-menu-mail'} - end - - should 'display *report* button when the user is logged in and is not a member of the community' do - @community.remove_member @user - get :index, :profile => @community.identifier - assert_tag :a, :attributes => {:class => 'button icon-alert report-abuse-action'} + assert_tag :span, :attributes => {:class => 'community-block-button icon-add'} end - - # USER LOGGED IN AND COMMUNITY ADMIN - - should 'display *configure* button when the user is logged in and is community admin' do + should 'display *control panel* link option when the user is logged in and is community admin' do get :index, :profile => @community.identifier - assert_tag :a, :attributes => {:class => 'button icon-menu-ctrl-panel'} + assert_match /\{"Control panel":\{"href":"\/myprofile\/#{@community.identifier}"\}\}/, @response.body end - - # USER NOT LOGGED IN - - should 'not display *send email to administrators* button when the user is not logged in' do + should 'display *join* button when the user is not logged in' do logout get :index, :profile => @community.identifier - assert_no_tag :a, :attributes => {:class => 'button icon-menu-mail'} + assert_tag :span, :attributes => {:class => 'community-block-button icon-add'} end - should 'not display *report* button when the user is not logged in' do + should 'not display *arrow* button when the user is not logged in' do logout get :index, :profile => @community.identifier - assert_no_tag :a, :attributes => {:class => 'button icon-alert report-abuse-action'} + assert_no_tag :span, :attributes => {:class => 'community-block-button icon-arrow'} end - - should 'not display *configure* button when the user is logged in and is admin of the community' do - logout - get :index, :profile => @community.identifier - assert_no_tag :a, :attributes => {:class => 'button icon-menu-ctrl-panel link-this-page'} - end - + end diff --git a/plugins/community_block/views/community_block.rhtml b/plugins/community_block/views/community_block.rhtml index 310d48f..717cd86 100644 --- a/plugins/community_block/views/community_block.rhtml +++ b/plugins/community_block/views/community_block.rhtml @@ -3,60 +3,50 @@ <%= link_to profile_image(profile, :big), profile.url %>
-

<%=profile.name%>

-
<%= profile.description %>
-
-
-
- <% if logged_in? %> - - <% if profile.members.include?(user) || profile.already_request_membership?(user) %> - <%= button_without_text( - :remove, - __('Leave community'), - profile.leave_url, - :title => _("Leave community"), - :style => 'position: relative;') %> - <% else %> - <%= button_without_text( - :add, - __('Join community'), - profile.join_url, - :title => _("Join community"), - :style => 'position: relative;') %> - <% end %> - - <% if profile.enable_contact? %> - <%= button_without_text( - :'menu-mail', - __('Send an e-mail'), - { :profile => profile.identifier, - :controller => 'contact', - :action => 'new' }, - :title => _('Send an e-mail to the administrators'), - :stle => 'position: relative;') %> - <% end %> - - <%= report_abuse(profile, :button_without_text) %> +
- <% if !user.nil? && user.has_permission?('edit_profile', profile) %> + <% + links = [] - <%= button_without_text( - :'menu-ctrl-panel', - __('Control Panel'), - profile.admin_url, - :title => _('Configure this community'), - :style => 'position: relative;') %> + if logged_in? + if profile.enable_contact? + links.push(_('Send an e-mail') => {:href => url_for({:controller => 'contact', :action => 'new', :profile => profile.identifier})}) + end + + links.push(_('Report abuse') => {:href => url_for({:controller => 'profile', :action => 'report_abuse', :profile => profile.identifier})}) + + if !user.nil? && user.has_permission?('edit_profile', profile) + links.push(_('Control panel') => {:href => url_for({:controller => 'profile_editor', :profile => profile.identifier})}) + end %> + + <%= link_to( + content_tag('span','',:class => 'community-block-button icon-arrow'), + '#', + :onclick => "toggleSubmenu(this,'',#{links.to_json}); return false;", + :class => 'simplemenu-trigger') %> + + <% end %> + + <% if logged_in? %> + <% if profile.members.include?(user) || profile.already_request_membership?(user) %> + <%= link_to( + content_tag('span', '', :class => 'community-block-button icon-remove'), + profile.leave_url) %> + <% else %> + <%= link_to( + content_tag('span', '', :class => 'community-block-button icon-add'), + profile.join_url) %> + <% end %> + <% else %> + <%= link_to( + content_tag('span', '', :class => 'community-block-button icon-add'), + profile.join_not_logged_url) %> <% end %> - <% else %> - <%= button_without_text( - :add, - __('Join community'), - profile.join_not_logged_url, - :title => _("Join community"), - :style => 'position: relative;') %> - <% end %> +

<%=profile.name%>

+
+
<%= profile.description %>
+
-- libgit2 0.21.2