jekyll-assets 2.0.0.pre.beta2 → 2.0.0.pre.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/README.md +33 -40
  4. data/lib/jekyll/assets.rb +18 -16
  5. data/lib/jekyll/assets/addons/autoprefixer.rb +5 -0
  6. data/lib/jekyll/assets/addons/bootstrap.rb +1 -0
  7. data/lib/jekyll/assets/addons/compass.rb +7 -0
  8. data/lib/jekyll/assets/addons/font_awesome.rb +1 -0
  9. data/lib/jekyll/assets/{extras/es6.rb → addons/js_es6.rb} +1 -1
  10. data/lib/jekyll/assets/addons/proxies/magick.rb +92 -0
  11. data/lib/jekyll/assets/config.rb +48 -0
  12. data/lib/jekyll/assets/env.rb +110 -91
  13. data/lib/jekyll/assets/hook.rb +42 -25
  14. data/lib/jekyll/assets/hooks/cache.rb +5 -0
  15. data/lib/jekyll/assets/hooks/compression.rb +11 -0
  16. data/lib/jekyll/assets/hooks/configuration.rb +3 -0
  17. data/lib/jekyll/assets/hooks/context_patches.rb +12 -0
  18. data/lib/jekyll/assets/hooks/disable_erb.rb +6 -0
  19. data/lib/jekyll/assets/hooks/helpers.rb +8 -0
  20. data/lib/jekyll/assets/hooks/logger.rb +3 -0
  21. data/lib/jekyll/assets/hooks/sources.rb +5 -0
  22. data/lib/jekyll/assets/hooks/sprockets.rb +3 -0
  23. data/lib/jekyll/assets/hooks/version.rb +3 -0
  24. data/lib/jekyll/assets/liquid/filters.rb +16 -0
  25. data/lib/jekyll/assets/liquid/tag.rb +162 -0
  26. data/lib/jekyll/assets/liquid/tag/parser.rb +163 -0
  27. data/lib/jekyll/assets/liquid/tag/proxied_asset.rb +98 -0
  28. data/lib/jekyll/assets/liquid/tag/proxies.rb +122 -0
  29. data/lib/jekyll/assets/logger.rb +34 -11
  30. data/lib/jekyll/assets/patches/hash.rb +5 -0
  31. data/lib/jekyll/assets/patches/jekyll/cleaner.rb +2 -2
  32. data/lib/jekyll/assets/patches/kernel.rb +31 -0
  33. data/lib/jekyll/assets/patches/sprockets/asset.rb +6 -6
  34. data/lib/jekyll/assets/version.rb +1 -1
  35. data/lib/jekyll/hooks/initialize.rb +3 -0
  36. data/lib/jekyll/hooks/write_assets.rb +3 -0
  37. metadata +28 -17
  38. data/lib/jekyll/assets/configuration.rb +0 -51
  39. data/lib/jekyll/assets/context.rb +0 -23
  40. data/lib/jekyll/assets/extras/font-awesome.rb +0 -1
  41. data/lib/jekyll/assets/extras/helpers.rb +0 -6
  42. data/lib/jekyll/assets/extras/prefix.rb +0 -5
  43. data/lib/jekyll/assets/filters.rb +0 -17
  44. data/lib/jekyll/assets/helpers.rb +0 -37
  45. data/lib/jekyll/assets/hooks/post_read.rb +0 -3
  46. data/lib/jekyll/assets/hooks/post_write.rb +0 -3
  47. data/lib/jekyll/assets/tag.rb +0 -148
  48. data/lib/jekyll/assets/tag/parser.rb +0 -129
  49. data/lib/jekyll/assets/tag/proxied_asset.rb +0 -84
  50. data/lib/jekyll/assets/tag/proxies.rb +0 -86
  51. data/lib/jekyll/assets/tag/proxies/magick.rb +0 -101
@@ -1,86 +0,0 @@
1
- module Jekyll
2
- module Assets
3
- class Tag
4
- module Proxies
5
- def self.add(cls, name, tag, args)
6
- names = [name, name.to_s, name.to_sym]
7
- tags = [tag].flatten.map { |v| [v.to_s, v, v.to_sym] }
8
- args = [args].flatten.map { |v| [v.to_s, v, v.to_sym] }
9
-
10
- all << {
11
- :name => names.uniq,
12
- :tags => tags.flatten.uniq,
13
- :args => args.flatten.uniq,
14
- :cls => cls
15
- }
16
- all
17
- end
18
-
19
- def self.keys
20
- all.select { |v| !v[:cls].is_a?(Symbol) }.map do |v|
21
- v[:name]
22
- end. \
23
- flatten
24
- end
25
-
26
- def self.base_keys
27
- all.select { |v| v[:cls].is_a?(Symbol) }.map do |v|
28
- v[:name]
29
- end. \
30
- flatten
31
- end
32
-
33
- def self.has?(name, tag = nil, arg = nil)
34
- get(name, tag, arg).any?
35
- end
36
-
37
- def self.get(name, tag = nil, arg = nil)
38
- if name && tag && arg
39
- get_by_name_and_tag_and_arg(
40
- name, tag, arg
41
- )
42
- elsif name && tag
43
- get_by_name_and_tag(
44
- name, tag
45
- )
46
- else
47
- all.select do |v|
48
- v[:name].include?(name)
49
- end
50
- end
51
- end
52
-
53
- def self.get_by_name_and_tag_and_arg(name, tag, arg)
54
- all.select do |v|
55
- (v[:name].include?(name)) && \
56
- (v[:tags].include?(:all) || \
57
- v[:tags].include?(tag)) && \
58
- (v[:args].include?( arg))
59
- end
60
- end
61
-
62
- def self.get_by_name_and_tag(name, tag)
63
- all.select do |v|
64
- (v[:name].include?(name)) &&
65
- (v[:tags].include?(:all) || \
66
- v[:tags].include?(tag))
67
- end
68
- end
69
-
70
- def self.all
71
- @_all ||= Set.new
72
- end
73
-
74
- # TODO: Put in a better place.
75
- add :internal, :data, :all, ["@uri"]
76
- add :internal, :sprockets, :all, [
77
- "accept", "write_to"
78
- ]
79
- end
80
- end
81
- end
82
- end
83
-
84
- Jekyll::Assets::Helpers.try_require("mini_magick") do
85
- require_relative "proxies/magick"
86
- end
@@ -1,101 +0,0 @@
1
- module Jekyll
2
- module Assets
3
- class Tag
4
- module Proxies
5
-
6
- # @see https://github.com/minimagick/minimagick#usage -- All but
7
- # the boolean @ options are provided by Minimagick.
8
-
9
- class Magick
10
- attr_reader :asset, :path, :opts
11
- class DoubleResizeError < RuntimeError
12
- def initialize
13
- "Both resize and @2x provided, this is not supported."
14
- end
15
- end
16
-
17
- def initialize(asset, opts)
18
- @asset, @path, @opts = asset, asset.filename, opts
19
- end
20
-
21
- def process
22
- img = MiniMagick::Image.open(path)
23
- private_methods(true).select { |v| v =~ /\Amagick_/ }.each do |k|
24
- send(k, img)
25
- end
26
-
27
- img.write(
28
- path
29
- )
30
- end
31
-
32
- private
33
- def quality(img)
34
- if opts[:quality]
35
- img.quality opts[:quality]
36
- end
37
- end
38
-
39
- private
40
- def magick_resize(img)
41
- if opts[:resize] && (opts[:"2x"] || opts[:"4x"] || opts[:half])
42
- raise DoubleResizeError
43
-
44
- elsif @opts[:resize]
45
- img.resize opts[:resize]
46
- end
47
- end
48
-
49
- private
50
- def magick_format(img)
51
- if opts[:format]
52
- img.format opts[:format]
53
- end
54
- end
55
-
56
- private
57
- def magick_rotate(img)
58
- if opts[:rotate]
59
- img.rotate opts[:rotate]
60
- end
61
- end
62
-
63
- private
64
- def magick_flip(img)
65
- if opts[:flip]
66
- img.flip opts[:flip]
67
- end
68
- end
69
-
70
- private
71
- def magick_crop(img)
72
- if opts[:crop]
73
- img.crop opts[:crop]
74
- end
75
- end
76
-
77
- private
78
- def magick_preset_resize(img)
79
- return unless opts[:"2x"] || opts[:"4x"] || opts[:half]
80
- width, height = img.width * 2, img.height * 2 if opts[:"2x"]
81
- width, height = img.width * 4, img.height * 4 if opts[:"4x"]
82
- width, height = img.width / 2, img.height / 2 if opts[:half]
83
- img.resize "#{width}x#{height}"
84
- end
85
- end
86
-
87
- add Magick, :magick, :img, [
88
- "quality",
89
- "resize",
90
- "format",
91
- "rotate",
92
- "crop",
93
- "flip",
94
- "@2x",
95
- "@4x",
96
- "@half"
97
- ]
98
- end
99
- end
100
- end
101
- end