Skip to content
Snippets Groups Projects
Commit 73916fec authored by Youhei SASAKI's avatar Youhei SASAKI :beer:
Browse files

Imported Upstream version 1.1.0

parents
No related branches found
No related tags found
No related merge requests found
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
*.bundle
*.so
*.o
*.a
mkmf.log
.rspec 0 → 100644
--color
--format progress
source 'https://rubygems.org'
# Specify your gem's dependencies in jekyll-gist.gemspec
gemspec
## HEAD
## 1.1.0 / 2014-06-18
### Minor Enhancements
* Update regex to allow for new sha-ish ids in Gist. (#1)
## 1.0.0 / 2014-06-01
* Birthday!
Copyright (c) 2014 Parker Moore
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Jekyll::Gist
Liquid tag for displaying GitHub Gists in Jekyll sites: `{% gist %}`.
[![Build Status](https://travis-ci.org/jekyll/jekyll-gist.svg?branch=master)](https://travis-ci.org/jekyll/jekyll-gist)
## Installation
Add this line to your application's Gemfile:
gem 'jekyll-gist'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jekyll-gist
## Usage
Use the tag as follows in your Jekyll pages, posts and collections:
```liquid
{% gist parkr/c08ee0f2726fd0e3909d %}
```
This will create the associated script tag:
```html
<script src="https://gist.github.com/parkr/c08ee0f2726fd0e3909d.js"> </script>
```
You may optionally specify a `filename` after the `gist_id`:
```liquid
{% gist parkr/c08ee0f2726fd0e3909d test.md %}
```
This will produce the correct URL to show just the specified file in your post rather than the entire Gist.
## Contributing
1. Fork it ( https://github.com/jekyll/jekyll-gist/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
require "bundler/gem_tasks"
File added
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'jekyll-gist/version'
Gem::Specification.new do |spec|
spec.name = "jekyll-gist"
spec.version = Jekyll::Gist::VERSION
spec.authors = ["Parker Moore"]
spec.email = ["parkrmoore@gmail.com"]
spec.summary = %q{Liquid tag for displaying GitHub Gists in Jekyll sites.}
spec.homepage = "https://github.com/jekyll/jekyll-gist"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "jekyll", "~> 2.0"
end
require "jekyll-gist/version"
require "jekyll-gist/gist_tag"
module Jekyll
module Gist
end
end
module Jekyll
module Gist
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:
{% gist user/1234567 %}
{% gist user/1234567 foo.js %}
{% gist 28949e1d5ee2273f9fd3 %}
{% gist 28949e1d5ee2273f9fd3 best.md %}
eos
end
end
private
def determine_arguments(input)
matched = input.match(/\A([\S]+|.*(?=\/).+)\s?(\S*)\Z/)
[matched[1].strip, matched[2].strip] if matched && matched.length >= 3
end
def gist_script_tag(gist_id, filename = nil)
if filename.empty?
"<script src=\"https://gist.github.com/#{gist_id}.js\"> </script>"
else
"<script src=\"https://gist.github.com/#{gist_id}.js?file=#{filename}\"> </script>"
end
end
end
end
end
Liquid::Template.register_tag('gist', Jekyll::Gist::GistTag)
module Jekyll
module Gist
VERSION = "1.1.0"
end
end
--- !ruby/object:Gem::Specification
name: jekyll-gist
version: !ruby/object:Gem::Version
version: 1.1.0
platform: ruby
authors:
- Parker Moore
autorequire:
bindir: bin
cert_chain: []
date: 2014-06-18 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: bundler
requirement: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: '1.6'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: '1.6'
- !ruby/object:Gem::Dependency
name: rake
requirement: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0'
- !ruby/object:Gem::Dependency
name: rspec
requirement: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0'
- !ruby/object:Gem::Dependency
name: jekyll
requirement: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: '2.0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
version: '2.0'
description:
email:
- parkrmoore@gmail.com
executables: []
extensions: []
extra_rdoc_files: []
files:
- ".gitignore"
- ".rspec"
- Gemfile
- History.markdown
- LICENSE.txt
- README.md
- Rakefile
- jekyll-gist.gemspec
- lib/jekyll-gist.rb
- lib/jekyll-gist/gist_tag.rb
- lib/jekyll-gist/version.rb
- spec/gist_tag_spec.rb
- spec/spec_helper.rb
homepage: https://github.com/jekyll/jekyll-gist
licenses:
- MIT
metadata: {}
post_install_message:
rdoc_options: []
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0'
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0'
requirements: []
rubyforge_project:
rubygems_version: 2.2.2
signing_key:
specification_version: 4
summary: Liquid tag for displaying GitHub Gists in Jekyll sites.
test_files:
- spec/gist_tag_spec.rb
- spec/spec_helper.rb
require 'spec_helper'
describe(Jekyll::Gist::GistTag) do
let(:doc) { doc_with_content(content) }
let(:content) { "{% gist #{gist} %}" }
let(:output) do
doc.content = content
doc.output = Jekyll::Renderer.new(doc.site, doc).run
end
context "valid gist" do
context "with user prefix" do
let(:gist) { "mattr-/24081a1d93d2898ecf0f" }
it "produces the correct script tag" do
expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
end
end
context "without user prefix" do
let(:gist) { "28949e1d5ee2273f9fd3" }
it "produces the correct script tag" do
expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
end
end
context "classic Gist id style" do
let(:gist) { "1234321" }
it "produces the correct script tag" do
expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js">\s<\/script>/)
end
end
context "with file specified" do
let(:gist) { "mattr-/24081a1d93d2898ecf0f" }
let(:filename) { "myfile.ext" }
let(:content) { "{% gist #{gist} #{filename} %}" }
it "produces the correct script tag" do
expect(output).to match(/<script src="https:\/\/gist.github.com\/#{gist}.js\?file=#{filename}">\s<\/script>/)
end
end
end
context "invalid gist" do
context "no gist id present" do
let(:gist) { "" }
it "raises an error" do
expect(->{ output }).to raise_error
end
end
end
end
TEST_DIR = File.dirname(__FILE__)
TMP_DIR = File.expand_path("../tmp", TEST_DIR)
require 'jekyll'
require File.expand_path("../lib/jekyll-gist.rb", TEST_DIR)
Jekyll.logger.log_level = :error
STDERR.reopen(test(?e, '/dev/null') ? '/dev/null' : 'NUL:')
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
config.order = 'random'
def tmp_dir(*files)
File.join(TMP_DIR, *files)
end
def source_dir(*files)
tmp_dir('source', *files)
end
def dest_dir(*files)
tmp_dir('dest', *files)
end
def doc_with_content(content, opts = {})
my_site = site
Jekyll::Document.new(source_dir('_test/doc.md'), {site: my_site, collection: collection(my_site)})
end
def collection(site, label = 'test')
Jekyll::Collection.new(site, label)
end
def site(opts = {})
conf = Jekyll::Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, opts.merge({
"source" => source_dir,
"destination" => dest_dir
}))
Jekyll::Site.new(conf)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment