blacklight_allmaps 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +47 -6
- data/Rakefile +4 -0
- data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.esm.js +41 -0
- data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.js +41 -0
- data/app/assets/javascripts/blacklight/allmaps/blacklight-allmaps.js.map +1 -1
- data/app/controllers/allmaps/annotations_controller.rb +65 -0
- data/app/helpers/blacklight/allmaps/application_helper.rb +1 -1
- data/app/javascript/blacklight/allmaps/index.js +6 -0
- data/app/javascript/blacklight/allmaps/update_georef_links.js +36 -0
- data/app/jobs/blacklight/allmaps/store_sidecar_annotation.rb +4 -1
- data/app/models/concerns/blacklight/allmaps/solr_document.rb +1 -2
- data/app/views/allmaps/show/_blacklight.html.erb +1 -1
- data/app/views/allmaps/show/_geoblacklight.html.erb +1 -1
- data/app/views/allmaps/sidebar/_allmaps.html.erb +4 -32
- data/app/views/annotations/_annotation.json.jbuilder +1 -0
- data/app/views/annotations/_pagination.json.jbuilder +9 -0
- data/app/views/annotations/index.json.jbuilder +4 -0
- data/app/views/annotations/show.json.jbuilder +1 -0
- data/app/views/catalog/_show_allmaps_tabbed_viewer_container.html.erb +3 -3
- data/config/locales/allmaps.en.yml +11 -0
- data/config/routes.rb +7 -0
- data/lib/blacklight/allmaps/tasks/index.rake +6 -57
- data/lib/blacklight/allmaps/tasks/sidecars.rake +9 -0
- data/lib/blacklight/allmaps/version.rb +1 -1
- data/lib/generators/blacklight/allmaps/blacklight_generator.rb +48 -0
- data/lib/generators/blacklight/allmaps/config_generator.rb +2 -54
- data/lib/generators/blacklight/allmaps/geoblacklight_generator.rb +50 -0
- data/lib/generators/blacklight/allmaps/install_generator.rb +10 -0
- metadata +26 -7
- data/app/controllers/blacklight/allmaps/application_controller.rb +0 -6
- data/app/jobs/blacklight/allmaps/application_job.rb +0 -6
- data/app/mailers/blacklight/allmaps/application_mailer.rb +0 -8
- data/app/models/blacklight/allmaps/application_record.rb +0 -7
@@ -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
|
@@ -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
|
+
};
|
@@ -15,7 +15,10 @@ module Blacklight
|
|
15
15
|
if response.code == 200
|
16
16
|
# @TODO: validate the response body is a valid IIIF Manifest
|
17
17
|
sidecar.iiif_manifest = response.body
|
18
|
-
|
18
|
+
|
19
|
+
# Store the Manifest ID
|
20
|
+
# - Could be either "@id" or "id"
|
21
|
+
sidecar.manifest_id = JSON.parse(sidecar.iiif_manifest)["@id"] || JSON.parse(sidecar.iiif_manifest)["id"]
|
19
22
|
end
|
20
23
|
|
21
24
|
# Store the Allmaps Annotation
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<!-- Georeferenced Map -->
|
2
|
-
<h3 class="h6"
|
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="
|
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 '
|
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
|
-
|
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 @@
|
|
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"
|
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"
|
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"
|
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,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
@@ -19,12 +19,12 @@ namespace :blacklight_allmaps do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
desc "Index - add Allmaps facet data to GeoBlacklight solr"
|
22
|
-
task
|
22
|
+
task georeferenced_facet: [:environment] do
|
23
23
|
# Steps
|
24
24
|
# 1. Use cursor to paginate all documents in Solr
|
25
25
|
# 2. Determine which documents have georeferenced data
|
26
26
|
# 3. Clean JSON for re-indexing
|
27
|
-
# 4. Add
|
27
|
+
# 4. Add georeferenced values
|
28
28
|
# 5. Re-index the georeferenced documents
|
29
29
|
|
30
30
|
# 1. Get all the documents from Solr
|
@@ -36,13 +36,13 @@ namespace :blacklight_allmaps do
|
|
36
36
|
fl: "*", # all fields
|
37
37
|
cursorMark: cursor_mark, # use the cursor mark to handle paging
|
38
38
|
rows: 1000,
|
39
|
-
sort: "
|
39
|
+
sort: "#{CatalogController.blacklight_config.default_solr_unique_key} asc" # must sort by id to use the cursor mark
|
40
40
|
}
|
41
41
|
)
|
42
42
|
|
43
43
|
response["response"]["docs"].each do |doc|
|
44
44
|
# 2. Determine which documents have georeferenced data
|
45
|
-
solr_document = SolrDocument.find(doc[
|
45
|
+
solr_document = SolrDocument.find(doc[CatalogController.blacklight_config.default_solr_unique_key])
|
46
46
|
if solr_document.sidecar_allmaps.present? && solr_document.sidecar_allmaps.annotated?
|
47
47
|
|
48
48
|
# 3. Clean JSON for re-indexing
|
@@ -58,59 +58,8 @@ namespace :blacklight_allmaps do
|
|
58
58
|
|
59
59
|
cleaned_doc = doc.except!(*keys_for_deletion)
|
60
60
|
|
61
|
-
# 4. Add
|
62
|
-
|
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
|
61
|
+
# 4. Add georeferenced value
|
62
|
+
cleaned_doc[CatalogController.blacklight_config.default_georeferenced_field] = true
|
114
63
|
|
115
64
|
# 5. Re-index the georeferenced documents
|
116
65
|
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
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators"
|
4
|
+
|
5
|
+
module Blacklight
|
6
|
+
module Allmaps
|
7
|
+
class BlacklightGenerator < Rails::Generators::Base
|
8
|
+
source_root File.expand_path("templates", __dir__)
|
9
|
+
|
10
|
+
desc <<-DESCRIPTION
|
11
|
+
This generator makes the following changes to your application:
|
12
|
+
1. Copies stylesheets to Blacklight app
|
13
|
+
2. Adds Blacklight::Allmaps configuration to CatalogController
|
14
|
+
3. Adds georeferenced facet to CatalogController
|
15
|
+
4. Includes Blacklight::Allmaps::SolrDocument in SolrDocument
|
16
|
+
DESCRIPTION
|
17
|
+
|
18
|
+
def add_bl_stylesheets
|
19
|
+
append_to_file "app/assets/stylesheets/blacklight.scss" do
|
20
|
+
"@import 'blacklight/allmaps/base';"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_configuration
|
25
|
+
inject_into_file "app/controllers/catalog_controller.rb", after: "#config.show.thumbnail_field = 'thumbnail_path_ss'" do
|
26
|
+
"\n
|
27
|
+
# Blacklight::Allmaps Viewer
|
28
|
+
config.show.partials.insert(1, :blacklight_allmaps)
|
29
|
+
config.default_solr_unique_key = \"id\"
|
30
|
+
config.default_georeferenced_field = \"bl_georeferenced_bsi\"
|
31
|
+
config.default_iiif_manifest_field = \"iiif_manifest_url_ssi\""
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_bl_georeferenced_facet
|
36
|
+
inject_into_file "app/controllers/catalog_controller.rb", after: "config.add_facet_field 'subject_era_ssim', label: 'Era'" do
|
37
|
+
"\n config.add_facet_field 'bl_georeferenced_bsi', label: I18n.t('allmaps.bl_facet_label')"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def include_blacklight_allmaps_solrdocument
|
42
|
+
inject_into_file "app/models/solr_document.rb", after: "include Blacklight::Solr::Document" do
|
43
|
+
"\n include Blacklight::Allmaps::SolrDocument"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -52,65 +52,13 @@ module Blacklight
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
|
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
|
55
|
+
def set_routes
|
56
|
+
inject_into_file "config/routes.rb", "mount Blacklight::Allmaps::Engine => '/'\n", before: /^end/
|
67
57
|
end
|
68
58
|
|
69
59
|
def set_active_job_config
|
70
60
|
inject_into_file "config/environments/development.rb", " config.active_job.queue_adapter = :inline\n", after: "Rails.application.configure do\n"
|
71
61
|
end
|
72
|
-
|
73
|
-
def add_geoblacklight
|
74
|
-
return unless ENV["LIGHT"] == "geoblacklight"
|
75
|
-
append_to_file "Gemfile", '"geoblacklight", "~> 4.4"'
|
76
|
-
end
|
77
|
-
|
78
|
-
def include_blacklight_allmaps_solrdocument
|
79
|
-
return unless ENV["LIGHT"] == "blacklight"
|
80
|
-
inject_into_file "app/models/solr_document.rb", after: "include Blacklight::Solr::Document" do
|
81
|
-
"\n include Blacklight::Allmaps::SolrDocument"
|
82
|
-
end
|
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
|
114
62
|
end
|
115
63
|
end
|
116
64
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators"
|
4
|
+
|
5
|
+
module Blacklight
|
6
|
+
module Allmaps
|
7
|
+
class GeoblacklightGenerator < Rails::Generators::Base
|
8
|
+
source_root File.expand_path("templates", __dir__)
|
9
|
+
|
10
|
+
desc <<-DESCRIPTION
|
11
|
+
This generator makes the following changes to your application:
|
12
|
+
1. Adds stylesheets to application.scss
|
13
|
+
2. Adds GeoBlacklight to Gemfile
|
14
|
+
3. Adds Blacklight::Allmaps configuration to CatalogController
|
15
|
+
4. Adds Blacklight::Allmaps Tabbed Viewer to CatalogController
|
16
|
+
DESCRIPTION
|
17
|
+
|
18
|
+
def add_gbl_stylesheets
|
19
|
+
append_to_file "app/assets/stylesheets/application.scss" do
|
20
|
+
"@import 'blacklight/allmaps/base';"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_geoblacklight
|
25
|
+
append_to_file "Gemfile", '"geoblacklight", "~> 4.4"'
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_configuration
|
29
|
+
inject_into_file "app/controllers/catalog_controller.rb", after: "config.raw_endpoint.enabled = true" do
|
30
|
+
"\n
|
31
|
+
# Blacklight::Allmaps Viewer
|
32
|
+
config.default_solr_unique_key = \"id\"
|
33
|
+
config.default_georeferenced_field = \"gbl_georeferenced_b\""
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_gbl_tabbed_viewer
|
38
|
+
# Use the tabbed viewer
|
39
|
+
inject_into_file "app/controllers/catalog_controller.rb", after: "config.show.partials << \"show_default_viewer_container\"" do
|
40
|
+
"\n
|
41
|
+
# Blacklight::Allmaps Tabbed Viewer
|
42
|
+
config.show.partials << \"show_allmaps_tabbed_viewer_container\""
|
43
|
+
end
|
44
|
+
|
45
|
+
# Remove the default viewer
|
46
|
+
gsub_file("app/controllers/catalog_controller.rb", "config.show.partials << \"show_default_viewer_container\"", "#config.show.partials << \"show_default_viewer_container\"")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -13,6 +13,16 @@ module Blacklight
|
|
13
13
|
generate "blacklight:allmaps:config"
|
14
14
|
end
|
15
15
|
|
16
|
+
def generate_blacklight_config
|
17
|
+
return unless ENV["LIGHT"] == "blacklight"
|
18
|
+
generate "blacklight:allmaps:blacklight"
|
19
|
+
end
|
20
|
+
|
21
|
+
def generate_geoblacklight_config
|
22
|
+
return unless ENV["LIGHT"] == "geoblacklight"
|
23
|
+
generate "blacklight:allmaps:geoblacklight"
|
24
|
+
end
|
25
|
+
|
16
26
|
def generate_models
|
17
27
|
generate "blacklight:allmaps:models"
|
18
28
|
end
|