blacklight_allmaps 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +107 -0
  3. data/.gitignore +20 -0
  4. data/.standard.yml +1 -0
  5. data/Gemfile +50 -0
  6. data/README.md +47 -6
  7. data/Rakefile +4 -0
  8. data/app/assets/images/blacklight_allmaps/.keep +0 -0
  9. data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.esm.js +41 -0
  10. data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.esm.js.map +1 -1
  11. data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.js +41 -0
  12. data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.js.map +1 -1
  13. data/app/assets/stylesheets/blacklight/allmaps/base.scss +4 -1
  14. data/app/assets/stylesheets/blacklight/allmaps/modules/leaflet.opacity.css +76 -0
  15. data/app/controllers/allmaps/annotations_controller.rb +65 -0
  16. data/app/helpers/blacklight/allmaps/application_helper.rb +1 -1
  17. data/app/javascript/blacklight/allmaps/index.js +6 -0
  18. data/app/javascript/blacklight/allmaps/update_georef_links.js +36 -0
  19. data/app/jobs/blacklight/allmaps/store_sidecar_annotation.rb +7 -1
  20. data/app/models/concerns/.keep +0 -0
  21. data/app/models/concerns/blacklight/allmaps/solr_document.rb +1 -2
  22. data/app/views/allmaps/show/_blacklight.html.erb +1 -1
  23. data/app/views/allmaps/show/_geoblacklight.html.erb +1 -1
  24. data/app/views/allmaps/sidebar/_allmaps.html.erb +4 -32
  25. data/app/views/annotations/_annotation.json.jbuilder +1 -0
  26. data/app/views/annotations/_pagination.json.jbuilder +9 -0
  27. data/app/views/annotations/index.json.jbuilder +4 -0
  28. data/app/views/annotations/show.json.jbuilder +1 -0
  29. data/app/views/catalog/_show_allmaps_tabbed_viewer_container.html.erb +3 -3
  30. data/blacklight_allmaps.gemspec +34 -0
  31. data/config/locales/allmaps.en.yml +11 -0
  32. data/config/routes.rb +7 -0
  33. data/doc/Proposal_Eric_Larson_Ian_Spangler_4CE510.pdf +0 -0
  34. data/doc/allmaps_branding_screenshot.png +0 -0
  35. data/doc/allmaps_screenshot.png +0 -0
  36. data/doc/allmaps_screenshot_window.png +0 -0
  37. data/doc/development.md +72 -0
  38. data/doc/gbl_screenshot.png +0 -0
  39. data/doc/gbl_screenshot_window.png +0 -0
  40. data/doc/georeferenced_facet.png +0 -0
  41. data/doc/screenshot_layers.acorn +0 -0
  42. data/doc/screenshot_layers.png +0 -0
  43. data/lib/blacklight/allmaps/tasks/index.rake +7 -57
  44. data/lib/blacklight/allmaps/tasks/sidecars.rake +9 -0
  45. data/lib/blacklight/allmaps/version.rb +1 -1
  46. data/lib/blacklight/allmaps.rb +10 -2
  47. data/lib/generators/blacklight/allmaps/blacklight_generator.rb +54 -0
  48. data/lib/generators/blacklight/allmaps/config_generator.rb +7 -53
  49. data/lib/generators/blacklight/allmaps/geoblacklight_generator.rb +59 -0
  50. data/lib/generators/blacklight/allmaps/install_generator.rb +10 -0
  51. data/lib/generators/blacklight/allmaps/templates/package.json +6 -0
  52. data/package.json +43 -0
  53. data/rollup.config.js +43 -0
  54. data/solr/blacklight/conf/_rest_managed.json +3 -0
  55. data/solr/blacklight/conf/admin-extra.html +31 -0
  56. data/solr/blacklight/conf/elevate.xml +36 -0
  57. data/solr/blacklight/conf/mapping-ISOLatin1Accent.txt +246 -0
  58. data/solr/blacklight/conf/protwords.txt +21 -0
  59. data/solr/blacklight/conf/schema.xml +388 -0
  60. data/solr/blacklight/conf/scripts.conf +24 -0
  61. data/solr/blacklight/conf/solrconfig.xml +265 -0
  62. data/solr/blacklight/conf/spellings.txt +2 -0
  63. data/solr/blacklight/conf/stopwords.txt +58 -0
  64. data/solr/blacklight/conf/stopwords_en.txt +58 -0
  65. data/solr/blacklight/conf/synonyms.txt +31 -0
  66. data/solr/blacklight/conf/xslt/example.xsl +132 -0
  67. data/solr/blacklight/conf/xslt/example_atom.xsl +67 -0
  68. data/solr/blacklight/conf/xslt/example_rss.xsl +66 -0
  69. data/solr/blacklight/conf/xslt/luke.xsl +337 -0
  70. data/solr/geoblacklight/conf/_rest_managed.json +3 -0
  71. data/solr/geoblacklight/conf/admin-extra.html +31 -0
  72. data/solr/geoblacklight/conf/core.properties +5 -0
  73. data/solr/geoblacklight/conf/elevate.xml +36 -0
  74. data/solr/geoblacklight/conf/mapping-ISOLatin1Accent.txt +246 -0
  75. data/solr/geoblacklight/conf/protwords.txt +21 -0
  76. data/solr/geoblacklight/conf/schema.xml +198 -0
  77. data/solr/geoblacklight/conf/scripts.conf +24 -0
  78. data/solr/geoblacklight/conf/solrconfig.xml +243 -0
  79. data/solr/geoblacklight/conf/spellings.txt +2 -0
  80. data/solr/geoblacklight/conf/stopwords.txt +58 -0
  81. data/solr/geoblacklight/conf/stopwords_en.txt +58 -0
  82. data/solr/geoblacklight/conf/synonyms.txt +31 -0
  83. data/solr/geoblacklight/conf/xslt/example.xsl +132 -0
  84. data/solr/geoblacklight/conf/xslt/example_atom.xsl +67 -0
  85. data/solr/geoblacklight/conf/xslt/example_rss.xsl +66 -0
  86. data/solr/geoblacklight/conf/xslt/luke.xsl +337 -0
  87. data/spec/controllers/annotations_controller_spec.rb +74 -0
  88. data/spec/factories/annotations.rb +12 -0
  89. data/spec/features/show_page_spec.rb +35 -0
  90. data/spec/features/sidebar_spec.rb +28 -0
  91. data/spec/fixtures/blacklight_allmaps_sidecars.yml +1203 -0
  92. data/spec/fixtures/solr_documents/README.md +15 -0
  93. data/spec/fixtures/solr_documents/blacklight/README.md +9 -0
  94. data/spec/fixtures/solr_documents/blacklight/bl_georeferenced.json +40 -0
  95. data/spec/fixtures/solr_documents/geoblacklight/gbl_btaa_northwestern_georeferenced.json +57 -0
  96. data/spec/fixtures/solr_documents/geoblacklight/gbl_harvard-g4124-m2-1855-m3_georefereneced.json +68 -0
  97. data/spec/fixtures/solr_documents/geoblacklight/gbl_not_georeferenced.json +67 -0
  98. data/spec/fixtures/solr_documents/geoblacklight/gbl_osu-0r967h708_georeferenced.json +60 -0
  99. data/spec/fixtures/solr_documents/geoblacklight/gbl_p16022coll230:1933_georeferenced.json +60 -0
  100. data/spec/fixtures/solr_documents/geoblacklight/gbl_p16022coll230:360_georeferenced.json +67 -0
  101. data/spec/fixtures/solr_documents/geoblacklight/gbl_p16022coll230:4038_georeferenced.json +53 -0
  102. data/spec/helpers/blacklight/allmaps/application_helper_spec.rb +28 -0
  103. data/spec/models/blacklight/allmaps/sidecar_allmaps_spec.rb +22 -0
  104. data/spec/spec_helper.rb +53 -0
  105. data/spec/test_app_templates/Gemfile.extra +2 -0
  106. data/spec/test_app_templates/lib/generators/test_app_generator.rb +48 -0
  107. data/vendor/assets/images/fullscreen.png +0 -0
  108. data/vendor/assets/images/fullscreen@2x.png +0 -0
  109. data/vendor/assets/images/layers-2x.png +0 -0
  110. data/vendor/assets/images/layers.png +0 -0
  111. data/vendor/assets/images/marker-icon-2x.png +0 -0
  112. data/vendor/assets/images/marker-icon.png +0 -0
  113. data/vendor/assets/images/marker-shadow.png +0 -0
  114. data/vendor/assets/stylesheets/leaflet.css +640 -0
  115. data/vendor/assets/stylesheets/leaflet.fullscreen.css +40 -0
  116. metadata +109 -7
  117. data/app/controllers/blacklight/allmaps/application_controller.rb +0 -6
  118. data/app/jobs/blacklight/allmaps/application_job.rb +0 -6
  119. data/app/mailers/blacklight/allmaps/application_mailer.rb +0 -8
  120. data/app/models/blacklight/allmaps/application_record.rb +0 -7
@@ -1,9 +1,12 @@
1
1
  @charset "UTF-8";
2
2
 
3
3
  // Blacklight::Allmaps
4
+ // Via NPM
4
5
  @import "leaflet";
5
6
  @import "leaflet.fullscreen";
6
- @import "leaflet.opacity";
7
+
8
+ // Via
9
+ @import "modules/leaflet.opacity";
7
10
 
8
11
  #blacklight-allmaps-map { height: 400px; }
9
12
  #geoblacklight-allmaps-map { height: 400px; }
@@ -0,0 +1,76 @@
1
+ .leaflet-control.opacity-control {
2
+ background-color: #a9acb1;
3
+ border-radius: 15px;
4
+ color: black;
5
+ font: bold 18px 'Lucida Console', Monaco, monospace;
6
+ display: block;
7
+ height: 200px;
8
+ left: 11px;
9
+ position: relative;
10
+ top: 15px;
11
+ width: 5px;
12
+ }
13
+ .leaflet-control.opacity-control .opacity-handle {
14
+ background-color: #fff;
15
+ border-radius: 4px;
16
+ border: 1px solid #eee;
17
+ cursor: ns-resize;
18
+ font-size: 10px;
19
+ height: 26px;
20
+ left: -11px;
21
+ line-height: 26px;
22
+ position: absolute;
23
+ text-align: center;
24
+ top: 0;
25
+ width: 26px;
26
+ }
27
+ .leaflet-control.opacity-control .opacity-handle:hover {
28
+ background-color: #f4f4f4;
29
+ }
30
+ .leaflet-control.opacity-control .opacity-arrow-up {
31
+ color: #aaa;
32
+ position: absolute;
33
+ top: -11px;
34
+ text-align: center;
35
+ width: 100%;
36
+ }
37
+ .leaflet-control.opacity-control .opacity-arrow-up:before {
38
+ content: '=';
39
+ }
40
+ .leaflet-control.opacity-control .opacity-arrow-down {
41
+ bottom: -10px;
42
+ color: #aaa;
43
+ position: absolute;
44
+ text-align: center;
45
+ width: 100%;
46
+ }
47
+ .leaflet-control.opacity-control .opacity-arrow-down:before {
48
+ content: '=';
49
+ }
50
+ .leaflet-control.opacity-control .opacity-bottom {
51
+ background-color: #017afd;
52
+ border-radius: 15px;
53
+ display: block;
54
+ height: 137px;
55
+ left: 0px;
56
+ position: relative;
57
+ top: 63px;
58
+ width: 5px;
59
+ }
60
+ .leaflet-control.opacity-control .opacity-area {
61
+ padding: 14px;
62
+ cursor: default;
63
+ height: 200px;
64
+ left: -11px;
65
+ position: absolute;
66
+ top: 0px;
67
+ width: 20px;
68
+ }
69
+ .opacity-control.unselectable {
70
+ -webkit-touch-callout: none;
71
+ -webkit-user-select: none;
72
+ -khtml-user-select: none;
73
+ -moz-user-select: none;
74
+ -ms-user-select: none;
75
+ user-select: none;
76
+ }
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Allmaps
4
+ class AnnotationsController < ApplicationController
5
+ # JSON Only
6
+ respond_to :json
7
+
8
+ # Set @annotation before show and update
9
+ before_action :set_annotation, only: %i[show update]
10
+
11
+ # GET /allmaps/annotations.json
12
+ def index
13
+ @annotations = Blacklight::Allmaps::Sidecar.order(:id).page params[:page]
14
+
15
+ respond_to do |format|
16
+ format.all { render json: @annotations }
17
+ end
18
+ end
19
+
20
+ # GET /allmaps/annotations/1.json
21
+ def show
22
+ respond_to do |format|
23
+ format.all { render json: @annotation }
24
+ end
25
+ end
26
+
27
+ # PATCH/PUT /allmaps/annotations/1.json
28
+ def update
29
+ # Background Job to store the Allmaps Annotation
30
+ Blacklight::Allmaps::StoreSidecarAnnotation.perform_later(@annotation.solr_document_id)
31
+
32
+ respond_to do |format|
33
+ format.json { render json: @annotation, status: :ok }
34
+ end
35
+ end
36
+
37
+ # GET /annotations/fetch/1.json
38
+ def fetch
39
+ # Background Job to store the Allmaps Annotation — Perform Now
40
+
41
+ Blacklight::Allmaps::StoreSidecarAnnotation.perform_now(params[:id])
42
+ set_annotation
43
+
44
+ respond_to do |format|
45
+ format.all { render json: @annotation }
46
+ end
47
+ rescue Blacklight::Exceptions::RecordNotFound
48
+ render json: {error: "Record not found"}, status: :not_found
49
+ end
50
+
51
+ private
52
+
53
+ # Find the annotation or throw a 404
54
+ def set_annotation
55
+ @annotation = Blacklight::Allmaps::Sidecar.where(solr_document_id: params[:id]).first!
56
+ rescue ActiveRecord::RecordNotFound
57
+ render json: {error: "Record not found"}, status: :not_found
58
+ end
59
+
60
+ # Only allow a list of trusted parameters through.
61
+ def annotation_params
62
+ params.require(:Blacklight::Allmaps::Sidecar).permit(:id, :solr_document_id)
63
+ end
64
+ end
65
+ end
@@ -10,7 +10,7 @@ module Blacklight
10
10
  document.iiif_manifest_url ? true : false
11
11
  rescue
12
12
  # Blacklight
13
- document["iiif_manifest_url_ssi"] ? true : false
13
+ document[CatalogController.blacklight_config.default_iiif_manifest_field] ? true : false
14
14
  end
15
15
  end
16
16
  end
@@ -9,3 +9,9 @@ initializeGeoBlacklightMap();
9
9
 
10
10
  import { initializeBlacklightMap } from "./initialize_blacklight_map";
11
11
  initializeBlacklightMap();
12
+
13
+ import { updateGeorefLinks } from './update_georef_links.js';
14
+
15
+ document.addEventListener('DOMContentLoaded', () => {
16
+ updateGeorefLinks();
17
+ });
@@ -0,0 +1,36 @@
1
+ // update_georef_links.js
2
+ export const updateGeorefLinks = async () => {
3
+ const sidebarElement = document.getElementById('allmaps-sidebar');
4
+ if (sidebarElement) {
5
+ const manifestUrl = sidebarElement.getAttribute('data-iiif-manifest');
6
+ const documentId = sidebarElement.getAttribute('data-document-id');
7
+ const georefDiv = document.getElementById('georeferencing');
8
+ const annotationUrlByIIIFUri = `https://annotations.allmaps.org/?url=${manifestUrl}`;
9
+
10
+ try {
11
+ const response = await fetch(annotationUrlByIIIFUri);
12
+ if (!response.ok) {
13
+ georefDiv.innerHTML = `<a href="https://editor.allmaps.org/#/collection?url=${manifestUrl}" target="_blank">Georeference this item</a>`;
14
+
15
+ const csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content");
16
+ fetch(`/allmaps/annotations/${documentId}`, {
17
+ method: "PUT",
18
+ headers: {
19
+ "X-CSRF-Token": csrfToken,
20
+ "Content-Type": "application/json",
21
+ "Accept": "application/json"
22
+ }
23
+ })
24
+ .then(response => response.json())
25
+ .then(data => console.log(data))
26
+ .catch(error => console.error(error));
27
+
28
+ } else {
29
+ const annotationUrl = response.url;
30
+ georefDiv.innerHTML = `<a href="https://viewer.allmaps.org/?url=${annotationUrl}" target="_blank">View this georeferenced item</a>`;
31
+ }
32
+ } catch (error) {
33
+ console.error("Fetch error:", error);
34
+ }
35
+ }
36
+ };
@@ -10,12 +10,18 @@ module Blacklight
10
10
  sidecar = solr_document.sidecar_allmaps
11
11
 
12
12
  if ApplicationController.helpers.georeferenceable?(solr_document)
13
+ # Sleep for a random amount of time to crawl politely
14
+ sleep(rand(1..5))
15
+
13
16
  # Store the IIIF Manifest
14
17
  response = HTTParty.get(solr_document.iiif_manifest_url, follow_redirects: true)
15
18
  if response.code == 200
16
19
  # @TODO: validate the response body is a valid IIIF Manifest
17
20
  sidecar.iiif_manifest = response.body
18
- sidecar.manifest_id = JSON.parse(sidecar.iiif_manifest)["@id"]
21
+
22
+ # Store the Manifest ID
23
+ # - Could be either "@id" or "id"
24
+ sidecar.manifest_id = JSON.parse(sidecar.iiif_manifest)["@id"] || JSON.parse(sidecar.iiif_manifest)["id"]
19
25
  end
20
26
 
21
27
  # Store the Allmaps Annotation
File without changes
@@ -5,9 +5,8 @@ module Blacklight
5
5
  module Allmaps
6
6
  module SolrDocument
7
7
  # Blacklight
8
- # @TODO: Make this configurable
9
8
  def iiif_manifest_url
10
- self["iiif_manifest_url_ssi"]
9
+ self[CatalogController.blacklight_config.default_iiif_manifest_field]
11
10
  end
12
11
  end
13
12
  end
@@ -1,3 +1,3 @@
1
1
  <!-- Georeferenced Map -->
2
- <h3 class="h6">Georeferenced Map</h3>
2
+ <h3 class="h6"><%= t('allmaps.map_heading') %></h3>
3
3
  <div id="blacklight-allmaps-map" data-allmaps-id="<%= document.sidecar_allmaps.allmaps_id %>" class="mt-3 mb-3"></div>
@@ -1,3 +1,3 @@
1
1
  <!-- Georeferenced Map -->
2
- <h3 class="h6">Georeferenced Map</h3>
2
+ <h3 class="h6"><%= t('allmaps.map_heading') %></h3>
3
3
  <div id="geoblacklight-allmaps-map" data-map-geom="<%= document.geometry.geojson %>" data-allmaps-id="<%= document.sidecar_allmaps.allmaps_id %>"></div>
@@ -1,4 +1,4 @@
1
- <div class="card mb-3 mt-3" id="allmaps-sidebar" data-iiif-manifest="<%=@document.iiif_manifest_url %>">
1
+ <div class="card mb-3 mt-3" id="allmaps-sidebar" data-document-id="<%= @document.id %>" data-iiif-manifest="<%= @document.iiif_manifest_url %>">
2
2
  <div class="card-header">
3
3
  <h2 class="mb-0 h6"><%= t('home.georeferencing') %></h2>
4
4
  </div>
@@ -6,12 +6,12 @@
6
6
  <div class="card-body" id="georeferencing">
7
7
  <% if @document.sidecar_allmaps.georeferenced? %>
8
8
  <div id="georef_present">
9
- <%= link_to 'View this georeferenced item', 'https://viewer.allmaps.org/?url=https://annotations.allmaps.org/?url=' + @document.iiif_manifest_url, target: '_blank' %>
9
+ <%= link_to t('allmaps.georeferenced_link'), 'https://viewer.allmaps.org/?url=https://annotations.allmaps.org/?url=' + @document.iiif_manifest_url, target: '_blank' %>
10
10
  </div>
11
11
  <% else %>
12
12
  <%# content will be updated via updateGeorefLinks(); %>
13
13
  <div id="georef_loading">
14
- Loading...
14
+ <%= t('allmaps.loading') %>
15
15
  </div>
16
16
  <% end %>
17
17
  </div>
@@ -24,32 +24,4 @@
24
24
  </a>
25
25
  </small>
26
26
  </div>
27
- </div>
28
-
29
- <script type="text/javascript">
30
- document.addEventListener('DOMContentLoaded', () => {
31
- const updateGeorefLinks = async () => {
32
- const manifestUrl = document.getElementById('allmaps-sidebar').getAttribute('data-iiif-manifest');
33
- const georefDiv = document.getElementById('georeferencing');
34
- const annotationUrlByIIIFUri = `https://annotations.allmaps.org/?url=${manifestUrl}`;
35
-
36
- try {
37
- const response = await fetch(annotationUrlByIIIFUri);
38
- if (!response.ok) {
39
- georefDiv.innerHTML = `<a href="https://editor.allmaps.org/#/collection?url=${manifestUrl}">Georeference this item</a>`;
40
- } else {
41
- const annotationUrl = response.url;
42
- georefDiv.innerHTML = `<a href="https://viewer.allmaps.org/?url=${annotationUrl}">View this georeferenced item</a>`;
43
-
44
- // TODO: Ping Blacklight::Allmaps::AnnotationsController to save the annotation data
45
-
46
-
47
- }
48
- } catch (error) {
49
- console.error("Fetch error:", error);
50
- }
51
- };
52
-
53
- updateGeorefLinks();
54
- });
55
- </script>
27
+ </div>
@@ -0,0 +1 @@
1
+ json.extract! annotation, :id, :solr_document_id, :document_type, :manifest_id, :annotated, :allmaps_id, :iiif_manifest, :allmaps_annotation, :solr_version, :created_at, :updated_at
@@ -0,0 +1,9 @@
1
+ json.pagination do
2
+ current, total, per_page = collection.current_page, collection.total_pages, collection.limit_value
3
+ json.current current
4
+ json.previous((current > 1) ? (current - 1) : nil)
5
+ json.next((current == total) ? nil : (current + 1))
6
+ json.per_page per_page
7
+ json.pages total
8
+ json.count collection.total_count
9
+ end
@@ -0,0 +1,4 @@
1
+ json.partial! "pagination", collection: @annotations
2
+ json.data do
3
+ json.array! @annotations, partial: "annotations/annotation", as: :annotation
4
+ end
@@ -0,0 +1 @@
1
+ json.partial! "annotations/annotation", annotation: @annotation
@@ -2,15 +2,15 @@
2
2
  <div class='row'>
3
3
  <div id='viewer-container' class="col-md-12">
4
4
 
5
- <span class="sr-only">Georeferenced: <%= document.sidecar_allmaps.georeferenced? %></span>
5
+ <span class="sr-only"><%= t('allmaps.georeferenced')%>: <%= document.sidecar_allmaps.georeferenced? %></span>
6
6
 
7
7
  <ul class="nav nav-tabs mt-3" id="myTab" role="tablist">
8
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>
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"><%= t('allmaps.item_viewer')%></button>
10
10
  </li>
11
11
  <% if document.sidecar_allmaps.georeferenced? %>
12
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>
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"><%= t('allmaps.map_heading')%></button>
14
14
  </li>
15
15
  <% end %>
16
16
  </ul>
@@ -0,0 +1,34 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "blacklight/allmaps/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "blacklight_allmaps"
7
+ spec.version = Blacklight::Allmaps::VERSION
8
+ spec.platform = Gem::Platform::RUBY
9
+ spec.authors = ["Eric Larson"]
10
+ spec.email = ["ewlarson@gmail.com"]
11
+ spec.homepage = "https://github.com/bplmaps/blacklight-allmaps"
12
+ spec.summary = "Blacklight::Allmaps plugin"
13
+ spec.description = "Description of Blacklight::Allmaps"
14
+ spec.license = "Apache 2.0"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = spec.homepage
21
+
22
+ spec.add_dependency "blacklight", ">= 7.25.2", "< 9"
23
+ spec.add_dependency "httparty", "~> 0.20"
24
+
25
+ spec.add_development_dependency "solr_wrapper"
26
+ spec.add_development_dependency "rails-controller-testing"
27
+ spec.add_development_dependency "rspec-rails"
28
+ spec.add_development_dependency "engine_cart", "~> 2.1"
29
+ spec.add_development_dependency "factory_bot_rails"
30
+ spec.add_development_dependency "capybara", "~> 3"
31
+ spec.add_development_dependency "webdrivers"
32
+ spec.add_development_dependency "standard", "~> 1.34"
33
+ spec.add_development_dependency "sqlite3"
34
+ end
@@ -0,0 +1,11 @@
1
+ en:
2
+ allmaps:
3
+ bl_facet_label: 'Allmaps Georeferenced'
4
+ item_viewer: 'Item Viewer'
5
+ gbl_tab_label: 'Georeferenced Map'
6
+ georeference_link: 'Georeference this item'
7
+ georeferenced: 'Georeferenced'
8
+ georeferenced_link: 'View this georeferenced item'
9
+ loading: 'Loading...'
10
+ map_heading: 'Georeferenced Map'
11
+
data/config/routes.rb CHANGED
@@ -1,2 +1,9 @@
1
1
  Blacklight::Allmaps::Engine.routes.draw do
2
+ namespace :allmaps do
3
+ resources :annotations, only: [:index, :show, :update], defaults: {format: :json} do
4
+ member do
5
+ get "fetch"
6
+ end
7
+ end
8
+ end
2
9
  end
Binary file
Binary file
Binary file
@@ -0,0 +1,72 @@
1
+ # Development Notes
2
+
3
+ ## Running the Application
4
+
5
+ ### Blacklight / MARC
6
+
7
+ IIIF Manifest URI is likely in 856 4#$u
8
+ https://www.loc.gov/marc/bibliographic/bd856.html
9
+
10
+ Solr Field: iiif_manifest_url_ssi (from Spotlight fixtures)
11
+ Georeferenced Field: georeferenced_bsi (Blacklight dynamicField Schema)
12
+
13
+ @TODO: Use mods_xml_ssm instead of marc_ss?
14
+
15
+ #### TERMINAL 1 / Run Solr
16
+
17
+ ```
18
+ bundle exec rake engine_cart:clean
19
+ LIGHT=blacklight bundle exec rake blacklight_allmaps:solr
20
+ ```
21
+
22
+ #### TERMINAL 2 / Index
23
+ ```
24
+ cd .internal_test_app
25
+ rake blacklight_allmaps:index:bl_fixtures
26
+ rake blacklight_allmaps:sidecars:harvest:allmaps
27
+ rake blacklight_allmaps:index:georeferenced_facet
28
+ rails s
29
+ ```
30
+
31
+ ### GeoBlacklight / Aardvark Schema
32
+
33
+ IIIF Manifest URI is in dct_references_s
34
+ https://opengeometadata.org/ogm-aardvark/#references
35
+ Key: http://iiif.io/api/presentation#manifest
36
+
37
+ Solr Field: dct_references_s
38
+ Georeferenced Field: gbl_georeferenced_b (Aardvark Schema)
39
+
40
+ #### TERMINAL 1 / Run Solr
41
+ ```
42
+ bundle exec rake engine_cart:clean
43
+ LIGHT=geoblacklight bundle exec rake blacklight_allmaps:solr
44
+ ```
45
+
46
+ #### TERMINAL 2 / Index, Harvest, Facet
47
+ ```
48
+ cd .internal_test_app
49
+ rake blacklight_allmaps:index:gbl_fixtures
50
+ rake blacklight_allmaps:sidecars:harvest:allmaps
51
+ rake blacklight_allmaps:index:georeferenced_facet
52
+ rails s
53
+ ```
54
+
55
+ ## Building the Javascript / Publishing the NPM Package
56
+
57
+ The javascript is built by npm from sources in `app/javascript` into a bundle
58
+ in `app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.js`. This file should not be edited by hand as any changes would be overwritten. When any of the javascript
59
+ components in the gem are changed, this bundle should be rebuild with the
60
+ following steps:
61
+ 1. [Install npm](https://www.npmjs.com/get-npm)
62
+ 1. run `npm install` to download dependencies
63
+ 1. run `npm run prepare` to build the bundle
64
+ 1. run `npm publish` to push the javascript package to https://npmjs.org/package/blacklight-allmaps
65
+
66
+ ## Running the Test suite
67
+
68
+ ```LIGHT=blacklight bundle exec rake ci```
69
+
70
+ or
71
+
72
+ ```LIGHT=geoblacklight bundle exec rake ci```
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "blacklight"
4
+ require "blacklight/allmaps/version"
4
5
 
5
6
  namespace :blacklight_allmaps do
6
7
  namespace :index do
@@ -19,12 +20,12 @@ namespace :blacklight_allmaps do
19
20
  end
20
21
 
21
22
  desc "Index - add Allmaps facet data to GeoBlacklight solr"
22
- task gbl_georeferenced_facet: [:environment] do
23
+ task georeferenced_facet: [:environment] do
23
24
  # Steps
24
25
  # 1. Use cursor to paginate all documents in Solr
25
26
  # 2. Determine which documents have georeferenced data
26
27
  # 3. Clean JSON for re-indexing
27
- # 4. Add gbl_georeferenced_b values
28
+ # 4. Add georeferenced values
28
29
  # 5. Re-index the georeferenced documents
29
30
 
30
31
  # 1. Get all the documents from Solr
@@ -36,13 +37,13 @@ namespace :blacklight_allmaps do
36
37
  fl: "*", # all fields
37
38
  cursorMark: cursor_mark, # use the cursor mark to handle paging
38
39
  rows: 1000,
39
- sort: "id asc" # must sort by id to use the cursor mark
40
+ sort: "#{CatalogController.blacklight_config.default_solr_unique_key} asc" # must sort by id to use the cursor mark
40
41
  }
41
42
  )
42
43
 
43
44
  response["response"]["docs"].each do |doc|
44
45
  # 2. Determine which documents have georeferenced data
45
- solr_document = SolrDocument.find(doc["id"])
46
+ solr_document = SolrDocument.find(doc[CatalogController.blacklight_config.default_solr_unique_key])
46
47
  if solr_document.sidecar_allmaps.present? && solr_document.sidecar_allmaps.annotated?
47
48
 
48
49
  # 3. Clean JSON for re-indexing
@@ -58,59 +59,8 @@ namespace :blacklight_allmaps do
58
59
 
59
60
  cleaned_doc = doc.except!(*keys_for_deletion)
60
61
 
61
- # 4. Add gbl_georeferenced_b value
62
- # @TODO: add allmaps_id?
63
- cleaned_doc["gbl_georeferenced_b"] = true
64
-
65
- # 5. Re-index the georeferenced documents
66
- Blacklight.default_index.connection.add cleaned_doc
67
- end
68
- end
69
-
70
- break if response["nextCursorMark"] == cursor_mark # this means the result set is finished
71
- cursor_mark = response["nextCursorMark"]
72
- end
73
- Blacklight.default_index.connection.commit
74
- end
75
-
76
- desc "Index - add Allmaps facet data to Blacklight solr"
77
- task bl_georeferenced_facet: [:environment] do
78
- # Steps
79
- # 1. Use cursor to paginate all documents in Solr
80
- # 2. Determine which documents have georeferenced data
81
- # 3. Clean JSON for re-indexing
82
- # 4. Add bl_georeferenced_bsi values
83
- # 5. Re-index the georeferenced documents
84
-
85
- # 1. Get all the documents from Solr
86
- cursor_mark = "*"
87
- loop do
88
- response = Blacklight.default_index.connection.get(
89
- "select", params: {
90
- q: "*:*", # all docs
91
- fl: "*", # all fields
92
- cursorMark: cursor_mark, # use the cursor mark to handle paging
93
- rows: 1000,
94
- sort: "id asc" # must sort by id to use the cursor mark
95
- }
96
- )
97
-
98
- response["response"]["docs"].each do |doc|
99
- # 2. Determine which documents have georeferenced data
100
- solr_document = SolrDocument.find(doc["id"])
101
- if solr_document.sidecar_allmaps.present? && solr_document.sidecar_allmaps.annotated?
102
-
103
- # 3. Clean JSON for re-indexing
104
- keys_for_deletion = %w[
105
- _version_
106
- timestamp
107
- ]
108
-
109
- cleaned_doc = doc.except!(*keys_for_deletion)
110
-
111
- # 4. Add gbl_georeferenced_b value
112
- # @TODO: add allmaps_id?
113
- cleaned_doc["bl_georeferenced_bsi"] = true
62
+ # 4. Add georeferenced value
63
+ cleaned_doc[CatalogController.blacklight_config.default_georeferenced_field] = true
114
64
 
115
65
  # 5. Re-index the georeferenced documents
116
66
  Blacklight.default_index.connection.add cleaned_doc
@@ -46,5 +46,14 @@ namespace :blacklight_allmaps do
46
46
  puts "orphaned / #{sc.document_id} / destroyed"
47
47
  end
48
48
  end
49
+
50
+ desc "Sidecars - Harvest list of document ids"
51
+ task :harvest_ids, [:ids] => :environment do |t, args|
52
+ docs = args[:ids].split(" ")
53
+ docs.each do |doc|
54
+ puts "Harvesting Allmaps data for #{doc}"
55
+ Blacklight::Allmaps::StoreSidecarAnnotation.perform_later(doc)
56
+ end
57
+ end
49
58
  end
50
59
  end
@@ -1,6 +1,6 @@
1
1
  module Blacklight
2
2
  module Allmaps
3
- VERSION = "0.2.0"
3
+ VERSION = "0.4.0"
4
4
 
5
5
  def self.version
6
6
  @version ||= VERSION
@@ -1,8 +1,16 @@
1
1
  require "blacklight"
2
+ require "blacklight/allmaps/version"
3
+ require "blacklight/allmaps/engine"
2
4
 
3
5
  module Blacklight
4
6
  module Allmaps
5
- require "blacklight/allmaps/engine"
6
- require "blacklight/allmaps/version"
7
+ def self.version
8
+ @version ||= VERSION
9
+ end
10
+
11
+ # returns the full path the the plugin installation
12
+ def self.root
13
+ @root ||= __dir__
14
+ end
7
15
  end
8
16
  end