diff --git a/jekyll-gist.gemspec b/jekyll-gist.gemspec
index d1ec8f5..c88b5e7 100644
--- a/jekyll-gist.gemspec
+++ b/jekyll-gist.gemspec
@@ -20,5 +20,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
+ spec.add_development_dependency "webmock"
spec.add_development_dependency "jekyll", "~> 2.0"
end
diff --git a/lib/jekyll-gist/gist_tag.rb b/lib/jekyll-gist/gist_tag.rb
index 9822bd7..a78174f 100644
--- a/lib/jekyll-gist/gist_tag.rb
+++ b/lib/jekyll-gist/gist_tag.rb
@@ -1,3 +1,6 @@
+require 'cgi'
+require 'open-uri'
+
module Jekyll
module Gist
class GistTag < Liquid::Tag
@@ -11,7 +14,9 @@ def render(context)
if context.has_key?(filename)
filename = context[filename]
end
- gist_script_tag(gist_id, filename)
+ noscript_tag = gist_noscript_tag(gist_id, filename)
+ script_tag = gist_script_tag(gist_id, filename)
+ "#{noscript_tag}#{script_tag}"
else
raise ArgumentError.new <<-eos
Syntax error in tag 'gist' while parsing the following markup:
@@ -35,13 +40,33 @@ def determine_arguments(input)
end
def gist_script_tag(gist_id, filename = nil)
- if filename.empty?
- ""
+ url = "https://gist.github.com/#{gist_id}.js"
+ url = "#{url}?file=#{filename}" unless filename.empty?
+ ""
+ end
+
+ def gist_noscript_tag(gist_id, filename = nil)
+ code = fetch_raw_code(gist_id, filename)
+ if !code.nil?
+ ""
else
- ""
+ Jekyll.logger.warn "Warning:", "The