geoblacklight 0.12.1 → 1.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +8 -0
  3. data/.jshintignore +2 -0
  4. data/.jshintrc +67 -0
  5. data/.rubocop.yml +29 -3
  6. data/Gemfile +20 -16
  7. data/README.md +1 -0
  8. data/Rakefile +3 -2
  9. data/app/assets/javascripts/geoblacklight/basemaps.js +0 -9
  10. data/app/assets/javascripts/geoblacklight/controls.js +1 -0
  11. data/app/assets/javascripts/geoblacklight/controls/opacity.js +8 -0
  12. data/app/assets/javascripts/geoblacklight/geoblacklight.js +3 -2
  13. data/app/assets/javascripts/geoblacklight/viewers.js +1 -1
  14. data/app/assets/javascripts/geoblacklight/viewers/esri.js +2 -3
  15. data/app/assets/javascripts/geoblacklight/viewers/esri/dynamic_map_layer.js +2 -2
  16. data/app/assets/javascripts/geoblacklight/viewers/esri/feature_layer.js +1 -5
  17. data/app/assets/javascripts/geoblacklight/viewers/iiif.js +1 -1
  18. data/app/assets/javascripts/geoblacklight/viewers/map.js +1 -9
  19. data/app/assets/javascripts/geoblacklight/viewers/viewer.js +42 -1
  20. data/app/assets/javascripts/geoblacklight/viewers/wms.js +1 -1
  21. data/app/assets/stylesheets/geoblacklight/modules/toolbar.scss +4 -0
  22. data/app/helpers/geoblacklight_helper.rb +28 -14
  23. data/app/models/concerns/geoblacklight/solr_document.rb +20 -11
  24. data/{lib/geoblacklight/search_builder.rb → app/models/concerns/geoblacklight/spatial_search_behavior.rb} +6 -8
  25. data/app/presenters/geoblacklight/document_presenter.rb +14 -7
  26. data/app/views/catalog/_document_split.html.erb +1 -1
  27. data/app/views/catalog/_downloads.html.erb +46 -38
  28. data/app/views/catalog/_facet_tag_item.html.erb +1 -1
  29. data/app/views/catalog/_facet_tag_layout.html.erb +1 -1
  30. data/app/views/catalog/_header_icons.html.erb +3 -0
  31. data/app/views/catalog/_home_text.html.erb +5 -5
  32. data/app/views/catalog/_index_split_default.html.erb +5 -7
  33. data/app/views/catalog/_search_form_no_navbar.html.erb +2 -2
  34. data/app/views/catalog/_show_default_viewer_container.html.erb +2 -2
  35. data/app/views/catalog/_show_header_default.html.erb +1 -3
  36. data/app/views/catalog/_web_services_wfs.html.erb +1 -1
  37. data/app/views/catalog/_web_services_wms.html.erb +1 -1
  38. data/config/jetty.yml +1 -1
  39. data/config/locales/geoblacklight.en.yml +1 -0
  40. data/geoblacklight.gemspec +4 -4
  41. data/lib/generators/geoblacklight/install_generator.rb +34 -3
  42. data/lib/generators/geoblacklight/templates/catalog_controller.rb +36 -31
  43. data/lib/generators/geoblacklight/templates/config/jetty.yml +1 -1
  44. data/lib/generators/geoblacklight/templates/geoblacklight.js +1 -0
  45. data/lib/generators/geoblacklight/templates/{geoblacklight.css.scss → geoblacklight.scss} +0 -0
  46. data/lib/generators/geoblacklight/templates/settings.yml +42 -2
  47. data/lib/geoblacklight.rb +1 -2
  48. data/lib/geoblacklight/constants.rb +1 -1
  49. data/lib/geoblacklight/download.rb +8 -7
  50. data/lib/geoblacklight/download/geojson_download.rb +1 -1
  51. data/lib/geoblacklight/download/geotiff_download.rb +1 -1
  52. data/lib/geoblacklight/download/kmz_download.rb +1 -1
  53. data/lib/geoblacklight/download/shapefile_download.rb +1 -1
  54. data/lib/geoblacklight/geoblacklight_helper_behavior.rb +4 -10
  55. data/lib/geoblacklight/metadata.rb +3 -6
  56. data/lib/geoblacklight/references.rb +2 -2
  57. data/lib/geoblacklight/routes.rb +3 -17
  58. data/lib/geoblacklight/routes/downloadable.rb +14 -0
  59. data/lib/geoblacklight/routes/exportable.rb +16 -0
  60. data/lib/geoblacklight/routes/wms.rb +13 -0
  61. data/lib/geoblacklight/version.rb +1 -1
  62. data/spec/controllers/catalog_controller_spec.rb +1 -1
  63. data/spec/controllers/download_controller_spec.rb +7 -1
  64. data/spec/features/bookmarks_spec.rb +1 -1
  65. data/spec/features/configurable_basemap_spec.rb +9 -8
  66. data/spec/features/download_layer_spec.rb +33 -15
  67. data/spec/features/esri_viewer_spec.rb +9 -8
  68. data/spec/features/exports_spec.rb +3 -3
  69. data/spec/features/home_page_spec.rb +1 -1
  70. data/spec/features/iiif_viewer_spec.rb +1 -1
  71. data/spec/features/layer_inspection_spec.rb +2 -2
  72. data/spec/features/layer_opacity_spec.rb +7 -2
  73. data/spec/features/layer_preview_spec.rb +2 -2
  74. data/spec/features/metadata_panel_spec.rb +3 -3
  75. data/spec/features/saved_searches_spec.rb +1 -1
  76. data/spec/features/search_bar_spec.rb +2 -2
  77. data/spec/features/show_page_metadata_spec.rb +1 -1
  78. data/spec/features/split_view.html.erb_spec.rb +6 -5
  79. data/spec/features/web_services_modal_spec.rb +3 -3
  80. data/spec/helpers/geoblacklight_helpers_spec.rb +71 -3
  81. data/spec/lib/geoblacklight/document_presenter_spec.rb +41 -13
  82. data/spec/lib/geoblacklight/download_spec.rb +9 -1
  83. data/spec/lib/geoblacklight/geoblacklight_helper_behavior_spec.rb +12 -9
  84. data/spec/lib/geoblacklight/item_viewer_spec.rb +4 -3
  85. data/spec/lib/geoblacklight/references_spec.rb +22 -18
  86. data/spec/lib/geoblacklight/view_helper_override_spec.rb +1 -1
  87. data/spec/lib/geoblacklight/wms_layer/feature_info_response_spec.rb +1 -1
  88. data/spec/lib/geoblacklight/wms_layer_spec.rb +1 -1
  89. data/spec/models/concerns/geoblacklight/solr_document/carto_db_spec.rb +7 -1
  90. data/spec/models/concerns/geoblacklight/solr_document_spec.rb +34 -11
  91. data/spec/{lib/geoblacklight/search_builder_spec.rb → models/concerns/geoblacklight/spatial_search_behavior_spec.rb} +10 -15
  92. data/spec/spec_helper.rb +6 -6
  93. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  94. metadata +25 -22
@@ -21,21 +21,19 @@ class CatalogController < ApplicationController
21
21
  :q => '{!raw f=layer_slug_s v=$id}'
22
22
  }
23
23
 
24
- config.search_builder_class = Geoblacklight::SearchBuilder
25
-
26
24
  # solr field configuration for search results/index views
27
25
  # config.index.show_link = 'title_display'
28
26
  # config.index.record_display_type = 'format'
29
27
 
30
- config.index.title_field = 'dc_title_s'
28
+ config.index.title_field = Settings.FIELDS.TITLE
31
29
 
32
30
  # solr field configuration for document/show views
33
31
 
34
32
  config.show.display_type_field = 'format'
35
33
 
36
- # Custom GeoBlacklight fields which currently map to GeoBlacklight-Schema
37
- # v0.3.2
38
- config.wxs_identifier_field = 'layer_id_s'
34
+ ##
35
+ # Configure the index document presenter.
36
+ config.index.document_presenter_class = Geoblacklight::DocumentPresenter
39
37
 
40
38
  # solr fields that will be treated as facets by the blacklight application
41
39
  # The ordering of the field names is the order of the display
@@ -72,18 +70,18 @@ class CatalogController < ApplicationController
72
70
  # :years_25 => { :label => 'within 25 Years', :fq => "pub_date:[#{Time.now.year - 25 } TO *]" }
73
71
  # }
74
72
 
75
- config.add_facet_field 'dct_provenance_s', label: 'Institution', limit: 8, partial: "icon_facet"
76
- config.add_facet_field 'dc_creator_sm', :label => 'Author', :limit => 8
77
- config.add_facet_field 'dc_publisher_s', :label => 'Publisher', :limit => 8
78
- config.add_facet_field 'dc_subject_sm', :label => 'Subject', :limit => 8
79
- config.add_facet_field 'dct_spatial_sm', :label => 'Place', :limit => 8
80
- config.add_facet_field 'dct_isPartOf_sm', :label => 'Collection', :limit => 8
73
+ config.add_facet_field Settings.FIELDS.PROVENANCE, label: 'Institution', limit: 8, partial: "icon_facet"
74
+ config.add_facet_field Settings.FIELDS.CREATOR, :label => 'Author', :limit => 8
75
+ config.add_facet_field Settings.FIELDS.PUBLISHER, :label => 'Publisher', :limit => 8
76
+ config.add_facet_field Settings.FIELDS.SUBJECT, :label => 'Subject', :limit => 8
77
+ config.add_facet_field Settings.FIELDS.SPATIAL_COVERAGE, :label => 'Place', :limit => 8
78
+ config.add_facet_field Settings.FIELDS.PART_OF, :label => 'Collection', :limit => 8
81
79
 
82
- config.add_facet_field 'solr_year_i', :label => 'Year', :limit => 10
80
+ config.add_facet_field Settings.FIELDS.YEAR, :label => 'Year', :limit => 10
83
81
 
84
- config.add_facet_field 'dc_rights_s', label: 'Access', limit: 8, partial: "icon_facet"
85
- config.add_facet_field 'layer_geom_type_s', label: 'Data type', limit: 8, partial: "icon_facet"
86
- config.add_facet_field 'dc_format_s', :label => 'Format', :limit => 8
82
+ config.add_facet_field Settings.FIELDS.RIGHTS, label: 'Access', limit: 8, partial: "icon_facet"
83
+ config.add_facet_field Settings.FIELDS.GEOM_TYPE, label: 'Data type', limit: 8, partial: "icon_facet"
84
+ config.add_facet_field Settings.FIELDS.FILE_FORMAT, :label => 'Format', :limit => 8
87
85
 
88
86
  # Have BL send all facet field names to Solr, which has been the default
89
87
  # previously. Simply remove these lines if you'd rather use Solr request
@@ -103,10 +101,14 @@ class CatalogController < ApplicationController
103
101
  # config.add_index_field 'lc_callnum_display', :label => 'Call number:'
104
102
 
105
103
  # config.add_index_field 'dc_title_t', :label => 'Display Name:'
106
- # config.add_index_field 'dct_provenance_s', :label => 'Institution:'
107
- # config.add_index_field 'dc_rights_s', :label => 'Access:'
104
+ # config.add_index_field Settings.FIELDS.PROVENANCE, :label => 'Institution:'
105
+ # config.add_index_field Settings.FIELDS.RIGHTS, :label => 'Access:'
108
106
  # # config.add_index_field 'Area', :label => 'Area:'
109
- # config.add_index_field 'dc_subject_sm', :label => 'Keywords:'
107
+ # config.add_index_field Settings.FIELDS.SUBJECT, :label => 'Keywords:'
108
+ config.add_index_field Settings.FIELDS.YEAR
109
+ config.add_index_field Settings.FIELDS.CREATOR
110
+ config.add_index_field Settings.FIELDS.DESCRIPTION, helper_method: :snippit
111
+ config.add_index_field Settings.FIELDS.PUBLISHER
110
112
 
111
113
 
112
114
 
@@ -116,14 +118,14 @@ class CatalogController < ApplicationController
116
118
  # item_prop: [String] property given to span with Schema.org item property
117
119
  # link_to_search: [Boolean] that can be passed to link to a facet search
118
120
  # helper_method: [Symbol] method that can be used to render the value
119
- config.add_show_field 'dc_creator_sm', label: 'Author(s)', itemprop: 'author'
120
- config.add_show_field 'dc_description_s', label: 'Description', itemprop: 'description', helper_method: :render_value_as_truncate_abstract
121
- config.add_show_field 'dc_publisher_s', label: 'Publisher', itemprop: 'publisher'
122
- config.add_show_field 'dct_isPartOf_sm', label: 'Collection', itemprop: 'isPartOf'
123
- config.add_show_field 'dct_spatial_sm', label: 'Place(s)', itemprop: 'spatial', link_to_search: true
124
- config.add_show_field 'dc_subject_sm', label: 'Subject(s)', itemprop: 'keywords', link_to_search: true
125
- config.add_show_field 'dct_temporal_sm', label: 'Year', itemprop: 'temporal'
126
- config.add_show_field 'dct_provenance_s', label: 'Held by', link_to_search: true
121
+ config.add_show_field Settings.FIELDS.CREATOR, label: 'Author(s)', itemprop: 'author'
122
+ config.add_show_field Settings.FIELDS.DESCRIPTION, label: 'Description', itemprop: 'description', helper_method: :render_value_as_truncate_abstract
123
+ config.add_show_field Settings.FIELDS.PUBLISHER, label: 'Publisher', itemprop: 'publisher'
124
+ config.add_show_field Settings.FIELDS.PART_OF, label: 'Collection', itemprop: 'isPartOf'
125
+ config.add_show_field Settings.FIELDS.SPATIAL_COVERAGE, label: 'Place(s)', itemprop: 'spatial', link_to_search: true
126
+ config.add_show_field Settings.FIELDS.SUBJECT, label: 'Subject(s)', itemprop: 'keywords', link_to_search: true
127
+ config.add_show_field Settings.FIELDS.TEMPORAL, label: 'Year', itemprop: 'temporal'
128
+ config.add_show_field Settings.FIELDS.PROVENANCE, label: 'Held by', link_to_search: true
127
129
 
128
130
  # "fielded" search configuration. Used by pulldown among other places.
129
131
  # For supported keys in hash, see rdoc for Blacklight::SearchFields
@@ -198,8 +200,8 @@ class CatalogController < ApplicationController
198
200
  # whether the sort is ascending or descending (it must be asc or desc
199
201
  # except in the relevancy case).
200
202
  config.add_sort_field 'score desc, dc_title_sort asc', :label => 'relevance'
201
- config.add_sort_field 'solr_year_i desc, dc_title_sort asc', :label => 'year'
202
- config.add_sort_field 'dc_publisher_sort asc, dc_title_sort asc', :label => 'publisher'
203
+ config.add_sort_field "#{Settings.FIELDS.YEAR} desc, dc_title_sort asc", :label => 'year'
204
+ config.add_sort_field "#{Settings.FIELDS.PUBLISHER} asc, dc_title_sort asc", :label => 'publisher'
203
205
  config.add_sort_field 'dc_title_sort asc', :label => 'title'
204
206
 
205
207
  # If there are more than this many search results, no spelling ("did you
@@ -215,10 +217,13 @@ class CatalogController < ApplicationController
215
217
  # Configure basemap provider for GeoBlacklight maps (uses https only basemap
216
218
  # providers with open licenses)
217
219
  # Valid basemaps include:
218
- # 'mapquest' http://developer.mapquest.com/web/products/open/map
219
220
  # 'positron' http://cartodb.com/basemaps/
220
221
  # 'darkMatter' http://cartodb.com/basemaps/
221
- config.basemap_provider = 'mapquest'
222
+ config.basemap_provider = 'positron'
223
+
224
+ # Configuration for autocomplete suggestor
225
+ config.autocomplete_enabled = true
226
+ config.autocomplete_path = 'suggest'
222
227
  end
223
228
 
224
229
 
@@ -3,7 +3,7 @@ development:
3
3
  jetty_port: 8983
4
4
  test:
5
5
  startup_wait: 60
6
- jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
6
+ jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8983 %>
7
7
  <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
8
8
  production:
9
9
  startup_wait: 15
@@ -1,5 +1,6 @@
1
1
  //= require geoblacklight/geoblacklight
2
2
  //= require geoblacklight/basemaps
3
+ //= require geoblacklight/controls
3
4
  //= require geoblacklight/viewers
4
5
  //= require geoblacklight/modules
5
6
  //= require geoblacklight/downloaders
@@ -7,9 +7,28 @@ CARTODB_ONECLICK_LINK: 'http://oneclick.cartodb.com/'
7
7
  # Download path can be configured using this setting
8
8
  #DOWNLOAD_PATH: "./tmp/cache/downloads"
9
9
 
10
- #Main Solr geometry field used for spatial search and bounding box. Should be type 'rpt'
10
+ # DEPRECATED Main Solr geometry field used for spatial search and bounding box. Should be type 'rpt'
11
11
  GEOMETRY_FIELD: 'solr_geom'
12
12
 
13
+ #Solr field mappings
14
+ FIELDS:
15
+ :FILE_FORMAT: 'dc_format_s'
16
+ :GEOMETRY: 'solr_geom'
17
+ :WXS_IDENTIFIER: 'layer_id_s'
18
+ :RIGHTS: 'dc_rights_s'
19
+ :PROVENANCE: 'dct_provenance_s'
20
+ :GEOM_TYPE: 'layer_geom_type_s'
21
+ :SPATIAL_COVERAGE: 'dct_spatial_sm'
22
+ :SUBJECT: 'dc_subject_sm'
23
+ :REFERENCES: 'dct_references_s'
24
+ :YEAR: 'solr_year_i'
25
+ :CREATOR: 'dc_creator_sm'
26
+ :DESCRIPTION: 'dc_description_s'
27
+ :PUBLISHER: 'dc_publisher_s'
28
+ :PART_OF: 'dct_isPartOf_sm'
29
+ :TEMPORAL: 'dct_temporal_sm'
30
+ :TITLE: 'dc_title_s'
31
+
13
32
  # Institution deployed at
14
33
  INSTITUTION: 'Stanford'
15
34
 
@@ -29,6 +48,7 @@ TIMEOUT_WMS: 4
29
48
  WEBSERVICES_SHOWN:
30
49
  - 'wms'
31
50
  - 'wfs'
51
+ - 'iiif'
32
52
  - 'feature_layer'
33
53
  - 'tiled_map_layer'
34
54
  - 'dynamic_map_layer'
@@ -42,4 +62,24 @@ WMS_PARAMS:
42
62
  :STYLES: ''
43
63
  :SRS: 'EPSG:4326'
44
64
  :EXCEPTIONS: 'application/json'
45
- :INFO_FORMAT: 'text/html'
65
+ :INFO_FORMAT: 'text/html'
66
+
67
+ # Settings for leaflet
68
+ OPACITY_CONTROL: &opacity_control
69
+ CONTROLS:
70
+ - 'Opacity'
71
+
72
+ LEAFLET:
73
+ MAP:
74
+ LAYERS:
75
+ VIEWERS:
76
+ WMS:
77
+ <<: *opacity_control
78
+ TILEDMAPLAYER:
79
+ <<: *opacity_control
80
+ FEATURELAYER:
81
+ <<: *opacity_control
82
+ DYNAMICMAPLAYER:
83
+ <<: *opacity_control
84
+ IMAGEMAPLAYER:
85
+ <<: *opacity_control
data/lib/geoblacklight.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'active_support/dependencies'
1
2
  require 'geoblacklight/engine'
2
3
 
3
4
  module Geoblacklight
@@ -21,7 +22,6 @@ module Geoblacklight
21
22
  require 'geoblacklight/reference'
22
23
  require 'geoblacklight/references'
23
24
  require 'geoblacklight/routes'
24
- require 'geoblacklight/search_builder'
25
25
 
26
26
  def self.inject!
27
27
  CatalogController.send(:include, Geoblacklight::ControllerOverride)
@@ -33,7 +33,6 @@ module Geoblacklight
33
33
  SearchHistoryController.helpers.is_a?(Geoblacklight::ViewHelperOverride)
34
34
  SavedSearchesController.send(:helper, Geoblacklight::ViewHelperOverride) unless
35
35
  SavedSearchesController.helpers.is_a?(Geoblacklight::ViewHelperOverride)
36
- Blacklight::Routes.send(:include, Geoblacklight::Routes)
37
36
  end
38
37
 
39
38
  def self.logger
@@ -19,6 +19,6 @@ module Geoblacklight
19
19
  tiled_map_layer: 'urn:x-esri:serviceType:ArcGIS#TiledMapLayer',
20
20
  dynamic_map_layer: 'urn:x-esri:serviceType:ArcGIS#DynamicMapLayer',
21
21
  image_map_layer: 'urn:x-esri:serviceType:ArcGIS#ImageMapLayer'
22
- }
22
+ }.freeze
23
23
  end
24
24
  end
@@ -10,7 +10,7 @@ module Geoblacklight
10
10
  end
11
11
 
12
12
  def file_name
13
- "#{@document[:layer_slug_s]}-#{@options[:type]}.#{@options[:extension]}"
13
+ "#{@document.id}-#{@options[:type]}.#{@options[:extension]}"
14
14
  end
15
15
 
16
16
  def self.file_path
@@ -40,13 +40,10 @@ module Geoblacklight
40
40
  def create_download_file
41
41
  download = initiate_download
42
42
  File.open("#{file_path_and_name}.tmp", 'wb') do |file|
43
- if download.headers['content-type'] == @options[:content_type]
44
- file.write download.body
45
- else
46
- fail Geoblacklight::Exceptions::WrongDownloadFormat
47
- end
43
+ fail Geoblacklight::Exceptions::WrongDownloadFormat unless matches_mimetype?(download)
44
+ file.write download.body
48
45
  end
49
- File.rename("#{file_path_and_name}.tmp", "#{file_path_and_name}")
46
+ File.rename("#{file_path_and_name}.tmp", file_path_and_name)
50
47
  file_name
51
48
  rescue Geoblacklight::Exceptions::WrongDownloadFormat => error
52
49
  Geoblacklight.logger.error "#{error} expected #{@options[:content_type]} "\
@@ -86,6 +83,10 @@ module Geoblacklight
86
83
 
87
84
  private
88
85
 
86
+ def matches_mimetype?(download)
87
+ MIME::Type.simplified(download.headers['content-type']) == @options[:content_type]
88
+ end
89
+
89
90
  ##
90
91
  # Returns timeout for the download request. `timeout` passed as an option to
91
92
  # the Geoblacklight::Download class
@@ -6,7 +6,7 @@ module Geoblacklight
6
6
  request: 'GetFeature',
7
7
  srsName: 'EPSG:4326',
8
8
  outputformat: 'application/json'
9
- }
9
+ }.freeze
10
10
 
11
11
  def initialize(document, options = {})
12
12
  request_params = GEOJSON_DOWNLOAD_PARAMS.merge(typeName: document[:layer_id_s])
@@ -3,7 +3,7 @@ module Geoblacklight
3
3
  GEOTIFF_DOWNLOAD_PARAMS = {
4
4
  format: 'image/geotiff',
5
5
  width: 4096
6
- }
6
+ }.freeze
7
7
 
8
8
  def initialize(document, options = {})
9
9
  request_params = GEOTIFF_DOWNLOAD_PARAMS.merge(layers: document[:layer_id_s])
@@ -5,7 +5,7 @@ module Geoblacklight
5
5
  request: 'GetMap',
6
6
  srsName: 'EPSG:900913',
7
7
  format: 'application/vnd.google-earth.kmz',
8
- width: 2000, height: 2000 }
8
+ width: 2000, height: 2000 }.freeze
9
9
 
10
10
  def initialize(document, options = {})
11
11
  bbox_wsen = document.bounding_box_as_wsen.split(' ').join(', ')
@@ -4,7 +4,7 @@ module Geoblacklight
4
4
  version: '2.0.0',
5
5
  request: 'GetFeature',
6
6
  srsName: 'EPSG:4326',
7
- outputformat: 'SHAPE-ZIP' }
7
+ outputformat: 'SHAPE-ZIP' }.freeze
8
8
 
9
9
  def initialize(document, options = {})
10
10
  request_params = SHAPEFILE_DOWNLOAD_PARAMS.merge(typeName: document[:layer_id_s])
@@ -4,17 +4,11 @@ module Geoblacklight
4
4
  # BlacklightHelperBehavior
5
5
  module GeoblacklightHelperBehavior
6
6
  ##
7
- # @param [SolrDocument]
7
+ # Calls the presenter on the requested method
8
+ # @param [Symbol, String] presenting_method
8
9
  # @return [String]
9
- def wxs_identifier(document = nil)
10
- document ||= @document
11
- presenter(document).wxs_identifier
12
- end
13
-
14
- ##
15
- # Use the Geoblacklight::DocumentPresenter
16
- def presenter_class
17
- Geoblacklight::DocumentPresenter
10
+ def geoblacklight_present(presenting_method, document = @document)
11
+ presenter(document).try(presenting_method.to_sym) || ''
18
12
  end
19
13
  end
20
14
  end
@@ -14,12 +14,9 @@ module Geoblacklight
14
14
  # @return [String] returned metadata string
15
15
  def metadata
16
16
  response = retrieve_metadata
17
- if response.nil? || response.status == 404
18
- Geoblacklight.logger.error "Could not reach #{@reference.endpoint}"
19
- return "Could not reach #{@reference.endpoint}"
20
- else
21
- return response.body
22
- end
17
+ return response.body unless response.nil? || response.status == 404
18
+ Geoblacklight.logger.error "Could not reach #{@reference.endpoint}"
19
+ "Could not reach #{@reference.endpoint}"
23
20
  end
24
21
 
25
22
  ##
@@ -2,7 +2,7 @@ module Geoblacklight
2
2
  # References is a geoblacklight-schema dct:references parser
3
3
  class References
4
4
  attr_reader :refs, :reference_field
5
- def initialize(document, reference_field = :dct_references_s)
5
+ def initialize(document, reference_field = Settings.FIELDS.REFERENCES)
6
6
  @document = document
7
7
  @reference_field = reference_field
8
8
  @refs = parse_references.map { |ref| Reference.new(ref) }
@@ -12,7 +12,7 @@ module Geoblacklight
12
12
  # Accessor for a document's file format
13
13
  # @return [String] file format for the document
14
14
  def format
15
- @document[:dc_format_s]
15
+ @document[Settings.FIELDS.FILE_FORMAT]
16
16
  end
17
17
 
18
18
  ##
@@ -1,21 +1,7 @@
1
1
  module Geoblacklight
2
2
  module Routes
3
- extend ActiveSupport::Concern
4
- included do |klass|
5
- klass.default_route_sets += [:web_services_routes]
6
- end
7
-
8
- def web_services_routes(primary_resource)
9
- add_routes do
10
- post 'wms/handle'
11
- resources :download, only: [:show, :file]
12
- get 'download/file/:id' => 'download#file', as: :download_file
13
- get 'download/hgl/:id' => 'download#hgl', as: :download_hgl
14
- get "#{primary_resource}/:id/web_services" => "#{primary_resource}#web_services",
15
- as: "web_services_#{primary_resource}"
16
- get "#{primary_resource}/:id/metadata" => "#{primary_resource}#metadata",
17
- as: "metadata_#{primary_resource}"
18
- end
19
- end
3
+ require 'geoblacklight/routes/exportable'
4
+ require 'geoblacklight/routes/downloadable'
5
+ require 'geoblacklight/routes/wms'
20
6
  end
21
7
  end
@@ -0,0 +1,14 @@
1
+ module Geoblacklight
2
+ module Routes
3
+ class Downloadable
4
+ def initialize(defaults = {})
5
+ @defaults = defaults
6
+ end
7
+
8
+ def call(mapper, _options = {})
9
+ mapper.get 'file'
10
+ mapper.get 'hgl'
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ module Geoblacklight
2
+ module Routes
3
+ class Exportable
4
+ def initialize(defaults = {})
5
+ @defaults = defaults
6
+ end
7
+
8
+ def call(mapper, _options = {})
9
+ mapper.member do
10
+ mapper.get 'web_services'
11
+ mapper.get 'metadata'
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ module Geoblacklight
2
+ module Routes
3
+ class Wms
4
+ def initialize(defaults = {})
5
+ @defaults = defaults
6
+ end
7
+
8
+ def call(mapper, _options = {})
9
+ mapper.post 'handle'
10
+ end
11
+ end
12
+ end
13
+ end