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) 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