Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0be5ccb
Showing
36 changed files
with
891 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
*.gem | |||
*.rbc | |||
.bundle | |||
.config | |||
.yardoc | |||
Gemfile.lock | |||
InstalledFiles | |||
_yardoc | |||
coverage | |||
doc/ | |||
lib/bundler/man | |||
pkg | |||
rdoc | |||
spec/reports | |||
test/tmp | |||
test/version_tmp | |||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
--require ./lib/jekyll-assets --color --format documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
language: ruby | |||
rvm: [ 1.9.3 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
source 'https://rubygems.org' | |||
|
|||
# Specify your gem's dependencies in jekyll-assets.gemspec | |||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
guard 'rspec' do | |||
watch(%r{^spec/.+_spec\.rb$}) | |||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } | |||
watch('spec/spec_helper.rb') { "spec" } | |||
end | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
Copyright (c) 2012 Aleksey V Zapparov (http://ixti.net/) | |||
|
|||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,120 @@ | |||
# Jekyll::AssetsPlugin | |||
|
|||
Jekyll plugin, that adds Rails-alike assets pipelines. | |||
|
|||
|
|||
## Installation | |||
|
|||
Add this line to your application's Gemfile: | |||
|
|||
gem 'jekyll-assets' | |||
|
|||
And then execute: | |||
|
|||
$ bundle | |||
|
|||
Or install it yourself as: | |||
|
|||
$ gem install jekyll-assets | |||
|
|||
|
|||
## Usage | |||
|
|||
Add this line to your sites `_plugins/ext.rb`: | |||
|
|||
require 'jekyll-assets' | |||
|
|||
Put your assets under following paths: | |||
|
|||
- `_assets/javascripts` | |||
- `_assets/stylesheets` | |||
- `_assets/images` | |||
|
|||
Name your "main" asset files `app.js` and `app.css` and use liquid tags: | |||
|
|||
- `{% javascript app %}` to output `<script>` tag for `app.js` | |||
- `{% stylesheet app %}` to output `<link>` tag for `app.css` | |||
- `{% asset_path logo.jpg %}` to output URL for `logo.jpg` | |||
|
|||
In order to use these tags, assets must be "bundled". By default only `app.js`, | |||
`app.css`, and all files with extensions `.jpg`, `.png` or `.gif` are bundled. | |||
You can change this by tuning up you `_config.yml` (see below). | |||
|
|||
|
|||
## Configuration | |||
|
|||
You can fine-tune configuration by editing your `_config.yml`: | |||
|
|||
assets: | |||
# | |||
# Pathname of the destination of generated (bundled) assets relative | |||
# to the destination of the root. | |||
# | |||
dirname: assets | |||
# | |||
# Pathnames where to find assets relative to the root of the site. | |||
# | |||
sources: | |||
- _assets/javascripts | |||
- _assets/stylesheets | |||
- _assets/images | |||
# | |||
# Array of filenames or filename patterns that needs to be generated for | |||
# the generated site. You can use `*` and `**` wildcards in patterns: | |||
# | |||
# 'foobar.jpg' will match 'foobar.jpg' only | |||
# '*.jpg' will match 'foo.jpg', but not 'foo/bar.jpg' | |||
# '**.jpg' will match 'foo.jpg', 'foo/bar.jpg', etc. | |||
# | |||
bundles: | |||
- 'app.css' | |||
- 'app.js' | |||
- '**.jpg' | |||
- '**.png' | |||
- '**.gif' | |||
# | |||
# Sets compressors for the specific types of file: `js`, or `css`. | |||
# No compression by default. | |||
# | |||
# Possible variants: | |||
# | |||
# css => 'yui', 'sass', nil | |||
# js => 'yui', 'unglifier', nil | |||
# | |||
compress: | |||
js: ~ | |||
css: ~ | |||
|
|||
|
|||
## Contributing | |||
|
|||
1. Fork it | |||
2. Create your feature branch (`git checkout -b my-new-feature`) | |||
3. Commit your changes (`git commit -am 'Added some feature'`) | |||
4. Push to the branch (`git push origin my-new-feature`) | |||
5. Create new Pull Request | |||
|
|||
|
|||
## License | |||
|
|||
Copyright (C) 2012 Aleksey V Zapparov (http://ixti.net/) | |||
|
|||
The 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
#!/usr/bin/env rake | |||
|
|||
require "bundler/gem_tasks" | |||
require "rspec/core/rake_task" | |||
|
|||
RSpec::Core::RakeTask.new | |||
|
|||
task :default => :spec | |||
task :test => :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
# -*- encoding: utf-8 -*- | |||
require File.expand_path('../lib/jekyll/assets_plugin/version', __FILE__) | |||
|
|||
|
|||
Gem::Specification.new do |gem| | |||
gem.name = "jekyll-assets" | |||
gem.version = Jekyll::AssetsPlugin::VERSION | |||
gem.homepage = "http://ixti.github.com/jekyll-assets" | |||
gem.authors = %w{Aleksey V Zapparov} | |||
gem.email = %w{ixti@member.fsf.org} | |||
gem.summary = "jekyll-assets-#{Jekyll::AssetsPlugin::VERSION}" | |||
gem.description = %q{Adds assets pipelines for Jekyll} | |||
|
|||
gem.add_dependency "jekyll" | |||
gem.add_dependency "sprockets", "~> 2.8" | |||
|
|||
gem.add_development_dependency "rake" | |||
gem.add_development_dependency "rspec" | |||
gem.add_development_dependency "guard-rspec" | |||
gem.add_development_dependency "rb-inotify" | |||
|
|||
gem.files = `git ls-files`.split($\) | |||
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } | |||
gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) | |||
|
|||
gem.require_paths = ["lib"] | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
require 'jekyll/assets_plugin' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,16 @@ | |||
require 'jekyll' | |||
require 'liquid' | |||
|
|||
|
|||
require 'jekyll/assets_plugin/generator' | |||
require 'jekyll/assets_plugin/site_patch' | |||
require 'jekyll/assets_plugin/tag' | |||
require 'jekyll/assets_plugin/version' | |||
|
|||
|
|||
Jekyll::Site.send :include, Jekyll::AssetsPlugin::SitePatch | |||
|
|||
|
|||
Liquid::Template.register_tag('javascript', Jekyll::AssetsPlugin::Tag) | |||
Liquid::Template.register_tag('stylesheet', Jekyll::AssetsPlugin::Tag) | |||
Liquid::Template.register_tag('asset_path', Jekyll::AssetsPlugin::Tag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,45 @@ | |||
# stdlib | |||
require 'set' | |||
|
|||
|
|||
module Jekyll | |||
module AssetsPlugin | |||
# Represents single asset that can be used as StaticFile for Site | |||
# | |||
class AssetFile | |||
@@mtimes = Hash.new | |||
|
|||
attr_reader :asset | |||
|
|||
def initialize site, asset | |||
@site, @asset = site, asset | |||
end | |||
|
|||
def destination dest | |||
File.join(dest, @site.assets_config.dirname, @asset.digest_path) | |||
end | |||
|
|||
def path | |||
@asset.pathname.to_s | |||
end | |||
|
|||
def mtime | |||
@asset.mtime.to_i | |||
end | |||
|
|||
def modified? | |||
@@mtimes[path] != mtime | |||
end | |||
|
|||
def write dest | |||
dest_path = destination dest | |||
|
|||
return false if File.exist?(dest_path) and !modified? | |||
@@mtimes[path] = mtime | |||
|
|||
@asset.write_to dest_path | |||
true | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,98 @@ | |||
# stdlib | |||
require 'ostruct' | |||
|
|||
|
|||
module Jekyll | |||
module AssetsPlugin | |||
# Plugin configuration class. | |||
# | |||
# | |||
# ##### sources | |||
# | |||
# Pathnames where to find assets relative to the root of the site. | |||
# | |||
# Default: ['_assets/javascripts', '_assets/stylesheets', '_assets/images'] | |||
# | |||
# | |||
# ##### bundles | |||
# | |||
# Array of filenames or filename patterns that needs to be generated for the | |||
# generated site. You can use `*` and `**` wildcards in filename patterns: | |||
# | |||
# 'foobar.jpg' will match 'foobar.jpg' only | |||
# '*.jpg' will match 'foo.jpg', but not 'foo/bar.jpg' | |||
# '**.jpg' will match 'foo.jpg', 'foo/bar.jpg', etc. | |||
# | |||
# Default: ['app.css', 'app.js', '**.jpg', '**.png', '**.gif'] | |||
# | |||
# | |||
# ##### compress | |||
# | |||
# Sets compressors for the specific types of file: `js`, or `css`. | |||
# | |||
# Possible variants: | |||
# | |||
# css => 'yui', 'sass', nil | |||
# js => 'yui', 'unglifier', nil | |||
# | |||
# Default: { 'css' => nil, 'js' => nil } (no compression at all) | |||
# | |||
# | |||
# ##### dirname | |||
# | |||
# Pathname of the destination of generated (bundled) assets relative to the | |||
# destination of the root. | |||
# | |||
# Default: 'assets' | |||
# | |||
class Configuration < OpenStruct | |||
@@defaults = { | |||
:dirname => 'assets', | |||
:sources => %w{_assets/javascripts _assets/stylesheets _assets/images}, | |||
:bundles => %w{app.css app.js **.jpg **.png **.gif}, | |||
:compress => { :css => nil, :js => nil } | |||
} | |||
|
|||
def initialize config = {} | |||
super @@defaults.merge(config) | |||
|
|||
self.sources = [ self.sources ] if self.sources.is_a? String | |||
self.bundles = [ self.bundles ] if self.bundles.is_a? String | |||
|
|||
self.compress = OpenStruct.new(self.compress) | |||
end | |||
|
|||
# Returns bundles array with pattern strings converted to RegExps | |||
# | |||
# 'foobar.jpg' => 'foobar.jpg' | |||
# '*.png' => /[^\]+\.png/ | |||
# '**.gif' => /.+?\.gif/ | |||
# | |||
def bundle_filenames | |||
bundles.map do |pattern| | |||
if pattern =~ /^\*/ | |||
pattern = pattern.dup | |||
|
|||
pattern.gsub!(/\./, '\\.') | |||
pattern.sub!(/\*{2}/, '.+?') | |||
pattern.sub!(/\*{1}/, '[^/]+') | |||
|
|||
pattern = /^#{pattern}$/ | |||
end | |||
|
|||
pattern | |||
end | |||
end | |||
|
|||
def js_compressor | |||
return compress.js.to_sym if compress.js | |||
false | |||
end | |||
|
|||
def css_compressor | |||
return compress.css.to_sym if compress.css | |||
false | |||
end | |||
end | |||
end | |||
end |
Oops, something went wrong.