auto_breadcrumbs 0.2.1 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef333978318c7bf16abc9ecb45e172d91d2cc65f
4
- data.tar.gz: 9964525a13aaf232da045f36a4393895eb499e0f
3
+ metadata.gz: db5a5d9098b01750c0510c78e3807fee42dc50bd
4
+ data.tar.gz: b0df76255442bb13f15820b8581feca85e21f12d
5
5
  SHA512:
6
- metadata.gz: 737be4c34d4be1d3c3504b8031260fcc72e1e14fa54f5c162765da5a1d557e2776e744c244bbe5bd007f518ec5d9e66b88abace7767f1829dcc0a5979577349b
7
- data.tar.gz: c0804f8e495cccb51dcccb05c737513e0c03067a6a2650224e6b50a2b2418d7afd2b0cc4e4c2d977a04614da2e31eaee58fc33834c29463bda04a115ea2f23f0
6
+ metadata.gz: 28cb5e660fda4d610091970c33cbd29c08c6ae6455982e19d7a42c5e31902c37f2c79cf47a93e0d84f08327c3d831a229b6270b144f9be1268852c4087adbc0a
7
+ data.tar.gz: 5f00dbea9aa60a5d5ed1d12c8da2698d1de08e98bfdfd0bf29c8c536b1866b9b83d6d7151f5ca3c423e66d777fb452d46a63669b0ce17308c37f7afe4bccb3cc
data/README.md CHANGED
@@ -57,6 +57,9 @@ en:
57
57
 
58
58
  For example, if you go to `/users/1/edit` it will show breadcrums like `Home / Users / Settings`.
59
59
 
60
+ In case when translations are absent it will try to build breadcrumbs automatically depending on resource and action names.
61
+ For example, if you visit `/countries/new` it will show breadcrums `Home / Countries / New`.
62
+
60
63
  ## Customization
61
64
 
62
65
  For more information about customization of breadcrumbs visit [breadcrumbs_on_rails](https://github.com/weppos/breadcrumbs_on_rails).
@@ -6,6 +6,9 @@ module AutoBreadcrumbs
6
6
 
7
7
  included do
8
8
  before_filter :add_breadcrumb_on_action, except: :destroy
9
+
10
+ helper_method :resource_translation
11
+ helper_method :action_translation
9
12
  end
10
13
 
11
14
  private
@@ -14,28 +17,23 @@ module AutoBreadcrumbs
14
17
  add_breadcrumb breadcrumbs_t('root'), :root_path
15
18
 
16
19
  unless request.path == root_path
17
- add_breadcrumb(index_translation, controllers_index_path) if controllers_index_path
20
+ add_breadcrumb(resource_translation, index_path) if index_path
18
21
  add_breadcrumb(action_translation) unless params[:action] == 'index'
19
22
  end
20
23
  end
21
24
 
22
- def index_translation
23
- begin
24
- breadcrumbs_t!("controllers.#{ params[:controller] }.index")
25
- rescue I18n::MissingTranslationData
26
- params[:controller].split('_').map(&:capitalize).join(' ')
27
- end
25
+ def resource_translation
26
+ breadcrumbs_t("controllers.#{ params[:controller] }.index") ||
27
+ params[:controller].humanize
28
28
  end
29
29
 
30
30
  def action_translation
31
- begin
32
- breadcrumbs_t!("controllers.#{ params[:controller] }.#{ breadcrumbs_action_name }")
33
- rescue I18n::MissingTranslationData
34
- breadcrumbs_t("actions.#{ breadcrumbs_action_name }")
35
- end
31
+ breadcrumbs_t("controllers.#{ params[:controller] }.#{ breadcrumbs_action_name }") ||
32
+ breadcrumbs_t("actions.#{ breadcrumbs_action_name }") ||
33
+ breadcrumbs_action_name.humanize
36
34
  end
37
35
 
38
- def controllers_index_path
36
+ def index_path
39
37
  url_for(controller: params[:controller]) rescue nil
40
38
  end
41
39
 
@@ -51,11 +49,7 @@ module AutoBreadcrumbs
51
49
  end
52
50
 
53
51
  def breadcrumbs_t(path)
54
- I18n.t('auto_breadcrumbs.' << path)
55
- end
56
-
57
- def breadcrumbs_t!(path)
58
- I18n.t!('auto_breadcrumbs.' << path)
52
+ I18n.t('auto_breadcrumbs.' << path, default: '').presence
59
53
  end
60
54
  end
61
55
  end
@@ -1,3 +1,3 @@
1
1
  module AutoBreadcrumbs
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.5'
3
3
  end
@@ -13,4 +13,7 @@ class UsersController < ApplicationController
13
13
 
14
14
  def sync
15
15
  end
16
+
17
+ def ban
18
+ end
16
19
  end
@@ -3,7 +3,10 @@ Dummy::Application.routes.draw do
3
3
 
4
4
  resources :users, only: [:index, :show, :edit] do
5
5
  get :sync, on: :collection
6
- get :dup, on: :member
6
+ member do
7
+ get :dup
8
+ get :ban
9
+ end
7
10
  end
8
11
 
9
12
  resources :country_names, only: [:index]
@@ -12,7 +12,7 @@ feature 'Rendering breadcrumbs' do
12
12
  # Country name page -----------------------------------------------------------------------------
13
13
 
14
14
  let(:country_name_page) { BreadcrumbPage.new(index: country_names_path) }
15
- let(:country_name_index_breadcrumbs) { root_breadcrumbs + ['Country Names'] }
15
+ let(:country_name_index_breadcrumbs) { root_breadcrumbs + ['Country names'] }
16
16
 
17
17
  # City page -------------------------------------------------------------------------------------
18
18
 
@@ -30,6 +30,7 @@ feature 'Rendering breadcrumbs' do
30
30
  show: user_path('id'),
31
31
  edit: edit_user_path('id'),
32
32
  dup: dup_user_path('id'),
33
+ ban: ban_user_path('id'),
33
34
  sync: sync_users_path
34
35
  }
35
36
  let(:user_index_breadcrumbs) { root_breadcrumbs + [locale['controllers']['users']['index']] }
@@ -37,6 +38,7 @@ feature 'Rendering breadcrumbs' do
37
38
  let(:user_edit_breadcrumbs) { user_index_breadcrumbs + [locale['controllers']['users']['edit']] }
38
39
  let(:user_dup_breadcrumbs) { user_index_breadcrumbs + [locale['controllers']['users']['dup']] }
39
40
  let(:user_sync_breadcrumbs) { user_index_breadcrumbs + [locale['controllers']['users']['sync']] }
41
+ let(:user_ban_breadcrumbs) { user_index_breadcrumbs + ['Ban'] }
40
42
 
41
43
  # -----------------------------------------------------------------------------------------------
42
44
 
@@ -73,5 +75,8 @@ feature 'Rendering breadcrumbs' do
73
75
 
74
76
  user_page.visit_page(:sync)
75
77
  expect(user_page.breadcrumbs).to eq(user_sync_breadcrumbs)
78
+
79
+ user_page.visit_page(:ban)
80
+ expect(user_page.breadcrumbs).to eq(user_ban_breadcrumbs)
76
81
  end
77
82
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_breadcrumbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeny Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2013-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: breadcrumbs_on_rails