dub_thee 1.0.0 → 2.0.0
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 +5 -5
- data/README.md +19 -18
- data/Rakefile +1 -21
- data/lib/dub_thee/railtie.rb +3 -1
- data/lib/dub_thee/version.rb +1 -1
- data/lib/dub_thee.rb +13 -13
- metadata +12 -43
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: de1f33a0da20c01beec728de48819ff8594bb77dbc388491424c14c4d132745b
|
|
4
|
+
data.tar.gz: e9555f31237f2a3f2a148df1a2bc813a2a0caa3838e61e8b6122f3761911f737
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 108578d881677fb5f1bb6012e682b878018ebf8a8257d1a2f81425ebb6beaa7df8803dd09664ce0d722bb24ae9f9a24830e02da0ad931ee49befef5fbb9f62e7
|
|
7
|
+
data.tar.gz: b94579254b1c7e0406ee1b6b577afeecafad54fe9127d65014bfd9574ae02ac41826db1bd9d775edcfc864e1f12adaea2ed4429b08ae48e2acdb5e8c6a658e09
|
data/README.md
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Rails page titles via I18n. For example, given the following
|
|
4
4
|
application layout:
|
|
5
5
|
|
|
6
|
-
```erb
|
|
6
|
+
```html+erb
|
|
7
7
|
<!-- app/views/layouts/application.html.erb -->
|
|
8
|
+
|
|
8
9
|
<html>
|
|
9
10
|
<head>
|
|
10
11
|
<title><%= page_title %> | My Web Site</title>
|
|
@@ -16,7 +17,8 @@ application layout:
|
|
|
16
17
|
And the following translations:
|
|
17
18
|
|
|
18
19
|
```yaml
|
|
19
|
-
|
|
20
|
+
## config/locales/page_title.en.yml
|
|
21
|
+
|
|
20
22
|
en:
|
|
21
23
|
page_title:
|
|
22
24
|
home:
|
|
@@ -28,7 +30,7 @@ The "app/views/home/index.html.erb" view will automatically be titled
|
|
|
28
30
|
|
|
29
31
|
The `page_title` helper fetches the title via `I18n.t`, using the
|
|
30
32
|
controller name and action name to make up the translation key. Any
|
|
31
|
-
action name is allowed, however "create", "update", and "
|
|
33
|
+
action name is allowed, however "create", "update", and "destroy" are
|
|
32
34
|
special-cased to instead fetch the titles of their render-on-failure
|
|
33
35
|
counterparts: "new", "edit", and "show", respectively.
|
|
34
36
|
|
|
@@ -41,7 +43,8 @@ is included to enable attribute interpolation. For example, given the
|
|
|
41
43
|
following translations:
|
|
42
44
|
|
|
43
45
|
```yaml
|
|
44
|
-
|
|
46
|
+
## config/locales/page_title.en.yml
|
|
47
|
+
|
|
45
48
|
en:
|
|
46
49
|
page_title:
|
|
47
50
|
products:
|
|
@@ -63,7 +66,8 @@ of the controller, and `singular` is the `String#singularize`'d form of
|
|
|
63
66
|
`plural`. For example, given the following translations:
|
|
64
67
|
|
|
65
68
|
```yaml
|
|
66
|
-
|
|
69
|
+
## config/locales/page_title.en.yml
|
|
70
|
+
|
|
67
71
|
en:
|
|
68
72
|
page_title:
|
|
69
73
|
index: "%{plural}"
|
|
@@ -85,7 +89,8 @@ return `@page_title`. Thus, individual views can implement more nuanced
|
|
|
85
89
|
title logic. For example, given the following translations:
|
|
86
90
|
|
|
87
91
|
```yaml
|
|
88
|
-
|
|
92
|
+
## config/locales/page_title.en.yml
|
|
93
|
+
|
|
89
94
|
en:
|
|
90
95
|
page_title:
|
|
91
96
|
users:
|
|
@@ -94,9 +99,11 @@ en:
|
|
|
94
99
|
|
|
95
100
|
And the following view:
|
|
96
101
|
|
|
97
|
-
```erb
|
|
102
|
+
```html+erb
|
|
98
103
|
<!-- app/views/users/show.html.erb -->
|
|
104
|
+
|
|
99
105
|
<% @page_title = "Your Profile" if current_user == @user %>
|
|
106
|
+
|
|
100
107
|
...
|
|
101
108
|
```
|
|
102
109
|
|
|
@@ -107,19 +114,13 @@ own profile. Else, it will be equivalent to `"#{@user[:name]}"`.
|
|
|
107
114
|
|
|
108
115
|
## Installation
|
|
109
116
|
|
|
110
|
-
Add
|
|
111
|
-
|
|
112
|
-
```ruby
|
|
113
|
-
gem "dub_thee"
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
Then execute:
|
|
117
|
+
Add the gem to your Gemfile:
|
|
117
118
|
|
|
118
119
|
```bash
|
|
119
|
-
$ bundle
|
|
120
|
+
$ bundle add dub_thee
|
|
120
121
|
```
|
|
121
122
|
|
|
122
|
-
And
|
|
123
|
+
And run the install generator:
|
|
123
124
|
|
|
124
125
|
```bash
|
|
125
126
|
$ rails generate dub_thee:install
|
|
@@ -128,9 +129,9 @@ $ rails generate dub_thee:install
|
|
|
128
129
|
|
|
129
130
|
## Contributing
|
|
130
131
|
|
|
131
|
-
Run `
|
|
132
|
+
Run `bin/test` to run the tests.
|
|
132
133
|
|
|
133
134
|
|
|
134
135
|
## License
|
|
135
136
|
|
|
136
|
-
[MIT License](
|
|
137
|
+
[MIT License](MIT-LICENSE)
|
data/Rakefile
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
require 'bundler/setup'
|
|
3
|
-
rescue LoadError
|
|
4
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
require 'yard'
|
|
8
|
-
|
|
9
|
-
YARD::Rake::YardocTask.new(:doc) do |t|
|
|
10
|
-
end
|
|
11
|
-
|
|
1
|
+
require 'bundler/setup'
|
|
12
2
|
|
|
13
3
|
require 'bundler/gem_tasks'
|
|
14
|
-
|
|
15
|
-
require 'rake/testtask'
|
|
16
|
-
|
|
17
|
-
Rake::TestTask.new(:test) do |t|
|
|
18
|
-
t.libs << 'test'
|
|
19
|
-
t.pattern = 'test/**/*_test.rb'
|
|
20
|
-
t.verbose = false
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
task default: :test
|
data/lib/dub_thee/railtie.rb
CHANGED
data/lib/dub_thee/version.rb
CHANGED
data/lib/dub_thee.rb
CHANGED
|
@@ -15,22 +15,22 @@ module DubThee::PageTitleHelper
|
|
|
15
15
|
# @!visibility private
|
|
16
16
|
I18N_RESERVED_OPTIONS = I18n::RESERVED_KEYS.index_by(&:itself)
|
|
17
17
|
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
# controllers, the namespace is included as part of +controller_name
|
|
23
|
-
#
|
|
18
|
+
# Retrieves the current page's title via +I18n.t+. Translation keys
|
|
19
|
+
# are derived from the current controller and action. Specifically,
|
|
20
|
+
# the keys +"page_title.#{controller_name}.#{action_name}"+ and
|
|
21
|
+
# +"page_title.#{action_name}"+ are tried. For namespaced
|
|
22
|
+
# controllers, the namespace is included as part of +controller_name+,
|
|
23
|
+
# dot-separated.
|
|
24
24
|
#
|
|
25
|
-
# I18n string interpolation is supported using the view's
|
|
26
|
-
# variables. Additionally, the +titleize+'d controller name
|
|
27
|
-
# singular and plural form
|
|
28
|
-
# +singular+ and +plural+, respectively.
|
|
25
|
+
# I18n string interpolation is supported using the view's instance
|
|
26
|
+
# variables. Additionally, the +titleize+'d controller name is
|
|
27
|
+
# available in both singular and plural form via the interpolation
|
|
28
|
+
# keys +singular+ and +plural+, respectively.
|
|
29
29
|
#
|
|
30
30
|
# This method is memoized to +@page_title+, and can be invoked
|
|
31
31
|
# multiple times without additional cost. This also allows views to
|
|
32
|
-
#
|
|
33
|
-
#
|
|
32
|
+
# bypass I18n title lookup, if necessary, by assigning to the
|
|
33
|
+
# +@page_title+ variable.
|
|
34
34
|
#
|
|
35
35
|
# @return [String]
|
|
36
36
|
def page_title
|
|
@@ -45,7 +45,7 @@ module DubThee::PageTitleHelper
|
|
|
45
45
|
options[:singular] = options[:plural].singularize
|
|
46
46
|
options[:default] = :"page_title.#{action_part}"
|
|
47
47
|
|
|
48
|
-
@page_title = I18n.t("page_title.#{controller_part}.#{action_part}", options)
|
|
48
|
+
@page_title = I18n.t("page_title.#{controller_part}.#{action_part}", **options)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dub_thee
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Hefner
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
|
-
- - "
|
|
16
|
+
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '8.1'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
|
-
- - "
|
|
23
|
+
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
25
|
+
version: '8.1'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: i18n-interpolate_nested
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -38,37 +37,8 @@ dependencies:
|
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '1.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: sqlite3
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: yard
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0.9'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0.9'
|
|
69
|
-
description:
|
|
70
40
|
email:
|
|
71
|
-
- jonathan
|
|
41
|
+
- jonathan@hefner.pro
|
|
72
42
|
executables: []
|
|
73
43
|
extensions: []
|
|
74
44
|
extra_rdoc_files: []
|
|
@@ -84,8 +54,9 @@ files:
|
|
|
84
54
|
homepage: https://github.com/jonathanhefner/dub_thee
|
|
85
55
|
licenses:
|
|
86
56
|
- MIT
|
|
87
|
-
metadata:
|
|
88
|
-
|
|
57
|
+
metadata:
|
|
58
|
+
source_code_uri: https://github.com/jonathanhefner/dub_thee
|
|
59
|
+
changelog_uri: https://github.com/jonathanhefner/dub_thee/blob/master/CHANGELOG.md
|
|
89
60
|
rdoc_options: []
|
|
90
61
|
require_paths:
|
|
91
62
|
- lib
|
|
@@ -93,16 +64,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
93
64
|
requirements:
|
|
94
65
|
- - ">="
|
|
95
66
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '
|
|
67
|
+
version: '3.4'
|
|
97
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
69
|
requirements:
|
|
99
70
|
- - ">="
|
|
100
71
|
- !ruby/object:Gem::Version
|
|
101
72
|
version: '0'
|
|
102
73
|
requirements: []
|
|
103
|
-
|
|
104
|
-
rubygems_version: 2.5.2.1
|
|
105
|
-
signing_key:
|
|
74
|
+
rubygems_version: 4.0.10
|
|
106
75
|
specification_version: 4
|
|
107
76
|
summary: Rails page titles via I18n
|
|
108
77
|
test_files: []
|