From b019a653af8a241dab1d6ac24822b686f4c4b94a Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Thu, 6 Oct 2016 15:47:49 -0500 Subject: [PATCH 1/2] Fix broken test --- 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 5d514aa..db30693 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,7 +26,7 @@ def make_page(options = {}) end def make_post(options = {}) - filename = File.expand_path("2015-01-01-post.md", CONFIG_DEFAULTS["source"]) + filename = File.expand_path("_posts/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) From df09740757543e6f5a5cf59401c9c7ec7e67362f Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Thu, 6 Oct 2016 15:56:15 -0500 Subject: [PATCH 2/2] Take advantage of Jekyll 3.3.0 URL filters --- Gemfile | 1 + jekyll-seo-tag.gemspec | 2 +- lib/jekyll-seo-tag.rb | 3 +-- lib/jekyll-seo-tag/filters.rb | 13 ------------- lib/template.html | 22 +++++++++------------- spec/jekyll_seo_tag_spec.rb | 16 ++-------------- 6 files changed, 14 insertions(+), 43 deletions(-) delete mode 100644 lib/jekyll-seo-tag/filters.rb diff --git a/Gemfile b/Gemfile index a215af7..0919f4a 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ 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 diff --git a/jekyll-seo-tag.gemspec b/jekyll-seo-tag.gemspec index aa56203..872c582 100644 --- a/jekyll-seo-tag.gemspec +++ b/jekyll-seo-tag.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.add_dependency 'jekyll', '~> 3.1' + 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' diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index fab9f05..8e9141e 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -1,4 +1,3 @@ -require "jekyll-seo-tag/filters" require "jekyll-seo-tag/version" module Jekyll @@ -42,7 +41,7 @@ module Jekyll def info { :registers => context.registers, - :filters => [Jekyll::Filters, JekyllSeoTag::Filters] + :filters => [Jekyll::Filters] } end diff --git a/lib/jekyll-seo-tag/filters.rb b/lib/jekyll-seo-tag/filters.rb deleted file mode 100644 index 2a40da4..0000000 --- a/lib/jekyll-seo-tag/filters.rb +++ /dev/null @@ -1,13 +0,0 @@ -module JekyllSeoTag - module Filters - # This is available in Liquid from version 3 which is required by Jekyll 3 - # Provided here for compatibility with Jekyll 2.x - def default(input, default_value = "".freeze) - if !input || input.respond_to?(:empty?) && input.empty? - default_value - else - input - end - end - end -end diff --git a/lib/template.html b/lib/template.html index 420bc75..5d26ea0 100644 --- a/lib/template.html +++ b/lib/template.html @@ -4,10 +4,6 @@ {% assign seo_homepage_or_about = true %} {% endif %} -{% if site.url %} - {% assign seo_url = site.url | append: site.baseurl %} -{% endif %} -{% assign seo_url = seo_url | default: site.github.url %} {% assign seo_site_title = site.title | default: site.name %} {% if page.title %} @@ -87,7 +83,7 @@ {% if site.logo %} {% assign seo_site_logo = site.logo %} {% unless seo_site_logo contains "://" %} - {% assign seo_site_logo = seo_site_logo | prepend: seo_url %} + {% assign seo_site_logo = seo_site_logo | absolute_url %} {% endunless %} {% assign seo_site_logo = seo_site_logo | escape %} {% endif %} @@ -95,7 +91,7 @@ {% if page.image %} {% assign seo_page_image = page.image.path | default: page.image.facebook | default: page.image %} {% unless seo_page_image contains "://" %} - {% assign seo_page_image = seo_page_image | prepend: seo_url %} + {% assign seo_page_image = seo_page_image | absolute_url %} {% endunless %} {% assign seo_page_image = seo_page_image | escape %} {% endif %} @@ -113,9 +109,9 @@ {% endif %} -{% if seo_url %} - - +{% if page.url %} + + {% endif %} {% if seo_site_title %} @@ -133,7 +129,7 @@ {% endif %} {% if page.image.twitter %} - + {% endif %} {% if page.date %} @@ -142,10 +138,10 @@ {% endif %} {% if paginator.previous_page %} - + {% endif %} {% if paginator.next_page %} - + {% endif %} {% if site.twitter %} @@ -216,7 +212,7 @@ "sameAs": {{ seo_links | jsonify }}, {% endif %} - "url": {{ page.url | prepend: seo_url | replace:'/index.html','/' | jsonify }} + "url": {{ page.url | replace:'/index.html','/' | absolute_url | jsonify }} } diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 76821a8..98bb82c 100644 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -218,18 +218,6 @@ EOS end end - context "with site.github.url" do - let(:github_namespace) { { "url" => "http://example.invalid" } } - let(:site) { make_site("github" => github_namespace) } - - it "uses site.github.url to build the seo url" do - expected = %r!! - expect(output).to match(expected) - expected = %r!! - expect(output).to match(expected) - end - end - context "posts" do context "with post meta" do let(:site) { make_site("url" => "http://example.invalid") } @@ -449,8 +437,8 @@ EOS let(:context) { make_context({}, "paginator" => paginator) } it "outputs pagination links" do - expect(output).to match(%r!!) - expect(output).to match(%r!!) + expect(output).to match(%r!!) + expect(output).to match(%r!!) end end end