geoblacklight_sidecar_images 0.6.2 → 0.8.1

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
2
  SHA256:
3
- metadata.gz: 6e89b436bb5ef1c4905c614eb923397f8837fe7169095e5ec784c8631cfe04e1
4
- data.tar.gz: 18b958b4b4b274ae213281220f00f8557ccc2249807799d467a09fdce33e1986
3
+ metadata.gz: dc1fb2b7358b4783e0275b47a341170fa2e252bf19eae91c735bc97e562fb5e9
4
+ data.tar.gz: 73f43cd9d9aaef743bff32e888ca7be68e7a5b216b69fb69e5defd1ac1a73070
5
5
  SHA512:
6
- metadata.gz: bda9efbc7d361c8c171ff39179f63f8b7046d4aff1892c38a58d92a4cede4c6314838778a07a179809ce7c223a4996b910ba48446f6d6405e012dc3332ed9b99
7
- data.tar.gz: 8b0a0b1a0e2a6a6de19b441e192656f0a224505b19f5130f998668084b3698476afbec31b55320609adca7ef16b3967f0a63a7f6b9b7dcebebcd7cb22b4b743a
6
+ metadata.gz: 489500acdc7152c6efffce9d82fe3c5368f155a9f653984cab5226c3977b24c6d4814cbc23c8ddde48293a243901cd3a50681ecd626525b8f601ac351fc5a3d7
7
+ data.tar.gz: 37bea86e335908b5a9bb7301028c9a11f6c9f9e637de0b8d93699a30604ddad0f2ad74e4ddfe4d8d86d4bac8d17de91c7781e7d2b7e4d27e2518f15bada3e34f
data/.rubocop.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  require: rubocop-rspec
2
+ require: rubocop-rails
2
3
 
3
4
  Rails:
4
5
  Enabled: true
data/.solr_wrapper.yml ADDED
@@ -0,0 +1,5 @@
1
+ validate: false
2
+ download_dir: tmp/solr
3
+ collection:
4
+ dir: solr/conf/
5
+ name: blacklight-core
data/Gemfile CHANGED
@@ -16,7 +16,7 @@ group :development, :test do
16
16
  # Peg simplecov to < 0.8 until this is resolved:
17
17
  # https://github.com/colszowka/simplecov/issues/281
18
18
  gem 'coveralls', require: false
19
- gem 'rubocop', '0.60.0', require: false
19
+ gem 'rubocop', '~> 1.9', require: false
20
20
  end
21
21
 
22
22
  # To use a debugger
@@ -37,11 +37,11 @@ if File.exist?(file)
37
37
  end
38
38
  else
39
39
  Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in #{file}, using placeholder dependencies"
40
- gem 'geoblacklight', '~> 2.0'
40
+ gem 'geoblacklight', '>= 2.0'
41
41
  gem 'mini_magick', '~> 4.9.4'
42
42
  gem 'image_processing', '~> 1.6'
43
- gem 'mimemagic', '~> 0.3'
44
- gem 'statesman', '~> 3.4'
45
- gem 'rails', '~> 5.2.0', '< 6'
43
+ gem 'statesman', '>= 3.4'
44
+ gem 'marcel', '>= 1.0'
45
+ gem 'rails', '>= 5.2.5', '< 6.2'
46
46
  end
47
47
  # END ENGINE_CART BLOCK
data/README.md CHANGED
@@ -3,10 +3,16 @@
3
3
  [![Build Status](https://travis-ci.org/geoblacklight/geoblacklight_sidecar_images.svg?branch=master)](https://travis-ci.org/geoblacklight/geoblacklight_sidecar_images)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/88c14165af5459963011/maintainability)](https://codeclimate.com/github/geoblacklight/geoblacklight_sidecar_images/maintainability)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/geoblacklight/geoblacklight_sidecar_images/badge.svg?branch=master)](https://coveralls.io/github/geoblacklight/geoblacklight_sidecar_images?branch=master)
6
- [![Gem Version](https://badge.fury.io/rb/geoblacklight_sidecar_images.svg)](https://badge.fury.io/rb/geoblacklight_sidecar_images)
6
+ [![rubygem](https://badgen.net/rubygems/v/geoblacklight_sidecar_images)](https://badgen.net/rubygems/v/geoblacklight_sidecar_images)
7
7
 
8
8
  Store local copies of remote imagery in GeoBlacklight.
9
9
 
10
+ * [Requirements](#requirements)
11
+ * [Installation](#installation)
12
+ * [Rake Tasks](#rake-tasks)
13
+ * [View Customization](#view-customization)
14
+ * [Development](#development)
15
+
10
16
  ## Description
11
17
  This GeoBlacklight plugin captures remote images from geographic web services and saves them locally. It borrows the concept of a [SolrDocumentSidecar](https://github.com/projectblacklight/spotlight/blob/master/app/models/spotlight/solr_document_sidecar.rb) from [Spotlight](https://github.com/projectblacklight/spotlight), to have an ActiveRecord-based "sidecar" to match each non-AR SolrDocument. This allows us to use [ActiveStorage](https://github.com/rails/rails/tree/master/activestorage) to attach images to our solr documents.
12
18
 
@@ -15,11 +21,11 @@ This GeoBlacklight plugin captures remote images from geographic web services an
15
21
 
16
22
  ## Requirements
17
23
 
18
- * [Ruby on Rails 5.2](https://weblog.rubyonrails.org/releases/)
19
- * [GeoBlacklight](https://github.com/geoblacklight/geoblacklight)
24
+ * [Ruby on Rails >= 5.2.5](https://weblog.rubyonrails.org/releases/)
25
+ * [GeoBlacklight >= 3.3](https://github.com/geoblacklight/geoblacklight)
20
26
  * [ImageMagick](https://github.com/ImageMagick/ImageMagick)
21
27
 
22
- ## Suggested
28
+ ### Suggested
23
29
 
24
30
  * Background Job Processor
25
31
 
@@ -47,6 +53,23 @@ Run the database migration.
47
53
  $ bin/rails db:migrate
48
54
  ```
49
55
 
56
+ Complete any necessary [Active Storage setup](https://edgeguides.rubyonrails.org/active_storage_overview.html#setup) steps, for example:
57
+
58
+ 1. Add a config/storage.yml file
59
+
60
+ ```
61
+ local:
62
+ service: Disk
63
+ root: <%= Rails.root.join("storage") %>
64
+ ```
65
+
66
+ 2. Add config/environments declarations, development.rb for example:
67
+
68
+ ```
69
+ # Store uploaded files on the local file system (see config/storage.yml for options)
70
+ config.active_storage.service = :local
71
+ ```
72
+
50
73
  ### New GeoBlacklight Instance
51
74
 
52
75
  Create a new GeoBlacklight instance with the GBLSI code
@@ -182,7 +205,9 @@ Then you can edit your GeoBlacklight settings.yml file to point at that solr fie
182
205
 
183
206
  ## View customization
184
207
 
185
- This GBL plugin includes a custom catalog/_index_split_default.html.erb file. Look there for examples on calling the image method.
208
+ Use basic Active Storage patterns to display imagery in your application.
209
+
210
+ ### Example Methods
186
211
 
187
212
  ```ruby
188
213
  # Is there an image?
@@ -196,7 +221,30 @@ document.sidecar.image.variable?
196
221
 
197
222
  ```
198
223
 
199
- You'll definitely want to update this file to fit your own design's needs.
224
+ ### Search results
225
+
226
+ This GBL plugin includes a custom [catalog/_index_split_default.html.erb file](https://github.com/geoblacklight/geoblacklight_sidecar_images/blob/develop/lib/generators/geoblacklight_sidecar_images/templates/views/catalog/_index_split_default.html.erb). Look there for examples on calling the image method.
227
+
228
+ ### Show pages
229
+
230
+ Example for adding a thumbnail to the show page sidebar.
231
+
232
+ *catalog/_show_sidebar.html.erb*
233
+
234
+ ```ruby
235
+ # Add to end of file
236
+ <% if @document.sidecar.image.attached? %>
237
+ <% if @document.sidecar.image.variable? %>
238
+ <div class="card">
239
+ <div class="card-header">Thumbnail</div>
240
+ <div class="card-body">
241
+ <%= image_tag @document.sidecar.image.variant(resize: "200"), {class: 'mr-3'} %>
242
+ </div>
243
+ </div>
244
+ <% end %>
245
+ <% end %>
246
+
247
+ ```
200
248
 
201
249
  ## Development
202
250
 
@@ -229,5 +277,7 @@ tail -f log/image_service_development.log
229
277
  * ~~0.2.0 - Forgo attaching placeholder imagery~~
230
278
  * ~~0.3.0 - Add Statesman (state machine library)~~
231
279
  * ~~0.4.0 - Rails 5.2 branch / Switch to ActionStorage~~
232
- * 0.5.0 to 0.9.0 - Feedback; Improve test coverage; Collect additional real-world issues
233
- * 1.0.0 - Final 5.2 release
280
+ * ~~0.7.0 - Rails 5.2+ and 6+ / GeoBlacklight 2+ and 3+ support~~
281
+ * ~~0.8.0 - GeoBlacklight Aardvark support~~
282
+ * 0.7.0 to 0.9.0 - Feedback; Improve test coverage; Collect additional real-world issues
283
+ * 1.0.0 - Final release
data/Rakefile CHANGED
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rails'
3
4
  begin
4
5
  require 'bundler/setup'
6
+ require 'bundler/gem_tasks'
5
7
  rescue LoadError
6
8
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
9
  end
@@ -16,17 +18,14 @@ RSpec::Core::RakeTask.new(:spec)
16
18
  require 'rubocop/rake_task'
17
19
  RuboCop::RakeTask.new(:rubocop)
18
20
 
21
+ require 'solr_wrapper/rake_task'
19
22
  require 'engine_cart/rake_task'
20
23
  require 'geoblacklight_sidecar_images/version'
21
24
 
22
25
  task ci: ['engine_cart:generate'] do
23
26
  ENV['environment'] = 'test'
24
-
25
- SolrWrapper.wrap(port: '8983') do |solr|
27
+ SolrWrapper.wrap do |solr|
26
28
  solr.with_collection(name: 'blacklight-core', dir: File.join(__dir__, 'solr', 'conf')) do
27
- # Fixtures here
28
- # Rake::Task['spotlight:fixtures'].invoke
29
-
30
29
  # run the tests
31
30
  Rake::Task['spec'].invoke
32
31
  end
@@ -17,6 +17,6 @@ module WmsRewriteConcern
17
17
  end
18
18
 
19
19
  def local?
20
- fetch(:dct_provenance_s, '').casecmp(Settings.INSTITUTION_LOCAL_NAME).zero?
20
+ fetch(Settings.FIELDS.PROVENANCE, '').casecmp(Settings.INSTITUTION_LOCAL_NAME).zero?
21
21
  end
22
22
  end
@@ -3,7 +3,10 @@
3
3
  ##
4
4
  # Metadata for indexed documents
5
5
  class SolrDocumentSidecar < ApplicationRecord
6
- include Statesman::Adapters::ActiveRecordQueries
6
+ include Statesman::Adapters::ActiveRecordQueries[
7
+ transition_class: SidecarImageTransition,
8
+ initial_state: :initialized
9
+ ]
7
10
 
8
11
  belongs_to :document, optional: false, polymorphic: true
9
12
  has_many :sidecar_image_transitions, autosave: false, dependent: :destroy
@@ -41,8 +41,8 @@ module GeoblacklightSidecarImages
41
41
  end
42
42
 
43
43
  log_output
44
- rescue Exception => invalid
45
- @metadata['exception'] = invalid.inspect
44
+ rescue Exception => e
45
+ @metadata['exception'] = e.inspect
46
46
  @document.sidecar.image_state.transition_to!(:failed, @metadata)
47
47
 
48
48
  log_output
@@ -53,7 +53,6 @@ module GeoblacklightSidecarImages
53
53
  def image_tempfile(document_id)
54
54
  @metadata['viewer_protocol'] = @document.viewer_protocol
55
55
  @metadata['image_url'] = image_url
56
- @metadata['service_url'] = service_url
57
56
  @metadata['gblsi_thumbnail_uri'] = gblsi_thumbnail_uri
58
57
 
59
58
  return nil unless image_data && @metadata['placeheld'] == false
@@ -151,17 +150,15 @@ module GeoblacklightSidecarImages
151
150
  # have not been set beyond the default, then a thumbnail url from
152
151
  # dct references is used instead.
153
152
  def image_url
154
- @image_url ||= begin
155
- if gblsi_thumbnail_uri
156
- gblsi_thumbnail_uri
157
- elsif restricted_scanned_map?
158
- image_reference
159
- elsif restricted_wms_layer? && !geoserver_credentials_valid?
160
- image_reference
161
- else
162
- service_url || image_reference
163
- end
164
- end
153
+ @image_url ||= if gblsi_thumbnail_uri
154
+ gblsi_thumbnail_uri
155
+ elsif restricted_scanned_map?
156
+ image_reference
157
+ elsif restricted_wms_layer? && !geoserver_credentials_valid?
158
+ image_reference
159
+ else
160
+ service_url || image_reference
161
+ end
165
162
  end
166
163
 
167
164
  # Checks if the document is Local restriced access and is a scanned map.
@@ -180,11 +177,8 @@ module GeoblacklightSidecarImages
180
177
  # from the viewer protocol, and if it's loaded, the image_url
181
178
  # method is called.
182
179
  def service_url
183
-
184
180
  # Follow image_url instead
185
- if gblsi_thumbnail_uri
186
- return nil
187
- end
181
+ return nil if gblsi_thumbnail_uri
188
182
 
189
183
  @service_url ||=
190
184
  begin
@@ -18,12 +18,12 @@ Gem::Specification.new do |s|
18
18
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  s.require_paths = ['lib']
20
20
 
21
- s.add_dependency 'geoblacklight', '~> 2.0'
21
+ s.add_dependency 'geoblacklight', '>= 3.3'
22
22
  s.add_dependency 'mini_magick', '~> 4.9.4'
23
23
  s.add_dependency 'image_processing', '~> 1.6'
24
- s.add_dependency 'statesman', '~> 3.4'
24
+ s.add_dependency 'statesman', '>= 3.4'
25
25
  s.add_dependency 'mimemagic', '~> 0.3'
26
- s.add_dependency 'rails', '>= 5.2', '< 6'
26
+ s.add_dependency 'rails', '>= 5.2', '< 6.2'
27
27
 
28
28
  s.add_development_dependency 'byebug'
29
29
  s.add_development_dependency 'capybara'
@@ -31,8 +31,10 @@ Gem::Specification.new do |s|
31
31
  s.add_development_dependency 'database_cleaner', '~> 1.3'
32
32
  s.add_development_dependency 'engine_cart', '~> 2.2'
33
33
  s.add_development_dependency 'rspec-rails', '~> 3.0'
34
- s.add_development_dependency 'rubocop', '~> 0.60.0'
34
+ s.add_development_dependency 'rubocop', '~> 1.9'
35
35
  s.add_development_dependency 'rubocop-rspec', '~> 1.30.0'
36
+ s.add_development_dependency 'rubocop-rails', '~> 2.9'
36
37
  s.add_development_dependency 'selenium-webdriver'
37
- s.add_development_dependency 'solr_wrapper'
38
+ s.add_development_dependency 'solr_wrapper', '~> 3.1'
39
+ s.add_development_dependency 'sprockets', '< 4'
38
40
  end
@@ -1,5 +1,5 @@
1
1
  <% # header bar for doc items in index view -%>
2
- <%= content_tag :div, class: 'documentHeader row', data: { layer_id: document.id, bbox: document.bounding_box_as_wsen } do %>
2
+ <%= content_tag :div, class: 'documentHeader row', data: { layer_id: document.id, geom: document.geometry.geojson } do %>
3
3
  <div class='status-icons'>
4
4
  <%= render partial: 'header_icons', locals: { document: document } %>
5
5
  </div>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GeoblacklightSidecarImages
4
- VERSION = '0.6.2'
4
+ VERSION = '0.8.1'
5
5
  end
@@ -20,7 +20,7 @@ namespace :gblsci do
20
20
  namespace :images do
21
21
  desc 'Harvest image for specific document'
22
22
  task :harvest_doc_id, [:doc_id] => [:environment] do |_t, args|
23
- StoreImageJob.perform_later(args[:doc_id])
23
+ GeoblacklightSidecarImages::StoreImageJob.perform_later(args[:doc_id])
24
24
  end
25
25
 
26
26
  desc 'Harvest all images'
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'rails_helper'
4
4
 
5
- describe GeoblacklightSidecarImages::SolrDocumentSidecar do
5
+ describe SolrDocumentSidecar do
6
6
  let(:document) { SolrDocument.new(document_attributes) }
7
7
 
8
8
  describe '#sidecar' do
@@ -35,8 +35,7 @@ describe GeoblacklightSidecarImages::ImageService do
35
35
  expect(wms_imgsvc.send(:image_url)).to include 'wms'
36
36
  end
37
37
 
38
- it 'returns image_url over service_url when settings thumbnail field' do
39
- expect(map_imgsvc.send(:image_url)).to include 'illinois'
38
+ it 'returns no service_url when settings thumbnail field' do
40
39
  expect(map_imgsvc.send(:service_url)).to be_falsey
41
40
  end
42
41
  end
@@ -11,7 +11,7 @@ class TestAppGenerator < Rails::Generators::Base
11
11
 
12
12
  def add_gems
13
13
  gem 'blacklight', '~> 7.0'
14
- gem 'geoblacklight', '~> 2.0'
14
+ gem 'geoblacklight', '>= 3.0'
15
15
 
16
16
  Bundler.with_clean_env do
17
17
  run 'bundle install'
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.6.2
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Larson
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-10-22 00:00:00.000000000 Z
12
+ date: 2021-04-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: geoblacklight
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '2.0'
20
+ version: '3.3'
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: '2.0'
27
+ version: '3.3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: mini_magick
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -57,14 +57,14 @@ dependencies:
57
57
  name: statesman
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '3.4'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '3.4'
70
70
  - !ruby/object:Gem::Dependency
@@ -90,7 +90,7 @@ dependencies:
90
90
  version: '5.2'
91
91
  - - "<"
92
92
  - !ruby/object:Gem::Version
93
- version: '6'
93
+ version: '6.2'
94
94
  type: :runtime
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
@@ -100,7 +100,7 @@ dependencies:
100
100
  version: '5.2'
101
101
  - - "<"
102
102
  - !ruby/object:Gem::Version
103
- version: '6'
103
+ version: '6.2'
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: byebug
106
106
  requirement: !ruby/object:Gem::Requirement
@@ -191,14 +191,14 @@ dependencies:
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: 0.60.0
194
+ version: '1.9'
195
195
  type: :development
196
196
  prerelease: false
197
197
  version_requirements: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 0.60.0
201
+ version: '1.9'
202
202
  - !ruby/object:Gem::Dependency
203
203
  name: rubocop-rspec
204
204
  requirement: !ruby/object:Gem::Requirement
@@ -213,6 +213,20 @@ dependencies:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
215
  version: 1.30.0
216
+ - !ruby/object:Gem::Dependency
217
+ name: rubocop-rails
218
+ requirement: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '2.9'
223
+ type: :development
224
+ prerelease: false
225
+ version_requirements: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '2.9'
216
230
  - !ruby/object:Gem::Dependency
217
231
  name: selenium-webdriver
218
232
  requirement: !ruby/object:Gem::Requirement
@@ -231,16 +245,30 @@ dependencies:
231
245
  name: solr_wrapper
232
246
  requirement: !ruby/object:Gem::Requirement
233
247
  requirements:
234
- - - ">="
248
+ - - "~>"
235
249
  - !ruby/object:Gem::Version
236
- version: '0'
250
+ version: '3.1'
237
251
  type: :development
238
252
  prerelease: false
239
253
  version_requirements: !ruby/object:Gem::Requirement
240
254
  requirements:
241
- - - ">="
255
+ - - "~>"
242
256
  - !ruby/object:Gem::Version
243
- version: '0'
257
+ version: '3.1'
258
+ - !ruby/object:Gem::Dependency
259
+ name: sprockets
260
+ requirement: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "<"
263
+ - !ruby/object:Gem::Version
264
+ version: '4'
265
+ type: :development
266
+ prerelease: false
267
+ version_requirements: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "<"
270
+ - !ruby/object:Gem::Version
271
+ version: '4'
244
272
  description:
245
273
  email:
246
274
  - ewlarson@umn.edu
@@ -252,6 +280,7 @@ files:
252
280
  - ".gitignore"
253
281
  - ".rspec"
254
282
  - ".rubocop.yml"
283
+ - ".solr_wrapper.yml"
255
284
  - ".travis.yml"
256
285
  - Gemfile
257
286
  - LICENSE
@@ -379,8 +408,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
379
408
  - !ruby/object:Gem::Version
380
409
  version: '0'
381
410
  requirements: []
382
- rubyforge_project:
383
- rubygems_version: 2.7.6
411
+ rubygems_version: 3.1.4
384
412
  signing_key:
385
413
  specification_version: 4
386
414
  summary: Store local copies of remote imagery in GeoBlacklight