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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 905b57b97b08acd97e7305dca9bb78ce393d3cfb
4
- data.tar.gz: 7792436582d0ecabeb0e0e340de188e28804db5b
3
+ metadata.gz: eb52042c35467ac74d487bd3b00deaac99f22127
4
+ data.tar.gz: 5561cfd621050ed045af7511c59f945c42d979b7
5
5
  SHA512:
6
- metadata.gz: 5ba9d6c37b5d0e2fcd187861b799cf244fa42858ec00a9b1a9a13f4797a92a709ea245da95ddd7db6d3472437cc87eebf8cbb36e84003b5629d318e65a7bdb19
7
- data.tar.gz: d2058bf70334d73aa65fda7fa3721b31feb1a7a450ad3bec4a604215c02fb8472bcf67a905345f6141eef053c00d93192930cc4c3bdc99dfa0f1f3d1295b5312
6
+ metadata.gz: df37d610c126e6f2765a9d7f3207b288b18067f2f33ce7f9141a185be675bc9ca2e133e3490bf31781424f77ff38e7558d927e668a18e005c65f8afd0c64e58b
7
+ data.tar.gz: 8ba5950d3fb5ef5dc5aee0c178b413ccdd10aaa9ad6bde2238fe91d9be147e51fdfc3a58279bdb88a492db3ad17deda3af29071de7e2e051d316b37a093a8079
@@ -1,5 +1,7 @@
1
1
  language: ruby
2
2
  cache: bundler
3
+ before_install:
4
+ - gem update bundler
3
5
  rvm:
4
6
  - 2.3.0
5
7
  - 2.2.0
@@ -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 )
@@ -2,5 +2,5 @@ require 'middleman-core'
2
2
 
3
3
  ::Middleman::Extensions.register(:title) do
4
4
  require 'middleman-title/extension'
5
- ::Middleman::Title
6
- end
5
+ ::Middleman::TitleExtension
6
+ end
@@ -1,35 +1,21 @@
1
+ require 'middleman-core'
1
2
  require 'middleman-title/helpers'
2
3
 
3
4
  module Middleman
4
- module Title
5
+ class TitleExtension < Middleman::Extension
6
+ option :site, false, 'Name of your website'
7
+ option :separator, ' &mdash; ', 'Title section separator'
8
+ option :reverse, false, 'Reverse the order of title sections'
5
9
 
6
- class Options < Struct.new(:site, :separator, :reverse)
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 ||= ' &mdash; '
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::Title.options
17
+ ::Middleman::TitleExtension.options
15
18
  end
16
19
 
17
20
  def website_name
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Title
3
- VERSION = '0.0.3'
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
@@ -18,5 +18,5 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'middleman-core', '>= 3.2'
21
+ spec.add_dependency 'middleman-core', '>= 4.0'
22
22
  end
@@ -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
@@ -1,5 +1,5 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
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.3
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: 2016-03-11 00:00:00.000000000 Z
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: '3.2'
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: '3.2'
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.5.1
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: