geoblacklight 6.0.0.pre.alpha.3 → 6.0.0.pre.alpha.5
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/Rakefile +0 -1
- data/app/assets/stylesheets/geoblacklight/global.css +30 -0
- data/app/assets/stylesheets/geoblacklight/record.css +41 -1
- data/app/components/geoblacklight/document/download_link_component.html.erb +6 -0
- data/app/components/geoblacklight/document/download_link_component.rb +66 -0
- data/app/components/geoblacklight/document/download_links_component.html.erb +8 -0
- data/app/components/geoblacklight/document/download_links_component.rb +59 -0
- data/app/components/geoblacklight/document/sidebar_component.html.erb +3 -9
- data/app/components/geoblacklight/document/sidebar_component.rb +6 -11
- data/app/components/geoblacklight/login_link_component.html.erb +3 -5
- data/app/helpers/geoblacklight_helper.rb +1 -1
- data/app/javascript/geoblacklight/core.js +0 -2
- data/app/javascript/geoblacklight/index.js +0 -2
- data/app/javascript/geoblacklight/leaflet/inspection.js +5 -4
- data/app/models/concerns/geoblacklight/solr_document.rb +1 -2
- data/config/locales/geoblacklight.en.yml +5 -14
- data/geoblacklight.gemspec +0 -1
- data/lib/generators/geoblacklight/install_generator.rb +0 -9
- data/lib/generators/geoblacklight/templates/settings.yml +1 -15
- data/lib/geoblacklight/configuration/settings_builder.rb +0 -3
- data/lib/geoblacklight/configuration.rb +0 -10
- data/lib/geoblacklight/exceptions.rb +0 -23
- data/lib/geoblacklight/references.rb +0 -80
- data/lib/geoblacklight/version.rb +1 -1
- data/lib/geoblacklight.rb +0 -1
- data/lib/tasks/geoblacklight.rake +0 -30
- data/spec/components/geoblacklight/document/sidebar_component_spec.rb +1 -1
- data/spec/components/geoblacklight/download_links_component_spec.rb +59 -85
- data/spec/features/index_view_spec.rb +0 -33
- data/spec/features/layer_inspection_spec.rb +0 -10
- data/spec/features/layer_opacity_spec.rb +0 -7
- data/spec/helpers/geoblacklight_helper_spec.rb +1 -1
- data/spec/lib/geoblacklight/configuration/settings_builder_spec.rb +0 -2
- data/spec/lib/geoblacklight/references_spec.rb +1 -57
- data/spec/models/concerns/geoblacklight/solr_document_spec.rb +0 -7
- data/template.rb +1 -1
- metadata +6 -42
- data/app/components/geoblacklight/download_links_component.html.erb +0 -31
- data/app/components/geoblacklight/download_links_component.rb +0 -87
- data/app/controllers/download_controller.rb +0 -76
- data/app/javascript/geoblacklight/controllers/downloads_controller.js +0 -64
- data/lib/geoblacklight/download/csv_download.rb +0 -22
- data/lib/geoblacklight/download/geojson_download.rb +0 -24
- data/lib/geoblacklight/download/geotiff_download.rb +0 -22
- data/lib/geoblacklight/download/kmz_download.rb +0 -24
- data/lib/geoblacklight/download/shapefile_download.rb +0 -22
- data/lib/geoblacklight/download.rb +0 -110
- data/lib/geoblacklight/routes/downloadable.rb +0 -15
- data/spec/controllers/download_controller_spec.rb +0 -99
- data/spec/features/download_layer_spec.rb +0 -96
- data/spec/features/esri_viewer_spec.rb +0 -43
- data/spec/features/index_map_spec.rb +0 -40
- data/spec/features/layer_with_no_references_spec.rb +0 -10
- data/spec/features/linkified_attribute_table_spec.rb +0 -13
- data/spec/features/multiple_downloads_spec.rb +0 -17
- data/spec/features/show_page_download_spec.rb +0 -22
- data/spec/lib/geoblacklight/download/csv_download_spec.rb +0 -21
- data/spec/lib/geoblacklight/download/geojson_download_spec.rb +0 -22
- data/spec/lib/geoblacklight/download/geotiff_download_spec.rb +0 -25
- data/spec/lib/geoblacklight/download/kmz_download_spec.rb +0 -22
- data/spec/lib/geoblacklight/download/shapefile_download_spec.rb +0 -21
- data/spec/lib/geoblacklight/download_spec.rb +0 -188
- data/spec/tasks/geoblacklight_spec.rb +0 -20
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: geoblacklight
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.0.0.pre.alpha.
|
|
4
|
+
version: 6.0.0.pre.alpha.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Graves
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
- Jack Reed
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2026-07-
|
|
13
|
+
date: 2026-07-15 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rails
|
|
@@ -164,20 +164,6 @@ dependencies:
|
|
|
164
164
|
- - ">="
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
166
|
version: '0'
|
|
167
|
-
- !ruby/object:Gem::Dependency
|
|
168
|
-
name: rsolr
|
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
|
170
|
-
requirements:
|
|
171
|
-
- - ">="
|
|
172
|
-
- !ruby/object:Gem::Version
|
|
173
|
-
version: '0'
|
|
174
|
-
type: :runtime
|
|
175
|
-
prerelease: false
|
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
177
|
-
requirements:
|
|
178
|
-
- - ">="
|
|
179
|
-
- !ruby/object:Gem::Version
|
|
180
|
-
version: '0'
|
|
181
167
|
- !ruby/object:Gem::Dependency
|
|
182
168
|
name: rails-controller-testing
|
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -436,14 +422,16 @@ files:
|
|
|
436
422
|
- app/components/geoblacklight/display_note_component.rb
|
|
437
423
|
- app/components/geoblacklight/document/citation_component.html.erb
|
|
438
424
|
- app/components/geoblacklight/document/citation_component.rb
|
|
425
|
+
- app/components/geoblacklight/document/download_link_component.html.erb
|
|
426
|
+
- app/components/geoblacklight/document/download_link_component.rb
|
|
427
|
+
- app/components/geoblacklight/document/download_links_component.html.erb
|
|
428
|
+
- app/components/geoblacklight/document/download_links_component.rb
|
|
439
429
|
- app/components/geoblacklight/document/relations_container_component.html.erb
|
|
440
430
|
- app/components/geoblacklight/document/relations_container_component.rb
|
|
441
431
|
- app/components/geoblacklight/document/sidebar_component.html.erb
|
|
442
432
|
- app/components/geoblacklight/document/sidebar_component.rb
|
|
443
433
|
- app/components/geoblacklight/document_component.html.erb
|
|
444
434
|
- app/components/geoblacklight/document_component.rb
|
|
445
|
-
- app/components/geoblacklight/download_links_component.html.erb
|
|
446
|
-
- app/components/geoblacklight/download_links_component.rb
|
|
447
435
|
- app/components/geoblacklight/header_component.html.erb
|
|
448
436
|
- app/components/geoblacklight/header_component.rb
|
|
449
437
|
- app/components/geoblacklight/header_icons_component.html.erb
|
|
@@ -479,12 +467,10 @@ files:
|
|
|
479
467
|
- app/components/geoblacklight/web_services_wfs_component.rb
|
|
480
468
|
- app/components/geoblacklight/web_services_wms_component.html.erb
|
|
481
469
|
- app/components/geoblacklight/web_services_wms_component.rb
|
|
482
|
-
- app/controllers/download_controller.rb
|
|
483
470
|
- app/controllers/relation_controller.rb
|
|
484
471
|
- app/controllers/wms_controller.rb
|
|
485
472
|
- app/helpers/geoblacklight_helper.rb
|
|
486
473
|
- app/javascript/geoblacklight/controllers/clipboard_controller.js
|
|
487
|
-
- app/javascript/geoblacklight/controllers/downloads_controller.js
|
|
488
474
|
- app/javascript/geoblacklight/controllers/leaflet_viewer_controller.js
|
|
489
475
|
- app/javascript/geoblacklight/controllers/oembed_viewer_controller.js
|
|
490
476
|
- app/javascript/geoblacklight/controllers/openlayers_viewer_controller.js
|
|
@@ -556,12 +542,6 @@ files:
|
|
|
556
542
|
- lib/geoblacklight/configuration/settings_builder.rb
|
|
557
543
|
- lib/geoblacklight/constants.rb
|
|
558
544
|
- lib/geoblacklight/deprecation.rb
|
|
559
|
-
- lib/geoblacklight/download.rb
|
|
560
|
-
- lib/geoblacklight/download/csv_download.rb
|
|
561
|
-
- lib/geoblacklight/download/geojson_download.rb
|
|
562
|
-
- lib/geoblacklight/download/geotiff_download.rb
|
|
563
|
-
- lib/geoblacklight/download/kmz_download.rb
|
|
564
|
-
- lib/geoblacklight/download/shapefile_download.rb
|
|
565
545
|
- lib/geoblacklight/engine.rb
|
|
566
546
|
- lib/geoblacklight/exceptions.rb
|
|
567
547
|
- lib/geoblacklight/geometry.rb
|
|
@@ -581,7 +561,6 @@ files:
|
|
|
581
561
|
- lib/geoblacklight/relation/descendants.rb
|
|
582
562
|
- lib/geoblacklight/relation/relation_response.rb
|
|
583
563
|
- lib/geoblacklight/routes.rb
|
|
584
|
-
- lib/geoblacklight/routes/downloadable.rb
|
|
585
564
|
- lib/geoblacklight/routes/exportable.rb
|
|
586
565
|
- lib/geoblacklight/routes/wms.rb
|
|
587
566
|
- lib/geoblacklight/version.rb
|
|
@@ -622,7 +601,6 @@ files:
|
|
|
622
601
|
- spec/components/geoblacklight/viewer_help_text_component_spec.rb
|
|
623
602
|
- spec/components/geoblacklight/web_services_component_spec.rb
|
|
624
603
|
- spec/controllers/catalog_controller_spec.rb
|
|
625
|
-
- spec/controllers/download_controller_spec.rb
|
|
626
604
|
- spec/controllers/relation_controller_spec.rb
|
|
627
605
|
- spec/controllers/wms_controller_spec.rb
|
|
628
606
|
- spec/factories/user.rb
|
|
@@ -631,23 +609,17 @@ files:
|
|
|
631
609
|
- spec/features/citations_spec.rb
|
|
632
610
|
- spec/features/configurable_basemap_spec.rb
|
|
633
611
|
- spec/features/data_dictionary_download_spec.rb
|
|
634
|
-
- spec/features/download_layer_spec.rb
|
|
635
612
|
- spec/features/empty_search_spec.rb
|
|
636
|
-
- spec/features/esri_viewer_spec.rb
|
|
637
613
|
- spec/features/exports_spec.rb
|
|
638
614
|
- spec/features/full_screen_control_spec.rb
|
|
639
615
|
- spec/features/help_text_spec.rb
|
|
640
616
|
- spec/features/home_page_spec.rb
|
|
641
|
-
- spec/features/index_map_spec.rb
|
|
642
617
|
- spec/features/index_view_spec.rb
|
|
643
618
|
- spec/features/layer_inspection_spec.rb
|
|
644
619
|
- spec/features/layer_opacity_spec.rb
|
|
645
620
|
- spec/features/layer_preview_spec.rb
|
|
646
|
-
- spec/features/layer_with_no_references_spec.rb
|
|
647
|
-
- spec/features/linkified_attribute_table_spec.rb
|
|
648
621
|
- spec/features/metadata_panel_spec.rb
|
|
649
622
|
- spec/features/missing_metadata_spec.rb
|
|
650
|
-
- spec/features/multiple_downloads_spec.rb
|
|
651
623
|
- spec/features/oembed_spec.rb
|
|
652
624
|
- spec/features/relations_spec.rb
|
|
653
625
|
- spec/features/saved_searches_spec.rb
|
|
@@ -657,7 +629,6 @@ files:
|
|
|
657
629
|
- spec/features/search_results_map_spec.rb
|
|
658
630
|
- spec/features/search_results_overlap_ratio_spec.rb
|
|
659
631
|
- spec/features/search_spec.rb
|
|
660
|
-
- spec/features/show_page_download_spec.rb
|
|
661
632
|
- spec/features/show_page_metadata_spec.rb
|
|
662
633
|
- spec/features/sms_spec.rb
|
|
663
634
|
- spec/features/suppressed_records_spec.rb
|
|
@@ -750,12 +721,6 @@ files:
|
|
|
750
721
|
- spec/lib/geoblacklight/configuration/leaflet_layers_config_spec.rb
|
|
751
722
|
- spec/lib/geoblacklight/configuration/settings_builder_spec.rb
|
|
752
723
|
- spec/lib/geoblacklight/configuration_spec.rb
|
|
753
|
-
- spec/lib/geoblacklight/download/csv_download_spec.rb
|
|
754
|
-
- spec/lib/geoblacklight/download/geojson_download_spec.rb
|
|
755
|
-
- spec/lib/geoblacklight/download/geotiff_download_spec.rb
|
|
756
|
-
- spec/lib/geoblacklight/download/kmz_download_spec.rb
|
|
757
|
-
- spec/lib/geoblacklight/download/shapefile_download_spec.rb
|
|
758
|
-
- spec/lib/geoblacklight/download_spec.rb
|
|
759
724
|
- spec/lib/geoblacklight/geometry_spec.rb
|
|
760
725
|
- spec/lib/geoblacklight/item_viewer_spec.rb
|
|
761
726
|
- spec/lib/geoblacklight/metadata/base_spec.rb
|
|
@@ -785,7 +750,6 @@ files:
|
|
|
785
750
|
- spec/support/features.rb
|
|
786
751
|
- spec/support/features/session_helpers.rb
|
|
787
752
|
- spec/support/fixtures.rb
|
|
788
|
-
- spec/tasks/geoblacklight_spec.rb
|
|
789
753
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
|
790
754
|
- template.rb
|
|
791
755
|
homepage: http://github.com/geoblacklight/geoblacklight
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<div data-controller="downloads" class="downloads-sidebar">
|
|
2
|
-
<%# the dropdown-toggle class gives us the little arrow %>
|
|
3
|
-
<button type="button" class="btn btn-primary dropdown-toggle sidebar-btn" id="downloads-button" data-bs-toggle="collapse" data-bs-target="#downloads-collapse" aria-expanded="false" aria-controls="downloads-collapse">
|
|
4
|
-
<%= t('geoblacklight.download.download') %>
|
|
5
|
-
</button>
|
|
6
|
-
<div class="collapse" id="downloads-collapse">
|
|
7
|
-
<div class="card card-body">
|
|
8
|
-
<%# Renders the options of the downloads dropdown button %>
|
|
9
|
-
<% if document.direct_download.present? %>
|
|
10
|
-
<% if document.direct_download[:download].is_a? Array %>
|
|
11
|
-
<% document.direct_download[:download].each do |download| %>
|
|
12
|
-
<%= download_link_file(download['label'], document.id, download['url']) %>
|
|
13
|
-
<% end %>
|
|
14
|
-
<% end %>
|
|
15
|
-
<% if document.direct_download[:download].is_a? String %>
|
|
16
|
-
<%= download_link_file(download_text(document.file_format), document.id, document.direct_download[:download]) %>
|
|
17
|
-
<% end %>
|
|
18
|
-
<% end %>
|
|
19
|
-
|
|
20
|
-
<% if document.iiif_download.present? %>
|
|
21
|
-
<%= download_link_iiif %>
|
|
22
|
-
<% end %>
|
|
23
|
-
|
|
24
|
-
<% if document.download_types.present? %>
|
|
25
|
-
<% document.download_types.each do |type| %>
|
|
26
|
-
<%= download_link_generated(type.first, document) %>
|
|
27
|
-
<% end %>
|
|
28
|
-
<% end %>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Geoblacklight
|
|
4
|
-
# Display expandable file download links in sidebar
|
|
5
|
-
class DownloadLinksComponent < ViewComponent::Base
|
|
6
|
-
attr_reader :document
|
|
7
|
-
|
|
8
|
-
def initialize(document:)
|
|
9
|
-
@document = document
|
|
10
|
-
super()
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def render?
|
|
14
|
-
downloadable? && (document.direct_download.present? || document.iiif_download.present? || document.download_types.present?)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def downloadable?
|
|
18
|
-
helpers.document_available?(@document) && @document.downloadable?
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def download_link_file(label, id, url)
|
|
22
|
-
link_to(
|
|
23
|
-
label,
|
|
24
|
-
url,
|
|
25
|
-
"contentUrl" => url,
|
|
26
|
-
:data => {
|
|
27
|
-
download: "trigger",
|
|
28
|
-
download_type: "direct",
|
|
29
|
-
download_id: id
|
|
30
|
-
}
|
|
31
|
-
)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Generates the link markup for the IIIF JPEG download
|
|
35
|
-
# @return [String]
|
|
36
|
-
def download_link_iiif
|
|
37
|
-
link_to(
|
|
38
|
-
download_text("JPG"),
|
|
39
|
-
iiif_jpg_url,
|
|
40
|
-
"contentUrl" => iiif_jpg_url,
|
|
41
|
-
:data => {
|
|
42
|
-
download: "trigger"
|
|
43
|
-
}
|
|
44
|
-
)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def download_link_generated(download_type, document)
|
|
48
|
-
link_to(
|
|
49
|
-
t("geoblacklight.download.export_link", download_format: export_format_label(download_type)),
|
|
50
|
-
"",
|
|
51
|
-
data: {
|
|
52
|
-
download_path: download_path(document.id, type: download_type),
|
|
53
|
-
download: "trigger",
|
|
54
|
-
action: "downloads#download:once",
|
|
55
|
-
download_type: download_type,
|
|
56
|
-
download_id: document.id,
|
|
57
|
-
download_preparing_message: t("geoblacklight.download.preparing"),
|
|
58
|
-
download_ready_message: t("geoblacklight.download.ready", type: download_type),
|
|
59
|
-
download_failed_message: t("geoblacklight.download.failed", type: download_type)
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
##
|
|
65
|
-
# Wraps download text with proper_case_format
|
|
66
|
-
#
|
|
67
|
-
def download_text(format)
|
|
68
|
-
download_format = proper_case_format(format)
|
|
69
|
-
value = t("geoblacklight.download.download_link", download_format: download_format)
|
|
70
|
-
value.html_safe
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# Format labels are customized for exports - look up the appropriate key.
|
|
74
|
-
def export_format_label(format)
|
|
75
|
-
t("geoblacklight.download.export_#{format.to_s.parameterize(separator: "_")}_link")
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# Looks up properly formatted names for formats
|
|
79
|
-
def proper_case_format(format)
|
|
80
|
-
t("geoblacklight.formats.#{format.to_s.parameterize(separator: "_")}")
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def iiif_jpg_url
|
|
84
|
-
@document.references.iiif.endpoint.sub! "info.json", "full/full/0/default.jpg"
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class DownloadController < ApplicationController
|
|
4
|
-
include Blacklight::Catalog
|
|
5
|
-
|
|
6
|
-
rescue_from Geoblacklight::Exceptions::ExternalDownloadFailed do |exception|
|
|
7
|
-
Geoblacklight.logger.error exception.message + " " + exception.url
|
|
8
|
-
flash.now[:danger] = view_context
|
|
9
|
-
.tag.span(t("geoblacklight.download.error"),
|
|
10
|
-
data: {
|
|
11
|
-
download: "error",
|
|
12
|
-
download_id: params[:id],
|
|
13
|
-
download_type: "generated-#{params[:type]}"
|
|
14
|
-
})
|
|
15
|
-
respond_to do |format|
|
|
16
|
-
format.json { render json: [flash, ""], response: response, status: 500 }
|
|
17
|
-
format.html { render json: [flash, ""], response: response, status: 500 }
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def show
|
|
22
|
-
@document = search_service.fetch params[:id]
|
|
23
|
-
restricted_should_authenticate
|
|
24
|
-
response = check_type
|
|
25
|
-
validate response
|
|
26
|
-
respond_to do |format|
|
|
27
|
-
format.json { render json: [flash, download_file_path(response)], response: response }
|
|
28
|
-
format.html { render json: [flash, download_file_path(response)], response: response }
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def file
|
|
33
|
-
# Grab the solr document to check if it should be public or not
|
|
34
|
-
@document = search_service.fetch(file_name_to_id(params[:id]))
|
|
35
|
-
restricted_should_authenticate
|
|
36
|
-
send_file download_file_path_and_name, x_sendfile: true
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
private
|
|
40
|
-
|
|
41
|
-
def download_file_path_and_name
|
|
42
|
-
"#{Geoblacklight::Download.file_path}/#{params[:id]}.#{params[:format]}"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def check_type
|
|
46
|
-
case params[:type]
|
|
47
|
-
when "shapefile"
|
|
48
|
-
Geoblacklight::ShapefileDownload.new(@document).get
|
|
49
|
-
when "kmz"
|
|
50
|
-
Geoblacklight::KmzDownload.new(@document).get
|
|
51
|
-
when "geojson"
|
|
52
|
-
Geoblacklight::GeojsonDownload.new(@document).get
|
|
53
|
-
when "geotiff"
|
|
54
|
-
Geoblacklight::GeotiffDownload.new(@document).get
|
|
55
|
-
when "csv"
|
|
56
|
-
Geoblacklight::CsvDownload.new(@document).get
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def validate(response)
|
|
61
|
-
flash.now[:success] = view_context.link_to(t("geoblacklight.download.success", title: response),
|
|
62
|
-
download_file_path(response),
|
|
63
|
-
data: {download: "trigger",
|
|
64
|
-
download_id: params[:id],
|
|
65
|
-
download_type: "generated-#{params[:type]}"})
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Checks whether a document is public, if not require user to authenticate
|
|
69
|
-
def restricted_should_authenticate
|
|
70
|
-
authenticate_user! unless @document.public?
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def file_name_to_id(file_name)
|
|
74
|
-
file_name.split("-")[0..-2].join("-")
|
|
75
|
-
end
|
|
76
|
-
end
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Controller } from "@hotwired/stimulus"
|
|
2
|
-
|
|
3
|
-
export default class extends Controller {
|
|
4
|
-
download(ev) {
|
|
5
|
-
ev.preventDefault()
|
|
6
|
-
if (this.downloading) {
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
this.downloading = true
|
|
10
|
-
ev.target.classList.add("download-in-progress")
|
|
11
|
-
const url = ev.target.dataset.downloadPath
|
|
12
|
-
ev.target.removeAttribute("href")
|
|
13
|
-
ev.target.innerHTML = `<div class="spinner-border spinner-border-sm float-end"></div> ${ev.target.dataset.downloadPreparingMessage}`
|
|
14
|
-
|
|
15
|
-
fetch(url)
|
|
16
|
-
.then((response) => {
|
|
17
|
-
if (!response.ok) {
|
|
18
|
-
return response.json().then((errorData) => {
|
|
19
|
-
const exception = new Error("Network response was not ok")
|
|
20
|
-
exception.data = errorData // Attach the parsed JSON data to the error object
|
|
21
|
-
throw exception
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
return response.json()
|
|
25
|
-
})
|
|
26
|
-
.then((data) => this.complete(data, ev.target))
|
|
27
|
-
.catch((error) => this.error(error, ev.target))
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
complete(data, target) {
|
|
31
|
-
this.downloading = false
|
|
32
|
-
target.classList.remove("download-in-progress")
|
|
33
|
-
target.classList.add("download-complete")
|
|
34
|
-
target.innerHTML = target.dataset.downloadReadyMessage
|
|
35
|
-
target.href = data[1]
|
|
36
|
-
this.renderMessage(data[0])
|
|
37
|
-
//target.click();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
error(exception, target) {
|
|
41
|
-
this.downloading = false
|
|
42
|
-
target.classList.remove("download-in-progress")
|
|
43
|
-
target.classList.add("download-complete")
|
|
44
|
-
target.innerHTML = target.dataset.downloadFailedMessage
|
|
45
|
-
console.log(exception)
|
|
46
|
-
|
|
47
|
-
this.renderMessage(exception.data[0])
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
renderMessage(message) {
|
|
51
|
-
let flashContainer = document.querySelector("div.flash_messages")
|
|
52
|
-
if (!flashContainer) {
|
|
53
|
-
flashContainer = document.createElement("div")
|
|
54
|
-
flashContainer.className = "flash_messages"
|
|
55
|
-
document.getElementById("document").prepend(flashContainer)
|
|
56
|
-
}
|
|
57
|
-
Object.entries(message).forEach(([idx, msg]) => {
|
|
58
|
-
const flash = document.createElement("div")
|
|
59
|
-
flash.className = `alert alert-${msg[0]} alert-dismissible fade show`
|
|
60
|
-
flash.innerHTML = `${msg[1]}<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>`
|
|
61
|
-
flashContainer.appendChild(flash)
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Geoblacklight
|
|
4
|
-
class CsvDownload < Geoblacklight::Download
|
|
5
|
-
CSV_DOWNLOAD_PARAMS = {service: "wfs",
|
|
6
|
-
version: "2.0.0",
|
|
7
|
-
request: "GetFeature",
|
|
8
|
-
srsName: "EPSG:4326",
|
|
9
|
-
outputformat: "csv"}.freeze
|
|
10
|
-
|
|
11
|
-
def initialize(document, options = {})
|
|
12
|
-
request_params = CSV_DOWNLOAD_PARAMS.merge(typeName: document.wxs_identifier)
|
|
13
|
-
super(document, {
|
|
14
|
-
type: "csv",
|
|
15
|
-
extension: "csv",
|
|
16
|
-
request_params: request_params,
|
|
17
|
-
content_type: "text/csv",
|
|
18
|
-
service_type: "wfs"
|
|
19
|
-
}.merge(options))
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Geoblacklight
|
|
4
|
-
class GeojsonDownload < Geoblacklight::Download
|
|
5
|
-
GEOJSON_DOWNLOAD_PARAMS = {
|
|
6
|
-
service: "wfs",
|
|
7
|
-
version: "2.0.0",
|
|
8
|
-
request: "GetFeature",
|
|
9
|
-
srsName: "EPSG:4326",
|
|
10
|
-
outputformat: "application/json"
|
|
11
|
-
}.freeze
|
|
12
|
-
|
|
13
|
-
def initialize(document, options = {})
|
|
14
|
-
request_params = GEOJSON_DOWNLOAD_PARAMS.merge(typeName: document.wxs_identifier)
|
|
15
|
-
super(document, {
|
|
16
|
-
type: "geojson",
|
|
17
|
-
extension: "geojson",
|
|
18
|
-
request_params: request_params,
|
|
19
|
-
content_type: "application/json",
|
|
20
|
-
service_type: "wfs"
|
|
21
|
-
}.merge(options))
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Geoblacklight
|
|
4
|
-
class GeotiffDownload < Geoblacklight::Download
|
|
5
|
-
GEOTIFF_DOWNLOAD_PARAMS = {
|
|
6
|
-
format: "image/geotiff",
|
|
7
|
-
width: 4096
|
|
8
|
-
}.freeze
|
|
9
|
-
|
|
10
|
-
def initialize(document, options = {})
|
|
11
|
-
request_params = GEOTIFF_DOWNLOAD_PARAMS.merge(layers: document.wxs_identifier)
|
|
12
|
-
super(document, {
|
|
13
|
-
type: "geotiff",
|
|
14
|
-
extension: "tif",
|
|
15
|
-
request_params: request_params,
|
|
16
|
-
content_type: "image/geotiff",
|
|
17
|
-
service_type: "wms",
|
|
18
|
-
reflect: true
|
|
19
|
-
}.merge(options))
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Geoblacklight
|
|
4
|
-
class KmzDownload < Geoblacklight::Download
|
|
5
|
-
KMZ_DOWNLOAD_PARAMS = {service: "wms",
|
|
6
|
-
version: "1.1.0",
|
|
7
|
-
request: "GetMap",
|
|
8
|
-
srsName: "EPSG:3857",
|
|
9
|
-
format: "application/vnd.google-earth.kmz",
|
|
10
|
-
width: 2000, height: 2000}.freeze
|
|
11
|
-
|
|
12
|
-
def initialize(document, options = {})
|
|
13
|
-
bbox_wsen = document.geometry.bounding_box
|
|
14
|
-
request_params = KMZ_DOWNLOAD_PARAMS.merge(layers: document.wxs_identifier, bbox: bbox_wsen)
|
|
15
|
-
super(document, {
|
|
16
|
-
type: "kmz",
|
|
17
|
-
extension: "kmz",
|
|
18
|
-
request_params: request_params,
|
|
19
|
-
content_type: "application/vnd.google-earth.kmz",
|
|
20
|
-
service_type: "wms"
|
|
21
|
-
}.merge(options))
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Geoblacklight
|
|
4
|
-
class ShapefileDownload < Geoblacklight::Download
|
|
5
|
-
SHAPEFILE_DOWNLOAD_PARAMS = {service: "wfs",
|
|
6
|
-
version: "2.0.0",
|
|
7
|
-
request: "GetFeature",
|
|
8
|
-
srsName: "EPSG:4326",
|
|
9
|
-
outputformat: "SHAPE-ZIP"}.freeze
|
|
10
|
-
|
|
11
|
-
def initialize(document, options = {})
|
|
12
|
-
request_params = SHAPEFILE_DOWNLOAD_PARAMS.merge(typeName: document.wxs_identifier)
|
|
13
|
-
super(document, {
|
|
14
|
-
type: "shapefile",
|
|
15
|
-
extension: "zip",
|
|
16
|
-
request_params: request_params,
|
|
17
|
-
content_type: "application/zip",
|
|
18
|
-
service_type: "wfs"
|
|
19
|
-
}.merge(options))
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Geoblacklight
|
|
4
|
-
class Download
|
|
5
|
-
def initialize(document, options = {})
|
|
6
|
-
@document = document
|
|
7
|
-
@options = options
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def downloadable?
|
|
11
|
-
@document.downloadable?
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def file_name
|
|
15
|
-
"#{@document.id}-#{@options[:type]}.#{@options[:extension]}"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.file_path
|
|
19
|
-
Geoblacklight.configuration.download_path
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def file_path_and_name
|
|
23
|
-
"#{self.class.file_path}/#{file_name}"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def download_exists?
|
|
27
|
-
File.file?(file_path_and_name)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def get
|
|
31
|
-
if download_exists?
|
|
32
|
-
file_name
|
|
33
|
-
else
|
|
34
|
-
create_download_file
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
##
|
|
39
|
-
# Creates temporary file on file system and renames it if download completes
|
|
40
|
-
# successfully. Will raise and rescue if the wrong file format is downloaded
|
|
41
|
-
# @return [String] filename of the completed download
|
|
42
|
-
def create_download_file
|
|
43
|
-
download = initiate_download
|
|
44
|
-
|
|
45
|
-
File.open("#{file_path_and_name}.tmp", "wb") do |file|
|
|
46
|
-
fail Geoblacklight::Exceptions::WrongDownloadFormat unless matches_mimetype?(download)
|
|
47
|
-
file.write download.body
|
|
48
|
-
end
|
|
49
|
-
File.rename("#{file_path_and_name}.tmp", file_path_and_name)
|
|
50
|
-
file_name
|
|
51
|
-
rescue Geoblacklight::Exceptions::WrongDownloadFormat => error
|
|
52
|
-
Geoblacklight.logger.error "#{error} expected #{@options[:content_type]} " \
|
|
53
|
-
"received #{download.headers["content-type"]}"
|
|
54
|
-
File.delete("#{file_path_and_name}.tmp")
|
|
55
|
-
raise Geoblacklight::Exceptions::ExternalDownloadFailed, message: "Wrong download type"
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
##
|
|
59
|
-
# Initiates download from a remote source url using the `request_params`.
|
|
60
|
-
# Will catch Faraday::ConnectionFailed and
|
|
61
|
-
# Faraday::TimeoutError
|
|
62
|
-
# @return [Faraday::Request] returns a Faraday::Request object
|
|
63
|
-
def initiate_download
|
|
64
|
-
conn = Faraday.new(url: url)
|
|
65
|
-
conn.get do |request|
|
|
66
|
-
request.params = @options[:request_params]
|
|
67
|
-
request.options.timeout = timeout
|
|
68
|
-
request.options.open_timeout = timeout
|
|
69
|
-
end
|
|
70
|
-
rescue Faraday::ConnectionFailed
|
|
71
|
-
raise Geoblacklight::Exceptions::ExternalDownloadFailed,
|
|
72
|
-
message: "Download connection failed",
|
|
73
|
-
url: conn.url_prefix.to_s
|
|
74
|
-
rescue Faraday::TimeoutError
|
|
75
|
-
raise Geoblacklight::Exceptions::ExternalDownloadFailed,
|
|
76
|
-
message: "Download timed out",
|
|
77
|
-
url: conn.url_prefix.to_s
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
##
|
|
81
|
-
# Creates a download url for the object
|
|
82
|
-
# @return [String]
|
|
83
|
-
def url_with_params
|
|
84
|
-
url + "/?" + URI.encode_www_form(@options[:request_params])
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
private
|
|
88
|
-
|
|
89
|
-
def matches_mimetype?(download)
|
|
90
|
-
MIME::Type.simplified(download.headers["content-type"]) == @options[:content_type]
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
##
|
|
94
|
-
# Returns timeout for the download request. `timeout` passed as an option to
|
|
95
|
-
# the Geoblacklight::Download class
|
|
96
|
-
# @return [Fixnum] download timeout in seconds
|
|
97
|
-
def timeout
|
|
98
|
-
@options[:timeout] || Geoblacklight.configuration.timeout_download
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
##
|
|
102
|
-
# URL for download
|
|
103
|
-
# @return [String] URL that is checked in download
|
|
104
|
-
def url
|
|
105
|
-
url = @document.references.public_send(@options[:service_type]).endpoint
|
|
106
|
-
url += "/reflect" if @options[:reflect]
|
|
107
|
-
url
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Geoblacklight
|
|
4
|
-
module Routes
|
|
5
|
-
class Downloadable
|
|
6
|
-
def initialize(defaults = {})
|
|
7
|
-
@defaults = defaults
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def call(mapper, _options = {})
|
|
11
|
-
mapper.get "file/:id", action: "file", as: :file
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|