commonwealth-vlr-engine 0.0.4 → 0.0.7
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 +2 -1
- data/app/assets/images/commonwealth-vlr-engine/vlr_mobile-icons_120x120.png +0 -0
- data/app/assets/images/commonwealth-vlr-engine/vlr_mobile-icons_152x152.png +0 -0
- data/app/assets/images/commonwealth-vlr-engine/vlr_mobile-icons_60x60.png +0 -0
- data/app/assets/images/commonwealth-vlr-engine/vlr_mobile-icons_76x76.png +0 -0
- data/app/assets/javascripts/blacklight_google_analytics/blacklight_google_analytics.js.erb +11 -0
- data/app/assets/javascripts/commonwealth-vlr-engine.js +3 -0
- data/app/assets/javascripts/commonwealth-vlr-engine/download_utils.js +4 -0
- data/app/assets/stylesheets/commonwealth-vlr-engine/commonwealth-vlr-engine.css +1 -0
- data/app/assets/stylesheets/commonwealth-vlr-engine/downloads.scss +18 -0
- data/app/assets/stylesheets/commonwealth-vlr-engine/facets.scss +64 -0
- data/app/assets/stylesheets/commonwealth-vlr-engine/vlr_dependencies.css +3 -1
- data/app/controllers/bookmarks_controller.rb +7 -2
- data/app/controllers/collections_controller.rb +1 -109
- data/app/controllers/concerns/commonwealth_vlr_engine/collections_controller_behavior.rb +132 -0
- data/app/controllers/concerns/commonwealth_vlr_engine/downloads_controller_behavior.rb +184 -0
- data/app/controllers/concerns/commonwealth_vlr_engine/institutions_controller_behavior.rb +70 -0
- data/app/controllers/downloads_controller.rb +4 -0
- data/app/controllers/iiif_manifest_controller.rb +2 -7
- data/app/controllers/image_viewer_controller.rb +3 -13
- data/app/controllers/institutions_controller.rb +1 -65
- data/app/controllers/ocr_search_controller.rb +1 -1
- data/app/controllers/saved_searches_controller.rb +2 -0
- data/app/controllers/search_history_controller.rb +2 -0
- data/app/helpers/commonwealth_vlr_engine/application_helper.rb +20 -2
- data/app/helpers/commonwealth_vlr_engine/catalog_helper.rb +36 -53
- data/app/helpers/commonwealth_vlr_engine/downloads_helper_behavior.rb +192 -0
- data/app/helpers/commonwealth_vlr_engine/facets_helper.rb +3 -1
- data/app/helpers/commonwealth_vlr_engine/ocr_search_helper_behavior.rb +5 -0
- data/app/helpers/commonwealth_vlr_engine/search_history_constraints_helper.rb +25 -0
- data/app/helpers/downloads_helper.rb +3 -0
- data/app/views/catalog/_add_this.html.erb +3 -1
- data/app/views/catalog/_folder_item_control.html.erb +2 -1
- data/app/views/catalog/_index_mapview.html.erb +9 -0
- data/app/views/catalog/_more_like_this.html.erb +1 -1
- data/app/views/catalog/_show_cite_tools.html.erb +3 -0
- data/app/views/catalog/_show_default.html.erb +13 -12
- data/app/views/catalog/_show_partials/_show_book_viewer_link.html.erb +1 -1
- data/app/views/catalog/_show_partials/_show_default_metadata.html.erb +3 -3
- data/app/views/catalog/_show_partials/_show_downloads.html.erb +1 -1
- data/app/views/catalog/_show_partials/_show_volumes.html.erb +1 -1
- data/app/views/catalog/_show_sharing_tools.html.erb +3 -0
- data/app/views/collections/show.html.erb +1 -0
- data/app/views/downloads/_terms_of_use.html.erb +29 -0
- data/app/views/downloads/show.html.erb +29 -0
- data/app/views/image_viewer/_render_book_viewer.html.erb +1 -1
- data/app/views/institutions/show.html.erb +2 -10
- data/app/views/layouts/commonwealth-vlr-engine.html.erb +1 -4
- data/app/views/ocr_search/_index_ocr_list.html.erb +3 -3
- data/app/views/shared/_mobile_icon_tags.html.erb +4 -0
- data/app/views/shared/_search_form_header.html.erb +1 -1
- data/app/views/shared/_tools.html.erb +5 -5
- data/commonwealth-vlr-engine.gemspec +8 -6
- data/config/initializers/patch_blacklight_advanced_search.rb +6 -6
- data/config/initializers/patch_blacklight_range_limit.rb +18 -0
- data/config/jetty.yml +1 -1
- data/config/locales/commonwealth-vlr-engine.en.yml +12 -0
- data/config/routes.rb +6 -0
- data/lib/commonwealth-vlr-engine.rb +1 -0
- data/lib/commonwealth-vlr-engine/controller.rb +18 -3
- data/lib/commonwealth-vlr-engine/controller_override.rb +79 -21
- data/lib/commonwealth-vlr-engine/engine.rb +1 -0
- data/lib/commonwealth-vlr-engine/render_constraints_override.rb +15 -14
- data/lib/commonwealth-vlr-engine/search_builder/collections_search_builder.rb +1 -1
- data/lib/commonwealth-vlr-engine/search_builder/commonwealth_search_builder_behavior.rb +13 -1
- data/lib/commonwealth-vlr-engine/search_builder/flagged_search_builder.rb +1 -1
- data/lib/commonwealth-vlr-engine/search_builder/institutions_search_builder.rb +1 -1
- data/lib/commonwealth-vlr-engine/search_builder/mlt_search_builder.rb +2 -1
- data/lib/commonwealth-vlr-engine/streaming.rb +50 -0
- data/lib/commonwealth-vlr-engine/version.rb +1 -1
- data/lib/generators/commonwealth_vlr_engine/routes_generator.rb +8 -0
- data/lib/generators/commonwealth_vlr_engine/templates/commonwealth_search_builder.rb +4 -3
- data/lib/generators/commonwealth_vlr_engine/templates/config/vlr.yml +3 -0
- data/solr_conf/conf/solrconfig.xml +42 -5
- data/spec/controllers/collections_controller_spec.rb +20 -0
- data/spec/controllers/downloads_controller_spec.rb +65 -0
- data/spec/controllers/image_viewer_controller_spec.rb +0 -18
- data/spec/controllers/institutions_controller_spec.rb +7 -0
- data/spec/features/advanced_search_date_range_spec.rb +36 -0
- data/spec/features/collections/index_spec.rb +6 -0
- data/spec/features/collections/show_spec.rb +38 -0
- data/spec/features/more_like_this_search_spec.rb +18 -1
- data/spec/fixtures/sample_solr_documents.yml +107 -19
- data/spec/helpers/application_helper_spec.rb +9 -2
- data/spec/helpers/catalog_helper_spec.rb +26 -42
- data/spec/helpers/downloads_helper_spec.rb +173 -0
- data/spec/helpers/ocr_search_helper_spec.rb +15 -7
- data/spec/helpers/range_limit_helper_spec.rb +20 -0
- data/spec/helpers/search_history_constraints_helper_spec.rb +39 -0
- data/spec/lib/commonwealth-vlr-engine/controller_override_spec.rb +37 -0
- data/spec/lib/commonwealth-vlr-engine/render_constraints_override_spec.rb +0 -10
- data/spec/lib/commonwealth-vlr-engine/search_builder/commonwealth_search_builder_behavior_spec.rb +21 -3
- data/spec/lib/commonwealth-vlr-engine/search_builder/mlt_search_builder_spec.rb +1 -1
- metadata +99 -12
- data/app/helpers/commonwealth_vlr_engine/component_helper.rb +0 -22
- data/app/views/catalog/_show_tools.html.erb +0 -42
- data/spec/helpers/component_helper_spec.rb +0 -34
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 080fbde6b3ffc26b744a723c8e6d47b3a5a5c1e3
|
|
4
|
+
data.tar.gz: 0003b8e33adcffa223a1a58e49aa5cef0b7e017e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7efc248209d8fa6bf744c1266d3db57d73c3aab18d18c64a531c349cd7e371e14c2f5a3debdd97b082af109a521e3898b192b3303f44a50c8ff3f2312138baea
|
|
7
|
+
data.tar.gz: c79fa6e0c8d619ab9c33a7ac81a01062a549e887f11269e487b26f1b3f29251fedc197429f14fef4edc4ae210eb8b45dab77c87e959c89581bb8fe2a9df5a4ba
|
data/README.md
CHANGED
|
@@ -42,5 +42,6 @@ The table below indicates which versions of Commonwealth-VLR-Engine are compatib
|
|
|
42
42
|
|
|
43
43
|
VLR-Engine version | works with Blacklight version
|
|
44
44
|
----------------------- | ---------------------
|
|
45
|
-
0.0.
|
|
45
|
+
0.0.7 | >= 6.3.0 to < 7.*
|
|
46
|
+
0.0.2 | >= 6.1.0 to < 6.3
|
|
46
47
|
0.0.1 | >= 5.14.0 to < 6.*
|
|
@@ -162,4 +162,15 @@ $(function() {
|
|
|
162
162
|
}
|
|
163
163
|
})
|
|
164
164
|
|
|
165
|
+
// start download button clicks
|
|
166
|
+
$("#downloads_start_links").find("a").off("click").click(function(){
|
|
167
|
+
try{
|
|
168
|
+
var action = 'trigger_download';
|
|
169
|
+
var label = $(this).attr('class').split(' ').pop();
|
|
170
|
+
ga('send', 'event', category, action, label);
|
|
171
|
+
} catch(err) {
|
|
172
|
+
BlacklightGoogleAnalytics.console_log_error(err, [category, action, label]);
|
|
173
|
+
}
|
|
174
|
+
})
|
|
175
|
+
|
|
165
176
|
});
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
// bootstrap-accessibility-plugin
|
|
18
18
|
//= require bootstrap-accessibility-plugin/bootstrap-accessibility
|
|
19
19
|
|
|
20
|
+
// blacklight_range_limit
|
|
21
|
+
//= require 'blacklight_range_limit'
|
|
22
|
+
|
|
20
23
|
// WARNING: require tree disabled to avoid heavy JS files such as modernizr, openseadragon, etc.
|
|
21
24
|
// from being automatically included on pages that don't need them
|
|
22
25
|
// WARNING: to require any further app-specific JS, you must use the 'require_directory' directive
|
|
@@ -75,6 +75,70 @@ body.blacklight-catalog-formats_facet {
|
|
|
75
75
|
font-size: 12px;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/* blacklight_range_limit */
|
|
79
|
+
.range_limit {
|
|
80
|
+
margin-bottom: 10px;
|
|
81
|
+
|
|
82
|
+
form.range_limit {
|
|
83
|
+
line-height: 2;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
input.range_begin, input.range_end {
|
|
87
|
+
height: 25px;
|
|
88
|
+
padding: 6px;
|
|
89
|
+
width: 46px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
input.submit {
|
|
93
|
+
height: 25px;
|
|
94
|
+
padding: 2px 6px 6px;
|
|
95
|
+
margin-left: 3px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.slider {
|
|
99
|
+
margin-left: 5px;
|
|
100
|
+
|
|
101
|
+
&.slider-horizontal {
|
|
102
|
+
|
|
103
|
+
& .slider-track {
|
|
104
|
+
height: 7px;
|
|
105
|
+
background-color: $light_gray;
|
|
106
|
+
background-image: linear-gradient(to bottom, #d9d9d9, $lighter_gray);
|
|
107
|
+
border-bottom: 1px solid #d9d9d9;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
& .slider-handle {
|
|
111
|
+
margin-left: -5px;
|
|
112
|
+
background-color: $dark_gray;
|
|
113
|
+
background-image: linear-gradient(to bottom, $dark_gray, $dark_gray)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.slider_js .slider-selection {
|
|
121
|
+
background-color: $light_gray;
|
|
122
|
+
box-shadow: none;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.slider-handle {
|
|
126
|
+
height: 15px;
|
|
127
|
+
width: 10px;
|
|
128
|
+
opacity: 1;
|
|
129
|
+
|
|
130
|
+
&.round {
|
|
131
|
+
border-radius: 5px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.distribution {
|
|
137
|
+
margin-left: -8px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
78
142
|
}
|
|
79
143
|
|
|
80
144
|
/* responsive styles */
|
|
@@ -5,4 +5,6 @@
|
|
|
5
5
|
@import 'bootstrap-accessibility-plugin/bootstrap-accessibility';
|
|
6
6
|
@import 'blacklight_advanced_search';
|
|
7
7
|
@import 'font-awesome';
|
|
8
|
-
@import 'openseadragon';
|
|
8
|
+
@import 'openseadragon';
|
|
9
|
+
@import 'blacklight_range_limit/blacklight_range_limit';
|
|
10
|
+
@import 'slider'; /* blacklight_range_limit */
|
|
@@ -19,7 +19,7 @@ class BookmarksController < CatalogController
|
|
|
19
19
|
|
|
20
20
|
if request.xhr?
|
|
21
21
|
# success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count }}) : render(:text => "", :status => "500")
|
|
22
|
-
success ? render(:update) : render(:
|
|
22
|
+
success ? render(:update) : render(plain: '', status: '500')
|
|
23
23
|
else
|
|
24
24
|
if @bookmarks.any? && success
|
|
25
25
|
flash[:notice] = I18n.t('blacklight.bookmarks.add.success', :count => @bookmarks.length)
|
|
@@ -27,7 +27,12 @@ class BookmarksController < CatalogController
|
|
|
27
27
|
flash[:error] = I18n.t('blacklight.bookmarks.add.failure', :count => @bookmarks.length)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
if respond_to? :redirect_back
|
|
31
|
+
redirect_back fallback_location: bookmarks_path
|
|
32
|
+
else
|
|
33
|
+
# Deprecated in Rails 5.0
|
|
34
|
+
redirect_to :back
|
|
35
|
+
end
|
|
31
36
|
end
|
|
32
37
|
end
|
|
33
38
|
|
|
@@ -1,112 +1,4 @@
|
|
|
1
1
|
class CollectionsController < CatalogController
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
# Give CollectionsController access to the CatalogController configuration
|
|
5
|
-
include Blacklight::Configurable
|
|
6
|
-
include Blacklight::SearchHelper
|
|
7
|
-
|
|
8
|
-
copy_blacklight_config_from(CatalogController)
|
|
9
|
-
|
|
10
|
-
# remove collection facet and collapse others
|
|
11
|
-
before_filter :relation_base_blacklight_config, :only => [:index, :show]
|
|
12
|
-
before_filter :add_series_facet, :only => :show
|
|
13
|
-
before_filter :collections_limit, :only => [:index, :facet]
|
|
14
|
-
before_filter :collapse_institution_facet, :only => :index
|
|
15
|
-
|
|
16
|
-
# Blacklight uses #search_action_url to figure out the right URL for
|
|
17
|
-
# the global search box
|
|
18
|
-
def search_action_url options = {}
|
|
19
|
-
search_catalog_url(options.except(:controller, :action))
|
|
20
|
-
end
|
|
21
|
-
helper_method :search_action_url
|
|
22
|
-
|
|
23
|
-
def index
|
|
24
|
-
@nav_li_active = 'explore'
|
|
25
|
-
(@response, @document_list) = search_results(params)
|
|
26
|
-
params[:view] = 'list'
|
|
27
|
-
params[:sort] = 'title_info_primary_ssort asc'
|
|
28
|
-
|
|
29
|
-
respond_to do |format|
|
|
30
|
-
format.html
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def show
|
|
35
|
-
@nav_li_active = 'explore'
|
|
36
|
-
@show_response, @document = fetch(params[:id])
|
|
37
|
-
@collection_title = @document[blacklight_config.index.title_field.to_sym]
|
|
38
|
-
|
|
39
|
-
# add params[:f] for proper facet links
|
|
40
|
-
params[:f] = set_collection_facet_params(@collection_title, @document)
|
|
41
|
-
|
|
42
|
-
# get the response for the facets representing items in collection
|
|
43
|
-
(@response, @document_list) = search_results({:f => params[:f]})
|
|
44
|
-
|
|
45
|
-
# get an image for the collection
|
|
46
|
-
if @document[:exemplary_image_ssi]
|
|
47
|
-
@collection_image_pid = @document[:exemplary_image_ssi]
|
|
48
|
-
@collection_image_info = get_collection_image_info(@collection_image_pid,
|
|
49
|
-
@document[:id])
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
respond_to do |format|
|
|
53
|
-
format.html
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
private
|
|
59
|
-
|
|
60
|
-
# show series facet
|
|
61
|
-
def add_series_facet
|
|
62
|
-
blacklight_config.facet_fields['related_item_series_ssim'].include_in_request = true
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# collapse the institution facet, if Institutions supported
|
|
66
|
-
def collapse_institution_facet
|
|
67
|
-
return unless t('blacklight.home.browse.institutions.enabled')
|
|
68
|
-
blacklight_config.facet_fields['physical_location_ssim'].collapse = true
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# filter out non-collection items
|
|
72
|
-
def collections_limit
|
|
73
|
-
blacklight_config.search_builder_class = CommonwealthCollectionsSearchBuilder
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# find the title and pid for the object representing the collection image
|
|
77
|
-
def get_collection_image_info(image_pid, collection_pid)
|
|
78
|
-
col_img_info = {title: '', pid: collection_pid, access_master: false}
|
|
79
|
-
col_img_file_doc = fetch(image_pid)[1]
|
|
80
|
-
if col_img_file_doc
|
|
81
|
-
col_img_info[:access_master] = true if col_img_file_doc[:is_image_of_ssim]
|
|
82
|
-
col_img_field = col_img_file_doc[:is_image_of_ssim].presence || col_img_file_doc[:is_file_of_ssim].presence
|
|
83
|
-
if col_img_field
|
|
84
|
-
col_img_obj_pid = col_img_field.first.gsub(/info:fedora\//,'')
|
|
85
|
-
col_img_obj_doc = fetch(col_img_obj_pid)[1]
|
|
86
|
-
if col_img_obj_doc
|
|
87
|
-
col_img_info[:title] = col_img_obj_doc[blacklight_config.index.title_field.to_sym]
|
|
88
|
-
col_img_info[:pid] = col_img_obj_pid
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
col_img_info
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# find a representative image/item for a series
|
|
96
|
-
def get_series_image_obj(series_title,collection_title)
|
|
97
|
-
blacklight_config.search_builder_class = CommonwealthFlaggedSearchBuilder # ignore flagged items
|
|
98
|
-
series_doc_list = search_results({f: {'related_item_series_ssim' => series_title,
|
|
99
|
-
blacklight_config.collection_field => collection_title},
|
|
100
|
-
rows: 1})[1]
|
|
101
|
-
series_doc_list.first
|
|
102
|
-
end
|
|
103
|
-
helper_method :get_series_image_obj
|
|
104
|
-
|
|
105
|
-
# set the correct facet params for facets from the collection
|
|
106
|
-
def set_collection_facet_params(collection_title, document)
|
|
107
|
-
facet_params = {blacklight_config.collection_field => [collection_title]}
|
|
108
|
-
facet_params[blacklight_config.institution_field] = document[blacklight_config.institution_field.to_sym] if t('blacklight.home.browse.institutions.enabled')
|
|
109
|
-
facet_params
|
|
110
|
-
end
|
|
2
|
+
include CommonwealthVlrEngine::CollectionsControllerBehavior
|
|
111
3
|
|
|
112
4
|
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
module CommonwealthVlrEngine
|
|
2
|
+
module CollectionsControllerBehavior
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
##
|
|
5
|
+
# Give CollectionsController access to the CatalogController configuration
|
|
6
|
+
include Blacklight::Configurable
|
|
7
|
+
include Blacklight::SearchHelper
|
|
8
|
+
|
|
9
|
+
included do
|
|
10
|
+
copy_blacklight_config_from(CatalogController)
|
|
11
|
+
|
|
12
|
+
# remove collection facet and collapse others
|
|
13
|
+
before_filter :relation_base_blacklight_config, :only => [:index, :show]
|
|
14
|
+
before_filter :add_series_facet, :only => :show
|
|
15
|
+
before_filter :collections_limit, :only => :index
|
|
16
|
+
before_filter :collections_limit_for_facets, :only => :facet
|
|
17
|
+
before_filter :collapse_institution_facet, :only => :index
|
|
18
|
+
|
|
19
|
+
helper_method :search_action_url
|
|
20
|
+
helper_method :get_series_image_obj
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def index
|
|
24
|
+
@nav_li_active = 'explore'
|
|
25
|
+
(@response, @document_list) = search_results(params)
|
|
26
|
+
params[:view] = 'list'
|
|
27
|
+
params[:sort] = 'title_info_primary_ssort asc'
|
|
28
|
+
|
|
29
|
+
respond_to do |format|
|
|
30
|
+
format.html
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def show
|
|
35
|
+
@nav_li_active = 'explore'
|
|
36
|
+
@show_response, @document = fetch(params[:id])
|
|
37
|
+
@collection_title = @document[blacklight_config.index.title_field.to_sym]
|
|
38
|
+
|
|
39
|
+
# add params[:f] for proper facet links
|
|
40
|
+
params[:f] = set_collection_facet_params(@collection_title, @document)
|
|
41
|
+
|
|
42
|
+
# get the response for the facets representing items in collection
|
|
43
|
+
(@response, @document_list) = search_results({:f => params[:f]})
|
|
44
|
+
|
|
45
|
+
# get an image for the collection
|
|
46
|
+
if @document[:exemplary_image_ssi]
|
|
47
|
+
@collection_image_pid = @document[:exemplary_image_ssi]
|
|
48
|
+
@collection_image_info = get_collection_image_info(@collection_image_pid,
|
|
49
|
+
@document[:id])
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
respond_to do |format|
|
|
53
|
+
format.html
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def range_limit
|
|
59
|
+
redirect_to range_limit_catalog_path(params.except('controller', 'action')) and return
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
protected
|
|
63
|
+
|
|
64
|
+
# Blacklight uses #search_action_url to figure out the right URL for the global search box
|
|
65
|
+
def search_action_url options = {}
|
|
66
|
+
search_catalog_url(options.except(:controller, :action))
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# find a representative image/item for a series
|
|
70
|
+
def get_series_image_obj(series_title,collection_title)
|
|
71
|
+
blacklight_config.search_builder_class = CommonwealthFlaggedSearchBuilder # ignore flagged items
|
|
72
|
+
series_doc_list = search_results({f: {'related_item_series_ssim' => series_title,
|
|
73
|
+
blacklight_config.collection_field => collection_title},
|
|
74
|
+
rows: 1})[1]
|
|
75
|
+
series_doc_list.first
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# show series facet
|
|
79
|
+
def add_series_facet
|
|
80
|
+
blacklight_config.facet_fields['related_item_series_ssim'].include_in_request = true
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# collapse the institution facet, if Institutions supported
|
|
84
|
+
def collapse_institution_facet
|
|
85
|
+
return unless t('blacklight.home.browse.institutions.enabled')
|
|
86
|
+
blacklight_config.facet_fields['physical_location_ssim'].collapse = true
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# find only collection objects
|
|
90
|
+
def collections_limit
|
|
91
|
+
blacklight_config.search_builder_class = CommonwealthCollectionsSearchBuilder
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# find object data for facet results
|
|
95
|
+
# collections#facet can be called within BOTH collections#index and collections#show contexts
|
|
96
|
+
# when collections#index, want to limit to collection objects
|
|
97
|
+
# when collections#show, should be objects that are child of collection
|
|
98
|
+
# so we use the check below, since request.query_parameters['f'] is only added in collections#show
|
|
99
|
+
# via set_collection_facet_params
|
|
100
|
+
def collections_limit_for_facets
|
|
101
|
+
unless request.query_parameters['f'] && request.query_parameters['f'][blacklight_config.collection_field]
|
|
102
|
+
self.collections_limit
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# find the title and pid for the object representing the collection image
|
|
107
|
+
def get_collection_image_info(image_pid, collection_pid)
|
|
108
|
+
col_img_info = {title: '', pid: collection_pid, access_master: false}
|
|
109
|
+
col_img_file_doc = fetch(image_pid)[1]
|
|
110
|
+
if col_img_file_doc
|
|
111
|
+
col_img_info[:access_master] = true if col_img_file_doc[:is_image_of_ssim]
|
|
112
|
+
col_img_field = col_img_file_doc[:is_image_of_ssim].presence || col_img_file_doc[:is_file_of_ssim].presence
|
|
113
|
+
if col_img_field
|
|
114
|
+
col_img_obj_pid = col_img_field.first.gsub(/info:fedora\//,'')
|
|
115
|
+
col_img_obj_doc = fetch(col_img_obj_pid)[1]
|
|
116
|
+
if col_img_obj_doc
|
|
117
|
+
col_img_info[:title] = col_img_obj_doc[blacklight_config.index.title_field.to_sym]
|
|
118
|
+
col_img_info[:pid] = col_img_obj_pid
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
col_img_info
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# set the correct facet params for facets from the collection
|
|
126
|
+
def set_collection_facet_params(collection_title, document)
|
|
127
|
+
facet_params = {blacklight_config.collection_field => [collection_title]}
|
|
128
|
+
facet_params[blacklight_config.institution_field] = document[blacklight_config.institution_field.to_sym] if t('blacklight.home.browse.institutions.enabled')
|
|
129
|
+
facet_params
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# heavily based on Hydra::Controller::DownloadBehavior
|
|
2
|
+
module CommonwealthVlrEngine
|
|
3
|
+
module DownloadsControllerBehavior
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
include Blacklight::Catalog
|
|
7
|
+
include CommonwealthVlrEngine::Streaming
|
|
8
|
+
include CommonwealthVlrEngine::ApplicationHelper
|
|
9
|
+
include CommonwealthVlrEngine::Finder
|
|
10
|
+
# for some reason have to require AND include Zipline, or you get errors
|
|
11
|
+
require 'zipline'
|
|
12
|
+
include Zipline
|
|
13
|
+
require 'open-uri'
|
|
14
|
+
|
|
15
|
+
included do
|
|
16
|
+
copy_blacklight_config_from(CatalogController)
|
|
17
|
+
helper_method :search_action_url
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# render a page/modal with license terms, download links, etc
|
|
21
|
+
def show
|
|
22
|
+
@doc_response, @document = fetch(params[:id])
|
|
23
|
+
if @document[:has_model_ssim].include? 'info:fedora/afmodel:Bplmodels_File'
|
|
24
|
+
parent_response, @parent_document = fetch(parent_id(@document))
|
|
25
|
+
@object_profile = JSON.parse(@document['object_profile_ssm'].first)
|
|
26
|
+
else
|
|
27
|
+
@parent_document = @document
|
|
28
|
+
@object_profile = nil
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
respond_to do |format|
|
|
32
|
+
format.html # for users w/o JS
|
|
33
|
+
format.js { render :layout => false } # download modal window
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# initiates the file download
|
|
38
|
+
def trigger_download
|
|
39
|
+
response, @solr_document = fetch(params[:id])
|
|
40
|
+
if !@solr_document.to_h.empty? && params[:datastream_id]
|
|
41
|
+
if @solr_document[:has_model_ssim].include? 'info:fedora/afmodel:Bplmodels_File'
|
|
42
|
+
@object_id = parent_id(@solr_document)
|
|
43
|
+
send_content
|
|
44
|
+
elsif @solr_document[:has_model_ssim].include? 'info:fedora/afmodel:Bplmodels_ObjectBase'
|
|
45
|
+
@file_list = get_image_files(params[:id])
|
|
46
|
+
if !@file_list.empty?
|
|
47
|
+
@object_id = params[:id]
|
|
48
|
+
send_zipped_content
|
|
49
|
+
else
|
|
50
|
+
not_found
|
|
51
|
+
end
|
|
52
|
+
else
|
|
53
|
+
not_found
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
protected
|
|
59
|
+
|
|
60
|
+
# Blacklight uses #search_action_url to figure out the right URL for
|
|
61
|
+
# the global search box
|
|
62
|
+
def search_action_url options = {}
|
|
63
|
+
search_catalog_url(options.except(:controller, :action))
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Handle the HTTP show request
|
|
67
|
+
def send_content
|
|
68
|
+
response.headers['Accept-Ranges'] = 'bytes'
|
|
69
|
+
if request.head?
|
|
70
|
+
content_head
|
|
71
|
+
elsif request.headers['HTTP_RANGE']
|
|
72
|
+
send_range
|
|
73
|
+
else
|
|
74
|
+
send_file_contents
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# send multiple files as a zip archive
|
|
79
|
+
def send_zipped_content
|
|
80
|
+
files_array = []
|
|
81
|
+
@file_list.each_with_index do |file,index|
|
|
82
|
+
params[:id] = file[:id] # hack this so file_url returns correct value
|
|
83
|
+
@solr_document = file
|
|
84
|
+
files_array << [file_url, "#{(index+1).to_s}_#{file_name_with_extension}"]
|
|
85
|
+
end
|
|
86
|
+
file_mappings = files_array.lazy.map { |url, path| [open(url), path] }
|
|
87
|
+
zipline(file_mappings, "#{file_name}.zip")
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# render an HTTP HEAD response
|
|
91
|
+
def content_head
|
|
92
|
+
response.headers['Content-Length'] = file_size if file_size
|
|
93
|
+
head :ok, content_type: mime_type
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Create some headers for the datastream
|
|
97
|
+
def content_options
|
|
98
|
+
{ disposition: 'attachment', type: mime_type, filename: file_name_with_extension }
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# returns a Fedora datastream url or IIIF url
|
|
102
|
+
def file_url
|
|
103
|
+
if params[:datastream_id] == 'accessFull'
|
|
104
|
+
iiif_image_url(params[:id], {})
|
|
105
|
+
else
|
|
106
|
+
datastream_disseminator_url(params[:id], params[:datastream_id])
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def file_extension
|
|
111
|
+
if params[:datastream_id] =~ /Master/
|
|
112
|
+
JSON.parse(@solr_document[:object_profile_ssm].first)["objLabel"].split('.')[1]
|
|
113
|
+
else
|
|
114
|
+
'jpg'
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# @return [String] the filename
|
|
119
|
+
def file_name
|
|
120
|
+
"#{@object_id}_#{params[:datastream_id]}"
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# @return [String] the filename with extension
|
|
124
|
+
def file_name_with_extension
|
|
125
|
+
"#{file_name}.#{file_extension}"
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def file_size
|
|
129
|
+
return false if params[:datastream_id] == 'accessFull'
|
|
130
|
+
JSON.parse(@solr_document[:object_profile_ssm].first)["datastreams"][params[:datastream_id]]["dsSize"]
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def mime_type
|
|
134
|
+
if params[:datastream_id] =~ /Master/
|
|
135
|
+
@solr_document[:mime_type_tesim].first
|
|
136
|
+
else
|
|
137
|
+
'image/jpeg'
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def prepare_file_headers
|
|
142
|
+
send_file_headers! content_options
|
|
143
|
+
response.headers['Content-Type'] = mime_type
|
|
144
|
+
response.headers['Content-Length'] ||= file_size.to_s if file_size
|
|
145
|
+
# Prevent Rack::ETag from calculating a digest over body
|
|
146
|
+
response.headers['Last-Modified'] = Time.new(@solr_document[:system_modified_dtsi]).utc.strftime("%a, %d %b %Y %T GMT")
|
|
147
|
+
self.content_type = mime_type
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def send_file_contents
|
|
151
|
+
self.status = 200
|
|
152
|
+
prepare_file_headers
|
|
153
|
+
stream_body file_stream(file_url)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# render an HTTP Range response
|
|
157
|
+
def send_range
|
|
158
|
+
_, range = request.headers['HTTP_RANGE'].split('bytes=')
|
|
159
|
+
from, to = range.split('-').map(&:to_i)
|
|
160
|
+
to = file_size.to_i - 1 unless to
|
|
161
|
+
length = to - from + 1
|
|
162
|
+
response.headers['Content-Range'] = "bytes #{from}-#{to}/#{file_size}"
|
|
163
|
+
response.headers['Content-Length'] = "#{length}"
|
|
164
|
+
self.status = 206
|
|
165
|
+
prepare_file_headers
|
|
166
|
+
stream_body file_stream(file_url, request.headers['HTTP_RANGE'])
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
private
|
|
170
|
+
|
|
171
|
+
def parent_id(document)
|
|
172
|
+
document[:is_file_of_ssim].first.gsub(/info:fedora\//,'')
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def stream_body(iostream)
|
|
176
|
+
iostream.each do |in_buff|
|
|
177
|
+
response.stream.write in_buff
|
|
178
|
+
end
|
|
179
|
+
ensure
|
|
180
|
+
response.stream.close
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
end
|
|
184
|
+
end
|