From 308cf7a523df8321e2c8290e30f23309b5da3bd1 Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Fri, 31 Mar 2017 14:19:37 -0400 Subject: [PATCH 01/11] 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/11] 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/11] 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/11] 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 8a5b022a89826c3e48fff37c13c42e90835530ee Mon Sep 17 00:00:00 2001 From: Aaron Gustafson Date: Mon, 3 Apr 2017 11:11:59 -0400 Subject: [PATCH 05/11] 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 06/11] 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 07/11] 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 08/11] 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 09/11] 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 10/11] 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 11/11] 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") }