blacklight_allmaps 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +38 -24
  3. data/Rakefile +2 -1
  4. data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.esm.js +26776 -0
  5. data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.esm.js.map +1 -0
  6. data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.js +26783 -0
  7. data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.js.map +1 -0
  8. data/app/assets/stylesheets/blacklight/allmaps/base.scss +9 -0
  9. data/app/javascript/blacklight/allmaps/index.js +11 -0
  10. data/app/javascript/blacklight/allmaps/initialize_blacklight_map.js +44 -0
  11. data/app/javascript/blacklight/allmaps/initialize_geoblacklight_map.js +53 -0
  12. data/app/javascript/blacklight/allmaps/leaflet_layer_opacity.js +69 -0
  13. data/app/views/allmaps/show/_blacklight.html.erb +1 -211
  14. data/app/views/allmaps/show/_geoblacklight.html.erb +1 -45
  15. data/app/views/catalog/_blacklight_allmaps.html.erb +5 -0
  16. data/app/views/catalog/_show_allmaps_tabbed_viewer_container.html.erb +53 -0
  17. data/db/migrate/{20240307155110_create_solr_document_sidecars.rb → 20240307155110_create_solr_document_sidecar_allmaps.rb} +1 -1
  18. data/lib/blacklight/allmaps/tasks/index.rake +53 -4
  19. data/lib/blacklight/allmaps/version.rb +10 -1
  20. data/lib/blacklight/allmaps.rb +1 -0
  21. data/lib/generators/blacklight/allmaps/config_generator.rb +67 -5
  22. metadata +20 -13
  23. data/app/assets/stylesheets/blacklight_allmaps/application.css +0 -15
  24. data/app/javascripts/map_controller.js +0 -39
  25. data/app/views/catalog/_show_default_viewer_container.html.erb +0 -52
  26. data/app/views/catalog/_show_main_content.html.erb +0 -58
@@ -16,31 +16,63 @@ module Blacklight
16
16
  copy_file "manifest.js", "app/assets/config/manifest.js", force: true
17
17
  end
18
18
 
19
+ def add_assets_initialier
20
+ append_to_file "config/initializers/assets.rb" do
21
+ "
22
+ # Blacklight Allmaps
23
+ Rails.application.config.assets.paths << Rails.root.join('vendor', 'assets', 'images')
24
+ Rails.application.config.assets.precompile += %w( blacklight/allmaps/allmaps-logo.svg )"
25
+ end
26
+ end
27
+
19
28
  def copy_rake_tasks
20
29
  append_to_file "Rakefile", "require 'blacklight/allmaps/rake_task'\n"
21
30
  end
22
31
 
23
32
  def prioritize_blacklight_allmaps_views
24
- inject_into_file "config/application.rb", "\nrequire \"blacklight/allmaps/engine\"\n", after: "require \"action_cable/engine\""
25
- inject_into_file "config/application.rb", "\nconfig.railties_order = [Blacklight::Allmaps::Engine, :main_app, :all]\n", after: "class Application < Rails::Application\n"
33
+ inject_into_file "config/application.rb", "\nrequire \"blacklight/allmaps/engine\"\n", before: "# Require the gems listed in Gemfile"
34
+ inject_into_file "config/application.rb", "\n config.railties_order = [Blacklight::Allmaps::Engine, :main_app, :all]\n", after: "class Application < Rails::Application\n"
26
35
  end
27
36
 
28
37
  def add_importmap_pins
29
38
  append_to_file "config/importmap.rb" do
30
39
  <<~CONTENT
31
- pin "leaflet" # @1.9.4
32
- pin '@allmaps/leaflet', to: "@allmaps--leaflet.js"
40
+ pin "leaflet", to: "https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.js", preload: true
41
+ pin "leaflet-fullscreen", to: "https://cdn.jsdelivr.net/npm/leaflet-fullscreen@1.0.2/dist/Leaflet.fullscreen.min.js", preload: true
42
+ pin "@allmaps/leaflet", to: "https://cdn.jsdelivr.net/npm/@allmaps/leaflet/dist/bundled/allmaps-leaflet-1.9.umd.js", preload: true
33
43
  CONTENT
34
44
  end
35
45
  end
36
46
 
47
+ def add_javascript
48
+ inject_into_file "app/assets/javascripts/application.js", after: "//= require blacklight/blacklight" do
49
+ "\n
50
+ // Required by Blacklight::Allmaps
51
+ //= require blacklight/allmaps/blacklight-allmaps"
52
+ end
53
+ end
54
+
55
+ def add_bl_stylesheets
56
+ return unless ENV["LIGHT"] == "blacklight"
57
+ append_to_file "app/assets/stylesheets/blacklight.scss" do
58
+ "@import 'blacklight/allmaps/base';"
59
+ end
60
+ end
61
+
62
+ def add_gbl_stylesheets
63
+ return unless ENV["LIGHT"] == "geoblacklight"
64
+ append_to_file "app/assets/stylesheets/application.scss" do
65
+ "@import 'blacklight/allmaps/base';"
66
+ end
67
+ end
68
+
37
69
  def set_active_job_config
38
70
  inject_into_file "config/environments/development.rb", " config.active_job.queue_adapter = :inline\n", after: "Rails.application.configure do\n"
39
71
  end
40
72
 
41
73
  def add_geoblacklight
42
74
  return unless ENV["LIGHT"] == "geoblacklight"
43
- append_to_file "Gemfile", '"geoblacklight", "4.1"'
75
+ append_to_file "Gemfile", '"geoblacklight", "~> 4.4"'
44
76
  end
45
77
 
46
78
  def include_blacklight_allmaps_solrdocument
@@ -49,6 +81,36 @@ module Blacklight
49
81
  "\n include Blacklight::Allmaps::SolrDocument"
50
82
  end
51
83
  end
84
+
85
+ def add_gbl_tabbed_viewer
86
+ return unless ENV["LIGHT"] == "geoblacklight"
87
+ # Use the tabbed viewer
88
+ inject_into_file "app/controllers/catalog_controller.rb", after: "config.show.partials << \"show_default_viewer_container\"" do
89
+ "\n
90
+ # Blacklight::Allmaps Tabbed Viewer
91
+ config.show.partials << \"show_allmaps_tabbed_viewer_container\""
92
+ end
93
+
94
+ # Remove the default viewer
95
+ gsub_file("app/controllers/catalog_controller.rb", "config.show.partials << \"show_default_viewer_container\"", "#config.show.partials << \"show_default_viewer_container\"")
96
+ end
97
+
98
+ def add_bl_allmaps_viewer
99
+ return unless ENV["LIGHT"] == "blacklight"
100
+ # Use the allmaps viewer
101
+ inject_into_file "app/controllers/catalog_controller.rb", after: "#config.show.thumbnail_field = 'thumbnail_path_ss'" do
102
+ "\n
103
+ # Blacklight::Allmaps Viewer
104
+ config.show.partials.insert(1, :blacklight_allmaps)"
105
+ end
106
+ end
107
+
108
+ def add_bl_georeferenced_facet
109
+ return unless ENV["LIGHT"] == "blacklight"
110
+ inject_into_file "app/controllers/catalog_controller.rb", after: "config.add_facet_field 'subject_era_ssim', label: 'Era'" do
111
+ "\n config.add_facet_field 'bl_georeferenced_bsi', label: 'Allmaps Georeferenced'"
112
+ end
113
+ end
52
114
  end
53
115
  end
54
116
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight_allmaps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Larson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-27 00:00:00.000000000 Z
11
+ date: 2024-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blacklight
@@ -34,16 +34,16 @@ dependencies:
34
34
  name: httparty
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0'
39
+ version: '0.20'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
46
+ version: '0.20'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: solr_wrapper
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -156,7 +156,7 @@ dependencies:
156
156
  - - ">="
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
- description: Description of BlacklightAllmaps
159
+ description: Description of Blacklight::Allmaps
160
160
  email:
161
161
  - ewlarson@gmail.com
162
162
  executables: []
@@ -171,10 +171,17 @@ files:
171
171
  - app/assets/images/blacklight/allmaps/blacklight-logo.png
172
172
  - app/assets/images/blacklight/allmaps/geoblacklight-logo.png
173
173
  - app/assets/images/blacklight/allmaps/logo.svg
174
- - app/assets/stylesheets/blacklight_allmaps/application.css
174
+ - app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.esm.js
175
+ - app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.esm.js.map
176
+ - app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.js
177
+ - app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.js.map
178
+ - app/assets/stylesheets/blacklight/allmaps/base.scss
175
179
  - app/controllers/blacklight/allmaps/application_controller.rb
176
180
  - app/helpers/blacklight/allmaps/application_helper.rb
177
- - app/javascripts/map_controller.js
181
+ - app/javascript/blacklight/allmaps/index.js
182
+ - app/javascript/blacklight/allmaps/initialize_blacklight_map.js
183
+ - app/javascript/blacklight/allmaps/initialize_geoblacklight_map.js
184
+ - app/javascript/blacklight/allmaps/leaflet_layer_opacity.js
178
185
  - app/jobs/blacklight/allmaps/application_job.rb
179
186
  - app/jobs/blacklight/allmaps/store_sidecar_annotation.rb
180
187
  - app/mailers/blacklight/allmaps/application_mailer.rb
@@ -184,13 +191,13 @@ files:
184
191
  - app/views/allmaps/show/_blacklight.html.erb
185
192
  - app/views/allmaps/show/_geoblacklight.html.erb
186
193
  - app/views/allmaps/sidebar/_allmaps.html.erb
187
- - app/views/catalog/_show_default_viewer_container.html.erb
188
- - app/views/catalog/_show_main_content.html.erb
194
+ - app/views/catalog/_blacklight_allmaps.html.erb
195
+ - app/views/catalog/_show_allmaps_tabbed_viewer_container.html.erb
189
196
  - app/views/catalog/_show_sidebar.html.erb
190
197
  - app/views/catalog/_show_sidebar_blacklight.html.erb
191
198
  - app/views/catalog/_show_sidebar_geoblacklight.html.erb
192
199
  - config/routes.rb
193
- - db/migrate/20240307155110_create_solr_document_sidecars.rb
200
+ - db/migrate/20240307155110_create_solr_document_sidecar_allmaps.rb
194
201
  - lib/blacklight/allmaps.rb
195
202
  - lib/blacklight/allmaps/engine.rb
196
203
  - lib/blacklight/allmaps/rake_task.rb
@@ -225,5 +232,5 @@ requirements: []
225
232
  rubygems_version: 3.4.21
226
233
  signing_key:
227
234
  specification_version: 4
228
- summary: Blacklight Allmaps plugin
235
+ summary: Blacklight::Allmaps plugin
229
236
  test_files: []
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,39 +0,0 @@
1
- // map_controller.js
2
- import { Controller } from "@hotwired/stimulus"
3
- import L from 'leaflet'
4
- import { WarpedMapLayer } from '@allmaps/leaflet'
5
-
6
- export default class extends Controller {
7
- static targets = [ "placeholder" ]
8
-
9
- connect(){
10
-
11
- console.log("Map Controller Connected");
12
- console.log(this.element);
13
-
14
- // Grok: Allmaps annotation for center and zoom level?
15
- this.map = L.map('allmaps-map', {
16
- center: [43.063518, -89.3906863],
17
- zoom: 10,
18
- zoomAnimationThreshold: 1
19
- })
20
-
21
- L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
22
- maxZoom: 18,
23
- attribution: '&copy; <a href=https://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors'
24
- }).addTo(this.map)
25
-
26
- const annotationUrl = 'https://annotations.allmaps.org/manifests/c2f9fc8490151424'
27
- const warpedMapLayer = new WarpedMapLayer(annotationUrl)
28
- .addTo(this.map)
29
-
30
- const bounds = warpedMapLayer.getBounds();
31
- this.map.fitBounds(bounds, {
32
- padding
33
- });
34
- }
35
-
36
- disconnect(){
37
- this.map.remove()
38
- }
39
- }
@@ -1,52 +0,0 @@
1
- <% document ||= @document %>
2
- <div class='row'>
3
- <div id='viewer-container' class="col-md-12">
4
-
5
- <span class="sr-only">Georeferenced: <%= document.sidecar_allmaps.georeferenced? %></span>
6
-
7
- <ul class="nav nav-tabs mt-3" id="myTab" role="tablist">
8
- <li class="nav-item" role="presentation">
9
- <button class="nav-link active" id="item-viewer" data-toggle="tab" data-target="#item-viewer-tab" type="button" role="tab" aria-controls="home" aria-selected="true">Item Viewer</button>
10
- </li>
11
- <% if document.sidecar_allmaps.georeferenced? %>
12
- <li class="nav-item" role="presentation">
13
- <button class="nav-link" id="georeferenced-viewer" data-toggle="tab" data-target="#georeferenced-tab" type="button" role="tab" aria-controls="profile" aria-selected="false">Georeferenced Map</button>
14
- </li>
15
- <% end %>
16
- </ul>
17
-
18
- <div class="tab-content mt-3">
19
- <div class="tab-pane fade show active" id="item-viewer-tab" role="tabpanel" aria-labelledby="item-viewer-tab">
20
- <% if show_help_text?('viewer_protocol', document.viewer_protocol) %>
21
- <%= render_help_text_entry('viewer_protocol', document.viewer_protocol) %>
22
- <% end %>
23
-
24
- <% if document.item_viewer.index_map %>
25
- <div class="index-map-legend">
26
- <div class="index-map-legend-info">
27
- <span class="index-map-legend-default"></span>
28
- <p><span class="sr-only">Green tile indicates </span>Map held by collection</p>
29
- </div>
30
- <div class="index-map-legend-info">
31
- <span class="index-map-legend-unavailable"></span>
32
- <p><span class="sr-only">Yellow tile indicates </span>Map not held by collection</p>
33
- </div>
34
- <div class="index-map-legend-info">
35
- <span class="index-map-legend-selected"></span>
36
- <p><span class="sr-only">Blue tile indicates </span>Selected map tile</p>
37
- </div>
38
- </div>
39
- <% end %>
40
-
41
- <%= content_tag :div, id: 'map', aria: { label: t('geoblacklight.map.label') }, data: { map: 'item', protocol: document.viewer_protocol.camelize, url: document.viewer_endpoint, 'layer-id' => document.wxs_identifier, 'map-geom' => document.geometry.geojson, 'catalog-path'=> search_catalog_path, available: document_available?, inspect: show_attribute_table?, basemap: geoblacklight_basemap, leaflet_options: leaflet_options } do %>
42
- <% end %>
43
- </div>
44
-
45
- <% if document.sidecar_allmaps.georeferenced? %>
46
- <div class="tab-pane fade" id="georeferenced-tab" role="tabpanel" aria-labelledby="georeferenced-tab">
47
- <%= render partial: 'allmaps/show/geoblacklight', locals: { document: document } %>
48
- </div>
49
- <% end %>
50
- </div>
51
- </div>
52
- </div>
@@ -1,58 +0,0 @@
1
- <% if Blacklight::VERSION.to_i > 8 %>
2
- <%= render blacklight_config.track_search_session.item_pagination_component.new(search_context: @search_context, search_session: search_session, current_document: @document) if blacklight_config.track_search_session.item_pagination_component %>
3
- <% @page_title = t('blacklight.search.show.title', document_title: document_presenter(@document).html_title, application_name: application_name).html_safe %>
4
- <% content_for(:head) { render_link_rel_alternates } %>
5
-
6
- <% document_component = blacklight_config.view_config(:show).document_component -%>
7
- <%= render (document_component).new(document_component.collection_parameter => document_presenter(@document), component: :div, show: true, partials: blacklight_config.view_config(:show).partials) do |component| %>
8
- <% component.with_title(as: 'h1', classes: '', link_to_document: false, actions: false) %>
9
- <% component.with_footer do %>
10
-
11
- <% unless defined?(Geoblacklight) %>
12
- <% if @document.sidecar_allmaps.georeferenced? %>
13
- <%= render partial: 'allmaps/show/blacklight', locals: { document: @document } %>
14
- <% end %>
15
- <% end %>
16
-
17
- <% if @document.respond_to?(:export_as_openurl_ctx_kev) %>
18
- <!-- COinS, for Zotero among others. -->
19
- <span class="Z3988" title="<%= @document.export_as_openurl_ctx_kev(document_presenter(@document).display_type) %>"></span>
20
- <% end %>
21
- <% end %>
22
- <% end %>
23
-
24
- <% else %>
25
- <%= render(Blacklight::SearchContextComponent.new(search_context: @search_context, search_session: search_session)) if search_session['document_id'] == @document.id %>
26
-
27
- <% @page_title = t('blacklight.search.show.title', document_title: Deprecation.silence(Blacklight::BlacklightHelperBehavior) { document_show_html_title }, application_name: application_name).html_safe %>
28
- <% content_for(:head) { render_link_rel_alternates } %>
29
-
30
- <%= render (blacklight_config.view_config(:show).document_component || Blacklight::DocumentComponent).new(presenter: document_presenter(@document), component: :div, title_component: :h1, show: true) do |component| %>
31
- <% component.with_footer do %>
32
-
33
- <% unless defined?(Geoblacklight) %>
34
- <% if @document.sidecar_allmaps.georeferenced? %>
35
- <%= render partial: 'allmaps/show/blacklight', locals: { document: @document } %>
36
- <% end %>
37
- <% end %>
38
-
39
- <% if @document.respond_to?(:export_as_openurl_ctx_kev) %>
40
- <!--
41
- // COinS, for Zotero among others.
42
- // This document_partial_name(@document) business is not quite right,
43
- // but has been there for a while.
44
- -->
45
- <span class="Z3988" title="<%= @document.export_as_openurl_ctx_kev(Deprecation.silence(Blacklight::RenderPartialsHelperBehavior) { document_partial_name(@document) }) %>"></span>
46
- <% end %>
47
- <% end %>
48
-
49
- <%# Use :body for complete backwards compatibility (overriding the component body markup),
50
- but if the app explicitly opted-in to components, make the partials data available as :partials to ease migrations pain %>
51
- <% component.public_send(blacklight_config.view_config(:show).document_component.blank? && blacklight_config.view_config(:show).partials.any? ? :with_body : :with_partial) do %>
52
- <div id="doc_<%= @document.id.to_s.parameterize %>">
53
- <%= render_document_partials @document, blacklight_config.view_config(:show).partials, component: component %>
54
- </div>
55
- <% end %>
56
- <% end %>
57
- <% end %>
58
-