geoblacklight_sidecar_images 0.1.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +5 -5
- data/README.md +136 -11
- data/db/migrate/20180118203155_create_solr_document_sidecars.rb +4 -2
- data/db/migrate/20180118203519_create_sidecar_image_transitions.rb +29 -0
- data/geoblacklight_sidecar_images.gemspec +5 -3
- data/lib/generators/geoblacklight_sidecar_images/{uploaders_generator.rb → config_generator.rb} +4 -5
- data/lib/generators/geoblacklight_sidecar_images/install_generator.rb +8 -14
- data/lib/generators/geoblacklight_sidecar_images/models_generator.rb +24 -2
- data/lib/generators/geoblacklight_sidecar_images/templates/config/initializers/statesman.rb +5 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/jobs/store_image_job.rb +10 -3
- data/lib/generators/geoblacklight_sidecar_images/templates/models/sidecar_image_state_machine.rb +19 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/models/sidecar_image_transition.rb +7 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/models/solr_document_sidecar.rb +34 -2
- data/lib/generators/geoblacklight_sidecar_images/templates/services/image_service.rb +103 -96
- data/lib/generators/geoblacklight_sidecar_images/templates/views/catalog/_index_split_default.html.erb +11 -1
- data/lib/geoblacklight_sidecar_images/version.rb +1 -1
- data/lib/tasks/geoblacklight_sidecar_images_tasks.rake +165 -39
- data/spec/jobs/store_image_job_spec.rb +16 -0
- data/spec/services/image_service_spec.rb +5 -8
- data/template.rb +3 -2
- metadata +48 -24
- data/lib/generators/geoblacklight_sidecar_images/assets_generator.rb +0 -31
- data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-image.png +0 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-line.png +0 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-mixed.png +0 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-multipoint.png +0 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-paper-map.png +0 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-point.png +0 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-polygon.png +0 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-raster.png +0 -0
- data/lib/generators/geoblacklight_sidecar_images/templates/uploaders/image_uploader.rb +0 -55
@@ -0,0 +1,16 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
describe StoreImageJob, type: :job do
|
4
|
+
let(:document) { SolrDocument.new(document_attributes) }
|
5
|
+
|
6
|
+
describe "#perform_later" do
|
7
|
+
let(:document_attributes) { json_data('umn_iiif_jpg') }
|
8
|
+
|
9
|
+
it "stores an image" do
|
10
|
+
ActiveJob::Base.queue_adapter = :test
|
11
|
+
expect {
|
12
|
+
StoreImageJob.perform_later(document.id)
|
13
|
+
}.to have_enqueued_job
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -10,6 +10,8 @@ describe ImageService do
|
|
10
10
|
let(:thumb_document) { SolrDocument.new(json_data('umn_solr_thumb')) }
|
11
11
|
let(:thumb_imgsvc) { ImageService.new(thumb_document) }
|
12
12
|
|
13
|
+
# @TODO: bdcbcd3e-f6db-4ee4-b7b7-d75fe35f1d92 - Michigan State - thumbnail_path_ss
|
14
|
+
|
13
15
|
describe '#store' do
|
14
16
|
it 'should respond to store' do
|
15
17
|
expect(iiif_imgsvc).to respond_to(:store)
|
@@ -32,14 +34,9 @@ describe ImageService do
|
|
32
34
|
expect(iiif_imgsvc.send(:image_url)).to be_kind_of String
|
33
35
|
expect(URI(iiif_imgsvc.send(:image_url))).to be_kind_of URI
|
34
36
|
end
|
35
|
-
|
36
|
-
it 'should determine :remote_content_type' do
|
37
|
-
expect(iiif_imgsvc.send(:remote_content_type)).to eq 'image/jpeg'
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should determine :image_extension' do
|
41
|
-
expect(iiif_imgsvc.send(:image_extension)).to eq '.jpeg'
|
42
|
-
end
|
43
37
|
end
|
44
38
|
end
|
39
|
+
|
40
|
+
# Minnesota-urn-0f7ae38b-4bf2-4e03-a32b-e87f245ccb03
|
41
|
+
# => attachable? should be false
|
45
42
|
end
|
data/template.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
# $ rails _5.
|
1
|
+
# $ rails _5.2.1_ new app-name -m https://raw.githubusercontent.com/ewlarson/geoblacklight_sidecar_images/master/template.rb
|
2
2
|
|
3
3
|
gem 'blacklight', '>= 6.3'
|
4
4
|
gem 'geoblacklight', '>= 1.4'
|
5
|
-
gem '
|
5
|
+
gem 'statesman', '>= 3.4'
|
6
|
+
gem 'geoblacklight_sidecar_images', :git => "git://github.com/ewlarson/geoblacklight_sidecar_images.git", :branch => "master"
|
6
7
|
|
7
8
|
run 'bundle install'
|
8
9
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoblacklight_sidecar_images
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Larson
|
@@ -9,57 +9,85 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-11-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: geoblacklight
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1.
|
20
|
+
version: '1.9'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '1.
|
27
|
+
version: '1.9'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: mini_magick
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '4.8'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '4.8'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: image_processing
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '1.6'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '1.6'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: statesman
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.4'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.4'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: mimemagic
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.3'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.3'
|
56
84
|
- !ruby/object:Gem::Dependency
|
57
85
|
name: rails
|
58
86
|
requirement: !ruby/object:Gem::Requirement
|
59
87
|
requirements:
|
60
88
|
- - ">="
|
61
89
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
90
|
+
version: '5.2'
|
63
91
|
- - "<"
|
64
92
|
- !ruby/object:Gem::Version
|
65
93
|
version: '6'
|
@@ -69,7 +97,7 @@ dependencies:
|
|
69
97
|
requirements:
|
70
98
|
- - ">="
|
71
99
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
100
|
+
version: '5.2'
|
73
101
|
- - "<"
|
74
102
|
- !ruby/object:Gem::Version
|
75
103
|
version: '6'
|
@@ -241,25 +269,21 @@ files:
|
|
241
269
|
- app/views/layouts/geoblacklight_sidecar_images/application.html.erb
|
242
270
|
- config/routes.rb
|
243
271
|
- db/migrate/20180118203155_create_solr_document_sidecars.rb
|
272
|
+
- db/migrate/20180118203519_create_sidecar_image_transitions.rb
|
244
273
|
- geoblacklight_sidecar_images.gemspec
|
245
|
-
- lib/generators/geoblacklight_sidecar_images/
|
274
|
+
- lib/generators/geoblacklight_sidecar_images/config_generator.rb
|
246
275
|
- lib/generators/geoblacklight_sidecar_images/example_docs_generator.rb
|
247
276
|
- lib/generators/geoblacklight_sidecar_images/install_generator.rb
|
248
277
|
- lib/generators/geoblacklight_sidecar_images/jobs_generator.rb
|
249
278
|
- lib/generators/geoblacklight_sidecar_images/models_generator.rb
|
250
279
|
- lib/generators/geoblacklight_sidecar_images/services_generator.rb
|
251
|
-
- lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-image.png
|
252
|
-
- lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-line.png
|
253
|
-
- lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-mixed.png
|
254
|
-
- lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-multipoint.png
|
255
|
-
- lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-paper-map.png
|
256
|
-
- lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-point.png
|
257
|
-
- lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-polygon.png
|
258
|
-
- lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-raster.png
|
259
280
|
- lib/generators/geoblacklight_sidecar_images/templates/assets/javascripts/geoblacklight.js
|
260
281
|
- lib/generators/geoblacklight_sidecar_images/templates/assets/stylesheets/geoblacklight.scss
|
282
|
+
- lib/generators/geoblacklight_sidecar_images/templates/config/initializers/statesman.rb
|
261
283
|
- lib/generators/geoblacklight_sidecar_images/templates/jobs/store_image_job.rb
|
262
284
|
- lib/generators/geoblacklight_sidecar_images/templates/models/concerns/wms_rewrite_concern.rb
|
285
|
+
- lib/generators/geoblacklight_sidecar_images/templates/models/sidecar_image_state_machine.rb
|
286
|
+
- lib/generators/geoblacklight_sidecar_images/templates/models/sidecar_image_transition.rb
|
263
287
|
- lib/generators/geoblacklight_sidecar_images/templates/models/solr_document_sidecar.rb
|
264
288
|
- lib/generators/geoblacklight_sidecar_images/templates/services/image_service.rb
|
265
289
|
- lib/generators/geoblacklight_sidecar_images/templates/services/image_service/dynamic_map_layer.rb
|
@@ -267,9 +291,7 @@ files:
|
|
267
291
|
- lib/generators/geoblacklight_sidecar_images/templates/services/image_service/image_map_layer.rb
|
268
292
|
- lib/generators/geoblacklight_sidecar_images/templates/services/image_service/tiled_map_layer.rb
|
269
293
|
- lib/generators/geoblacklight_sidecar_images/templates/services/image_service/wms.rb
|
270
|
-
- lib/generators/geoblacklight_sidecar_images/templates/uploaders/image_uploader.rb
|
271
294
|
- lib/generators/geoblacklight_sidecar_images/templates/views/catalog/_index_split_default.html.erb
|
272
|
-
- lib/generators/geoblacklight_sidecar_images/uploaders_generator.rb
|
273
295
|
- lib/generators/geoblacklight_sidecar_images/views_generator.rb
|
274
296
|
- lib/geoblacklight_sidecar_images.rb
|
275
297
|
- lib/geoblacklight_sidecar_images/engine.rb
|
@@ -318,6 +340,7 @@ files:
|
|
318
340
|
- spec/fixtures/files/umn_solr_thumb.json
|
319
341
|
- spec/fixtures/files/umn_state_result1.json
|
320
342
|
- spec/fixtures/files/umn_state_result2.json
|
343
|
+
- spec/jobs/store_image_job_spec.rb
|
321
344
|
- spec/models/solr_document_sidecar_spec.rb
|
322
345
|
- spec/models/solr_document_spec.rb
|
323
346
|
- spec/rails_helper.rb
|
@@ -376,6 +399,7 @@ test_files:
|
|
376
399
|
- spec/fixtures/files/umn_solr_thumb.json
|
377
400
|
- spec/fixtures/files/umn_state_result1.json
|
378
401
|
- spec/fixtures/files/umn_state_result2.json
|
402
|
+
- spec/jobs/store_image_job_spec.rb
|
379
403
|
- spec/models/solr_document_sidecar_spec.rb
|
380
404
|
- spec/models/solr_document_spec.rb
|
381
405
|
- spec/rails_helper.rb
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails/generators'
|
4
|
-
|
5
|
-
module GeoblacklightSidecarImages
|
6
|
-
class AssetsGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path('templates', __dir__)
|
8
|
-
|
9
|
-
desc <<-DESCRIPTION
|
10
|
-
This generator makes the following changes to your application:
|
11
|
-
1. Copies asset image files to host app/assets/images
|
12
|
-
DESCRIPTION
|
13
|
-
|
14
|
-
def create_images_assets
|
15
|
-
thumbs = [
|
16
|
-
'thumbnail-image.png',
|
17
|
-
'thumbnail-line.png',
|
18
|
-
'thumbnail-mixed.png',
|
19
|
-
'thumbnail-multipoint.png',
|
20
|
-
'thumbnail-paper-map.png',
|
21
|
-
'thumbnail-point.png',
|
22
|
-
'thumbnail-polygon.png',
|
23
|
-
'thumbnail-raster.png'
|
24
|
-
]
|
25
|
-
|
26
|
-
thumbs.each do |tbnl|
|
27
|
-
copy_file("assets/images/#{tbnl}", "app/assets/images/#{tbnl}")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-image.png
DELETED
Binary file
|
Binary file
|
data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-mixed.png
DELETED
Binary file
|
data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-multipoint.png
DELETED
Binary file
|
data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-paper-map.png
DELETED
Binary file
|
data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-point.png
DELETED
Binary file
|
data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-polygon.png
DELETED
Binary file
|
data/lib/generators/geoblacklight_sidecar_images/templates/assets/images/thumbnail-raster.png
DELETED
Binary file
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class ImageUploader < CarrierWave::Uploader::Base
|
4
|
-
# Include RMagick or MiniMagick support:
|
5
|
-
# include CarrierWave::RMagick
|
6
|
-
include CarrierWave::MiniMagick
|
7
|
-
|
8
|
-
# Choose what kind of storage to use for this uploader:
|
9
|
-
storage :file
|
10
|
-
# storage :fog
|
11
|
-
|
12
|
-
# Override the directory where uploaded files will be stored.
|
13
|
-
# This is a sensible default for uploaders that are meant to be mounted:
|
14
|
-
def store_dir
|
15
|
-
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
16
|
-
end
|
17
|
-
|
18
|
-
# Provide a default URL as a default if there hasn't been a file uploaded:
|
19
|
-
# def default_url(*args)
|
20
|
-
# # For Rails 3.1+ asset pipeline compatibility:
|
21
|
-
# # ActionController::Base.helpers.asset_path(
|
22
|
-
# "fallback/" + [version_name, "default.png"].compact.join('_')
|
23
|
-
# # )
|
24
|
-
#
|
25
|
-
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
26
|
-
# end
|
27
|
-
|
28
|
-
# Process files as they are uploaded:
|
29
|
-
# process scale: [200, 300]
|
30
|
-
#
|
31
|
-
# def scale(width, height)
|
32
|
-
# # do something
|
33
|
-
# end
|
34
|
-
|
35
|
-
# Create different versions of your uploaded files:
|
36
|
-
version :thumb do
|
37
|
-
process resize_to_fill: [300, 300]
|
38
|
-
end
|
39
|
-
|
40
|
-
version :square, from_version: :thumb do
|
41
|
-
process resize_to_fill: [100, 100]
|
42
|
-
end
|
43
|
-
|
44
|
-
# Add a white list of extensions which are allowed to be uploaded.
|
45
|
-
# For images you might use something like this:
|
46
|
-
def extension_whitelist
|
47
|
-
%w[jpg jpeg gif png]
|
48
|
-
end
|
49
|
-
|
50
|
-
# Override the filename of the uploaded files:
|
51
|
-
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
52
|
-
# def filename
|
53
|
-
# "something.jpg" if original_filename
|
54
|
-
# end
|
55
|
-
end
|