middleman-automatic-clowncar 0.0.4 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d89dafa2bff458ff5a70f1eba877d3075e4d1309
4
- data.tar.gz: c20c51ec82da48d292bf55fd3162eeaaad94f695
2
+ SHA256:
3
+ metadata.gz: 521f4d750e09f11d5dfbcb610cddce713f88b26ecf1bb36d083bee6a4604f72a
4
+ data.tar.gz: 3cd1edd638d3d4d94e7e3e6935a9c39c418ba93125d6c8829114e8ab5b8bae3e
5
5
  SHA512:
6
- metadata.gz: c33018469c8c46fb6896bada8868784cefca57b96380d4b95b7ecda9608496e67bc350d2a5f2c32de9ff5d50a7fd236849558b7de9edc837d45da713bb551d8e
7
- data.tar.gz: 0d1f00b7dbd72fb91a77b72c7e37124faa47e711cdc3e9cab41e410c0f547749bf1fe37d31b8e5bbac88b12c4f42b2d85c348cd5dd52492634b09045e3635348
6
+ metadata.gz: 7febf2daebd50e101f53088343ddbde2c60d631d6efd92be79e77a3225fbe951765ef8e3796723b6bcf48a63281c1076f4ff9e68396564f51b4f98a9d236aece
7
+ data.tar.gz: 1b993e4f93f1f367adab19e06f8da9fc81ee10ff424d64142ec6ee9103bf17274803bebac0c5d52e9bed84393b608188191560e37fc4dcf4d77c9837aacbdb61
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  fixtures/*/build
19
+ .byebug_history
@@ -0,0 +1 @@
1
+ 2.6.1
@@ -175,6 +175,6 @@ Feature: Generating SVG clowncars during preview mode
175
175
  And the file "testfile.html" should contain "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
176
176
  And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
177
177
  And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:401px)%20and%20(max-width:600px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
178
- And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:601px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/../test-image.jpg);%7D%7D"
178
+ And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:601px)%7Bsvg%7Bbackground-image:url(/photos/test-image/../test-image.jpg);%7D%7D"
179
179
 
180
180
 
@@ -1,5 +1,5 @@
1
1
  Given(/^the file "(.*?)" has been overwritten with "(.*?)"$/) do |file1,file2|
2
- FileUtils.cp File.join(current_dir,file2), File.join(current_dir,file1)
2
+ FileUtils.cp File.join(expand_path('.'),file2), File.join(expand_path('.'),file1)
3
3
  end
4
4
 
5
5
  Given(/^some time has passed$/) do
@@ -7,8 +7,8 @@ Given(/^some time has passed$/) do
7
7
  end
8
8
 
9
9
  Then(/^we should write some stuff to the console$/) do
10
- puts "here's index.html"
11
- puts File.open(File.join(current_dir,"index.html")).read
12
- puts "------"
13
- puts File.open(File.join(current_dir,"photos/test-image/test-image-small.jpg"),'rb').read
10
+ puts "here's testfile.html"
11
+ puts File.open(File.join(expand_path('.'),"testfile.html")).read
12
+ #puts "------"
13
+ #puts File.open(File.join(expand_path('.'),"photos/test-image/test-image-small.jpg"),'rb').read
14
14
  end
@@ -14,6 +14,7 @@ Feature: Generating thumbnails
14
14
  Scenario: Basic useage during preview
15
15
  Given a fixture app "automatic-clowncar-app"
16
16
  And the Server is running at "automatic-clowncar-app"
17
+ Given the Server is running at "automatic-clowncar-app"
17
18
  When I go to "/photos/test-image/test-image-small.jpg"
18
19
  Then the content type should be "image/jpeg"
19
20
  When I go to "/photos/test-image/test-image-medium.jpg"
@@ -11,9 +11,9 @@ require 'fastimage'
11
11
  module Middleman
12
12
  module AutomaticClowncar
13
13
  class Extension < Middleman::Extension
14
-
14
+
15
15
  SVG_TEMPLATE = "<svg viewBox='0 0 ::width:: ::height::' preserveAspectRatio='xMidYMid meet' xmlns='http://www.w3.org/2000/svg'><style>svg{background-size:100% 100%;background-repeat:no-repeat;}::media_queries::</style></svg>"
16
-
16
+
17
17
  option :sizes, {}, "The sizes of thumbnails to generate"
18
18
  option :namespace_directory, ["**"], "The directories that should be clowncared. (Outside of the sprockets images dir.)"
19
19
  option :filetypes, [:jpg, :jpeg, :png], "The types of files to use for automatic clowncaring."
@@ -33,31 +33,21 @@ module Middleman
33
33
  app.after_configuration do
34
34
 
35
35
  #stash the source images dir in options for the Rack middleware
36
- Extension.options_hash[:source_dir] = source_dir
36
+ Extension.options_hash[:source_dir] = app.source_dir
37
37
 
38
38
  sizes = Extension.options_hash[:sizes]
39
39
  namespace = Extension.options_hash[:namespace_directory].join(',')
40
40
 
41
- dir = Pathname.new(source_dir)
41
+ dir = Pathname.new(app.source_dir)
42
42
  glob = "#{dir}/{#{namespace}}/*.{#{Extension.options_hash[:filetypes].join(',')}}"
43
43
  files = Dir[glob]
44
-
45
- # don't build the files until after build
46
- #after_build do |builder|
47
- #puts "Generating automatic clowncar images"
48
- #files.each do |file|
49
- #path = file.gsub(source_dir, '')
50
- #specs = ThumbnailGenerator.specs(path, sizes, source_dir)
51
- #ThumbnailGenerator.generate(source_dir, File.join(root, build_dir), path, specs)
52
- #end
53
- #end
54
-
55
- sitemap.register_resource_list_manipulator(:thumbnailer, SitemapExtension.new(self), true)
56
-
57
- #app.use Rack, Extension.options_hash
58
44
  end
59
45
  end
60
-
46
+
47
+ def manipulate_resource_list(resources)
48
+ SitemapExtension.new(self).manipulate_resource_list(resources)
49
+ end
50
+
61
51
  def after_configuration
62
52
  @ready = true
63
53
  end
@@ -74,7 +64,7 @@ module Middleman
74
64
  end
75
65
 
76
66
  def get_image_path(name, path, is_relative, fallback_host)
77
- #puts "@@@@@@@ calling get_image_path for #{path}"
67
+ #puts "@@@@@@@ calling get_image_path for name:#{name} path:#{path}, is_relative:#{is_relative}, fallback_host:#{fallback_host}"
78
68
  begin
79
69
  uri = URI(path)
80
70
  rescue URI::InvalidURIError
@@ -85,14 +75,15 @@ module Middleman
85
75
  if uri.host
86
76
  path
87
77
  else
88
-
78
+
89
79
  svg_path = File.join(File.dirname(name),File.basename(name,".*"), path)
90
80
 
91
81
  if is_relative
92
82
  url = app.asset_path(:images, svg_path)
93
- url = url.sub("/#{app.images_dir}/",'/')
94
-
95
- if fallback_host &&is_relative_url?(url)
83
+ # TODO : Previously the images_dir could be configured. Now it seems to be hard coded by middleman?
84
+ images_dir = 'images' # app.images_dir
85
+ url = url.sub("/#{images_dir}/",'/')
86
+ if fallback_host && is_relative_url?(url)
96
87
  File.join(fallback_host, url)
97
88
  else
98
89
  url
@@ -150,7 +141,7 @@ module Middleman
150
141
 
151
142
  width, height = ::FastImage.size(main_abs_path, :raise_on_failure => true)
152
143
 
153
-
144
+
154
145
  sizes = {}
155
146
  Extension.options_hash[:sizes].each_pair do |sname,swidth|
156
147
  next if swidth > width
@@ -171,9 +162,9 @@ module Middleman
171
162
  #puts "name for generate_svg = #{name}"
172
163
  #puts "options for generate_svg = #{options}"
173
164
  sizes, width, height = get_image_sizes(name, options)
174
-
165
+
175
166
  fallback_host = false
176
- if is_relative
167
+ if is_relative
177
168
  test_path = app.asset_path(:images, "#{name}.svg")
178
169
  if is_relative_url?(test_path)
179
170
  if options.has_key?(:host)
@@ -197,17 +188,12 @@ module Middleman
197
188
  Extension.svg_files_to_generate << [name, options]
198
189
  end
199
190
 
200
-
201
191
 
202
-
203
-
204
-
205
192
  helpers do
206
193
  def automatic_clowncar_tag(name, options={})
207
194
  internal = ""
208
195
 
209
196
  if options[:fallback]
210
-
211
197
  fallback = File.basename thumbnail_url(name,:small)
212
198
  fallback_path = extensions[:automatic_clowncar].get_image_path(name, fallback, true, false)
213
199
  internal = %{<!--[if lte IE 8]><img src="#{fallback_path}"><![endif]-->}
@@ -220,7 +206,7 @@ module Middleman
220
206
  #else
221
207
  # width = extensions[:automatic_clowncar].options.sizes.map{|k,v| v }.sort.last
222
208
  #end
223
-
209
+
224
210
  object_style = "max-width:#{width}px;"
225
211
  end
226
212
 
@@ -235,7 +221,7 @@ module Middleman
235
221
 
236
222
  def thumbnail_specs(image, name)
237
223
  sizes = Extension.options_hash[:sizes]
238
- ThumbnailGenerator.specs(image, sizes, source_dir)
224
+ ThumbnailGenerator.specs(image, sizes, app.source_dir)
239
225
  end
240
226
 
241
227
  def thumbnail_url(image, name, options = {})
@@ -2,8 +2,9 @@ module Middleman
2
2
  module AutomaticClowncar
3
3
  class SitemapExtension
4
4
 
5
- def initialize(app)
6
- @app = app
5
+ def initialize(extension)
6
+ @extension = extension
7
+ @app = extension.app
7
8
  end
8
9
 
9
10
  # Add sitemap resource for every image in the sprockets load path
@@ -24,9 +25,9 @@ module Middleman
24
25
  default_resource = resources.select{|r| r.destination_path == spec[:name]}
25
26
  resources = resources - default_resource
26
27
  end
27
- dest_path = File.join(@app.root_path,@app.build_dir, spec[:name])
28
+ dest_path = File.join(@app.root_path,'build', spec[:name])
28
29
  source = File.exists?(dest_path) ? dest_path : file
29
- resource_list << Middleman::AutomaticClowncar::ThumbnailResource.new(@app.sitemap,spec[:name],spec[:dimensions],file,@app.root_path,@app.build_dir,@app.source_dir)
30
+ resource_list << Middleman::AutomaticClowncar::ThumbnailResource.new(@app.sitemap,spec[:name],spec[:dimensions],file,@app.root_path,'build',@app.source_dir)
30
31
  #resource_list << Middleman::Sitemap::Resource.new(@app.sitemap, spec[:name], source) unless name == :original
31
32
  end
32
33
  fname = specs.first[1][:name]
@@ -1,7 +1,7 @@
1
1
  module Middleman
2
2
  module AutomaticClowncar
3
3
  class ThumbnailResource < ::Middleman::Sitemap::Resource
4
-
4
+
5
5
  require 'mini_magick'
6
6
 
7
7
  attr_accessor :output
@@ -12,7 +12,7 @@ module Middleman
12
12
  @root_path = root_path
13
13
  @build_dir = build_dir
14
14
  @source_dir = source_dir
15
- super(store, path)
15
+ super(store, path, source_dir.to_s)
16
16
  end
17
17
 
18
18
  def template?
@@ -22,21 +22,10 @@ module Middleman
22
22
  def source_file
23
23
  nil
24
24
  end
25
- #def source_file
26
- #output_dir = File.join(@root_path,@build_dir)
27
- #dest_path = File.join(output_dir,@path)
28
- #source_path = File.join(@root_path,@source_dir)
29
- #if Utils.timestamp_current?(@source_dir,@build_dir,@origin) && File.exist?(dest_path)
30
- #File.join(@build_dir,@path)
31
- #else
32
- #@origin
33
- #end
34
- #end
35
25
 
36
26
  def render(*args, &block)
37
27
  output_dir = File.join(@root_path,@build_dir)
38
28
  dest_path = File.join(output_dir,@path)
39
- source_path = File.join(@source_dir,@origin)
40
29
  img = nil
41
30
  if Utils.timestamp_current?(@source_dir,@build_dir,@origin) && File.exist?(dest_path)
42
31
  img = MiniMagick::Image.open(dest_path)
@@ -47,10 +36,6 @@ module Middleman
47
36
  img.to_blob
48
37
  end
49
38
 
50
- # def request_path
51
- # @request_path
52
- # end
53
-
54
39
  def binary?
55
40
  false
56
41
  end
@@ -63,10 +48,6 @@ module Middleman
63
48
  false
64
49
  end
65
50
 
66
- def metadata
67
- @local_metadata.dup
68
- end
69
-
70
51
  end
71
52
  end
72
53
  end
@@ -1,13 +1,13 @@
1
1
  module Middleman
2
2
  module AutomaticClowncar
3
3
  class TimestampResource < ::Middleman::Sitemap::Resource
4
-
4
+
5
5
  attr_accessor :output
6
6
 
7
7
  def initialize(store, path, origin, source_dir)
8
8
  @source_dir = source_dir
9
9
  @origin = origin
10
- super(store, path)
10
+ super(store, path, source_dir.to_s)
11
11
  end
12
12
 
13
13
  def template?
@@ -37,11 +37,6 @@ module Middleman
37
37
  false
38
38
  end
39
39
 
40
- def metadata
41
- @local_metadata.dup
42
- end
43
-
44
-
45
40
  end
46
41
  end
47
42
  end
@@ -30,7 +30,7 @@ module Middleman
30
30
 
31
31
  # strip the source_dir and any leading slashes
32
32
  def self.naked_origin(source_dir,origin)
33
- origin.gsub(source_dir + File::SEPARATOR, '')
33
+ origin.gsub(source_dir.to_s + File::SEPARATOR, '')
34
34
  end
35
35
 
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module MiddlemanAutomaticClowncar
2
- VERSION = "0.0.4"
2
+ VERSION = "4.0.0"
3
3
  end
@@ -18,18 +18,21 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "middleman-core", "> 3.2.2"
21
+ spec.add_dependency "middleman-core", "~> 4.3.0"
22
22
 
23
23
  spec.add_dependency("mini_magick", ["~> 3.7.0"])
24
- spec.add_dependency "fastimage", "~> 1.6.0"
24
+ spec.add_dependency "fastimage", "~> 2.0"
25
25
 
26
26
  # These are here to make sure that we don't have any collisions with sprockets
27
- spec.add_dependency "middleman-sprockets", "> 3.2.0"
28
- spec.add_dependency "sass", "~> 3.4.0"
27
+ spec.add_dependency "middleman-sprockets", "~> 4.1.0"
28
+ #spec.add_dependency "sass", "~> 3.4.0"
29
29
 
30
+ spec.add_development_dependency "middleman", "~> 4.3.0"
30
31
  spec.add_development_dependency "bundler", "~> 1.5"
31
32
  spec.add_development_dependency "rake"
32
- spec.add_development_dependency "cucumber", "~> 1.3.10"
33
- spec.add_development_dependency "aruba", "~> 0.5.1"
33
+ spec.add_development_dependency "capybara", "~> 2.5.0"
34
+ spec.add_development_dependency "cucumber", "~> 2.0"
35
+ spec.add_development_dependency "aruba", "~> 0.14.0"
36
+ spec.add_development_dependency "byebug"
34
37
  #spec.add_development_dependency "simplecov", "~> 0.8.2"
35
38
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-automatic-clowncar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Green
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-08 00:00:00.000000000 Z
11
+ date: 2020-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.2
19
+ version: 4.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">"
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.2
26
+ version: 4.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mini_magick
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,42 +44,42 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.6.0
47
+ version: '2.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.6.0
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: middleman-sprockets
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">"
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.2.0
61
+ version: 4.1.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">"
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.2.0
68
+ version: 4.1.0
69
69
  - !ruby/object:Gem::Dependency
70
- name: sass
70
+ name: middleman
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 3.4.0
76
- type: :runtime
75
+ version: 4.3.0
76
+ type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 3.4.0
82
+ version: 4.3.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -108,34 +108,62 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: capybara
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 2.5.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 2.5.0
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: cucumber
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: 1.3.10
131
+ version: '2.0'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: 1.3.10
138
+ version: '2.0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: aruba
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: 0.5.1
145
+ version: 0.14.0
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: 0.5.1
152
+ version: 0.14.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: byebug
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  description: Automatically generated responsive images for middleman.
140
168
  email:
141
169
  - jeremy@octolabs.com
@@ -144,6 +172,7 @@ extensions: []
144
172
  extra_rdoc_files: []
145
173
  files:
146
174
  - ".gitignore"
175
+ - ".ruby-version"
147
176
  - ".travis.yml"
148
177
  - Gemfile
149
178
  - LICENSE.txt
@@ -175,7 +204,7 @@ homepage: ''
175
204
  licenses:
176
205
  - MIT
177
206
  metadata: {}
178
- post_install_message:
207
+ post_install_message:
179
208
  rdoc_options: []
180
209
  require_paths:
181
210
  - lib
@@ -190,9 +219,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
219
  - !ruby/object:Gem::Version
191
220
  version: '0'
192
221
  requirements: []
193
- rubyforge_project:
194
- rubygems_version: 2.2.2
195
- signing_key:
222
+ rubygems_version: 3.0.1
223
+ signing_key:
196
224
  specification_version: 4
197
225
  summary: Automatically generated responsive images for middleman.
198
226
  test_files: