jekyll-stitch-plus 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +92 -0
- data/Rakefile +1 -0
- data/jekyll-stitch-plus.gemspec +25 -0
- data/lib/jekyll-stitch-plus.rb +69 -0
- data/lib/jekyll-stitch-plus/version.rb +5 -0
- data/test/.gitignore +1 -0
- data/test/Gemfile +5 -0
- data/test/_config.yml +15 -0
- data/test/_layouts/default.html +13 -0
- data/test/_layouts/post.html +9 -0
- data/test/_plugins/jekyll-stitch-plus.rb +1 -0
- data/test/index.html +6 -0
- data/test/js/lib/foo.coffee +3 -0
- data/test/js/lib/test.js +4 -0
- data/test/js/modules/test-module.js +7 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MWRkZDAxNzg4MjhlODA0OTUyZTRhNDJiYWQ2NGJkMjRjODUyYmNlZg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZGFmOWIxYmNkYWJiM2I3MTQxM2VkNjg1Yzk4ZjZjYTMzZmMwY2NiOQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzZlYjhmNTY2ODFhZDFmZTBmNjNiNjgxYjE4ZGI2YjA5YmMyMGVjZDhiZWUx
|
10
|
+
ZjViZGFiZDU5ZjE3ZTNlNjA4YmRhMTI2NzNlMmVhYWIwNjNlM2RiODkzYTgw
|
11
|
+
ZjY3MmZhNDEwMzJjNzVmYmMwNmUxMWQ2MTNkOWVlZjc5ZTU1Mzg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NmM5NDBjNjRlNTc1YmE1OTNlMmU2N2UyNWEyMGQ3Nzk4OGFmOTRhZTFlZWE1
|
14
|
+
ZmIyMDQ0ZGE2MjYzNjViNGRlMWFhZWRmOTE4NmJmZjA2MzZmOGIxYjJiMGY3
|
15
|
+
MDE2NTA4YjI4ZjYxMzQzZGRjMmMyNjgwZGJhYTNiNTQzY2RiOWM=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Brandon Mathis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# Jekyll Stitch Plus
|
2
|
+
|
3
|
+
Easily package javascripts into a single file, with support for fingerprinting, uglification and CommonJS wrapping for easy modularization. This plugin is powered by
|
4
|
+
[Stitch Plus](https://github.com/imathis/stitch-plus) which is a fancy interface on top of [Stitch-rb](https://github.com/maccman/stitch-rb).
|
5
|
+
|
6
|
+
### Install the Gem
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'jekyll-stitch-plus'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install jekyll-stitch-plus
|
18
|
+
|
19
|
+
### Install the plugin
|
20
|
+
|
21
|
+
Add a ruby file (perhaps named `jekyll-stitch-plus.rb`) to your Jekyll plugins directory add add `require 'jekyll-stitch-plus'` to the top.
|
22
|
+
|
23
|
+
Next add `{% javascript_tag %}` to a template to render `<script src='/javascripts/all.js'></script>`
|
24
|
+
|
25
|
+
## Configuration
|
26
|
+
|
27
|
+
| Config | Description | Default |
|
28
|
+
|:-----------------|:---------------------------------------------------------------------------|:------------|
|
29
|
+
| `dependencies` | Array of files/directories to be added first as global javascripts | nil |
|
30
|
+
| `paths` | Array of directories where javascripts will be wrapped as CommonJS modules | nil |
|
31
|
+
| `output` | A path to write the compiled javascript | 'all.js' |
|
32
|
+
| `fingerprint` | Add a fingerprint to the file name for super cache busting power | false |
|
33
|
+
| `cleanup` | Automatically remove previously compiled files | true |
|
34
|
+
| `uglify` | Smash javascript using the Uglifier gem | false |
|
35
|
+
| `uglify_options` | Options for the Uglifier gem. See [the docs](https://github.com/lautis/uglifier#usage) for details. | {} |
|
36
|
+
|
37
|
+
To configure this plugin add Jekyll's YAML configuration file. Here's an example.
|
38
|
+
|
39
|
+
```yaml
|
40
|
+
# Set Jekyll's env to enable/disable Uglifier
|
41
|
+
env: 'production'
|
42
|
+
|
43
|
+
stitch:
|
44
|
+
dependencies:
|
45
|
+
- 'js/lib/jquery.js'
|
46
|
+
- 'js/lib/underscore.js'
|
47
|
+
- 'js/lib' # globs the js/lib dir
|
48
|
+
paths: 'js/modules' # globs the js/modules dir
|
49
|
+
output: 'js/site.js'
|
50
|
+
fingerprint: true
|
51
|
+
```
|
52
|
+
|
53
|
+
To uglify javascript output you must first install [the uglifier gem](https://github.com/lautis/uglifier) then set your Jekyll environment to production. There are two ways to do this;
|
54
|
+
either set `env: production` in your Jekyll config, or set your shell JEKYLL_ENV to 'production' (case does not matter).
|
55
|
+
|
56
|
+
Setting `uglify: true` (or false) in your Jekyll stitch config will always override any ENV setting.
|
57
|
+
|
58
|
+
If you're confused about paths and dependencies [read this](https://github.com/imathis/stitch-plus#regarding-dependencies).
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
1. Fork it
|
63
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
65
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
66
|
+
5. Create new Pull Request
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
Copyright (c) 2013 Brandon Mathis
|
71
|
+
|
72
|
+
MIT License
|
73
|
+
|
74
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
75
|
+
a copy of this software and associated documentation files (the
|
76
|
+
"Software"), to deal in the Software without restriction, including
|
77
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
78
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
79
|
+
permit persons to whom the Software is furnished to do so, subject to
|
80
|
+
the following conditions:
|
81
|
+
|
82
|
+
The above copyright notice and this permission notice shall be
|
83
|
+
included in all copies or substantial portions of the Software.
|
84
|
+
|
85
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
88
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
89
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
90
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
91
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
92
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jekyll-stitch-plus/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jekyll-stitch-plus"
|
8
|
+
spec.version = Jekyll::StitchPlusVersion::VERSION
|
9
|
+
spec.authors = ["Brandon Mathis"]
|
10
|
+
spec.email = ["brandon@imathis.com"]
|
11
|
+
spec.description = %q{A Jekyll plugin for compiling javascripts with Stitch Plus}
|
12
|
+
spec.summary = %q{A Jekyll plugin for compiling javascripts with Stitch Plus}
|
13
|
+
spec.homepage = "https://github.com/octopress/jekyll-stitch-plus"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_runtime_dependency "jekyll", "~> 1.0.0"
|
20
|
+
spec.add_runtime_dependency "jekyll-page-hooks", "~> 1.0.2"
|
21
|
+
spec.add_runtime_dependency "stitch-plus", "~> 1.0.8"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require "stitch-plus"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
class StitchPlus < Generator
|
6
|
+
def generate(site)
|
7
|
+
config = site.config
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'uglifier'
|
11
|
+
@uglifier = Uglifier.new(config['stitch']['uglify_options'])
|
12
|
+
if (ENV['JEKYLL_ENV'] || config['env']).downcase == 'production'
|
13
|
+
config['stitch']['uglify'] ||= true
|
14
|
+
end
|
15
|
+
rescue LoadError
|
16
|
+
end
|
17
|
+
|
18
|
+
stitch = ::StitchPlus.new(config['stitch'])
|
19
|
+
options = stitch.options
|
20
|
+
|
21
|
+
# Prepend source directory to file output config
|
22
|
+
path = File.join config['source'], options[:output]
|
23
|
+
stitch.set_options({output: path})
|
24
|
+
|
25
|
+
puts '' # Because Jekyll doesn't give a newline for other output
|
26
|
+
stitch.write
|
27
|
+
|
28
|
+
dir = File.dirname(options[:output])
|
29
|
+
filename = File.basename(stitch.last_write)
|
30
|
+
|
31
|
+
# Ensure the compiled file is written to the destination directory
|
32
|
+
site.static_files << StaticFile.new(site, site.source, dir, filename)
|
33
|
+
|
34
|
+
# Store the javascript tag for the liquid tag to retrieve
|
35
|
+
url = File.join (config['root'] || '/'), dir, filename
|
36
|
+
site.config['stitch']['js_tag'] = "<script src='#{url}'></script>"
|
37
|
+
|
38
|
+
# Don't copy static source files or deleted files to the destination directory
|
39
|
+
remove = stitch.all_files.map{ |f| File.join(site.source, f)}
|
40
|
+
remove.concat stitch.deleted
|
41
|
+
cleanup site, remove
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
# Remove files from Jekyll's static_files array
|
46
|
+
def cleanup(site, files)
|
47
|
+
if files.size > 0
|
48
|
+
site.static_files.clone.each do |sf|
|
49
|
+
if sf.kind_of?(Jekyll::StaticFile) and files.include? sf.path
|
50
|
+
site.static_files.delete(sf)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
end
|
58
|
+
class StitchPlusTag < Liquid::Tag
|
59
|
+
def initialize(tag_name, text, tokens)
|
60
|
+
super
|
61
|
+
end
|
62
|
+
|
63
|
+
def render(context)
|
64
|
+
context.registers[:site].config['stitch']['js_tag']
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
Liquid::Template.register_tag('stitch_js_tag', Jekyll::StitchPlusTag)
|
data/test/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
_site
|
data/test/Gemfile
ADDED
data/test/_config.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
name: Your New Jekyll Site
|
2
|
+
markdown: redcarpet
|
3
|
+
pygments: true
|
4
|
+
|
5
|
+
env: 'production'
|
6
|
+
|
7
|
+
stitch:
|
8
|
+
dependencies:
|
9
|
+
- 'js/lib/jquery.js'
|
10
|
+
- 'js/lib/underscore.js'
|
11
|
+
- 'js/lib' # globs the js/lib dir
|
12
|
+
paths: 'js/modules' # globs the js/modules dir
|
13
|
+
output: 'js/site.js'
|
14
|
+
fingerprint: true
|
15
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'jekyll-stitch-plus'
|
data/test/index.html
ADDED
data/test/js/lib/test.js
ADDED
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-stitch-plus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brandon Mathis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jekyll-page-hooks
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: stitch-plus
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.8
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.8
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
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: A Jekyll plugin for compiling javascripts with Stitch Plus
|
84
|
+
email:
|
85
|
+
- brandon@imathis.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- jekyll-stitch-plus.gemspec
|
96
|
+
- lib/jekyll-stitch-plus.rb
|
97
|
+
- lib/jekyll-stitch-plus/version.rb
|
98
|
+
- test/.gitignore
|
99
|
+
- test/Gemfile
|
100
|
+
- test/_config.yml
|
101
|
+
- test/_layouts/default.html
|
102
|
+
- test/_layouts/post.html
|
103
|
+
- test/_plugins/jekyll-stitch-plus.rb
|
104
|
+
- test/index.html
|
105
|
+
- test/js/lib/foo.coffee
|
106
|
+
- test/js/lib/test.js
|
107
|
+
- test/js/modules/test-module.js
|
108
|
+
homepage: https://github.com/octopress/jekyll-stitch-plus
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.0.7
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: A Jekyll plugin for compiling javascripts with Stitch Plus
|
132
|
+
test_files: []
|