jekyll-imgix 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 30709c12df5c591576a4d97c3954c1c748b8e0c1
4
+ data.tar.gz: c1245f18d540b9c34e0a668ec7f1e06a16f64df2
5
+ SHA512:
6
+ metadata.gz: 37a00151b31b000e2b746c4fe9c2012ddfbf0b166a78b2f9914377b581f3a2388707482826112020f879b22a8cd1d336f1e37c4a1ee74621ee00e55c2ec23408
7
+ data.tar.gz: 77976c39ad6896a331e59a0646f08fb5ef11a4636f3546df8d32aa16d513b9e31634952caa4cbadd16e37c2e76e8acc350ed9bdb8b9cfa40b6c32783cfbd3feb
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 kellysutton
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # jekyll-imgix ![Travis Build Status](https://travis-ci.org/imgix/jekyll-imgix.svg)
2
+
3
+ A simple Jekyll plugin for rolling imgix functionality into your Jekyll site.
4
+
5
+ ## Installation
6
+
7
+ There are a handful of ways to install Jekyll plugins.
8
+
9
+ ## Rubygems
10
+
11
+ ```
12
+ $ gem install jekyll-imgix
13
+ ```
14
+
15
+ Then include `jekyll-imgix` in the `gems:` section of your `_config.yml` file:
16
+
17
+ ```yaml
18
+ gems: [jekyll-other-plugin, jekyll-imgix]
19
+ ```
20
+
21
+ ## Bundler
22
+
23
+ Include the following in your `Gemfile`:
24
+
25
+ ```ruby
26
+ gem 'jekyll-imgix'
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ **jekyll-imgix does not do anything unless JEKYLL_ENV is set to production**. For example,
32
+ you will want to run `JEKYLL_ENV=production jekyll build` before deploying your site to
33
+ production.
34
+
35
+ jekyll-imgix exposes its functionality as a single Jekyll Filter, `imgix_url`.
36
+
37
+ Simply pass an existing image path to it to activate it:
38
+
39
+ ```html
40
+ <img src={{ "/images/bear.jpg" | imgix_url }} />
41
+ ```
42
+
43
+ That will generate the following HTML in your output:
44
+
45
+ ```html
46
+ <img src="https://assets.imgix.net/images/bear.jpg" />
47
+ ```
48
+
49
+ You can also pass parameters to the `imgix_url` helper like so:
50
+
51
+ ```html
52
+ <img src={{ "/images/bear.jpg" | imgix_url: w: 400, h: 300 }} />
53
+ ```
54
+
55
+ Which would result in the following HTML:
56
+
57
+ ```html
58
+ <img src="https://assets.imgix.net/images/bear.jpg?w=400&h300" />
59
+ ```
60
+
61
+ ### Configuration
62
+
63
+ jekyll-imgix requires a configuration block in your `_config.yml`:
64
+
65
+ ```yaml
66
+ imgix:
67
+ source: assets.imgix.net # Your imgix source address
68
+ secure_url_token: FACEBEEF12 # (optional) The Secure URL Token associated with your source
69
+ ```
70
+
71
+ ## Contributing
72
+
73
+ Bug reports and pull requests are welcome on GitHub at https://github.com/imgix/jekyll-imgix.
74
+
75
+
76
+ ## License
77
+
78
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
79
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jekyll/imgix"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll/imgix/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-imgix"
8
+ spec.version = Jekyll::Imgix::VERSION
9
+ spec.authors = ["kellysutton"]
10
+ spec.email = ["kelly@imgix.com"]
11
+
12
+ spec.summary = %q{A simple Ruby gem to bring imgix to your Jekyll site.}
13
+ spec.homepage = "https://github.com/imgix/jekyll-imgix"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "imgix"
22
+
23
+ spec.add_development_dependency "liquid", "~> 3.0"
24
+ spec.add_development_dependency "bundler", "~> 1.10"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec"
27
+ end
@@ -0,0 +1,60 @@
1
+ require "jekyll/imgix/version"
2
+ require "imgix"
3
+ require "liquid"
4
+
5
+ module Jekyll
6
+ module Imgix
7
+ def imgix_url(raw, opts={})
8
+ return raw unless production?
9
+ verify_config_present!
10
+ client.path(raw).to_url(opts)
11
+ end
12
+
13
+ private
14
+
15
+ def verify_config_present!
16
+ unless @context.registers[:site].config['imgix']
17
+ raise StandardError.new("No 'imgix' section present in _config.yml. Please see https://github.com/imgix/jekyll-imgix for configuration instructions")
18
+ end
19
+ end
20
+
21
+ def client
22
+ return @client if @client
23
+
24
+ opts = default_opts.dup
25
+ opts[:token] = token if token
26
+ @client = ::Imgix::Client.new(opts)
27
+ end
28
+
29
+ def default_opts
30
+ {
31
+ host: source,
32
+ library_param: "jekyll",
33
+ library_version: VERSION,
34
+ secure: true
35
+ }
36
+ end
37
+
38
+ def production?
39
+ env == 'production'
40
+ end
41
+
42
+ def development?
43
+ !production?
44
+ end
45
+
46
+ def source
47
+ @context.registers[:site].config.fetch('imgix', {}).fetch('source', nil)
48
+ end
49
+
50
+ def token
51
+ @context.registers[:site].config.fetch('imgix', {}).fetch('secure_url_token', nil)
52
+ end
53
+
54
+ def env
55
+ ENV['JEKYLL_ENV'] || 'development'
56
+ end
57
+ end
58
+ end
59
+
60
+ Liquid::Template.register_filter(Jekyll::Imgix)
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Imgix
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-imgix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kellysutton
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: imgix
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: liquid
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - kelly@imgix.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - jekyll-imgix.gemspec
100
+ - lib/jekyll/imgix.rb
101
+ - lib/jekyll/imgix/version.rb
102
+ homepage: https://github.com/imgix/jekyll-imgix
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.4.7
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: A simple Ruby gem to bring imgix to your Jekyll site.
126
+ test_files: []