hierarchical_page_titles 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,20 +1,23 @@
1
- ## hierarchical_page_titles
1
+ # hierarchical_page_titles
2
2
 
3
- ### What is this?
3
+ ## What is this?
4
4
 
5
- hierarchical_page_titles is a little gem that provides controller and view methods to make displaying of window/page titles DRYer. Currently, it's only compatible with Rails 3.
5
+ **hierarchical_page_titles** is a little gem that provides controller and view methods to make displaying of window/page titles DRYer.
6
6
 
7
- ### Why did you make it?
7
+ * [Documentation](http://rdoc.info/github/mcmire/hierarchical_page_titles/master/frames)
8
+ * [Known issues](http://github.com/mcmire/hierarchical_page_titles/issues)
8
9
 
9
- I made it because I found that I was doing the same thing over and over in my Rails apps. Setting the window or page title is a very common thing, and usually you'd handle this by simply setting a `@title` variable in your view and using it in your layout. However, I kept running into the case where I wanted to set the window title separate from the page title, or I wanted to set part of the window title globally for a controller, or I wanted to set the window title but hide the page title, and so on. So I decided to come up with a way to satisfy these requirements and yet keep things simple.
10
+ ## Why did you make it?
10
11
 
11
- ### How do I use it?
12
+ Well, I found that I was doing the same thing over and over in my Rails apps. Setting the window or page title is a very common thing, and usually you'd handle this by simply setting a `@title` variable in your view and using it in your layout. However, I kept running into the case where I wanted to set the window title separate from the page title, or I wanted to set part of the window title globally for a controller, or I wanted to set the window title but hide the page title, and so on. So I decided to come up with a very simple way to satisfy these requirements.
13
+
14
+ ## How do I use it?
12
15
 
13
16
  I'm going to walk through a few use cases and hopefully you'll get the idea.
14
17
 
15
- #### One
18
+ ### One
16
19
 
17
- The simplest case is if every page in your site has a title, and you want the window title to reflect the page title. hierarchical_page_titles gives you two helpers, `window_title` and `page_title`, that you can use in your layout. So let's do that:
20
+ The simplest case is if every page in your site has a title, and you want the window title to reflect the page title. **hierarchical_page_titles** gives you two helpers, `window_title` and `page_title`, that you can use in your layout. So let's do that:
18
21
 
19
22
  <html>
20
23
  <head><title><%= window_title %></title></head>
@@ -39,7 +42,7 @@ And now you get this when the page is rendered:
39
42
  </body>
40
43
  </html>
41
44
 
42
- #### Two
45
+ ### Two
43
46
 
44
47
  What if you want the name of your site to show up in the window title? The easiest way is to just hard-code it in your layout:
45
48
 
@@ -60,10 +63,10 @@ And this is what you get when a page is rendered:
60
63
  <p>Some content</p>
61
64
  </body>
62
65
  </html>
63
-
64
- #### Three
65
66
 
66
- What if there are some pages on your site in which you don't want to show a page title? Well, another helper hierarchical_page_titles gives you is `page_title?`, which will return true if the page title has been set. So let's say your layout looks like this:
67
+ ### Three
68
+
69
+ What if there are some pages on your site in which you don't want to show a page title? Well, another helper this gem gives you is `page_title?`, which will return true if the page title has been set. So let's say your layout looks like this:
67
70
 
68
71
  <html>
69
72
  <head><title><%= window_title %></title></head>
@@ -74,13 +77,13 @@ What if there are some pages on your site in which you don't want to show a page
74
77
  <%= yield %>
75
78
  </body>
76
79
  </html>
77
-
78
- And you have a view in which you set the window title, but not the page title:
80
+
81
+ In your view, instead of using `title`, you use `window_title`, which will set the window title, but not the page title:
79
82
 
80
83
  <% window_title "Some Page" %>
81
84
  <p>Some content</p>
82
85
 
83
- In this case your page will get rendered as follows:
86
+ Now your page will get rendered as follows:
84
87
 
85
88
  <html>
86
89
  <head><title>Some Page</title></head>
@@ -89,15 +92,59 @@ In this case your page will get rendered as follows:
89
92
  </body>
90
93
  </html>
91
94
 
92
- #### Four
95
+ ### Four
96
+
97
+ In many Rails apps, you are working with resources, so your controller hierarchy might look like this:
98
+
99
+ main
100
+ foos
101
+ index
102
+ new
103
+ edit
104
+ show
105
+ ...
106
+ bars
107
+ ...
108
+
109
+ You want to make sure that for every page, the window title reflects the current level of the hierarchy. For the pages within the "foos" resource, you *could* do something like this:
110
+
111
+ index
112
+ <% title "Foos" %>
113
+ new
114
+ <% title "Foos", "New Foo" %>
115
+ edit
116
+ <% title "Foos", "Edit Foo ##{foo.id}" %>
117
+ show
118
+ <% title "Foos", "Foo ##{foo.id}" >
119
+
120
+ This is okay, but it'd be nice if you didn't have to add "Foos" to every view. **hierarchical_page_titles** gives you a way to DRY this up too: a `title` helper in your controller. So your controller might look like this:
121
+
122
+ class FooController < ApplicationController
123
+ title "Foos"
93
124
 
94
- Let's combine the last two examples. That it, what happens if you want the
125
+ def index; ...; end
126
+ def new; ...; end
127
+ ...
128
+ end
95
129
 
96
- ....
130
+ Now that we have `title "Foos"` in the controller, `window_title` will be prepended with "Foos - ".
97
131
 
98
- ### How is it different from XYZ?
132
+ We could also use this method to set a global window title, say, in ApplicationController:
99
133
 
100
- There are several related gems/plugins:
134
+ class ApplicationController
135
+ title "My Website"
136
+ end
137
+ class FoosController < ApplicationController
138
+ title "Foos"
139
+ end
140
+
141
+ Now the window title will contain at least "My Website - Foos - ".
142
+
143
+ It's important to realize that **this only affects the window title**. The *page* title will always be equal to the last title "piece" set. This is because only the window title keeps an array of multiple title "pieces". A side effect of this is that if you call `window_title` multiple times, you add to the window title, whereas multiple calls to `page_title` always overrides what is previously set.
144
+
145
+ ## How is it different from XYZ?
146
+
147
+ This problem is not a new one, and there are several related gems/plugins:
101
148
 
102
149
  * **dynamic-page-title**: Provides options to `title` which are unnecessary. No support for hierarchical (controller-level) titles. Isn't compatible with Rails 3.
103
150
  * **entitled**: Interesting, but has totally different requirements.
@@ -108,20 +155,32 @@ There are several related gems/plugins:
108
155
  * **title_helper**: Not sure, Github project seems to be missing.
109
156
  * [**title_helpers**](https://github.com/henrik/title_helpers): Supports a page prefix, but doesn't support full hierarchy. Plus, I don't really like the API, and it isn't a gem.
110
157
 
111
- ### How do I install it?
158
+ ## How do I install it?
159
+
160
+ Just like you would any other gem: add this to your Gemfile:
161
+
162
+ gem 'hierarchical_page_titles', '0.1.1'
163
+
164
+ ## Can I use it with ... ?
165
+
166
+ At the moment, this gem is only compatible with Rails 3. If you need Rails 2 support, please see my related [title_helpers](https://github.com/mcmire/title_helpers) project.
167
+
168
+ ## I found a bug! or, I have a feature request...
112
169
 
113
- Just the usual way:
170
+ Great! Please file any issues in [Issues](http://github.com/mcmire/hierarchical_page_titles/issues).
114
171
 
115
- gem install hierarchical_page_titles
172
+ ## Can I contribute, and if so, how do I do so?
116
173
 
117
- ### I found a bug! or, I have a feature request...
174
+ Yes, I will be happy to accept any patches that you give me. At the moment there aren't any tests, so just make sure your code works with your own project. Then pull down the code, make a branch, and send me a pull request.
118
175
 
119
- Okay! Please file any issues in [Issues](http://github.com/mcmire/hierarchical_page_titles/issues).
176
+ ## Who made this?
120
177
 
121
- ### How do I contribute?
178
+ **hierarchical_page_titles** is (c) 2009-2011 Elliot Winkler. If you have any questions, please feel free to contact me through these channels:
122
179
 
123
- Pull down the code, make a branch, and send me a pull request.
180
+ * **Twitter**: [@mcmire](http://twitter.com/mcmire)
181
+ * **Email**: <elliot.winkler@gmail.com>
182
+ * **Blog**: <http://lostincode.net>
124
183
 
125
- ### Author/Copyright/License
184
+ ## Can I use this in my personal/commercial project?
126
185
 
127
- (c) 2009-2011 Elliot Winkler (email: <elliot.winkler@gmail.com>, twitter: [@mcmire](http://twitter.com/mcmire)). You are free to do whatever you want with this code, as long as I'm not held responsible, blah blah.
186
+ Yes, you are free to do whatever you like with this code. If you do use it, an attached courtesy would be appreciated. The only other thing I ask is that you make the world a better place with your awesome code powers!
@@ -1 +1,6 @@
1
- require 'hierarchical_page_titles/railtie'
1
+
2
+ require_relative 'hierarchical_page_titles/paths'
3
+
4
+ module HierarchicalPageTitles
5
+ require libpath('hierarchical_page_titles/railtie')
6
+ end
@@ -1,49 +1,179 @@
1
- require 'hierarchical_page_titles/shared_instance_methods'
1
+
2
+ require 'active_support/concern'
2
3
 
3
4
  module HierarchicalPageTitles
4
5
  module ControllerHelpers
5
- def self.included(base)
6
- base.extend(ClassMethods)
7
- end
8
-
9
- include SharedInstanceMethods
10
-
6
+ extend ActiveSupport::Concern
7
+
11
8
  module ClassMethods
12
- # Call this in the body of your controller with a string to add the string to
13
- # the window title before each action in your controller. This will work
14
- # for subcontrollers too -- so if you call window_title in a supercontroller
15
- # and also in a subcontroller, there will be two strings when you go to output
16
- # the window title. You can pass :only and :except to limit this to certain actions.
17
- def window_title(*args, &block)
18
- options = Hash === args.last ? args.last : {}
19
- before_filter(options) {|c| c.window_title(*args, &block) }
9
+ # Public: Append a string to the list of window titles for a group of
10
+ # actions.
11
+ #
12
+ # *titles - An Array of Strings which will be appended to the window
13
+ # titles.
14
+ # options - A Hash of options which filters the actions for which window
15
+ # titles are set:
16
+ # :only - Whitelist of actions (Symbol or Array of Symbols)
17
+ # :except - Blacklist of actions (Symbol or Array of Symbols)
18
+ # block - A block which will be evaluated but when the action is run
19
+ # and should return the value you want to add to the window
20
+ # titles. Useful if this value cannot be determined right away.
21
+ #
22
+ # Example:
23
+ #
24
+ # class ApplicationController
25
+ # window_title 'The best site evar'
26
+ # end
27
+ # class FoosController < ApplicationController
28
+ # window_title!(:only => :index) { winning? ? 'Zombies' : 'Vampires' }
29
+ # def winning?
30
+ # action_name == 'index'
31
+ # end
32
+ # end
33
+ #
34
+ # # foos/index.html.erb
35
+ # <%= window_title %>
36
+ # <%# => 'The best site evar - Zombies' %>
37
+ #
38
+ # # foos/new.html.erb
39
+ # <%= window_title %>
40
+ # <%# => 'The best site evar - Vampires' %>
41
+ #
42
+ # Returns nothing.
43
+ #
44
+ def window_title!(*args, &block)
45
+ options, titles = args.extract_options!, args
46
+ before_filter(options) do |c|
47
+ if block
48
+ c.window_titles! c.instance_eval(&block)
49
+ else
50
+ c.window_title!(titles)
51
+ end
52
+ end
20
53
  end
21
- alias :add_window_title :window_title
22
-
23
- # Call this in the body of your controller with a string to set the page title
24
- # globally for each action in your controller. Unlike window_title, this will not
25
- # work for subcontrollers -- so if you call page_title in a supercontroller and
26
- # also in a subcontroller, the subcontroller's title will override the supercontroller's.
27
- # You can pass :only and :except to limit this to certain actions.
28
- def page_title(*args, &block)
29
- options = Hash === args.last ? args.last : {}
30
- before_filter(options) {|c| c.page_title(*args, &block) }
31
- end
32
-
33
- # Call this in the body of your controller with a string to add it to the
34
- # window title AND set the page title at the same time.
35
- # See +window_title+ and +page_title+ for more.
36
- # You can pass :only and :except to limit this to certain actions.
37
- def title(*args, &block)
38
- options = Hash === args.last ? args.last : {}
39
- before_filter(options) {|c| c.title(*args, &block) }
40
- end
41
-
42
- # Call this in the body of your controller to tell page_title to not show anything.
43
- # You can pass :only and :except to limit this to certain actions.
44
- def hide_page_title(options={})
45
- before_filter(options) {|c| c.page_title(nil) }
54
+ alias :add_to_window_title :window_title!
55
+ alias :window_title :window_title! # for compatibility
56
+ end
57
+
58
+ # Public: Append a string to the list of window titles on a per-action
59
+ # basis.
60
+ #
61
+ # Note: This is really only here for use in a before_filter. If you wish to
62
+ # set the window title for a single action you should do so on the view
63
+ # level.
64
+ #
65
+ # *titles - An Array of Strings which will be appended to the window titles.
66
+ #
67
+ # Example:
68
+ #
69
+ # class FoosController < ApplicationController
70
+ # def index
71
+ # window_title! 'Foos'
72
+ # end
73
+ #
74
+ # def new
75
+ # end
76
+ # end
77
+ #
78
+ # # foos/index.html.erb
79
+ # <%= window_title %>
80
+ # <%# => 'Foos' %>
81
+ #
82
+ # # foos/new.html.erb
83
+ # <%= window_title %>
84
+ # <%# => "" %>
85
+ #
86
+ # Returns the current Array of window titles.
87
+ #
88
+ def window_title!(*titles)
89
+ @_window_titles ||= []
90
+ @_window_titles.concat titles.flatten
91
+ end
92
+ alias :add_to_window_title :window_title!
93
+ alias :window_title :window_title! # for compatibility
94
+
95
+ # Public: Return the current array of window titles.
96
+ #
97
+ def window_titles
98
+ @_window_titles
99
+ end
100
+
101
+ # Public: Determine whether there are any window titles to display.
102
+ #
103
+ # Returns true or false.
104
+ #
105
+ def window_title?
106
+ window_title_set? and @_window_titles.any?
107
+ end
108
+
109
+ # Public: Determine whether any window titles have been set yet.
110
+ #
111
+ # Returns true or false.
112
+ #
113
+ def window_title_set?
114
+ defined?(@_window_titles)
115
+ end
116
+
117
+ # Public: Set the page title for a single action.
118
+ #
119
+ # Note: This is really only here for use in a before_filter. If you wish to
120
+ # set the window title for a single action you should do so on the view
121
+ # level.
122
+ #
123
+ # title - A String.
124
+ #
125
+ # Returns the current page title.
126
+ #
127
+ def page_title!(title)
128
+ @_page_title = title
129
+ end
130
+ alias :set_page_title :page_title!
131
+ alias :page_title :page_title! # for compatibility
132
+
133
+ # Public: Return the current page title.
134
+ #
135
+ def page_title(title=nil)
136
+ # DEPRECATED: setting title
137
+ if title
138
+ page_title!(title)
139
+ else
140
+ @_page_title
46
141
  end
47
142
  end
143
+
144
+ # Public: Determine whether there is a page title to display.
145
+ #
146
+ # Returns true or false.
147
+ #
148
+ def page_title?
149
+ @_page_title.present?
150
+ end
151
+
152
+ # Public: Determine whether the page title has been set yet.
153
+ #
154
+ # Returns true or false.
155
+ #
156
+ def page_title_set?
157
+ defined?(@_page_title)
158
+ end
159
+
160
+ # Public: Add to the window titles and set the page title at the same time.
161
+ #
162
+ # Note: This is really only here for use in a before_filter. If you wish to
163
+ # set the window title for a single action you should do so on the view
164
+ # level.
165
+ #
166
+ # *titles - An Array of Strings. The whole Array will be appended to the
167
+ # window titles; the last item in the Array will be used as the
168
+ # page title.
169
+ #
170
+ # Returns nothing.
171
+ #
172
+ def title!(*titles)
173
+ window_title!(*titles)
174
+ page_title!(titles.last)
175
+ end
176
+ alias :set_window_and_page_title :title!
177
+ alias :title :title! # for compatibility
48
178
  end
49
- end
179
+ end
@@ -0,0 +1,37 @@
1
+
2
+ module HierarchicalPageTitles
3
+ LIBPATH = ::File.expand_path('../..', __FILE__) + ::File::SEPARATOR
4
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
5
+
6
+ # Returns the library path for the module. If any arguments are given, they
7
+ # will be joined to the end of the libray path using <tt>File.join</tt>.
8
+ #
9
+ def self.libpath( *args )
10
+ rv = args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
11
+ if block_given?
12
+ begin
13
+ $LOAD_PATH.unshift LIBPATH
14
+ rv = yield
15
+ ensure
16
+ $LOAD_PATH.shift
17
+ end
18
+ end
19
+ return rv
20
+ end
21
+
22
+ # Returns the path for the module. If any arguments are given, they will be
23
+ # joined to the end of the path using <tt>File.join</tt>.
24
+ #
25
+ def self.path( *args )
26
+ rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
27
+ if block_given?
28
+ begin
29
+ $LOAD_PATH.unshift PATH
30
+ rv = yield
31
+ ensure
32
+ $LOAD_PATH.shift
33
+ end
34
+ end
35
+ return rv
36
+ end
37
+ end
@@ -1,14 +1,27 @@
1
- require 'rails'
2
1
 
3
- require 'hierarchical_page_titles/controller_helpers'
4
- require 'hierarchical_page_titles/view_helpers'
2
+ require 'rails/railtie'
3
+ require 'active_support/lazy_load_hooks'
4
+ require_relative '../hierarchical_page_titles'
5
5
 
6
6
  module HierarchicalPageTitles
7
+ require libpath('hierarchical_page_titles/controller_helpers')
8
+ require libpath('hierarchical_page_titles/view_helpers')
9
+
7
10
  class Railtie < Rails::Railtie
8
- # copied from formtastic
9
- initializer "title-helpers.initialize", :after => :after_initialize do
10
- ActionController::Base.class_eval { include HierarchicalPageTitles::ControllerHelpers }
11
- ActionView::Base.class_eval { include HierarchicalPageTitles::ViewHelpers }
11
+ initializer 'hierarchical_page_titles.hook' do
12
+ ActiveSupport.on_load(:action_controller) do
13
+ include HierarchicalPageTitles::ControllerHelpers
14
+ end
15
+
16
+ ActiveSupport.on_load(:action_view) do
17
+ include HierarchicalPageTitles::ViewHelpers
18
+ end
19
+ end
20
+
21
+ def self.run_initializers(*args)
22
+ return if @initialized
23
+ super
24
+ @initialized = true
12
25
  end
13
26
  end
14
- end
27
+ end
@@ -1,3 +1,5 @@
1
+
1
2
  module HierarchicalPageTitles
2
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
+ def self.version; VERSION; end
3
5
  end
@@ -1,59 +1,124 @@
1
- require 'hierarchical_page_titles/shared_instance_methods'
2
1
 
3
2
  module HierarchicalPageTitles
4
3
  module ViewHelpers
5
- include SharedInstanceMethods
6
-
7
- # Call this in your view with a string to add the string to the array of window titles.
8
- # Call this in your layout to output the window title. You can specify a separator
9
- # that should be put between the titles by passing <tt>:separator => " - "</tt>.
10
- def window_title(*args, &block)
11
- options = args.extract_options!
12
- if args.empty?
13
- options[:separator] ||= " - "
14
- @_window_titles ||= []
15
- @_window_titles.join(options[:separator])
16
- else
17
- @_window_title_set = true
18
- super
19
- end
20
- end
21
-
22
- # Call this in your view with a string to set the page title to that string.
23
- # Call this in your layout with no arguments to output the page title.
24
- def page_title(*args)
25
- options = args.extract_options!
26
- if args.empty?
27
- @_page_title
28
- else
29
- @_page_title_set = true
30
- super
31
- end
4
+ # Public: Append a string to the list of window titles for the view.
5
+ #
6
+ # The window titles array used here is inherited from the controller level,
7
+ # so if you add a window title in the controller and then again in the view
8
+ # then there will be two items in the window titles array.
9
+ #
10
+ # *titles - An Array of Strings which will be appended to the window titles.
11
+ #
12
+ # Example:
13
+ #
14
+ # class FoosController < ApplicationController
15
+ # def index
16
+ # window_title! 'Foos'
17
+ # end
18
+ #
19
+ # def new
20
+ # end
21
+ # end
22
+ #
23
+ # # foos/index.html.erb
24
+ # <% window_title! 'Bars' %>
25
+ # <%= window_title %>
26
+ # <%# => 'Foos - Bars' %>
27
+ #
28
+ # Returns the current Array of window titles.
29
+ #
30
+ def window_title!(*titles)
31
+ controller.window_title!(*titles)
32
32
  end
33
-
34
- def title(*args)
35
- @_title_set = true
36
- super
33
+ alias :add_to_window_title :window_title!
34
+ alias :window_title :window_title! # for compatibility
35
+
36
+ # Public: Return the array of window titles.
37
+ #
38
+ def window_titles
39
+ controller.window_titles
37
40
  end
38
-
39
- # TODO: Document
40
- def page_title?
41
- @_page_title.present?
41
+
42
+ # Public: Determine whether there are any window titles to display.
43
+ #
44
+ # Returns true or false.
45
+ #
46
+ def window_title?
47
+ controller.window_title?
42
48
  end
43
-
44
- # TODO: Document
49
+
50
+ # Public: Determine whether any window titles have been set yet.
51
+ #
52
+ # Returns true or false.
53
+ #
45
54
  def window_title_set?
46
- @_window_title_set
55
+ controller.window_title_set?
56
+ end
57
+
58
+ # Public: Set the page title for the view.
59
+ #
60
+ # title - A String.
61
+ #
62
+ # Returns the current page title.
63
+ #
64
+ def page_title!(title)
65
+ controller.page_title!(title)
47
66
  end
48
-
49
- # TODO: Document
67
+ alias :set_page_title :page_title!
68
+ alias :page_title :page_title! # for compatibility
69
+
70
+ # Public: Return the current page title.
71
+ #
72
+ def page_title(title=nil) # DEPRECATED: setting title
73
+ controller.page_title(title)
74
+ end
75
+
76
+ # Public: Determine whether there is a page title to display.
77
+ #
78
+ # Returns true or false.
79
+ #
80
+ def page_title?
81
+ controller.page_title?
82
+ end
83
+
84
+ # Public: Determine whether the page title has been set yet.
85
+ #
86
+ # Returns true or false.
87
+ #
50
88
  def page_title_set?
51
- @_page_title_set
89
+ controller.page_title_set?
52
90
  end
53
-
54
- # TODO: Document
55
- def title_set?
56
- @_title_set
91
+
92
+ # Public: Add to the window titles and set the page title at the same time.
93
+ #
94
+ # *titles - An Array of Strings. The whole Array will be appended to the
95
+ # window titles; the last item in the Array will be used as the
96
+ # page title.
97
+ #
98
+ # Returns nothing.
99
+ #
100
+ def title!(*titles)
101
+ window_title!(*titles)
102
+ page_title!(titles.last)
103
+ end
104
+ alias :set_window_and_page_title :title!
105
+ alias :title :title! # for compatibility
106
+
107
+ # Public: Return a stringified version of the window titles array joined by
108
+ # a separator.
109
+ #
110
+ # options - A Hash of options (default: {}):
111
+ # separator - The string with which to join the window titles
112
+ # array.
113
+ #
114
+ def window_title(*args)
115
+ options = args.extract_options!
116
+ if args.any?
117
+ # TODO: Remove
118
+ window_title!(*args)
119
+ else
120
+ window_titles.join(options[:separator] || " - ")
121
+ end
57
122
  end
58
123
  end
59
- end
124
+ end
metadata CHANGED
@@ -1,75 +1,54 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hierarchical_page_titles
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Elliot Winkler
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-01-06 00:00:00 -07:00
19
- default_executable:
12
+ date: 2012-05-19 00:00:00.000000000 Z
20
13
  dependencies: []
21
-
22
- description: A gem that provides controller and view methods to make displaying of window/page titles DRYer.
23
- email:
14
+ description: A gem that provides controller and view methods to make displaying of
15
+ window/page titles DRYer.
16
+ email:
24
17
  - elliot.winkler@gmail.com
25
18
  executables: []
26
-
27
19
  extensions: []
28
-
29
20
  extra_rdoc_files: []
30
-
31
- files:
21
+ files:
32
22
  - README.md
33
- - hierarchical_page_titles.gemspec
34
23
  - lib/hierarchical_page_titles/controller_helpers.rb
24
+ - lib/hierarchical_page_titles/paths.rb
35
25
  - lib/hierarchical_page_titles/railtie.rb
36
- - lib/hierarchical_page_titles/shared_instance_methods.rb
37
26
  - lib/hierarchical_page_titles/version.rb
38
27
  - lib/hierarchical_page_titles/view_helpers.rb
39
28
  - lib/hierarchical_page_titles.rb
40
- has_rdoc: true
41
29
  homepage: http://github.com/mcmire/hierarchical_page_titles
42
30
  licenses: []
43
-
44
31
  post_install_message:
45
32
  rdoc_options: []
46
-
47
- require_paths:
33
+ require_paths:
48
34
  - lib
49
- required_ruby_version: !ruby/object:Gem::Requirement
35
+ required_ruby_version: !ruby/object:Gem::Requirement
50
36
  none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- hash: 3
55
- segments:
56
- - 0
57
- version: "0"
58
- required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
42
  none: false
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- hash: 3
64
- segments:
65
- - 0
66
- version: "0"
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
67
47
  requirements: []
68
-
69
48
  rubyforge_project:
70
- rubygems_version: 1.3.7
49
+ rubygems_version: 1.8.11
71
50
  signing_key:
72
51
  specification_version: 3
73
- summary: A gem that provides controller and view methods to make displaying of window/page titles DRYer.
52
+ summary: A gem that provides controller and view methods to make displaying of window/page
53
+ titles DRYer.
74
54
  test_files: []
75
-
@@ -1,21 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "hierarchical_page_titles/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "hierarchical_page_titles"
7
- s.version = HierarchicalPageTitles::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Elliot Winkler"]
10
- s.email = ["elliot.winkler@gmail.com"]
11
- s.homepage = "http://github.com/mcmire/hierarchical_page_titles"
12
- s.summary = %q{A gem that provides controller and view methods to make displaying of window/page titles DRYer.}
13
- s.description = %q{A gem that provides controller and view methods to make displaying of window/page titles DRYer.}
14
-
15
- #s.rubyforge_project = "title_helpers"
16
-
17
- s.files = ["README.md", "hierarchical_page_titles.gemspec"] + Dir["lib/**/*"]
18
- s.test_files = Dir["{test,spec,features}/**/*"]
19
- s.executables = Dir["bin/**/*"].map {|f| File.basename(f) }
20
- s.require_paths = ["lib"]
21
- end
@@ -1,37 +0,0 @@
1
- module HierarchicalPageTitles
2
- module SharedInstanceMethods
3
- # Call this in your view with a string to add the string to the array of window titles.
4
- # Call this in your layout to output the window title. You can specify a separator
5
- # that should be put between the titles by passing <tt>:separator => " - "</tt>.
6
- def window_title(*args, &block)
7
- options = args.extract_options!
8
- titles = args.flatten
9
- @_window_titles ||= []
10
- if block_given?
11
- @_window_titles << instance_eval(&block)
12
- else
13
- @_window_titles += titles
14
- end
15
- end
16
-
17
- # Call this in your view with a string to set the page title to that string.
18
- # Call this in your layout with no arguments to output the page title.
19
- def page_title(*args, &block)
20
- options = args.extract_options!
21
- title = args.first
22
- @_page_title = (block_given? ? instance_eval(&block) : title)
23
- end
24
-
25
- # Call this in your view to set the window title and the page title at the same time.
26
- # See +window_title+ and +page_title+ for more.
27
- def title(*args, &block)
28
- options = args.extract_options!
29
- window_title(*args, &block)
30
- page_title(args.last, &block)
31
- end
32
-
33
- def titles
34
- @_window_titles
35
- end
36
- end
37
- end