jekyll-assets 1.0.0 → 2.0.0.pre.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -10
  3. data/LICENSE +16 -18
  4. data/README.md +94 -554
  5. data/Rakefile +2 -8
  6. data/lib/jekyll/assets.rb +18 -12
  7. data/lib/jekyll/assets/cached.rb +12 -0
  8. data/lib/jekyll/assets/configuration.rb +43 -87
  9. data/lib/jekyll/assets/context.rb +23 -0
  10. data/lib/jekyll/assets/env.rb +181 -0
  11. data/lib/jekyll/assets/extras/es6.rb +5 -0
  12. data/lib/jekyll/assets/extras/font-awesome.rb +1 -0
  13. data/lib/jekyll/assets/extras/helpers.rb +6 -0
  14. data/lib/jekyll/assets/extras/prefix.rb +5 -0
  15. data/lib/jekyll/assets/filters.rb +9 -11
  16. data/lib/jekyll/assets/helpers.rb +37 -0
  17. data/lib/jekyll/assets/hook.rb +45 -0
  18. data/lib/jekyll/assets/hooks/post_read.rb +3 -0
  19. data/lib/jekyll/assets/hooks/post_write.rb +3 -0
  20. data/lib/jekyll/assets/logger.rb +25 -0
  21. data/lib/jekyll/assets/patches/jekyll/cleaner.rb +11 -0
  22. data/lib/jekyll/assets/patches/jekyll/site.rb +5 -0
  23. data/lib/jekyll/assets/patches/sprockets/asset.rb +13 -0
  24. data/lib/jekyll/assets/tag.rb +136 -9
  25. data/lib/jekyll/assets/tag/parser.rb +129 -0
  26. data/lib/jekyll/assets/tag/proxied_asset.rb +84 -0
  27. data/lib/jekyll/assets/tag/proxies.rb +86 -0
  28. data/lib/jekyll/assets/tag/proxies/magick.rb +101 -0
  29. data/lib/jekyll/assets/version.rb +1 -1
  30. metadata +59 -149
  31. data/.gitignore +0 -27
  32. data/.rspec +0 -1
  33. data/.rubocop.yml +0 -43
  34. data/.rubocop_todo.yml +0 -10
  35. data/.travis.yml +0 -16
  36. data/.yardopts +0 -1
  37. data/Appraisals +0 -7
  38. data/Guardfile +0 -7
  39. data/HISTORY.md +0 -297
  40. data/gemfiles/jekyll_2.gemfile +0 -17
  41. data/gemfiles/jekyll_3.gemfile +0 -17
  42. data/jekyll-assets.gemspec +0 -34
  43. data/lib/jekyll-assets.rb +0 -2
  44. data/lib/jekyll/assets/asset_path.rb +0 -39
  45. data/lib/jekyll/assets/environment.rb +0 -62
  46. data/lib/jekyll/assets/patches.rb +0 -1
  47. data/lib/jekyll/assets/patches/asset_patch.rb +0 -102
  48. data/lib/jekyll/assets/patches/bundled_asset_patch.rb +0 -16
  49. data/lib/jekyll/assets/patches/context_patch.rb +0 -31
  50. data/lib/jekyll/assets/patches/index_patch.rb +0 -25
  51. data/lib/jekyll/assets/patches/processed_asset_patch.rb +0 -59
  52. data/lib/jekyll/assets/patches/site_patch.rb +0 -62
  53. data/lib/jekyll/assets/renderer.rb +0 -122
  54. data/spec/fixtures/.gitignore +0 -2
  55. data/spec/fixtures/.jekyll-metadata +0 -0
  56. data/spec/fixtures/_assets/alert.js +0 -1
  57. data/spec/fixtures/_assets/app.css.erb +0 -5
  58. data/spec/fixtures/_assets/app.js +0 -1
  59. data/spec/fixtures/_assets/app.min.css +0 -0
  60. data/spec/fixtures/_assets/app.min.js +0 -0
  61. data/spec/fixtures/_assets/fonts/vapor.eot +0 -0
  62. data/spec/fixtures/_assets/fonts/vapor.svg +0 -0
  63. data/spec/fixtures/_assets/fonts/vapor.ttf +0 -0
  64. data/spec/fixtures/_assets/fonts/vapor.woff +0 -0
  65. data/spec/fixtures/_assets/lib/relative.css.scss +0 -12
  66. data/spec/fixtures/_assets/noise.png +0 -0
  67. data/spec/fixtures/_assets/noize.png +0 -0
  68. data/spec/fixtures/_assets/should_be_blank.css.erb +0 -1
  69. data/spec/fixtures/_assets/should_fail.css.erb +0 -1
  70. data/spec/fixtures/_assets/vapor.css.scss +0 -13
  71. data/spec/fixtures/_assets/vapor.js +0 -2
  72. data/spec/fixtures/_assets/vendor/with_bootstrap.css.sass +0 -1
  73. data/spec/fixtures/_assets/vendor/with_bourbon.css.sass +0 -4
  74. data/spec/fixtures/_assets/vendor/with_compass.css.sass +0 -4
  75. data/spec/fixtures/_assets/vendor/with_neat.css.sass +0 -5
  76. data/spec/fixtures/_assets/wowscript.js +0 -0
  77. data/spec/fixtures/_assets/wowstyle.css +0 -0
  78. data/spec/fixtures/_config.yml +0 -2
  79. data/spec/fixtures/_layouts/default.html +0 -9
  80. data/spec/fixtures/_posts/2012-10-19-hello-world.md +0 -6
  81. data/spec/fixtures/_posts/2015-02-02-duplicates.md +0 -8
  82. data/spec/fixtures/index.html +0 -0
  83. data/spec/lib/jekyll/assets/configuration_spec.rb +0 -172
  84. data/spec/lib/jekyll/assets/environment_spec.rb +0 -18
  85. data/spec/lib/jekyll/assets/filters_spec.rb +0 -112
  86. data/spec/lib/jekyll/assets/patches/site_patch_spec.rb +0 -176
  87. data/spec/lib/jekyll/assets/renderer_spec.rb +0 -286
  88. data/spec/lib/jekyll/assets/tag_spec.rb +0 -139
  89. data/spec/spec_helper.rb +0 -58
  90. data/spec/support/fixtures_helpers.rb +0 -7
@@ -1,34 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "jekyll/assets/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "jekyll-assets"
8
- spec.version = Jekyll::Assets::VERSION
9
- spec.homepage = "http://jekyll-assets.github.com/jekyll-assets"
10
- spec.authors = ["Aleksey V Zapparov", "Zachary Bush"]
11
- spec.email = %w(ixti@member.fsf.org zach@zmbush.com)
12
- spec.license = "MIT"
13
- spec.summary = "jekyll-assets-#{Jekyll::Assets::VERSION}"
14
- spec.description = <<-DESC
15
- Jekyll plugin, that allows you to write javascript/css assets in
16
- other languages such as CoffeeScript, Sass, Less and ERB, concatenate
17
- them, respecting dependencies, minify and many more.
18
- DESC
19
-
20
- spec.files = `git ls-files`.split($RS)
21
- spec.executables = spec.files.grep(/^bin\//).map { |f| File.basename(f) }
22
- spec.test_files = spec.files.grep(/^(test|spec|features)\//)
23
- spec.require_paths = ["lib"]
24
-
25
- spec.add_dependency "jekyll", ">= 2"
26
- spec.add_dependency "sass", "~> 3.2"
27
- spec.add_dependency "fastimage", "~> 1.6"
28
- spec.add_dependency "mini_magick", "~> 4.1"
29
- spec.add_dependency "sprockets", "~> 2.10"
30
- spec.add_dependency "sprockets-sass"
31
- spec.add_dependency "sprockets-helpers"
32
-
33
- spec.add_development_dependency "bundler", "~> 1.6"
34
- end
data/lib/jekyll-assets.rb DELETED
@@ -1,2 +0,0 @@
1
- # rubocop: disable FileName
2
- require "jekyll/assets"
@@ -1,39 +0,0 @@
1
- module Jekyll
2
- module Assets
3
- class AssetPath
4
- attr_writer :anchor, :query
5
-
6
- def initialize(asset)
7
- asset.bundle!
8
- @asset = asset
9
- end
10
-
11
- def cachebust
12
- @cachebust ||= @asset.site.assets_config.cachebust
13
- end
14
-
15
- def path
16
- :hard == cachebust && @asset.digest_path || @asset.logical_path
17
- end
18
-
19
- def query
20
- query = []
21
-
22
- query << "cb=#{@asset.digest}" if :soft == cachebust
23
- query << @query if @query
24
-
25
- return if query.empty?
26
-
27
- "?" << query.join("&")
28
- end
29
-
30
- def anchor
31
- "##{@anchor}" if @anchor
32
- end
33
-
34
- def to_s
35
- "#{@asset.site.assets_config.baseurl}/#{path}#{query}#{anchor}"
36
- end
37
- end
38
- end
39
- end
@@ -1,62 +0,0 @@
1
- # stdlib
2
- require "pathname"
3
-
4
- # 3rd-party
5
- require "sass"
6
- require "sprockets"
7
- require "sprockets-sass"
8
- require "sprockets-helpers"
9
-
10
- module Jekyll
11
- module Assets
12
- class Environment < Sprockets::Environment
13
- class AssetNotFound < StandardError
14
- def initialize(path)
15
- super "Couldn't find file '#{path}'"
16
- end
17
- end
18
-
19
- attr_reader :site
20
-
21
- # rubocop:disable Metrics/AbcSize
22
- def initialize(site)
23
- super site.source
24
-
25
- @site = site
26
-
27
- # append asset paths
28
- site.assets_config.sources.each { |p| append_path p }
29
- append_path resize_cache_path
30
-
31
- self.js_compressor = site.assets_config.js_compressor
32
- self.css_compressor = site.assets_config.css_compressor
33
-
34
- Jekyll::Assets::HOOKS.each { |block| block.call(self) }
35
-
36
- if site.assets_config.cache_assets?
37
- self.cache = Sprockets::Cache::FileStore.new cache_path
38
- end
39
-
40
- # reset cache if config changed
41
- self.version = site.assets_config.marshal_dump
42
-
43
- # bind jekyll and Sprockets context together
44
- context_class.instance_variable_set :@site, site
45
- context_class.send :include, Patches::ContextPatch
46
- end
47
- # rubocop:enable Metrics/AbcSize
48
-
49
- def cache_path
50
- Pathname.new(@site.source).join @site.assets_config.cache_path
51
- end
52
-
53
- def resize_cache_path
54
- cache_path.join "resize"
55
- end
56
-
57
- def find_asset(path, *args)
58
- super || fail(AssetNotFound, path)
59
- end
60
- end
61
- end
62
- end
@@ -1 +0,0 @@
1
- Dir[File.join File.dirname(__FILE__), "patches/**/*.rb"].each { |f| require f }
@@ -1,102 +0,0 @@
1
- # 3rd-party
2
- require "sprockets"
3
- require "mini_magick"
4
-
5
- module Jekyll
6
- module Assets
7
- module Patches
8
- module AssetPatch
9
- def self.included(base)
10
- base.send :extend, ClassMethods
11
- base.send :include, InstanceMethods
12
- end
13
-
14
- module ClassMethods
15
- def mtimes
16
- @mtimes ||= {}
17
- end
18
- end
19
-
20
- module InstanceMethods
21
- attr_reader :site
22
-
23
- def jekyll_assets
24
- []
25
- end
26
-
27
- def bundle!
28
- site.bundle_asset! self if site
29
- self
30
- end
31
-
32
- def destination(dest)
33
- File.join dest, site.assets_config.dirname, filename
34
- end
35
-
36
- def filename
37
- case cachebust = site.assets_config.cachebust
38
- when :none, :soft then logical_path
39
- when :hard then digest_path
40
- else fail "Unknown cachebust strategy: #{cachebust.inspect}"
41
- end
42
- end
43
-
44
- def modified?
45
- self.class.mtimes[pathname.to_s] != mtime.to_i
46
- end
47
-
48
- def write(dest)
49
- dest_path = destination dest
50
-
51
- return false if File.exist?(dest_path) && !modified?
52
- self.class.mtimes[pathname.to_s] = mtime.to_i
53
-
54
- write_to dest_path
55
- write_to "#{dest_path}.gz" if gzip?
56
-
57
- true
58
- end
59
-
60
- def gzip?
61
- site.assets_config.gzip.include? content_type
62
- end
63
-
64
- def extname
65
- @extname ||= File.extname(pathname)
66
- end
67
-
68
- def basename
69
- @basename ||= File.basename(pathname, extname)
70
- end
71
-
72
- def resize_outdir
73
- site.assets.resize_cache_path
74
- end
75
-
76
- def ensure_resize_directory!
77
- FileUtils.mkdir_p resize_outdir
78
- end
79
-
80
- def do_resize(dimensions)
81
- name = "#{basename}-#{dimensions}#{extname}".gsub(/%/, "P")
82
- img = MiniMagick::Image.read(to_s, extname)
83
- img.resize dimensions
84
- img.write "#{resize_outdir}/#{name}"
85
-
86
- [name, site.assets[name]]
87
- end
88
-
89
- def resize(dimensions)
90
- ensure_resize_directory!
91
-
92
- @outfiles ||= {}
93
-
94
- @outfiles[dimensions] ||= do_resize(dimensions)
95
- end
96
- end
97
- end
98
- end
99
- end
100
- end
101
-
102
- Sprockets::Asset.send :include, Jekyll::Assets::Patches::AssetPatch
@@ -1,16 +0,0 @@
1
- # 3rd-party
2
- require "sprockets"
3
-
4
- module Jekyll
5
- module Assets
6
- module Patches
7
- module BundledAssetPatch
8
- def jekyll_assets
9
- @processed_asset.jekyll_assets
10
- end
11
-
12
- ::Sprockets::BundledAsset.send :include, self
13
- end
14
- end
15
- end
16
- end
@@ -1,31 +0,0 @@
1
- # stdlib
2
- require "set"
3
-
4
- module Jekyll
5
- module Assets
6
- module Patches
7
- module ContextPatch
8
- def site
9
- self.class.instance_variable_get :@site
10
- end
11
-
12
- def jekyll_assets
13
- @jekyll_assets ||= Set.new
14
- end
15
-
16
- def asset_path(pathname, *args)
17
- pathname = pathname.to_s.strip
18
-
19
- return "" if pathname.empty?
20
-
21
- asset = resolve(pathname[/^[^#?]+/]).to_s
22
- jekyll_assets << asset
23
-
24
- site.asset_path(asset, *args) + (pathname[/[#?].+/] || "")
25
- rescue Sprockets::FileNotFound
26
- raise Environment::AssetNotFound, pathname
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,25 +0,0 @@
1
- # 3rd-party
2
- require "sprockets"
3
-
4
- module Jekyll
5
- module Assets
6
- module Patches
7
- module IndexPatch
8
- def self.included(base)
9
- base.class_eval do
10
- alias_method :__orig_find_asset, :find_asset
11
- alias_method :find_asset, :__wrap_find_asset
12
- end
13
- end
14
-
15
- def __wrap_find_asset(path, options = {})
16
- __orig_find_asset(path, options).tap do |asset|
17
- asset.instance_variable_set :@site, @environment.site if asset
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
-
25
- Sprockets::Index.send :include, Jekyll::Assets::Patches::IndexPatch
@@ -1,59 +0,0 @@
1
- # stdlib
2
- require "set"
3
-
4
- # 3rd-party
5
- require "sprockets"
6
-
7
- module Jekyll
8
- module Assets
9
- module Patches
10
- module ProcessedAssetPatch
11
- def self.included(base)
12
- base.class_eval do
13
- attr_reader :jekyll_assets
14
-
15
- alias_method :__orig_build_dependency_paths,
16
- :build_dependency_paths
17
-
18
- alias_method :build_dependency_paths,
19
- :__wrap_build_dependency_paths
20
-
21
- alias_method :__orig_init_with, :init_with
22
- alias_method :init_with, :__wrap_init_with
23
-
24
- alias_method :__orig_encode_with, :encode_with
25
- alias_method :encode_with, :__wrap_encode_with
26
- end
27
- end
28
-
29
- def __wrap_build_dependency_paths(environment, context)
30
- @jekyll_assets = Set.new
31
-
32
- context.jekyll_assets.each do |path|
33
- @jekyll_assets << path
34
- @jekyll_assets += environment.find_asset(path).jekyll_assets
35
- end
36
-
37
- __orig_build_dependency_paths environment, context
38
- end
39
-
40
- def __wrap_init_with(environment, coder)
41
- __orig_init_with environment, coder
42
-
43
- jekyll_assets = coder["jekyll_assets"].map { |p| expand_root_path(p) }
44
- @jekyll_assets = Set.new jekyll_assets
45
- end
46
-
47
- def __wrap_encode_with(coder)
48
- __orig_encode_with coder
49
-
50
- coder["jekyll_assets"] = jekyll_assets.map do |path|
51
- relativize_root_path path
52
- end
53
- end
54
-
55
- ::Sprockets::ProcessedAsset.send :include, self
56
- end
57
- end
58
- end
59
- end
@@ -1,62 +0,0 @@
1
- # stdlib
2
- require "digest/md5"
3
-
4
- # 3rd-party
5
- require "jekyll"
6
-
7
- # internal
8
- require "jekyll/assets/configuration"
9
- require "jekyll/assets/environment"
10
- require "jekyll/assets/asset_path"
11
-
12
- module Jekyll
13
- module Assets
14
- module Patches
15
- module SitePatch
16
- def self.included(base)
17
- base.class_eval do
18
- alias_method :__orig_write, :write
19
- alias_method :write, :__wrap_write
20
- end
21
- end
22
-
23
- def assets_config
24
- @assets_config ||= Configuration.new(self, config["assets"] || {})
25
- end
26
-
27
- def assets
28
- @assets ||= Environment.new self
29
- end
30
-
31
- def asset_files
32
- @asset_files ||= Set.new
33
- end
34
-
35
- def asset_path(pathname, *args)
36
- pathname, _, anchor = pathname.rpartition "#" if pathname["#"]
37
- pathname, _, query = pathname.rpartition "?" if pathname["?"]
38
-
39
- asset_path = AssetPath.new assets[pathname, *args]
40
- asset_path.anchor = anchor
41
- asset_path.query = query
42
-
43
- asset_path.to_s
44
- end
45
-
46
- def bundle_asset!(asset)
47
- return if asset_files.include? asset
48
-
49
- asset_files << asset
50
- asset.jekyll_assets.each { |path| bundle_asset! assets[path] }
51
- end
52
-
53
- def __wrap_write
54
- static_files.push(*asset_files)
55
- __orig_write
56
- end
57
- end
58
- end
59
- end
60
- end
61
-
62
- Jekyll::Site.send :include, Jekyll::Assets::Patches::SitePatch