middleman-title 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +5 -0
- data/README.md +8 -0
- data/lib/middleman-title.rb +2 -2
- data/lib/middleman-title/extension.rb +12 -26
- data/lib/middleman-title/helpers.rb +4 -1
- data/lib/middleman-title/version.rb +1 -1
- data/middleman-title.gemspec +1 -1
- data/spec/extension_spec.rb +9 -0
- data/spec/spec_helper.rb +3 -3
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb52042c35467ac74d487bd3b00deaac99f22127
|
4
|
+
data.tar.gz: 5561cfd621050ed045af7511c59f945c42d979b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df37d610c126e6f2765a9d7f3207b288b18067f2f33ce7f9141a185be675bc9ca2e133e3490bf31781424f77ff38e7558d927e668a18e005c65f8afd0c64e58b
|
7
|
+
data.tar.gz: 8ba5950d3fb5ef5dc5aee0c178b413ccdd10aaa9ad6bde2238fe91d9be147e51fdfc3a58279bdb88a492db3ad17deda3af29071de7e2e051d316b37a093a8079
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 1.0.0 (2017-04-01)
|
2
|
+
* Add compatibility with Middleman v4 (#2)
|
3
|
+
* Upgrade plugin to use the Middleman extension API (#2)
|
4
|
+
* Allow overriding individual page titles (#3)
|
5
|
+
|
1
6
|
## 0.0.3
|
2
7
|
* Fix Rspec stub name for title_options
|
3
8
|
* Adjust Middleman dependency to 3.2 or higher
|
data/README.md
CHANGED
@@ -93,6 +93,14 @@ This would output:
|
|
93
93
|
John Doe — Staff — Your Website Name
|
94
94
|
```
|
95
95
|
|
96
|
+
## Override Page Title
|
97
|
+
|
98
|
+
If at any point you want to completely override the page title, you can use `page_title` in the Frontmatter.
|
99
|
+
|
100
|
+
```YAML
|
101
|
+
page_title: The title of a page to be used as-is in <title> without site name
|
102
|
+
```
|
103
|
+
|
96
104
|
## Contributing
|
97
105
|
|
98
106
|
1. Fork it ( https://github.com/jcypret/middleman-title/fork )
|
data/lib/middleman-title.rb
CHANGED
@@ -1,35 +1,21 @@
|
|
1
|
+
require 'middleman-core'
|
1
2
|
require 'middleman-title/helpers'
|
2
3
|
|
3
4
|
module Middleman
|
4
|
-
|
5
|
+
class TitleExtension < Middleman::Extension
|
6
|
+
option :site, false, 'Name of your website'
|
7
|
+
option :separator, ' — ', 'Title section separator'
|
8
|
+
option :reverse, false, 'Reverse the order of title sections'
|
5
9
|
|
6
|
-
|
7
|
-
def initialize(h)
|
8
|
-
super(*h.values_at(:site, :separator, :reverse))
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class << self
|
13
|
-
|
14
|
-
def options
|
15
|
-
@@options
|
16
|
-
end
|
17
|
-
|
18
|
-
def registered(app, options_hash = {}, &block)
|
19
|
-
options = Options.new(options_hash)
|
20
|
-
yield options if block_given?
|
21
|
-
|
22
|
-
# default options
|
23
|
-
options.separator ||= ' — '
|
24
|
-
options.site = false if options.site.nil?
|
25
|
-
options.reverse = false if options.reverse.nil?
|
26
|
-
|
27
|
-
@@options = options
|
28
|
-
app.helpers Helpers
|
29
|
-
end
|
30
|
-
alias :included :registered
|
10
|
+
self.defined_helpers = [ Middleman::Title::Helpers ]
|
31
11
|
|
12
|
+
def initialize(app, options_hash={}, &block)
|
13
|
+
super
|
14
|
+
::Middleman::TitleExtension.class_variable_set(:@@options, options)
|
32
15
|
end
|
33
16
|
|
17
|
+
def self.options
|
18
|
+
@@options
|
19
|
+
end
|
34
20
|
end
|
35
21
|
end
|
@@ -3,6 +3,9 @@ module Middleman
|
|
3
3
|
module Helpers
|
4
4
|
|
5
5
|
def page_title
|
6
|
+
current_page_title = current_page.data.page_title
|
7
|
+
return current_page_title unless current_page_title.nil?
|
8
|
+
|
6
9
|
title = []
|
7
10
|
title = add_page_name_to_title(title)
|
8
11
|
title = add_website_name_to_title(title)
|
@@ -11,7 +14,7 @@ module Middleman
|
|
11
14
|
|
12
15
|
private
|
13
16
|
def title_options
|
14
|
-
::Middleman::
|
17
|
+
::Middleman::TitleExtension.options
|
15
18
|
end
|
16
19
|
|
17
20
|
def website_name
|
data/middleman-title.gemspec
CHANGED
data/spec/extension_spec.rb
CHANGED
@@ -12,6 +12,7 @@ describe Middleman::Title::Helpers do
|
|
12
12
|
h.stub_chain(:current_page, :data, :title).and_return(nil)
|
13
13
|
h.stub_chain(:current_page, :data, :title_site).and_return(nil)
|
14
14
|
h.stub_chain(:current_page, :data, :title_reverse).and_return(nil)
|
15
|
+
h.stub_chain(:current_page, :data, :page_title).and_return(nil)
|
15
16
|
end
|
16
17
|
|
17
18
|
context 'website name is set' do
|
@@ -93,5 +94,13 @@ describe Middleman::Title::Helpers do
|
|
93
94
|
|
94
95
|
end
|
95
96
|
|
97
|
+
context 'page_title is set' do
|
98
|
+
before(:each) { h.stub_chain(:current_page, :data, :page_title).and_return('This takes precedence') }
|
99
|
+
|
100
|
+
it 'returns page_title specified for the current page' do
|
101
|
+
expect(h.page_title).to eq 'This takes precedence'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
96
105
|
end
|
97
106
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
3
|
|
4
4
|
require 'bundler/setup'
|
5
5
|
Bundler.setup
|
@@ -8,4 +8,4 @@ require 'middleman-title/extension'
|
|
8
8
|
|
9
9
|
RSpec.configure do |config|
|
10
10
|
# some (optional) config here
|
11
|
-
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-title
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Cypret
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.0'
|
27
27
|
description: A Middleman extension for setting the page title
|
28
28
|
email:
|
29
29
|
- jcypret@gmail.com
|
@@ -67,11 +67,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
69
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
70
|
+
rubygems_version: 2.6.8
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: A Middleman extension for setting the page title
|
74
74
|
test_files:
|
75
75
|
- spec/extension_spec.rb
|
76
76
|
- spec/spec_helper.rb
|
77
|
-
has_rdoc:
|