From 594d99f752c5f35c20907323b92750165ffc1e47 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Wed, 3 Feb 2016 12:41:05 -0500 Subject: [PATCH 01/13] add google site verification meta tag --- README.md | 3 ++- lib/template.html | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 75f5f65..7ae7472 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content. -[![Gem Version](https://badge.fury.io/rb/jekyll-seo-tag.svg)](https://badge.fury.io/rb/jekyll-seo-tag) [![Build Status](https://travis-ci.org/benbalter/jekyll-seo-tag.svg)](https://travis-ci.org/benbalter/jekyll-seo-tag) +[![Gem Version](https://badge.fury.io/rb/jekyll-seo-tag.svg)](https://badge.fury.io/rb/jekyll-seo-tag) [![Build Status](https://travis-ci.org/benbalter/jekyll-seo-tag.svg)](https://travis-ci.org/benbalter/jekyll-seo-tag) ## What it does @@ -64,6 +64,7 @@ The SEO tag will respect any of the following if included in your site's `_confi * `type` - Either `person` or `organization` (defaults to `person`) * `name` - If the user or organization name differs from the site's name * `links` - An array of links to social media profiles. +* `google_site_verification` for verifying ownership via Google webmaster tools The SEO tag will respect the following YAML front matter if included in a post, page, or document: diff --git a/lib/template.html b/lib/template.html index 871348b..41b6aef 100644 --- a/lib/template.html +++ b/lib/template.html @@ -110,6 +110,10 @@ {% endif %} {% endif %} +{% if site.google_site_verification %} + +{% endif %} + {% if site.logo %} }m)[1] data = JSON.parse(data) - expect(data["name"]).to eql("Foo") - expect(data["url"]).to eql("http://example.invalid") + expect(data['name']).to eql('Foo') + expect(data['url']).to eql('http://example.invalid') end - it "outputs post meta" do - post = post({"title" => "post", "description" => "description", "image" => "/img.png" }) - context = context({ :page => post }) + it 'outputs post meta' do + post = post('title' => 'post', 'description' => 'description', 'image' => '/img.png') + context = context(page: post) output = subject.render(context) - expected = // + expected = %r{} expect(output).to match(expected) - data = output.match(/}m)[1] data = JSON.parse(data) - expect(data["headline"]).to eql("post") - expect(data["description"]).to eql("description") - expect(data["image"]).to eql("/img.png") + expect(data['headline']).to eql('post') + expect(data['description']).to eql('description') + expect(data['image']).to eql('/img.png') end - it "outputs twitter card meta" do - site = site({"twitter" => { "username" => "jekyllrb" }}) - page = page({"author" => "benbalter"}) - context = context({ :site => site, :page => page }) + it 'outputs twitter card meta' do + site = site('twitter' => { 'username' => 'jekyllrb' }) + page = page('author' => 'benbalter') + context = context(site: site, page: page) - expected = // + expected = %r{} expect(subject.render(context)).to match(expected) - expected = // + expected = %r{} expect(subject.render(context)).to match(expected) end - it "outputs social meta" do - links = ["http://foo.invalid", "http://bar.invalid"] - site = site({"social" => { "name" => "Ben", "links" => links }}) - context = context({ :site => site }) + it 'outputs social meta' do + links = ['http://foo.invalid', 'http://bar.invalid'] + site = site('social' => { 'name' => 'Ben', 'links' => links }) + context = context(site: site) output = subject.render(context) - data = output.match(/}m)[1] data = JSON.parse(data) - expect(data["@type"]).to eql("person") - expect(data["name"]).to eql("Ben") - expect(data["sameAs"]).to eql(links) + expect(data['@type']).to eql('person') + expect(data['name']).to eql('Ben') + expect(data['sameAs']).to eql(links) end - it "outputs the logo" do - site = site({"logo" => "logo.png", "url" => "http://example.invalid" }) - context = context({ :site => site }) + it 'outputs the logo' do + site = site('logo' => 'logo.png', 'url' => 'http://example.invalid') + context = context(site: site) output = subject.render(context) - data = output.match(/}m)[1] data = JSON.parse(data) - expect(data["logo"]).to eql("http://example.invalid/logo.png") - expect(data["url"]).to eql("http://example.invalid") + expect(data['logo']).to eql('http://example.invalid/logo.png') + expect(data['url']).to eql('http://example.invalid') end - it "outputs the image" do - page = page({ "image" => "foo.png" }) - site = site({ "url" => "http://example.invalid" }) - context = context({ :page => page, :site => site }) - expected = %r!! + it 'outputs the image' do + page = page('image' => 'foo.png') + site = site('url' => 'http://example.invalid') + context = context(page: page, site: site) + expected = %r{} expect(subject.render(context)).to match(expected) end - it "uses site.name if site.title is not present" do - site = site({"name" => "Site Name", "title" => nil }) - context = context({ :site => site }) - expected = %r!! + it 'uses site.name if site.title is not present' do + site = site('name' => 'Site Name', 'title' => nil) + context = context(site: site) + expected = %r{} expect(subject.render(context)).to match(expected) end - it "uses site.tile if both site.title and site.name are present" do - site = site({"name" => "Site Name", "title" => "Site Title" }) - context = context({ :site => site }) - expected = %r!! + it 'uses site.tile if both site.title and site.name are present' do + site = site('name' => 'Site Name', 'title' => 'Site Title') + context = context(site: site) + expected = %r{} expect(subject.render(context)).to match(expected) end - it "supports author data as an object" do - site = site({"twitter" => { "username" => "jekyllrb" }}) - page = page({"author" => {"twitter" => "@test"}}) - context = context({ :site => site, :page => page }) - expected = %r!! + it 'supports author data as an object' do + site = site('twitter' => { 'username' => 'jekyllrb' }) + page = page('author' => { 'twitter' => '@test' }) + context = context(site: site, page: page) + expected = %r{} expect(subject.render(context)).to match(expected) end - it "outputs valid HTML" do + it 'outputs valid HTML' do site.process options = { - :check_html => true, - :checks_to_ignore => ["ScriptCheck", "LinkCheck", "ImageCheck"] + check_html: true, + checks_to_ignore: %w(ScriptCheck LinkCheck ImageCheck) } status = HTML::Proofer.new(dest_dir, options).run expect(status).to eql(true) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a391dd0..ed7ff23 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,41 +3,41 @@ require 'jekyll' require 'jekyll-seo-tag' require 'html/proofer' -ENV["JEKYLL_LOG_LEVEL"] = "error" +ENV['JEKYLL_LOG_LEVEL'] = 'error' def dest_dir - File.expand_path("../tmp/dest", File.dirname(__FILE__)) + File.expand_path('../tmp/dest', File.dirname(__FILE__)) end def source_dir - File.expand_path("./fixtures", File.dirname(__FILE__)) + File.expand_path('./fixtures', File.dirname(__FILE__)) end CONFIG_DEFAULTS = { - "source" => source_dir, - "destination" => dest_dir, - "gems" => ["jekyll-seo-tag"] -} + 'source' => source_dir, + 'destination' => dest_dir, + 'gems' => ['jekyll-seo-tag'] +}.freeze -def page(options={}) - page = Jekyll::Page.new site, CONFIG_DEFAULTS["source"], "", "page.md" +def page(options = {}) + page = Jekyll::Page.new site, CONFIG_DEFAULTS['source'], '', 'page.md' page.data = options page end -def post(options={}) - filename = File.expand_path("2015-01-01-post.md", CONFIG_DEFAULTS["source"]) - config = { :site => site, :collection => site.collections["posts"] } +def post(options = {}) + filename = File.expand_path('2015-01-01-post.md', CONFIG_DEFAULTS['source']) + config = { site: site, collection: site.collections['posts'] } page = Jekyll::Document.new filename, config page.merge_data!(options) page end -def site(options={}) +def site(options = {}) config = Jekyll.configuration CONFIG_DEFAULTS.merge(options) Jekyll::Site.new(config) end -def context(registers={}) - Liquid::Context.new({}, {}, { :site => site, :page => page }.merge(registers)) +def context(registers = {}) + Liquid::Context.new({}, {}, { site: site, page: page }.merge(registers)) end From 2ee2f3e6e05e651c7e4b83a2592fe50570fe9e18 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Sat, 20 Feb 2016 14:04:43 -0500 Subject: [PATCH 11/13] Bump to 1.1.0 --- lib/jekyll-seo-tag/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll-seo-tag/version.rb b/lib/jekyll-seo-tag/version.rb index 97b1dca..01f9676 100644 --- a/lib/jekyll-seo-tag/version.rb +++ b/lib/jekyll-seo-tag/version.rb @@ -3,6 +3,6 @@ module Liquid; class Tag; end; end module Jekyll class SeoTag < Liquid::Tag - VERSION = '1.0.0'.freeze + VERSION = '1.1.0'.freeze end end From bdedd23bf20d4963c4f7c97934f3531fdb64cda3 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Sat, 20 Feb 2016 14:26:06 -0500 Subject: [PATCH 12/13] expose version in HTML comment --- lib/jekyll-seo-tag.rb | 1 + lib/template.html | 2 +- spec/jekyll_seo_tag_spec.rb | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index 376772f..dd71ea7 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -17,6 +17,7 @@ module Jekyll def payload { + 'seo_tag' => { 'version' => VERSION }, 'page' => context.registers[:page], 'site' => context.registers[:site].site_payload['site'] } diff --git a/lib/template.html b/lib/template.html index 9a77b4c..4c45ad0 100644 --- a/lib/template.html +++ b/lib/template.html @@ -1,4 +1,4 @@ - + {% if site.url %} {% assign seo_url = site.url | append: site.baseurl %} diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 4408cba..86c8124 100644 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -193,4 +193,9 @@ describe Jekyll::SeoTag do status = HTML::Proofer.new(dest_dir, options).run expect(status).to eql(true) end + + it 'outputs the plugin version' do + version = Jekyll::SeoTag::VERSION + expect(subject.render(context)).to match(/Jekyll SEO tag v#{version}/i) + end end From 86775d50f7028ce2d85cf0af5ca9702fe07f8dca Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Sat, 20 Feb 2016 14:27:04 -0500 Subject: [PATCH 13/13] whitespace --- lib/jekyll-seo-tag.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index dd71ea7..c2e443f 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -18,8 +18,8 @@ module Jekyll def payload { 'seo_tag' => { 'version' => VERSION }, - 'page' => context.registers[:page], - 'site' => context.registers[:site].site_payload['site'] + 'page' => context.registers[:page], + 'site' => context.registers[:site].site_payload['site'] } end