auto_breadcrumbs 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c84bd6b796c253c40ac1b1511d03a83f58ea9698
4
+ data.tar.gz: 68254ba6d275a6ea33a07bff0f13307f488eba24
5
+ SHA512:
6
+ metadata.gz: dae146312d466ecab2ca5d08ce706ad1f85875e952db0dcbc18b6d02e536a293b3b564c8959f4e42169039f40f9240a37223f07d4d2ea4c0656dc57a153e02d2
7
+ data.tar.gz: 9d2aba78058ec04c3608cb1dda7086670ccdf5d00272d2c28d907ecdf41d3bd1e9b02cd65de89da4d83971583ee17cdcbc21b20981c192a157cc4b6c67ca82f6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in auto_breadcrumbs.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Evgeny Li
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # AutoBreadcrumbs
2
+
3
+ Automatically add breadcrumbs to each page by using locales and gem `breadcrumbs_on_rails`.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'auto_breadcrumbs'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install auto_breadcrumbs
20
+
21
+ ### Installing locales
22
+
23
+ To install locale file run:
24
+
25
+ $ rails g auto_breadcrumbs:install
26
+
27
+ ## Usage
28
+
29
+ 1) Include `auto_breadcrumbs` in your controller:
30
+
31
+ ```ruby
32
+ class UsersController < ApplicationController
33
+ include AutoBreadcrumbs
34
+
35
+ ...
36
+ end
37
+ ```
38
+
39
+ 2) Fill your locale file:
40
+
41
+ ```yml
42
+ en:
43
+ breadcrumbs:
44
+ root: 'Home'
45
+ actions:
46
+ new: 'New'
47
+ show: 'Show'
48
+ edit: 'Edit'
49
+ controllers:
50
+ users:
51
+ index: 'Users'
52
+ edit: 'Settings'
53
+ sync: 'Synchronization'
54
+ ...
55
+ ```
56
+
57
+ 3) Use helper method to show breadcrumbs in your view file:
58
+
59
+ ```erb
60
+ <body>
61
+ <%= render_breadcrumbs %>
62
+ </body>
63
+ ```
64
+
65
+ ## Customization
66
+
67
+ For more information about breadcrumbs' customization visit [breadcrumbs_on_rails](https://github.com/weppos/breadcrumbs_on_rails).
68
+
69
+ ## Contributing
70
+
71
+ 1. Fork it
72
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
73
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
74
+ 4. Push to the branch (`git push origin my-new-feature`)
75
+ 5. Create new Pull Request
76
+
77
+ ## TODO
78
+
79
+ * Add tests
80
+ * Add supporting of nested resources
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'auto_breadcrumbs/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'auto_breadcrumbs'
8
+ spec.version = AutoBreadcrumbs::VERSION
9
+ spec.authors = ['Evgeny Li']
10
+ spec.email = ['exaspark@gmail.com']
11
+ spec.description = %q{Automatically add breadcrumbs to each page by using locales}
12
+ spec.summary = %q{Automatically adding breadcrumbs by using locales}
13
+ spec.homepage = 'https://github.com/exAspArk/auto_breadcrumbs'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'breadcrumbs_on_rails'
22
+ end
@@ -0,0 +1,9 @@
1
+ en:
2
+ breadcrumbs:
3
+ root: 'Home'
4
+ actions:
5
+ new: 'New'
6
+ show: 'Show'
7
+ edit: 'Edit'
8
+ controllers:
9
+
@@ -0,0 +1,10 @@
1
+ require 'auto_breadcrumbs/version'
2
+ require 'auto_breadcrumbs/controller'
3
+
4
+ module AutoBreadcrumbs
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ include AutoBreadcrumbs::Controller
9
+ end
10
+ end
@@ -0,0 +1,50 @@
1
+ module AutoBreadcrumbs
2
+ module Controller
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ before_filter :add_breadcrumb_on_action, except: :destroy
7
+ end
8
+
9
+ private
10
+
11
+ def add_breadcrumb_on_action(options = {})
12
+ add_breadcrumb I18n.t('breadcrumbs.root'), :root_path
13
+
14
+ if request.path != root_path
15
+ if controllers_index_path && params[:action] == 'index'
16
+ add_breadcrumb index_translation, controllers_index_path
17
+ else
18
+ add_breadcrumb action_translation
19
+ end
20
+ end
21
+ end
22
+
23
+ def index_translation
24
+ I18n.t("breadcrumbs.controllers.#{ params[:controller] }.index")
25
+ end
26
+
27
+ def action_translation
28
+ begin
29
+ I18n.t!("breadcrumbs.controllers.#{ params[:controller] }.#{ breadcrumbs_action_name }")
30
+ rescue I18n::MissingTranslationData
31
+ I18n.t("breadcrumbs.actions.#{ breadcrumbs_action_name }")
32
+ end
33
+ end
34
+
35
+ def controllers_index_path
36
+ url_for(controller: params[:controller]) rescue nil
37
+ end
38
+
39
+ def breadcrumbs_action_name
40
+ case params[:action]
41
+ when 'create'
42
+ 'new'
43
+ when 'update'
44
+ 'edit'
45
+ else
46
+ params[:action]
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module AutoBreadcrumbs
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,13 @@
1
+ module AutoBreadcrumbs
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../../../../', __FILE__)
5
+
6
+ desc 'Copy locale files to your application.'
7
+
8
+ def copy_locale
9
+ copy_file 'config/locales/en.yml', 'config/locales/auto_breadcrumbs.en.yml'
10
+ end
11
+ end
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: auto_breadcrumbs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Evgeny Li
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: breadcrumbs_on_rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Automatically add breadcrumbs to each page by using locales
28
+ email:
29
+ - exaspark@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - Gemfile
35
+ - LICENSE.txt
36
+ - README.md
37
+ - Rakefile
38
+ - auto_breadcrumbs.gemspec
39
+ - config/locales/en.yml
40
+ - lib/auto_breadcrumbs.rb
41
+ - lib/auto_breadcrumbs/controller.rb
42
+ - lib/auto_breadcrumbs/version.rb
43
+ - lib/generators/auto_breadcrumbs/install_generator.rb
44
+ homepage: https://github.com/exAspArk/auto_breadcrumbs
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 2.0.3
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Automatically adding breadcrumbs by using locales
68
+ test_files: []