page_title 0.0.4 → 0.1.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 +4 -4
- data/.rspec +0 -1
- data/.travis.yml +5 -1
- data/Gemfile.lock +94 -69
- data/README.md +12 -0
- data/lib/page_title.rb +8 -4
- data/lib/page_title/version.rb +1 -1
- data/spec/controllers/controllers_spec.rb +18 -6
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/support/controllers.rb +5 -0
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 566efe6e91936fdb642695020c3d37caf542266c
|
|
4
|
+
data.tar.gz: 8e5cfd6307972be29ad5b73bad9bfb030ed21f1c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d715c6eca59072f22f0f14dcb3632bef77ccf96edc891097939805de56fb6972dd1230d8e238c7967ad4eba92b96b931e0f002bf1c96ee0938ef28f5db3a558
|
|
7
|
+
data.tar.gz: 7aeac1dbfbcb5f9e5f9966dc06c7e51076937267088cbd63644c43910d6a50c02a80e613a92be8469efcba6385106fabf0f848ad40b96cf55594bef2dce5492b
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,103 +1,128 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
page_title (0.0
|
|
4
|
+
page_title (0.1.0)
|
|
5
5
|
rails
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
actionmailer (4.
|
|
11
|
-
actionpack (= 4.
|
|
12
|
-
actionview (= 4.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
actionmailer (4.2.0)
|
|
11
|
+
actionpack (= 4.2.0)
|
|
12
|
+
actionview (= 4.2.0)
|
|
13
|
+
activejob (= 4.2.0)
|
|
14
|
+
mail (~> 2.5, >= 2.5.4)
|
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
16
|
+
actionpack (4.2.0)
|
|
17
|
+
actionview (= 4.2.0)
|
|
18
|
+
activesupport (= 4.2.0)
|
|
19
|
+
rack (~> 1.6.0)
|
|
18
20
|
rack-test (~> 0.6.2)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
|
23
|
+
actionview (4.2.0)
|
|
24
|
+
activesupport (= 4.2.0)
|
|
21
25
|
builder (~> 3.1)
|
|
22
26
|
erubis (~> 2.7.0)
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
28
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
|
29
|
+
activejob (4.2.0)
|
|
30
|
+
activesupport (= 4.2.0)
|
|
31
|
+
globalid (>= 0.3.0)
|
|
32
|
+
activemodel (4.2.0)
|
|
33
|
+
activesupport (= 4.2.0)
|
|
25
34
|
builder (~> 3.1)
|
|
26
|
-
activerecord (4.
|
|
27
|
-
activemodel (= 4.
|
|
28
|
-
activesupport (= 4.
|
|
29
|
-
arel (~>
|
|
30
|
-
activesupport (4.
|
|
31
|
-
i18n (~> 0.
|
|
35
|
+
activerecord (4.2.0)
|
|
36
|
+
activemodel (= 4.2.0)
|
|
37
|
+
activesupport (= 4.2.0)
|
|
38
|
+
arel (~> 6.0)
|
|
39
|
+
activesupport (4.2.0)
|
|
40
|
+
i18n (~> 0.7)
|
|
32
41
|
json (~> 1.7, >= 1.7.7)
|
|
33
42
|
minitest (~> 5.1)
|
|
34
|
-
thread_safe (~> 0.
|
|
43
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
35
44
|
tzinfo (~> 1.1)
|
|
36
|
-
arel (
|
|
45
|
+
arel (6.0.0)
|
|
37
46
|
builder (3.2.2)
|
|
38
47
|
diff-lcs (1.2.5)
|
|
39
48
|
erubis (2.7.0)
|
|
49
|
+
globalid (0.3.3)
|
|
50
|
+
activesupport (>= 4.1.0)
|
|
40
51
|
hike (1.2.3)
|
|
41
|
-
i18n (0.
|
|
42
|
-
json (1.8.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
i18n (0.7.0)
|
|
53
|
+
json (1.8.2)
|
|
54
|
+
loofah (2.0.1)
|
|
55
|
+
nokogiri (>= 1.5.9)
|
|
56
|
+
mail (2.6.3)
|
|
57
|
+
mime-types (>= 1.16, < 3)
|
|
58
|
+
mime-types (2.4.3)
|
|
59
|
+
mini_portile (0.6.2)
|
|
60
|
+
minitest (5.5.1)
|
|
61
|
+
multi_json (1.11.0)
|
|
62
|
+
nokogiri (1.6.6.2)
|
|
63
|
+
mini_portile (~> 0.6.0)
|
|
64
|
+
rack (1.6.0)
|
|
65
|
+
rack-test (0.6.3)
|
|
52
66
|
rack (>= 1.0)
|
|
53
|
-
rails (4.
|
|
54
|
-
actionmailer (= 4.
|
|
55
|
-
actionpack (= 4.
|
|
56
|
-
actionview (= 4.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
rails (4.2.0)
|
|
68
|
+
actionmailer (= 4.2.0)
|
|
69
|
+
actionpack (= 4.2.0)
|
|
70
|
+
actionview (= 4.2.0)
|
|
71
|
+
activejob (= 4.2.0)
|
|
72
|
+
activemodel (= 4.2.0)
|
|
73
|
+
activerecord (= 4.2.0)
|
|
74
|
+
activesupport (= 4.2.0)
|
|
60
75
|
bundler (>= 1.3.0, < 2.0)
|
|
61
|
-
railties (= 4.
|
|
62
|
-
sprockets-rails
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
railties (= 4.2.0)
|
|
77
|
+
sprockets-rails
|
|
78
|
+
rails-deprecated_sanitizer (1.0.3)
|
|
79
|
+
activesupport (>= 4.2.0.alpha)
|
|
80
|
+
rails-dom-testing (1.0.5)
|
|
81
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
|
82
|
+
nokogiri (~> 1.6.0)
|
|
83
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
|
84
|
+
rails-html-sanitizer (1.0.1)
|
|
85
|
+
loofah (~> 2.0)
|
|
86
|
+
railties (4.2.0)
|
|
87
|
+
actionpack (= 4.2.0)
|
|
88
|
+
activesupport (= 4.2.0)
|
|
66
89
|
rake (>= 0.8.7)
|
|
67
90
|
thor (>= 0.18.1, < 2.0)
|
|
68
|
-
rake (10.
|
|
69
|
-
rspec (2.
|
|
70
|
-
rspec-core (~> 2.
|
|
71
|
-
rspec-expectations (~> 2.
|
|
72
|
-
rspec-mocks (~> 2.
|
|
73
|
-
rspec-core (2.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
rake (10.4.2)
|
|
92
|
+
rspec (3.2.0)
|
|
93
|
+
rspec-core (~> 3.2.0)
|
|
94
|
+
rspec-expectations (~> 3.2.0)
|
|
95
|
+
rspec-mocks (~> 3.2.0)
|
|
96
|
+
rspec-core (3.2.1)
|
|
97
|
+
rspec-support (~> 3.2.0)
|
|
98
|
+
rspec-expectations (3.2.0)
|
|
99
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
100
|
+
rspec-support (~> 3.2.0)
|
|
101
|
+
rspec-mocks (3.2.1)
|
|
102
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
103
|
+
rspec-support (~> 3.2.0)
|
|
104
|
+
rspec-rails (3.2.1)
|
|
105
|
+
actionpack (>= 3.0, < 4.3)
|
|
106
|
+
activesupport (>= 3.0, < 4.3)
|
|
107
|
+
railties (>= 3.0, < 4.3)
|
|
108
|
+
rspec-core (~> 3.2.0)
|
|
109
|
+
rspec-expectations (~> 3.2.0)
|
|
110
|
+
rspec-mocks (~> 3.2.0)
|
|
111
|
+
rspec-support (~> 3.2.0)
|
|
112
|
+
rspec-support (3.2.2)
|
|
113
|
+
sprockets (2.12.3)
|
|
86
114
|
hike (~> 1.2)
|
|
87
115
|
multi_json (~> 1.0)
|
|
88
116
|
rack (~> 1.0)
|
|
89
117
|
tilt (~> 1.1, != 1.3.0)
|
|
90
|
-
sprockets-rails (2.
|
|
118
|
+
sprockets-rails (2.2.4)
|
|
91
119
|
actionpack (>= 3.0)
|
|
92
120
|
activesupport (>= 3.0)
|
|
93
|
-
sprockets (
|
|
121
|
+
sprockets (>= 2.8, < 4.0)
|
|
94
122
|
thor (0.19.1)
|
|
95
|
-
thread_safe (0.3.
|
|
123
|
+
thread_safe (0.3.4)
|
|
96
124
|
tilt (1.4.1)
|
|
97
|
-
|
|
98
|
-
polyglot
|
|
99
|
-
polyglot (>= 0.3.1)
|
|
100
|
-
tzinfo (1.1.0)
|
|
125
|
+
tzinfo (1.2.2)
|
|
101
126
|
thread_safe (~> 0.1)
|
|
102
127
|
|
|
103
128
|
PLATFORMS
|
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# page_title
|
|
2
2
|
|
|
3
|
+
[](https://travis-ci.org/fnando/page_title)
|
|
4
|
+
|
|
3
5
|
Set the page title on Rails apps.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
@@ -74,6 +76,16 @@ class WorkshopsController < ApplicationController
|
|
|
74
76
|
end
|
|
75
77
|
```
|
|
76
78
|
|
|
79
|
+
You can also use a custom translation scope. Just set the `:scope` option.
|
|
80
|
+
|
|
81
|
+
```ruby
|
|
82
|
+
class PagesController < ApplicationController
|
|
83
|
+
def show
|
|
84
|
+
page_title[:scope] = "pages.titles.#{params[:page]}"
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
```
|
|
88
|
+
|
|
77
89
|
If you're creating a controller that do not extend from `ApplicationController`, remember to use the lines below:
|
|
78
90
|
|
|
79
91
|
```ruby
|
data/lib/page_title.rb
CHANGED
|
@@ -38,10 +38,14 @@ module PageTitle
|
|
|
38
38
|
|
|
39
39
|
private
|
|
40
40
|
def title_translation
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
if options[:scope]
|
|
42
|
+
I18n.t(options[:scope])
|
|
43
|
+
else
|
|
44
|
+
I18n.t(
|
|
45
|
+
title_scope,
|
|
46
|
+
options.merge(scope: "titles")
|
|
47
|
+
)
|
|
48
|
+
end
|
|
45
49
|
end
|
|
46
50
|
|
|
47
51
|
def base_translation
|
data/lib/page_title/version.rb
CHANGED
|
@@ -5,7 +5,7 @@ describe "Simple controller name" do
|
|
|
5
5
|
set_translations "titles.base" => "%{title} - SITE",
|
|
6
6
|
"titles.site.index" => "TITLE"
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
example do
|
|
9
9
|
routes.draw { get :index, to: "site#index" }
|
|
10
10
|
get :index
|
|
11
11
|
|
|
@@ -19,7 +19,7 @@ describe "Namespaced controller name" do
|
|
|
19
19
|
"titles.admin.categories.index" => "TITLE"
|
|
20
20
|
|
|
21
21
|
describe Admin::CategoriesController do
|
|
22
|
-
|
|
22
|
+
example do
|
|
23
23
|
routes.draw { get :index, to: "admin/categories#index" }
|
|
24
24
|
get :index
|
|
25
25
|
|
|
@@ -28,12 +28,26 @@ describe "Namespaced controller name" do
|
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
describe "Using custom scope" do
|
|
32
|
+
set_translations "titles.base" => "%{title} - SITE",
|
|
33
|
+
"custom_scope.title" => "CUSTOM SCOPE"
|
|
34
|
+
|
|
35
|
+
describe SiteController do
|
|
36
|
+
example do
|
|
37
|
+
routes.draw { get :about, to: "site#about" }
|
|
38
|
+
get :about
|
|
39
|
+
|
|
40
|
+
expect(response.body).to eql("CUSTOM SCOPE - SITE")
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
31
45
|
describe "Using placeholders" do
|
|
32
46
|
set_translations "titles.base" => "%{title} - SITE",
|
|
33
47
|
"titles.categories.show" => "%{name}"
|
|
34
48
|
|
|
35
49
|
describe CategoriesController do
|
|
36
|
-
|
|
50
|
+
example do
|
|
37
51
|
routes.draw { get :show, to: "categories#show" }
|
|
38
52
|
get :show
|
|
39
53
|
|
|
@@ -43,13 +57,11 @@ describe "Using placeholders" do
|
|
|
43
57
|
end
|
|
44
58
|
|
|
45
59
|
describe "Rendering template" do
|
|
46
|
-
render_views
|
|
47
|
-
|
|
48
60
|
set_translations "titles.base" => "%{title} - SITE",
|
|
49
61
|
"titles.site.contact" => "TITLE"
|
|
50
62
|
|
|
51
63
|
describe SiteController do
|
|
52
|
-
|
|
64
|
+
example do
|
|
53
65
|
routes.draw { get :contact, to: "site#contact" }
|
|
54
66
|
get :contact
|
|
55
67
|
|
|
@@ -13,7 +13,7 @@ Dummy::Application.configure do
|
|
|
13
13
|
config.eager_load = false
|
|
14
14
|
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
|
16
|
-
config.
|
|
16
|
+
config.serve_static_files = true
|
|
17
17
|
config.static_cache_control = "public, max-age=3600"
|
|
18
18
|
|
|
19
19
|
# Show full error reports and disable caching.
|
data/spec/spec_helper.rb
CHANGED
|
@@ -5,7 +5,6 @@ ENV["RAILS_ENV"] = "test"
|
|
|
5
5
|
|
|
6
6
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
|
7
7
|
require "rspec/rails"
|
|
8
|
-
require "rspec/autorun"
|
|
9
8
|
require "support/helpers"
|
|
10
9
|
require "support/controllers"
|
|
11
10
|
|
|
@@ -14,4 +13,6 @@ I18n.locale = :en
|
|
|
14
13
|
|
|
15
14
|
RSpec.configure do |config|
|
|
16
15
|
config.extend SpecHelper::ClassMethods
|
|
16
|
+
config.render_views
|
|
17
|
+
config.infer_spec_type_from_file_location!
|
|
17
18
|
end
|
data/spec/support/controllers.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: page_title
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nando Vieira
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-03-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
164
164
|
version: '0'
|
|
165
165
|
requirements: []
|
|
166
166
|
rubyforge_project:
|
|
167
|
-
rubygems_version: 2.
|
|
167
|
+
rubygems_version: 2.4.5
|
|
168
168
|
signing_key:
|
|
169
169
|
specification_version: 4
|
|
170
170
|
summary: Set the page title on Rails apps
|
|
@@ -213,4 +213,3 @@ test_files:
|
|
|
213
213
|
- spec/spec_helper.rb
|
|
214
214
|
- spec/support/controllers.rb
|
|
215
215
|
- spec/support/helpers.rb
|
|
216
|
-
has_rdoc:
|