From 308cf7a523df8321e2c8290e30f23309b5da3bd1 Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Fri, 31 Mar 2017 14:19:37 -0400 Subject: [PATCH 01/16] Added support for locale exposure as `og:locale` --- lib/template.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/template.html b/lib/template.html index eacff7f..50488b1 100755 --- a/lib/template.html +++ b/lib/template.html @@ -97,6 +97,10 @@ {% assign seo_page_image = seo_page_image | escape %} {% endif %} +{% if site.locale %} + {% assign seo_page_locale = page.locale | default: site.locale %} +{% endif %} + {% if seo_tag.title and seo_title %} {{ seo_title }} {% endif %} @@ -109,6 +113,10 @@ {% endif %} +{% if seo_page_locale %} + +{% endif %} + {% if seo_description %} From 59b20c7bf95a84d8031fe4ae040b5953f5cbaeb5 Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Fri, 31 Mar 2017 14:26:58 -0400 Subject: [PATCH 02/16] Added test --- spec/jekyll_seo_tag_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 1937ab9..700f524 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -581,4 +581,24 @@ EOS end end end + + context "with locale" do + let(:site) { make_site("locale" => "en_US") } + + it "uses site.locale if page.locale is not present" do + expected = %r!! + expect(output).to match(expected) + end + + context "with page.locale" do + let(:site) { make_site("locale" => "en_US") } + let(:page) { make_page("locale" => "en_UK") } + + it "uses page.locale if both site.locale and page.locale are present" do + expected = %r!! + expect(output).to match(expected) + end + end + end + end From 179530d8859688bcb30dcc40e615529e7c444130 Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Fri, 31 Mar 2017 14:31:16 -0400 Subject: [PATCH 03/16] Added documentation --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8f71d58..1f4169c 100644 --- a/README.md +++ b/README.md @@ -102,12 +102,15 @@ webmaster_verifications: yandex: 1234 ``` +* `locale` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`. + The SEO tag will respect the following YAML front matter if included in a post, page, or document: * `title` - The title of the post, page, or document * `description` - A short description of the page's content * `image` - URL to an image associated with the post, page, or document (e.g., `/assets/page-pic.jpg`) * `author` - Page-, post-, or document-specific author information (see below) +* `locale` - Page-, post-, or document-specific language information ## Advanced usage From 2191a550eee4037be44c13b761bc4b2cff1b9643 Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Fri, 31 Mar 2017 14:41:46 -0400 Subject: [PATCH 04/16] Test cleanup --- lib/template.html | 8 ++------ spec/jekyll_seo_tag_spec.rb | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/template.html b/lib/template.html index 50488b1..8ce8a9e 100755 --- a/lib/template.html +++ b/lib/template.html @@ -97,9 +97,7 @@ {% assign seo_page_image = seo_page_image | escape %} {% endif %} -{% if site.locale %} - {% assign seo_page_locale = page.locale | default: site.locale %} -{% endif %} +{% assign seo_page_locale = page.locale | default: site.locale | default: "en_US"" %} {% if seo_tag.title and seo_title %} {{ seo_title }} @@ -113,9 +111,7 @@ {% endif %} -{% if seo_page_locale %} - -{% endif %} + {% if seo_description %} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 700f524..38a020d 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -257,6 +257,7 @@ describe Jekyll::SeoTag do Foo + @@ -583,21 +584,27 @@ EOS end context "with locale" do - let(:site) { make_site("locale" => "en_US") } - - it "uses site.locale if page.locale is not present" do + it "uses en_US when no locale is specified" do expected = %r!! expect(output).to match(expected) end - context "with page.locale" do + context "with site.locale" do let(:site) { make_site("locale" => "en_US") } - let(:page) { make_page("locale" => "en_UK") } - - it "uses page.locale if both site.locale and page.locale are present" do - expected = %r!! + + it "uses site.locale if page.locale is not present" do + expected = %r!! expect(output).to match(expected) end + + context "with page.locale" do + let(:page) { make_page("locale" => "en_UK") } + + it "uses page.locale if both site.locale and page.locale are present" do + expected = %r!! + expect(output).to match(expected) + end + end end end From 5f3260809e575a5d2e866b0506a4badafe644bdc Mon Sep 17 00:00:00 2001 From: Frank Taillandier Date: Fri, 31 Mar 2017 21:39:22 +0200 Subject: [PATCH 05/16] No need to delete Jekyll's version from Gemfile Github Pages supports Jekyll 3.4.3 --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index 0919f4a..a215af7 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,6 @@ group :development, :test do versions.delete('ruby') versions.delete('jekyll-seo-tag') versions.delete('github-pages') - versions.delete('jekyll') # Remove this line when GitHub Pages supports 3.3.0 versions.each do |dep, version| gem dep, version From 2172ada23b2f07571b301c094d2262cfd13db6d9 Mon Sep 17 00:00:00 2001 From: Frank Taillandier Date: Fri, 31 Mar 2017 21:54:45 +0200 Subject: [PATCH 06/16] bump dev dependencies --- jekyll-seo-tag.gemspec | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/jekyll-seo-tag.gemspec b/jekyll-seo-tag.gemspec index 872c582..5d06090 100644 --- a/jekyll-seo-tag.gemspec +++ b/jekyll-seo-tag.gemspec @@ -1,34 +1,35 @@ # coding: utf-8 -lib = File.expand_path('../lib', __FILE__) + +lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'jekyll-seo-tag/version' +require "jekyll-seo-tag/version" Gem::Specification.new do |spec| - spec.name = 'jekyll-seo-tag' + spec.name = "jekyll-seo-tag" spec.version = Jekyll::SeoTag::VERSION - spec.authors = ['Ben Balter'] - spec.email = ['ben.balter@github.com'] + spec.authors = ["Ben Balter"] + spec.email = ["ben.balter@github.com"] spec.summary = "A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content." - spec.homepage = 'https://github.com/benbalter/jekyll-seo-tag' - spec.license = 'MIT' + spec.homepage = "https://github.com/benbalter/jekyll-seo-tag" + spec.license = "MIT" # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or # delete this section to allow pushing this gem to any host. if spec.respond_to?(:metadata) - spec.metadata['allowed_push_host'] = 'https://rubygems.org' + spec.metadata["allowed_push_host"] = "https://rubygems.org" else - raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' + raise "RubyGems 2.0 or newer is required to protect against public gem pushes." end - spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - spec.bindir = 'exe' - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ['lib'] + spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) } + spec.bindir = "exe" + spec.executables = spec.files.grep(%r!^exe/!) { |f| File.basename(f) } + spec.require_paths = ["lib"] - spec.add_dependency 'jekyll', '~> 3.3' - spec.add_development_dependency 'bundler', '~> 1.10' - spec.add_development_dependency 'rake', '~> 10.0' - spec.add_development_dependency 'rspec', '~> 3.3' - spec.add_development_dependency 'html-proofer', '~> 2.5' - spec.add_development_dependency 'rubocop', '~> 0.37' + spec.add_dependency "jekyll", "~> 3.3" + spec.add_development_dependency "bundler", "~> 1.14" + spec.add_development_dependency "rake", "~> 12.0" + spec.add_development_dependency "rspec", "~> 3.5" + spec.add_development_dependency "html-proofer", "~> 3.6" + spec.add_development_dependency "rubocop", "~> 0.48" end From 8a5b022a89826c3e48fff37c13c42e90835530ee Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Mon, 3 Apr 2017 11:11:59 -0400 Subject: [PATCH 07/16] Adding /bin/ to mask local testing --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b7e7725..3476aa5 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ /pkg/ /spec/reports/ /tmp/ +/bin/ *.gem From abf32914b7abc056f04064aeea4404f2329d0406 Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Mon, 3 Apr 2017 11:21:48 -0400 Subject: [PATCH 08/16] Switching to site.lang & page.lang to align with jekyll-feed --- lib/template.html | 2 +- spec/jekyll_seo_tag_spec.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/template.html b/lib/template.html index 8ce8a9e..ab25607 100755 --- a/lib/template.html +++ b/lib/template.html @@ -97,7 +97,7 @@ {% assign seo_page_image = seo_page_image | escape %} {% endif %} -{% assign seo_page_locale = page.locale | default: site.locale | default: "en_US"" %} +{% assign seo_page_locale = page.lang | default: site.lang | default: "en_US"" %} {% if seo_tag.title and seo_title %} {{ seo_title }} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 38a020d..c516d70 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -589,18 +589,18 @@ EOS expect(output).to match(expected) end - context "with site.locale" do - let(:site) { make_site("locale" => "en_US") } + context "with site.lang" do + let(:site) { make_site("lang" => "en_US") } - it "uses site.locale if page.locale is not present" do + it "uses site.lang if page.lang is not present" do expected = %r!! expect(output).to match(expected) end - context "with page.locale" do - let(:page) { make_page("locale" => "en_UK") } + context "with page.lang" do + let(:page) { make_page("lang" => "en_UK") } - it "uses page.locale if both site.locale and page.locale are present" do + it "uses page.lang if both site.lang and page.lang are present" do expected = %r!! expect(output).to match(expected) end From b3d5db35635b99585bf455803d012e5deeb57196 Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Mon, 3 Apr 2017 11:32:31 -0400 Subject: [PATCH 09/16] Fixing Rubocop offenses --- spec/jekyll_seo_tag_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index c516d70..579e7ce 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -591,7 +591,7 @@ EOS context "with site.lang" do let(:site) { make_site("lang" => "en_US") } - + it "uses site.lang if page.lang is not present" do expected = %r!! expect(output).to match(expected) @@ -607,5 +607,4 @@ EOS end end end - end From e2114abbb79463f91edfb5e8447538c5d062b1c6 Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Mon, 3 Apr 2017 14:41:21 -0400 Subject: [PATCH 10/16] Fixing the documentation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1f4169c..f6ec5ac 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ webmaster_verifications: yandex: 1234 ``` -* `locale` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`. +* `lang` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`. The SEO tag will respect the following YAML front matter if included in a post, page, or document: @@ -110,7 +110,7 @@ The SEO tag will respect the following YAML front matter if included in a post, * `description` - A short description of the page's content * `image` - URL to an image associated with the post, page, or document (e.g., `/assets/page-pic.jpg`) * `author` - Page-, post-, or document-specific author information (see below) -* `locale` - Page-, post-, or document-specific language information +* `lang` - Page-, post-, or document-specific language information ## Advanced usage From 18ec5736c205a1267fa879335417fa022ff07ddf Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Mon, 3 Apr 2017 15:09:35 -0400 Subject: [PATCH 11/16] Variable rename --- lib/template.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/template.html b/lib/template.html index ab25607..6531d1a 100755 --- a/lib/template.html +++ b/lib/template.html @@ -97,7 +97,7 @@ {% assign seo_page_image = seo_page_image | escape %} {% endif %} -{% assign seo_page_locale = page.lang | default: site.lang | default: "en_US"" %} +{% assign seo_page_lang = page.lang | default: site.lang | default: "en_US" %} {% if seo_tag.title and seo_title %} {{ seo_title }} @@ -111,7 +111,7 @@ {% endif %} - + {% if seo_description %} From 8a8a5e98599361c7738d511cfc33242b240cf31e Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Mon, 3 Apr 2017 20:04:29 -0400 Subject: [PATCH 12/16] Added hyphen to underscore coersion --- lib/template.html | 3 +-- spec/jekyll_seo_tag_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/template.html b/lib/template.html index 38e89f6..c06665c 100755 --- a/lib/template.html +++ b/lib/template.html @@ -111,7 +111,7 @@ {% endif %} - + {% if seo_description %} @@ -128,7 +128,6 @@ {% endif %} {% if seo_page_image %} - {% if page.image.height %} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index f738072..a96aea2 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -606,5 +606,14 @@ EOS end end end + + context "with site.lang hyphenated" do + let(:site) { make_site("lang" => "en-US") } + + it "coerces hyphen to underscore" do + expected = %r!! + expect(output).to match(expected) + end + end end end From 4f919b2aaaf398eecc4a37144279e9692095815c Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Mon, 3 Apr 2017 20:05:24 -0400 Subject: [PATCH 13/16] Anticitating Rubocop --- spec/jekyll_seo_tag_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index a96aea2..e2bcb0b 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -606,7 +606,7 @@ EOS end end end - + context "with site.lang hyphenated" do let(:site) { make_site("lang" => "en-US") } From 7de7c7a497478998d5adc1567a0e71f79b835f14 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Tue, 4 Apr 2017 09:50:57 -0400 Subject: [PATCH 14/16] require html-proofer, not html/proofer --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a68ada5..bbb2756 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,7 @@ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) require "jekyll" require "jekyll-seo-tag" -require "html/proofer" +require "html-proofer" ENV["JEKYLL_LOG_LEVEL"] = "error" From 8e8b11aab7bee8067e2b45114441f6597566e54c Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Tue, 4 Apr 2017 09:52:27 -0400 Subject: [PATCH 15/16] update to use new html proofer api --- spec/jekyll_seo_tag_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index e2bcb0b..47ca794 100755 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -31,7 +31,7 @@ describe Jekyll::SeoTag do :check_html => true, :checks_to_ignore => %w(ScriptCheck LinkCheck ImageCheck), } - status = HTML::Proofer.new(dest_dir, options).run + status = HTMLProofer.check_directory(dest_dir, options).run expect(status).to eql(true) end From f57ddb9c89b3ce4f913d271695bed207331960d5 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Tue, 4 Apr 2017 10:43:34 -0400 Subject: [PATCH 16/16] remove Rake dependency --- Rakefile | 6 ------ jekyll-seo-tag.gemspec | 1 - script/cibuild | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 Rakefile diff --git a/Rakefile b/Rakefile deleted file mode 100644 index b7e9ed5..0000000 --- a/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff --git a/jekyll-seo-tag.gemspec b/jekyll-seo-tag.gemspec index 5d06090..e6269cc 100644 --- a/jekyll-seo-tag.gemspec +++ b/jekyll-seo-tag.gemspec @@ -28,7 +28,6 @@ Gem::Specification.new do |spec| spec.add_dependency "jekyll", "~> 3.3" spec.add_development_dependency "bundler", "~> 1.14" - spec.add_development_dependency "rake", "~> 12.0" spec.add_development_dependency "rspec", "~> 3.5" spec.add_development_dependency "html-proofer", "~> 3.6" spec.add_development_dependency "rubocop", "~> 0.48" diff --git a/script/cibuild b/script/cibuild index e75ad1f..dec4aa6 100755 --- a/script/cibuild +++ b/script/cibuild @@ -2,6 +2,6 @@ set -ex -bundle exec rake spec +bundle exec rspec bundle exec rubocop -S -D bundle exec gem build jekyll-seo-tag.gemspec