rails_breadcrumbs 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Artem Rufanov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,41 @@
1
+ RailsBreadcrumbs
2
+ ===================
3
+
4
+ RailsBreadcrumbs is a gem that implements breadcrumbs.
5
+
6
+ * The gem supports ruby 1.9.x & rails 3.x
7
+ * The gem allows to create breadcrumbs based on path
8
+ * The gem allows ...
9
+
10
+ Quick Start
11
+ =======
12
+ In your Gemfile:
13
+
14
+ gem "rails_breadcrumbs", ">= 0.5.3"
15
+
16
+ In your controller:
17
+
18
+ before_filter :add_breadcrumbs_by_path
19
+
20
+ In your views:
21
+
22
+ <%= render_breadcrumbs %>
23
+
24
+ If you wish:
25
+
26
+ -Run ruby script/rails generate rails_breadcrumbs to gen resources such as css, sass and png files.
27
+ -Use config/initiaizers to configure options for this gem
28
+
29
+
30
+ Installation
31
+ =======
32
+
33
+ * Type 'gem install --local rails_breadcrumbs' with root account if you have installed RubyGems.
34
+
35
+
36
+ Example
37
+ =======
38
+
39
+ Example goes here.
40
+
41
+ Copyright (c) 2011 arufanov, released under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the rails_breadcrumbs plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the rails_breadcrumbs plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'RailsBreadcrumbs'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
data/changelog ADDED
@@ -0,0 +1,23 @@
1
+ Introduction:
2
+ To see the latest list of the change log please visit the Change Log page at www.majoron.com.
3
+
4
+ Legend:
5
+ Follow notation is used at change log, roadmap and known bugs. Each bug begins with a version,
6
+ then follow category of the bug inside {}. It can be bug report, feature request and etc.
7
+ Then follow component inside []. After follow bug number at bug tracking system between // signs.
8
+ And then follow a short description of the bug.
9
+
10
+ Example:
11
+ For example bug: "1.0 { Feature Request } [ AntHill ] / 380 / STLport support required" means
12
+ that bug was created for 1.0 version of the AntHill component, bug is feature request with
13
+ 380 number at bug tracking system. And bug requires STLPort support implementation.
14
+
15
+ Version 0.5
16
+ -----------
17
+ 0.5 { Bug Report } [ RailsBreadcrumbs ] / X / Don't put separator for root
18
+ 0.5 { Bug Report } [ RailsBreadcrumbs ] / X / Move separator out of link
19
+ 0.5 { Bug Report } [ RailsBreadcrumbs ] / X / Changed item separator from '&gt;' to ' &gt;'
20
+ 0.5 { Bug Report } [ RailsBreadcrumbs ] / X / Added configuratin parameter to show Home string instead of Home icons
21
+ 0.5 { Bug Report } [ RailsBreadcrumbs ] / X / Changelog, roadmap, knownbugs have been created
22
+ 0.5 { Bug Report } [ RailsBreadcrumbs ] / X / Use include, extend instead of class_eval
23
+ 0.5 { Bug Report } [ RailsBreadcrumbs ] / X / home_controller, home_action has been changed to home_path
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Include hook code here
2
+ require 'rails_breadcrumbs'
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
data/knownbugs ADDED
@@ -0,0 +1,17 @@
1
+ Introduction:
2
+ To see the latest list of the known bugs please visit the Known bugs page at www.majoron.com.
3
+
4
+ Legend:
5
+ Follow notation is used at change log, roadmap and known bugs. Each bug begins with a version,
6
+ then follow category of the bug inside {}. It can be bug report, feature request and etc.
7
+ Then follow component inside []. After follow bug number at bug tracking system between // signs.
8
+ And then follow a short description of the bug.
9
+
10
+ Example:
11
+ For example bug: "1.0 { Feature Request } [ AntHill ] / 380 / STLport support required" means
12
+ that bug was created for 1.0 version of the AntHill component, bug is feature request with
13
+ 380 number at bug tracking system. And bug requires STLPort support implementation.
14
+
15
+ Version 0.5
16
+ -----------
17
+ 0.5 { Bug Report } [ AuxiliaryAddons ] / X / There isn't known bugs
@@ -0,0 +1,3 @@
1
+ Description:
2
+ The rails_breadcrumbs generator creates an home icons at public/breadcrumbs
3
+ and rails_breadcrumbs css & cass at public/stylesheets/ directory.
@@ -0,0 +1,13 @@
1
+ module RailsBreadcrumbs
2
+ module Generators
3
+ class RailsBreadcrumbsGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def generate_rails_breadcrumbs
7
+ copy_file "home.png", "public/images/breadcrumbs/home.png"
8
+ copy_file "rails_breadcrumbs.css", "public/stylesheets/rails_breadcrumbs.css"
9
+ copy_file "rails_breadcrumbs.sass", "public/stylesheets/rails_breadcrumbs.sass"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ /* =Breadcrumbs styles
2
+ * This section contains breadcrumb's styles for markup
3
+ * <div id="breadcrumbs">
4
+ * <span>You are here:</span> <%= render_breadcrumbs %>
5
+ * </div>
6
+ */
7
+ #breadcrumbs {
8
+ float: left; }
9
+ #breadcrumbs span {
10
+ float: left;
11
+ font-size: 120%; }
12
+ #breadcrumbs ul.breadcrumbs {
13
+ float: left; }
14
+ #breadcrumbs ul.breadcrumbs li {
15
+ border: 1px;
16
+ float: left; }
17
+ #breadcrumbs ul.breadcrumbs li.first_breadcrumb_item {
18
+ border: 1px; }
19
+ #breadcrumbs ul.breadcrumbs li.last_breadcrumb_item a {
20
+ font-weight: bold; }
21
+ #breadcrumbs ul.breadcrumbs li.last_breadcrumb_item span {
22
+ font-weight: bold; }
@@ -0,0 +1,23 @@
1
+ /* =Breadcrumbs styles
2
+ * This section contains breadcrumb's styles for markup
3
+ * <div id="breadcrumbs">
4
+ * <span>You are here:</span> <%= render_breadcrumbs %>
5
+ * </div>
6
+ */
7
+ #breadcrumbs
8
+ float: left
9
+ span
10
+ float: left
11
+ font-size: 120%
12
+ ul.breadcrumbs
13
+ float: left
14
+ li
15
+ border: 1px
16
+ float: left
17
+ li.first_breadcrumb_item
18
+ border: 1px
19
+ li.last_breadcrumb_item
20
+ a
21
+ font-weight: bold
22
+ span
23
+ font-weight: bold
@@ -0,0 +1,64 @@
1
+ #
2
+ module RailsBreadcrumbs
3
+ module ControllerAdditions
4
+ # ::Rails.logger.error("...")
5
+
6
+ #
7
+ def self.add_breadcrumb(name, url, options = {})
8
+ before_filter options do |controller|
9
+ controller.send(:add_breadcrumb, name, url)
10
+ end
11
+ end
12
+
13
+ # Add breadcrumb for page
14
+ def add_breadcrumb name, url = ''
15
+ @breadcrumbs ||= []
16
+ url = eval(url) if url =~ /_path|_url|@/
17
+ @breadcrumbs << [name, url]
18
+ end
19
+
20
+ #
21
+ def add_breadcrumbs_by_path(names = {}, options = {})
22
+ options = ::RailsBreadcrumbs.options.merge(options)
23
+ path_parts = controller_path.split('/')
24
+ path_parts.each do |segment|
25
+ link_name = segment.sub('_', ' ').camelcase
26
+ link_name = names[segment] if names.has_key?(segment)
27
+ name = I18n.t options[:locale_root] + segment, :default => link_name
28
+ if segment != path_parts.last
29
+ route = nil
30
+ path_parts.each do |temp|
31
+ route = (route.nil? ? temp: route +'_'+ temp)
32
+ break if temp == segment
33
+ end
34
+ link = send(route + '_path')
35
+ else
36
+ link = request.path
37
+ end
38
+ add_breadcrumb(name, link)
39
+ end
40
+ end
41
+
42
+ #
43
+ def add_breadcrumbs_with_action_by_path(names = {}, options = {})
44
+ options = ::RailsBreadcrumbs.options.merge(options)
45
+ path_parts = controller_path.split('/') << action_name
46
+ path_parts.each do |segment|
47
+ link_name = segment.sub('_', ' ').camelcase
48
+ link_name = names[segment] if names.has_key?(segment)
49
+ name = I18n.t options[:locale_root] + segment, :default => link_name
50
+ if segment != path_parts.last
51
+ route = nil
52
+ path_parts.each do |temp|
53
+ route = (route.nil? ? temp: route +'_'+ temp)
54
+ break if temp == segment
55
+ end
56
+ link = send(route + '_path')
57
+ else
58
+ link = request.path
59
+ end
60
+ add_breadcrumb(name, link)
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,6 @@
1
+ #
2
+ module RailsBreadcrumbs
3
+ module ModelAdditions
4
+ # ::Rails.logger.error("...")
5
+ end
6
+ end
@@ -0,0 +1,72 @@
1
+ #
2
+ module RailsBreadcrumbs
3
+ module ViewAdditions
4
+ # ::Rails.logger.error("...")
5
+
6
+ #
7
+ # Renders breadcrumbs
8
+ #
9
+ # <ul>
10
+ # <li class="first">
11
+ # <%=link_to(image_tag("breadcrumbs/home.png", {:alt => "Home", :title => "Home"}), :controller => "/welcome") %> &gt;
12
+ # </li>
13
+ # <% if @breadcrumbs %>
14
+ # <% @breadcrumbs[0..-2].each do |txt, path| %>
15
+ # <li>
16
+ # <%= link_to(h(txt), path) %> &gt;
17
+ # </li>
18
+ # <% end %>
19
+ # <li>
20
+ # <span><%= link_to(h(@breadcrumbs.last.first), @breadcrumbs.last.second) %> </span>
21
+ # </li>
22
+ # <% end %>
23
+ # </ul>
24
+ #
25
+ def render_breadcrumbs(options = {})
26
+ output = ""
27
+ options = ::RailsBreadcrumbs.options.merge(options)
28
+
29
+ # First item is home
30
+ if options[:include_home_icon]
31
+ output << content_tag(:li, {:class => "first_breadcrumb_item"}, false) do
32
+ link_to(image_tag("breadcrumbs/home.png", {:alt => "Home", :title => "Home"}),options[:home_path]) +
33
+ (@breadcrumbs && @breadcrumbs.size() > 0 ? raw(options[:item_separator]) : "")
34
+ end
35
+ end
36
+
37
+ # First item is home
38
+ if options[:include_home_label]
39
+ output << content_tag(:li, {:class => "first_breadcrumb_item"}, false) do
40
+ link_to( h(options[:home_label]), options[:home_path]) +
41
+ (@breadcrumbs && @breadcrumbs.size() > 0 ? raw(options[:item_separator]) : "")
42
+ end
43
+ end
44
+
45
+ # Midle items
46
+ if @breadcrumbs
47
+ @breadcrumbs[0..-2].each do |txt, path|
48
+ output << content_tag(:li, {:class => "last_breadcrumb_item"}, false) do
49
+ link_to( h(txt), path) + raw(options[:item_separator])
50
+ end
51
+ end
52
+ end
53
+
54
+ # Last item
55
+ if @breadcrumbs
56
+ if options[:make_last_item_as_link]
57
+ output << content_tag(:li, {:class => "last_breadcrumb_item"}, false) do
58
+ link_to( h(@breadcrumbs.last.first), @breadcrumbs.last.second)
59
+ end
60
+ else
61
+ output << content_tag(:li, {:class => "last_breadcrumb_item"}, false) do
62
+ content_tag(:span, h(@breadcrumbs.last.first))
63
+ end
64
+ end
65
+ end
66
+
67
+ # Return result
68
+ content_tag('ul', output, {:class => options[:css_class]}, false)
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,43 @@
1
+ # Include
2
+ require 'rubygems'
3
+ require 'active_support'
4
+ require 'rails_breadcrumbs/model_additions'
5
+ require 'rails_breadcrumbs/controller_additions'
6
+ require 'rails_breadcrumbs/view_additions'
7
+
8
+ # = Rails breadcrumbs
9
+ #
10
+ module RailsBreadcrumbs
11
+ # ::Rails.logger.error("...")
12
+
13
+ # default options that can be overridden on the global level
14
+ @@options = {
15
+ :locale_root => 'navigation.breadcrumbs.', #
16
+ :home_path => '/welcome', #
17
+ :home_label => 'Home', #
18
+ :item_separator => ' &gt;', #
19
+ :css_class => 'breadcrumbs', #
20
+ :fist_item_css_class => 'first_breadcrumb_item', #
21
+ :last_item_css_class => 'last_breadcrumb_item', #
22
+ :make_last_item_as_link => true, #
23
+ :include_home_icon => true, #
24
+ :include_home_label => false, #
25
+ }
26
+ mattr_reader :options
27
+
28
+
29
+ def self.enable_activerecord
30
+ ActiveRecord::Base.send :include, RailsBreadcrumbs::ModelAdditions
31
+ end
32
+
33
+ def self.enable_actionpack
34
+ ActionController::Base.send :include, RailsBreadcrumbs::ControllerAdditions
35
+
36
+ ActionView::Base.send :include, RailsBreadcrumbs::ViewAdditions
37
+ end
38
+ end
39
+
40
+ if defined? Rails
41
+ RailsBreadcrumbs.enable_activerecord if defined? ActiveRecord
42
+ RailsBreadcrumbs.enable_actionpack if defined? ActionController
43
+ end
@@ -0,0 +1,17 @@
1
+ require 'date'
2
+ Gem::Specification.new do |s|
3
+ s.name = %q{rails_breadcrumbs}
4
+ s.version = "0.5.3"
5
+ s.date = Date.today.to_s
6
+ s.summary = %q{RailsBreadcrumbs is a gem that implements breadcrumbs.}
7
+ s.description = %q{RailsBreadcrumbs is a gem that implements breadcrumbs.}
8
+ s.author = %q{Artem Rufanov}
9
+ s.email = %q{developers@majoron.com}
10
+ s.homepage = %q{http://www.majoron.com/project/rbundle/rails_breadcrumbs}
11
+ s.files = Dir.glob('**/*') - Dir.glob('distrib/**/*') - Dir.glob('lib/api/**/*') - Dir.glob('doc/*.xpr')
12
+ s.bindir = 'bin'
13
+ s.executables = Dir.glob('bin/*').collect {|f| File.basename(f)}
14
+ s.require_paths << 'doc' << 'examples' << 'lib' << 'test'
15
+ s.has_rdoc = true
16
+ s.required_ruby_version = '>= 1.8.7'
17
+ end
data/roadmap ADDED
@@ -0,0 +1,19 @@
1
+ Introduction:
2
+ To see the latest list of the roadmap please visit the Roadmap page at www.majoron.com.
3
+
4
+ Legend:
5
+ Follow notation is used at change log, roadmap and known bugs. Each bug begins with a version,
6
+ then follow category of the bug inside {}. It can be bug report, feature request and etc.
7
+ Then follow component inside []. After follow bug number at bug tracking system between // signs.
8
+ And then follow a short description of the bug.
9
+
10
+ Example:
11
+ For example bug: "1.0 { Feature Request } [ AntHill ] / 380 / STLport support required" means
12
+ that bug was created for 1.0 version of the AntHill component, bug is feature request with
13
+ 380 number at bug tracking system. And bug requires STLPort support implementation.
14
+
15
+ Version 0.5
16
+ -----------
17
+ 0.5 { Feature Request } [ RailsBreadcrumbs ] / X / Add tests
18
+ 0.5 { Feature Request } [ RailsBreadcrumbs ] / X / Add RailsTie
19
+
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe RailsBreadcrumbs::ControllerAdditions do
4
+ it "should define controller additions" do
5
+ ::RailsBreadcrumbs::ControllerAdditions.should be
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe RailsBreadcrumbs::ModelAdditions do
4
+ it "should define model additions" do
5
+ ::RailsBreadcrumbs::ModelAdditions.should be
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe RailsBreadcrumbs::ViewAdditions do
4
+ it "should define view additions" do
5
+ ::RailsBreadcrumbs::ViewAdditions.should be
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe RailsBreadcrumbs do
4
+ it "should define rails" do
5
+ ::Rails::VERSION::MAJOR.should be
6
+ end
7
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --backtrace
@@ -0,0 +1,23 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+ $:.unshift File.join(File.dirname(__FILE__), '../lib')
3
+
4
+ ENV["RAILS_ENV"] = "test"
5
+ require 'rubygems'
6
+ require 'rspec'
7
+ require 'action_controller'
8
+ require 'rails_breadcrumbs'
9
+
10
+ module Rails
11
+ module VERSION
12
+ MAJOR = 3
13
+ end
14
+ end unless defined? Rails
15
+
16
+ # RailsBreadcrumbs.root = './'
17
+ RAILS_ROOT = './' unless defined?(RAILS_ROOT)
18
+ RAILS_ENV = 'test' unless defined?(RAILS_ENV)
19
+
20
+ RSpec.configure do |config|
21
+ config.mock_with :rspec
22
+ end
23
+
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :captcha_validateable do
3
+ # # Task goes here
4
+ # end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_breadcrumbs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Artem Rufanov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-16 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: RailsBreadcrumbs is a gem that implements breadcrumbs.
15
+ email: developers@majoron.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - changelog
21
+ - init.rb
22
+ - install.rb
23
+ - knownbugs
24
+ - lib/generators/rails_breadcrumbs/rails_breadcrumbs_generator.rb
25
+ - lib/generators/rails_breadcrumbs/templates/home.png
26
+ - lib/generators/rails_breadcrumbs/templates/rails_breadcrumbs.css
27
+ - lib/generators/rails_breadcrumbs/templates/rails_breadcrumbs.sass
28
+ - lib/generators/rails_breadcrumbs/USAGE
29
+ - lib/rails_breadcrumbs/controller_additions.rb
30
+ - lib/rails_breadcrumbs/model_additions.rb
31
+ - lib/rails_breadcrumbs/view_additions.rb
32
+ - lib/rails_breadcrumbs.rb
33
+ - MIT-LICENSE
34
+ - rails_breadcrumbs.gemspec
35
+ - Rakefile
36
+ - README
37
+ - roadmap
38
+ - spec/lib/rails_breadcrumbs/controller_additions_spec.rb
39
+ - spec/lib/rails_breadcrumbs/model_additions_spec.rb
40
+ - spec/lib/rails_breadcrumbs/view_additions_spec.rb
41
+ - spec/lib/rails_breadcrumbs_spec.rb
42
+ - spec/spec.opts
43
+ - spec/spec_helper.rb
44
+ - tasks/rails_breadcrumbs_tasks.rake
45
+ - uninstall.rb
46
+ homepage: http://www.majoron.com/project/rbundle/rails_breadcrumbs
47
+ licenses: []
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ - doc
53
+ - examples
54
+ - lib
55
+ - test
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.7
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 1.8.10
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: RailsBreadcrumbs is a gem that implements breadcrumbs.
74
+ test_files: []