[Git][noosfero/noosfero][master] 2 commits: Include some profile controller paths to show breadcrumbs block

Antonio Terceiro gitlab at mg.gitlab.com
Thu Nov 19 14:49:22 BRST 2015


Antonio Terceiro pushed to branch master at Noosfero / noosfero


Commits:
5b9ea251 by Melissa Wen at 2015-11-12T16:20:34Z
Include some profile controller paths to show breadcrumbs block

- - - - -
1a57fd09 by Antonio Terceiro at 2015-11-19T16:49:01Z
Merge branch 'increase_breadcrumbs_reach' into 'master'

Include some profile controller paths to show breadcrumbs block

Currently, pages from profile and event actions don't display breadcrumbs. This merge creates path links on profile and event actions page with profile index as ancestor, so breadcrumbs block will work on these pages.

See merge request !728
- - - - -


2 changed files:

- plugins/breadcrumbs/lib/breadcrumbs_plugin/content_breadcrumbs_block.rb
- plugins/breadcrumbs/test/unit/content_breadcrumbs_block_test.rb


Changes:

=====================================
plugins/breadcrumbs/lib/breadcrumbs_plugin/content_breadcrumbs_block.rb
=====================================
--- a/plugins/breadcrumbs/lib/breadcrumbs_plugin/content_breadcrumbs_block.rb
+++ b/plugins/breadcrumbs/lib/breadcrumbs_plugin/content_breadcrumbs_block.rb
@@ -31,6 +31,9 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock < Block
       id = params[:id] || params[:parent_id]
       links = page_trail(Article.find(id)) if id
       links << { :name => cms_action(params[:action]), :url => params } if show_cms_action
+    elsif (params[:controller] == 'profile' || params[:controller] == 'events')
+      links << { :name => _('Profile'), :url => {:controller=> 'profile', :action =>'index', :profile =>params[:profile]}}
+      links << { :name => profile_action(params[:action]), :url => params } unless params[:action] == 'index'
     end
     links
   end
@@ -74,9 +77,14 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock < Block
   protected
 
   CMS_ACTIONS = {:edit => c_('Edit'), :upload_files => _('Upload Files'), :new => c_('New')}
+  PROFILE_ACTIONS = {:members => _('Members'), :events => _('Events')}
 
   def cms_action(action)
     CMS_ACTIONS[action.to_sym] || action
   end
 
+  def profile_action(action)
+    PROFILE_ACTIONS[action.to_sym] || action
+  end
+
 end


=====================================
plugins/breadcrumbs/test/unit/content_breadcrumbs_block_test.rb
=====================================
--- a/plugins/breadcrumbs/test/unit/content_breadcrumbs_block_test.rb
+++ b/plugins/breadcrumbs/test/unit/content_breadcrumbs_block_test.rb
@@ -40,6 +40,24 @@ class ContentBreadcrumbsBlockTest < ActiveSupport::TestCase
     assert_equal links, @block.page_trail(nil, params)
   end
 
+  should 'include profile page link on path of links to reach a profile controller page' do
+    params = {:controller => 'profile', :action => 'members', :profile => @profile.identifier}
+    links = [{:name => 'Profile', :url => {:controller => 'profile', :action => 'index', :profile => @profile.identifier}}, {:name => 'Members', :url => {:controller=>'profile', :action=>'members', :profile=> @profile.identifier}}]
+    assert_equal links, @block.page_trail(nil, params)
+  end
+
+  should 'include only the profile page link on path links when profile action is index' do
+    params = {:controller => 'profile', :action => 'index', :profile => @profile.identifier}
+    links = [{:name => 'Profile', :url => {:controller => 'profile', :action => 'index', :profile => @profile.identifier}}]
+    assert_equal links, @block.page_trail(nil, params)
+  end
+
+  should 'profile page be the ancestor page of event profile page calendar' do
+    params = {:controller => 'profile', :action => 'events', :profile => @profile.identifier}
+    links = [{:name => 'Profile', :url => {:controller => 'profile', :action => 'index', :profile => @profile.identifier}}, {:name => 'Events', :url => {:controller=>'profile', :action=>'events', :profile=> @profile.identifier}}]
+    assert_equal links, @block.page_trail(nil, params)
+  end
+
   should 'include profile link on path of links to reach a page' do
     links = [{:name => @profile.name, :url => @profile.url}, {:name => @folder.name, :url => @folder.url}, {:name => @article.name, :url => @article.url}]
     assert_equal links, @block.trail(@article, @profile)



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/84ca7256e30e2ac68264f248c8c15457cb134771...1a57fd09fc736c8b0b586b96cf2f31fd5fa6e53c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20151119/0fe533dd/attachment-0001.html>


More information about the Noosfero-dev mailing list