From 879abc0949b441a427c447b00ef7f183cb82d0cb Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 1 Jun 2014 13:18:00 -0400 Subject: [PATCH 1/4] Externalize the {% gist %} tag as the jekyll-gist gem. --- jekyll.gemspec | 1 + lib/jekyll.rb | 1 + lib/jekyll/tags/gist.rb | 47 ----------------------------------------- 3 files changed, 2 insertions(+), 47 deletions(-) delete mode 100644 lib/jekyll/tags/gist.rb diff --git a/jekyll.gemspec b/jekyll.gemspec index 7b3a4b0b..328535d2 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -39,6 +39,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency('redcarpet', "~> 3.1") s.add_runtime_dependency('toml', '~> 0.1.0') s.add_runtime_dependency('jekyll-paginate', '~> 1.0') + s.add_runtime_dependency('jekyll-gist', '~> 1.0') s.add_runtime_dependency('jekyll-coffeescript', '~> 1.0') s.add_runtime_dependency('jekyll-sass-converter', '~> 1.0') diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 1b54ec4b..b36569b3 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -75,6 +75,7 @@ require_all 'jekyll/tags' require 'jekyll-coffeescript' require 'jekyll-sass-converter' require 'jekyll-paginate' +require 'jekyll-gist' SafeYAML::OPTIONS[:suppress_warnings] = true diff --git a/lib/jekyll/tags/gist.rb b/lib/jekyll/tags/gist.rb deleted file mode 100644 index 977933dc..00000000 --- a/lib/jekyll/tags/gist.rb +++ /dev/null @@ -1,47 +0,0 @@ -# Gist Liquid Tag -# -# Example: -# {% gist username/1234567 %} -# {% gist username/1234567 file.rb %} - -module Jekyll - class GistTag < Liquid::Tag - - def render(context) - if tag_contents = determine_arguments(@markup.strip) - gist_id, filename = tag_contents[0], tag_contents[1] - gist_script_tag(gist_id, filename) - else - raise ArgumentError.new <<-eos -Syntax error in tag 'gist' while parsing the following markup: - - #{@markup} - -Valid syntax: - for all gists: {% gist user/1234567 %} -eos - end - end - - private - - def determine_arguments(input) - matched = if input.include?("/") - input.match(/\A([a-zA-Z0-9\/\-_]+) ?(\S*)\Z/) - else - input.match(/\A(\d+) ?(\S*)\Z/) - end - [matched[1].strip, matched[2].strip] if matched && matched.length >= 3 - end - - def gist_script_tag(gist_id, filename = nil) - if filename.empty? - "" - else - "" - end - end - end -end - -Liquid::Template.register_tag('gist', Jekyll::GistTag) From 7977769d91b26910c94c5400a6d589223f9fcd29 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 1 Jun 2014 14:01:47 -0400 Subject: [PATCH 2/4] Test our RC1 of jekyll-gist. --- jekyll.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jekyll.gemspec b/jekyll.gemspec index 328535d2..30099325 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -39,7 +39,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency('redcarpet', "~> 3.1") s.add_runtime_dependency('toml', '~> 0.1.0') s.add_runtime_dependency('jekyll-paginate', '~> 1.0') - s.add_runtime_dependency('jekyll-gist', '~> 1.0') + s.add_runtime_dependency('jekyll-gist', '~> 1.0.0.rc1') s.add_runtime_dependency('jekyll-coffeescript', '~> 1.0') s.add_runtime_dependency('jekyll-sass-converter', '~> 1.0') From ed87454ff8b6b7b30f39d5bfdb9f7a1b54da837f Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 1 Jun 2014 14:01:57 -0400 Subject: [PATCH 3/4] Remove tests for gists. --- test/test_tags.rb | 109 ---------------------------------------------- 1 file changed, 109 deletions(-) diff --git a/test/test_tags.rb b/test/test_tags.rb index 97c82b91..7f2dd4d5 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -259,115 +259,6 @@ CONTENT end end - context "gist tag" do - context "simple" do - setup do - @gist = 358471 - content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) - end - - should "write script tag" do - assert_match "", @result - end - end - - context "for private gist" do - context "when valid" do - setup do - @gist = "mattr-/24081a1d93d2898ecf0f" - @filename = "myfile.ext" - content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) - end - - should "write script tag with specific file in gist" do - assert_match "", @result - end - end - - should "raise ArgumentError when invalid" do - @gist = "mattr-24081a1d93d2898ecf0f" - @filename = "myfile.ext" - content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) - end - end - end - - context "with specific file" do - setup do - @gist = 358471 - @filename = 'somefile.rb' - content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) - end - - should "write script tag with specific file in gist" do - assert_match "", @result - end - end - - context "with blank gist id" do - should "raise ArgumentError" do - content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) - end - end - end - - context "with invalid gist id" do - should "raise ArgumentError" do - invalid_gist = 'invalid' - content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) - end - end - end - end - context "include tag with parameters" do context "with symlink'd include" do From 3c1c8c397f04cd38e0ce5bb517164f19f5f170ef Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 1 Jun 2014 14:25:13 -0400 Subject: [PATCH 4/4] Jekyll-gist 1.0. :boom: --- jekyll.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jekyll.gemspec b/jekyll.gemspec index 30099325..328535d2 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -39,7 +39,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency('redcarpet', "~> 3.1") s.add_runtime_dependency('toml', '~> 0.1.0') s.add_runtime_dependency('jekyll-paginate', '~> 1.0') - s.add_runtime_dependency('jekyll-gist', '~> 1.0.0.rc1') + s.add_runtime_dependency('jekyll-gist', '~> 1.0') s.add_runtime_dependency('jekyll-coffeescript', '~> 1.0') s.add_runtime_dependency('jekyll-sass-converter', '~> 1.0')