cul_hydra 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +7 -0
  2. data/app/assets/images/cul_hydra/crystal/binary.png +0 -0
  3. data/app/assets/images/cul_hydra/crystal/document.png +0 -0
  4. data/app/assets/images/cul_hydra/crystal/file.png +0 -0
  5. data/app/assets/images/cul_hydra/crystal/file_broken.png +0 -0
  6. data/app/assets/images/cul_hydra/crystal/folder_documents.png +0 -0
  7. data/app/assets/images/cul_hydra/crystal/folder_images.png +0 -0
  8. data/app/assets/images/cul_hydra/crystal/folder_music.png +0 -0
  9. data/app/assets/images/cul_hydra/crystal/folder_sound.png +0 -0
  10. data/app/assets/images/cul_hydra/crystal/folder_video.png +0 -0
  11. data/app/assets/images/cul_hydra/crystal/kmultiple.png +0 -0
  12. data/app/assets/images/cul_hydra/crystal/knotify.png +0 -0
  13. data/app/assets/images/cul_hydra/crystal/mp3.png +0 -0
  14. data/app/assets/images/cul_hydra/crystal/multimedia2.png +0 -0
  15. data/app/assets/images/cul_hydra/crystal/video.png +0 -0
  16. data/app/assets/images/cul_hydra/filesystem/application.png +0 -0
  17. data/app/assets/images/cul_hydra/filesystem/code.png +0 -0
  18. data/app/assets/images/cul_hydra/filesystem/css.png +0 -0
  19. data/app/assets/images/cul_hydra/filesystem/db.png +0 -0
  20. data/app/assets/images/cul_hydra/filesystem/directory.png +0 -0
  21. data/app/assets/images/cul_hydra/filesystem/doc.png +0 -0
  22. data/app/assets/images/cul_hydra/filesystem/file.png +0 -0
  23. data/app/assets/images/cul_hydra/filesystem/film.png +0 -0
  24. data/app/assets/images/cul_hydra/filesystem/flash.png +0 -0
  25. data/app/assets/images/cul_hydra/filesystem/folder_open.png +0 -0
  26. data/app/assets/images/cul_hydra/filesystem/html.png +0 -0
  27. data/app/assets/images/cul_hydra/filesystem/java.png +0 -0
  28. data/app/assets/images/cul_hydra/filesystem/linux.png +0 -0
  29. data/app/assets/images/cul_hydra/filesystem/music.png +0 -0
  30. data/app/assets/images/cul_hydra/filesystem/pdf.png +0 -0
  31. data/app/assets/images/cul_hydra/filesystem/php.png +0 -0
  32. data/app/assets/images/cul_hydra/filesystem/picture.png +0 -0
  33. data/app/assets/images/cul_hydra/filesystem/ppt.png +0 -0
  34. data/app/assets/images/cul_hydra/filesystem/psd.png +0 -0
  35. data/app/assets/images/cul_hydra/filesystem/ruby.png +0 -0
  36. data/app/assets/images/cul_hydra/filesystem/script.png +0 -0
  37. data/app/assets/images/cul_hydra/filesystem/spinner.gif +0 -0
  38. data/app/assets/images/cul_hydra/filesystem/txt.png +0 -0
  39. data/app/assets/images/cul_hydra/filesystem/xls.png +0 -0
  40. data/app/assets/images/cul_hydra/filesystem/zip.png +0 -0
  41. data/app/controllers/concerns/cul/hydra/application_id_behavior.rb +43 -0
  42. data/app/controllers/concerns/cul/hydra/controller.rb +22 -0
  43. data/app/controllers/concerns/cul/hydra/resolver.rb +69 -0
  44. data/app/controllers/concerns/cul/hydra/thumbnails.rb +62 -0
  45. data/app/helpers/cul/hydra/ore_proxies_helper_behavior.rb +119 -0
  46. data/app/helpers/cul/hydra/struct_metadata_helper_behavior.rb +89 -0
  47. data/app/models/bag_aggregator.rb +7 -0
  48. data/app/models/concept.rb +23 -0
  49. data/app/models/concerns/cul/hydra/models.rb +24 -0
  50. data/app/models/concerns/cul/hydra/models/aggregator.rb +121 -0
  51. data/app/models/concerns/cul/hydra/models/common.rb +220 -0
  52. data/app/models/concerns/cul/hydra/models/image_resource.rb +106 -0
  53. data/app/models/concerns/cul/hydra/models/linkable_resources.rb +108 -0
  54. data/app/models/concerns/cul/hydra/models/resource.rb +87 -0
  55. data/app/models/concerns/nfo/common.rb +17 -0
  56. data/app/models/concerns/nfo/file_data_object.rb +10 -0
  57. data/app/models/concerns/nfo/folder.rb +10 -0
  58. data/app/models/concerns/nie/information_element.rb +10 -0
  59. data/app/models/concerns/ore/proxy.rb +124 -0
  60. data/app/models/concerns/rdf/cul.rb +77 -0
  61. data/app/models/concerns/rdf/fcrepo3.rb +360 -0
  62. data/app/models/concerns/rdf/nfo.rb +807 -0
  63. data/app/models/concerns/rdf/nie.rb +338 -0
  64. data/app/models/concerns/rdf/olo.rb +100 -0
  65. data/app/models/concerns/rdf/ore.rb +101 -0
  66. data/app/models/concerns/rdf/pimo.rb +605 -0
  67. data/app/models/concerns/rdf/sc.rb +47 -0
  68. data/app/models/concerns/sc/canvas.rb +12 -0
  69. data/app/models/concerns/sc/sequence.rb +21 -0
  70. data/app/models/content_aggregator.rb +3 -0
  71. data/app/models/cul/hydra/datastreams/dc_metadata.rb +107 -0
  72. data/app/models/cul/hydra/datastreams/mods_document.rb +195 -0
  73. data/app/models/cul/hydra/datastreams/struct_metadata.rb +176 -0
  74. data/app/models/dc_document.rb +39 -0
  75. data/app/models/generic_aggregator.rb +68 -0
  76. data/app/models/generic_object.rb +18 -0
  77. data/app/models/generic_resource.rb +210 -0
  78. data/app/models/jp2_image_aggregator.rb +34 -0
  79. data/app/models/mets_structured_aggregator.rb +18 -0
  80. data/app/models/resource.rb +78 -0
  81. data/app/models/resource_aggregator.rb +22 -0
  82. data/app/models/static_audio_aggregator.rb +12 -0
  83. data/app/models/static_image_aggregator.rb +32 -0
  84. data/bin/rails +12 -0
  85. data/config/fedora.yml +17 -0
  86. data/config/jetty.yml +6 -0
  87. data/config/locales/ldpd_hydra.en.yml +125 -0
  88. data/config/predicate_mappings.yml +79 -0
  89. data/config/solr.yml +8 -0
  90. data/config/solr_mappings.yml +26 -0
  91. data/config/solr_value_maps.yml +41 -0
  92. data/config/subs.yml +17 -0
  93. data/fixtures/cmodels/ldpd_ADLMetadata.xml +56 -0
  94. data/fixtures/cmodels/ldpd_AESMetadata.xml +56 -0
  95. data/fixtures/cmodels/ldpd_BagAggregator.xml +70 -0
  96. data/fixtures/cmodels/ldpd_Concept.xml +69 -0
  97. data/fixtures/cmodels/ldpd_ContentAggregator.xml +70 -0
  98. data/fixtures/cmodels/ldpd_DynamicAggregator.xml +56 -0
  99. data/fixtures/cmodels/ldpd_JP2ImageAggregator.xml +60 -0
  100. data/fixtures/cmodels/ldpd_METSMetadata.xml +56 -0
  101. data/fixtures/cmodels/ldpd_METSStructuredAggregator.xml +53 -0
  102. data/fixtures/cmodels/ldpd_MODSMetadata.xml +73 -0
  103. data/fixtures/cmodels/ldpd_MostRecent.xml +46 -0
  104. data/fixtures/cmodels/ldpd_PTIFImageAggregator.xml +63 -0
  105. data/fixtures/cmodels/ldpd_Resource.xml +72 -0
  106. data/fixtures/cmodels/ldpd_RestrictedResource.xml +54 -0
  107. data/fixtures/cmodels/ldpd_Since.xml +62 -0
  108. data/fixtures/cmodels/ldpd_StaticAudioAggregator.xml +54 -0
  109. data/fixtures/cmodels/ldpd_StaticImageAggregator.xml +71 -0
  110. data/fixtures/cmodels/ldpd_htest.xml +54 -0
  111. data/fixtures/cmodels/ldpd_nullbind.xml +63 -0
  112. data/fixtures/cmodels/ldpd_sdef.Aggregator.xml +71 -0
  113. data/fixtures/cmodels/ldpd_sdef.Core.xml +48 -0
  114. data/fixtures/cmodels/ldpd_sdef.Image.xml +47 -0
  115. data/fixtures/cmodels/ldpd_sdef.Metadata.xml +62 -0
  116. data/fixtures/cmodels/ldpd_sdef.Resource.xml +76 -0
  117. data/fixtures/cmodels/ldpd_sdef.ZoomingImage.xml +46 -0
  118. data/fixtures/cmodels/ldpd_sdep.BagAggregator.xml +160 -0
  119. data/fixtures/cmodels/ldpd_sdep.BagAggregatorCore.xml +221 -0
  120. data/fixtures/cmodels/ldpd_sdep.ContentAggregatorCore.xml +221 -0
  121. data/fixtures/cmodels/ldpd_sdep.DynamicAggregator.xml +171 -0
  122. data/fixtures/cmodels/ldpd_sdep.DynamicAggregatorCore.xml +215 -0
  123. data/fixtures/cmodels/ldpd_sdep.JP2Image.xml +220 -0
  124. data/fixtures/cmodels/ldpd_sdep.JP2ImageAggregator.xml +167 -0
  125. data/fixtures/cmodels/ldpd_sdep.JP2ImageCore.xml +229 -0
  126. data/fixtures/cmodels/ldpd_sdep.MODSMetadata.xml +158 -0
  127. data/fixtures/cmodels/ldpd_sdep.MODSMetadataCore.xml +227 -0
  128. data/fixtures/cmodels/ldpd_sdep.PTIFImage.xml +222 -0
  129. data/fixtures/cmodels/ldpd_sdep.PTIFImageAggregator.xml +167 -0
  130. data/fixtures/cmodels/ldpd_sdep.PTIFImageCore.xml +215 -0
  131. data/fixtures/cmodels/ldpd_sdep.StaticImage.xml +210 -0
  132. data/fixtures/cmodels/ldpd_sdep.StaticImageAggregator.xml +186 -0
  133. data/fixtures/cmodels/ldpd_sdep.StaticImageCore.xml +220 -0
  134. data/fixtures/cmodels/ore_Proxy.xml +50 -0
  135. data/fixtures/spec/BLOB/test001.jpg +0 -0
  136. data/fixtures/spec/CUL_DC/dc.xml +5 -0
  137. data/fixtures/spec/CUL_MODS/mods-001.xml +25 -0
  138. data/fixtures/spec/CUL_MODS/mods-all.xml +65 -0
  139. data/fixtures/spec/CUL_MODS/mods-bad-repo.xml +7 -0
  140. data/fixtures/spec/CUL_MODS/mods-date-created-range.xml +7 -0
  141. data/fixtures/spec/CUL_MODS/mods-date-created-single.xml +6 -0
  142. data/fixtures/spec/CUL_MODS/mods-date-end-with-all-u-characters.xml +7 -0
  143. data/fixtures/spec/CUL_MODS/mods-date-issued-range.xml +7 -0
  144. data/fixtures/spec/CUL_MODS/mods-date-issued-single.xml +6 -0
  145. data/fixtures/spec/CUL_MODS/mods-date-other-range.xml +7 -0
  146. data/fixtures/spec/CUL_MODS/mods-date-other-single.xml +6 -0
  147. data/fixtures/spec/CUL_MODS/mods-date-range-short-years.xml +7 -0
  148. data/fixtures/spec/CUL_MODS/mods-date-start-with-all-u-characters.xml +7 -0
  149. data/fixtures/spec/CUL_MODS/mods-dates-with-all-u-characters.xml +7 -0
  150. data/fixtures/spec/CUL_MODS/mods-dates-with-some-u-characters.xml +7 -0
  151. data/fixtures/spec/CUL_MODS/mods-item.xml +31 -0
  152. data/fixtures/spec/CUL_MODS/mods-names.xml +35 -0
  153. data/fixtures/spec/CUL_MODS/mods-notes.xml +8 -0
  154. data/fixtures/spec/CUL_MODS/mods-ns.xml +2 -0
  155. data/fixtures/spec/CUL_MODS/mods-origin-info.xml +9 -0
  156. data/fixtures/spec/CUL_MODS/mods-part.xml +22 -0
  157. data/fixtures/spec/CUL_MODS/mods-physical-description.xml +12 -0
  158. data/fixtures/spec/CUL_MODS/mods-physical-location.xml +9 -0
  159. data/fixtures/spec/CUL_MODS/mods-record-info.xml +4 -0
  160. data/fixtures/spec/CUL_MODS/mods-relateditem-project.xml +8 -0
  161. data/fixtures/spec/CUL_MODS/mods-subjects.xml +73 -0
  162. data/fixtures/spec/CUL_MODS/mods-textual-date.xml +8 -0
  163. data/fixtures/spec/CUL_MODS/mods-titles.xml +33 -0
  164. data/fixtures/spec/CUL_MODS/mods-top-level-location-vs-relateditem-location.xml +21 -0
  165. data/fixtures/spec/CUL_MODS/mods-unmapped-project.xml +7 -0
  166. data/fixtures/spec/CUL_SOLR/mods-001.xml +1 -0
  167. data/fixtures/spec/CUL_SOLR/mods-001.yml +30 -0
  168. data/fixtures/spec/FOXML/content-aggregator.xml +64 -0
  169. data/fixtures/spec/FOXML/content-cmodel.xml +48 -0
  170. data/fixtures/spec/FOXML/image-cmodel.xml +48 -0
  171. data/fixtures/spec/FOXML/resource-max.xml +83 -0
  172. data/fixtures/spec/FOXML/resource-screen.xml +273 -0
  173. data/fixtures/spec/FOXML/resource-thumb.xml +86 -0
  174. data/fixtures/spec/FOXML/static-image-aggregator.xml +31 -0
  175. data/fixtures/spec/STRUCTMAP/structmap-examples.xml +21 -0
  176. data/fixtures/spec/STRUCTMAP/structmap-nested.xml +10 -0
  177. data/fixtures/spec/STRUCTMAP/structmap-recto.xml +4 -0
  178. data/fixtures/spec/STRUCTMAP/structmap-seq.xml +5 -0
  179. data/fixtures/spec/STRUCTMAP/structmap-unordered-seq.xml +5 -0
  180. data/lib/cul_hydra.rb +20 -0
  181. data/lib/cul_hydra/access_controls_enforcement.rb +53 -0
  182. data/lib/cul_hydra/controllers.rb +13 -0
  183. data/lib/cul_hydra/controllers/aggregates.rb +93 -0
  184. data/lib/cul_hydra/controllers/aggregator_controller_helper.rb +27 -0
  185. data/lib/cul_hydra/controllers/catalog.rb +12 -0
  186. data/lib/cul_hydra/controllers/content_aggregators.rb +81 -0
  187. data/lib/cul_hydra/controllers/datastreams.rb +145 -0
  188. data/lib/cul_hydra/controllers/helpers.rb +10 -0
  189. data/lib/cul_hydra/controllers/helpers/active_fedora_helper_behavior.rb +9 -0
  190. data/lib/cul_hydra/controllers/helpers/application_helper_behavior.rb +16 -0
  191. data/lib/cul_hydra/controllers/helpers/dc_metadata_helper_behavior.rb +9 -0
  192. data/lib/cul_hydra/controllers/helpers/hydra_assets_helper_behavior.rb +46 -0
  193. data/lib/cul_hydra/controllers/helpers/hydra_autocomplete_helper_behavior.rb +35 -0
  194. data/lib/cul_hydra/controllers/helpers/hydra_uploader_helper_behavior.rb +34 -0
  195. data/lib/cul_hydra/controllers/helpers/resources_helper_behavior.rb +159 -0
  196. data/lib/cul_hydra/controllers/resources.rb +161 -0
  197. data/lib/cul_hydra/controllers/static_image_aggregators.rb +105 -0
  198. data/lib/cul_hydra/controllers/suggestions.rb +126 -0
  199. data/lib/cul_hydra/controllers/terms.rb +205 -0
  200. data/lib/cul_hydra/engine.rb +31 -0
  201. data/lib/cul_hydra/fedora.rb +41 -0
  202. data/lib/cul_hydra/fedora/dummy_object.rb +37 -0
  203. data/lib/cul_hydra/fedora/rubydora_patch.rb +16 -0
  204. data/lib/cul_hydra/fedora/url_helper_behavior.rb +32 -0
  205. data/lib/cul_hydra/indexer.rb +102 -0
  206. data/lib/cul_hydra/om.rb +7 -0
  207. data/lib/cul_hydra/om/standard_mods.rb +115 -0
  208. data/lib/cul_hydra/risearch_members.rb +92 -0
  209. data/lib/cul_hydra/solrizer.rb +10 -0
  210. data/lib/cul_hydra/solrizer/extractor.rb +27 -0
  211. data/lib/cul_hydra/solrizer/mods_fieldable.rb +473 -0
  212. data/lib/cul_hydra/solrizer/terminology_based_solrizer.rb +35 -0
  213. data/lib/cul_hydra/solrizer/value_mapper.rb +46 -0
  214. data/lib/cul_hydra/solrizer_patch.rb +172 -0
  215. data/lib/cul_hydra/version.rb +8 -0
  216. data/lib/cul_hydra/version.rb~ +8 -0
  217. data/lib/tasks/cmodel.rake +122 -0
  218. data/lib/tasks/cul_hydra_dev.rake +54 -0
  219. data/lib/tasks/index.rake +73 -0
  220. data/lib/tasks/transform.rake +23 -0
  221. metadata +503 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9669d16a11214de3beece7b70f8f270c9c3e6f74
4
+ data.tar.gz: b029e107109a3d13720dc03a026b2a855af76a25
5
+ SHA512:
6
+ metadata.gz: 8abbcd3eca758e1057983a6bea70b1bbe076c33151044743fd05725f699d4eabe202370bced90839571b86150823227037cf6d884489c2ea741788dc0d402553
7
+ data.tar.gz: 49be88f1af4b2612432942a8a6e706dea75d1d05218e1e3623ce440b1e52462aaf641bfab541f74448e9a16b1598a2b2c751a93c98c0bf22dc28e8036669517c
@@ -0,0 +1,43 @@
1
+ module Cul::Hydra::ApplicationIdBehavior
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ include Blacklight::SolrHelper
5
+ end
6
+
7
+ def find_for_params(path,solr_params)
8
+ res = blacklight_solr.send_and_receive(path, {key=>solr_params.to_hash, method:blacklight_config.http_method})
9
+ Blacklight::SolrResponse.new(res, solr_params, solr_document_model: blacklight_config.solr_document_model)
10
+ end
11
+
12
+ def get_solr_response_for_app_id(id=nil, extra_controller_params={})
13
+ id ||= params[:id]
14
+ id = id.clone
15
+ id.sub!(/apt\:\/columbia/,'apt://columbia') # TOTAL HACK
16
+ id.gsub!(':','\:')
17
+ id.gsub!('/','\/')
18
+ p = blacklight_config.default_document_solr_params.merge(extra_controller_params)
19
+ p[:fq] = "identifier_ssim:#{(id)}"
20
+ p[:fl] ||= '*'
21
+ #p[:qt] ||= blacklight_config.document_solr_request_handler
22
+ solr_response = find(blacklight_config.document_solr_path, p)
23
+ raise Blacklight::Exceptions::InvalidSolrID.new(id) if solr_response.docs.empty?
24
+ document = SolrDocument.new(solr_response.docs.first, solr_response)
25
+ @response, @document = [solr_response, document]
26
+ end
27
+
28
+ def get_solr_response_for_dc_id(id=nil, extra_controller_params={})
29
+ id ||= params[:id]
30
+ id = id.clone
31
+ p = blacklight_config.default_document_solr_params.merge(extra_controller_params)
32
+ id.sub!(/apt\:\/columbia/,'apt://columbia') # TOTAL HACK
33
+ id.gsub!(':','\:')
34
+ id.gsub!('/','\/')
35
+ p[:fq] = "dc_identifier_ssim:#{(id)}"
36
+ p[:fl] ||= '*'
37
+ #p[:qt] ||= blacklight_config.document_solr_request_handler
38
+ solr_response = find(blacklight_config.document_solr_path, p)
39
+ raise Blacklight::Exceptions::InvalidSolrID.new(id) if solr_response.docs.empty?
40
+ document = SolrDocument.new(solr_response.docs.first, solr_response)
41
+ @response, @document = [solr_response, document]
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+ module Cul::Hydra::Controller
2
+
3
+ def asset_path_from_config(asset)
4
+ Rails.configuration.assets.paths.each do |dir|
5
+ result = "#{dir}/#{asset}"
6
+ return result if File.exists?(result)
7
+ end
8
+ return nil
9
+ end
10
+
11
+ def asset_url(source)
12
+ URI.join(root_url, ActionController::Base.helpers.asset_path(source))
13
+ end
14
+
15
+ def http_client
16
+ unless @http_client
17
+ @http_client ||= HTTPClient.new
18
+ end
19
+ @http_client
20
+ end
21
+
22
+ end
@@ -0,0 +1,69 @@
1
+ require 'blacklight'
2
+ require 'active-fedora'
3
+ module Cul::Hydra::Resolver
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ # Whenever an action raises SolrHelper::InvalidSolrID, this block gets executed.
8
+ # Hint: the SolrHelper #get_solr_response_for_doc_id method raises this error,
9
+ # which is used in the #show action here.
10
+ self.rescue_from Blacklight::Exceptions::InvalidSolrID, :with => :invalid_solr_id_error
11
+ # When RSolr::RequestError is raised, the rsolr_request_error method is executed.
12
+ # The index action will more than likely throw this one.
13
+ # Example, when the standard query parser is used, and a user submits a "bad" query.
14
+ self.rescue_from RSolr::Error::Http, :with => :rsolr_request_error
15
+ end
16
+
17
+ def get_solr_response_for_app_id(id=nil, extra_controller_params={})
18
+ id ||= params[:id]
19
+ solr_params = blacklight_config.default_document_solr_params.merge!(extra_controller_params)
20
+ solr_params[:fq] = "identifier_ssim:#{(id)}"
21
+ solr_response = find((blacklight_config.document_solr_request_handler || blacklight_config.qt), solr_params)
22
+ raise Blacklight::Exceptions::InvalidSolrID.new if solr_response.docs.empty?
23
+ document = SolrDocument.new(solr_response.docs.first, solr_response)
24
+ @response, @document = [solr_response, document]
25
+ end
26
+
27
+ def get
28
+ get_solr_response_for_app_id
29
+ action = params.delete(:action)
30
+ action.sub!(/s$/,'')
31
+ method_name = action + '_url'
32
+ url = send method_name.to_sym, @document[:id]
33
+ redirect_to url
34
+ end
35
+
36
+ # when solr (RSolr) throws an error (RSolr::RequestError), this method is executed.
37
+ def rsolr_request_error(exception)
38
+ if Rails.env == "development"
39
+ raise exception # Rails own code will catch and give usual Rails error page with stack trace
40
+ else
41
+ flash_notice = I18n.t('blacklight.search.errors.request_error')
42
+ # Set the notice flag if the flash[:notice] is already set to the error that we are setting.
43
+ # This is intended to stop the redirect loop error
44
+ notice = flash[:notice] if flash[:notice] == flash_notice
45
+ logger.error exception
46
+ unless notice
47
+ flash[:notice] = flash_notice
48
+ redirect_to root_path, :status => 500
49
+ else
50
+ render :file => "#{Rails.root}/public/500.html", :status => 500
51
+ end
52
+ end
53
+ end
54
+
55
+ # when a request for /resolve/:action/BAD_SOLR_ID is made, this method is executed...
56
+ def invalid_solr_id_error
57
+ id = params.delete(:id)
58
+ flash[:notice] = I18n.t('blacklight.search.errors.invalid_solr_id') + " (#{id})"
59
+ redirect_to(root_path)
60
+ end
61
+
62
+ def blacklight_solr
63
+ @solr ||= RSolr.connect(blacklight_solr_config)
64
+ end
65
+
66
+ def blacklight_solr_config
67
+ Blacklight.solr_config
68
+ end
69
+ end
@@ -0,0 +1,62 @@
1
+ require 'httpclient'
2
+ module Cul::Hydra::Thumbnails
3
+ # some thumbnail urls
4
+ NO_THUMB = "cul_hydra/crystal/file.png"
5
+ BROKEN_THUMB = "cul_hydra/crystal/file_broken.png"
6
+ COLLECTION_THUMB = "cul_hydra/crystal/kmultiple.png"
7
+ AUDIO_THUMB = "cul_hydra/crystal/sound.png"
8
+ # some rel predicates
9
+ FORMAT = "http://purl.org/dc/elements/1.1/format"
10
+ MEMBER_OF = "http://purl.oclc.org/NET/CUL/memberOf"
11
+ HAS_MODEL = "info:fedora/fedora-system:def/model#hasModel"
12
+ IMAGE_WIDTH = "http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/imageWidth"
13
+ IMAGE_LENGTH = "http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/imageLength"
14
+
15
+ def show
16
+ pid = params[:id].split(/@/)[0]
17
+ get_by_pid(pid)
18
+ end
19
+
20
+ def get_by_pid(pid)
21
+ r_obj = ActiveFedora::Base.find(pid, :cast=>true)
22
+
23
+ if r_obj.respond_to? :thumbnail_info
24
+ url = r_obj.thumbnail_info
25
+ else
26
+ url = {:asset=>(COLLECTION_THUMB),:mime=>'image/png'}
27
+ end
28
+ if url[:asset]
29
+ #url = {:url=>asset_url(COLLECTION_THUMB),:mime=>'image/png'}
30
+ #redirect_to asset_url(url[:asset]).to_s, status: 302
31
+ #return
32
+ end
33
+ Rails.logger.debug "thumbnail #{url[:url] || url[:asset]} #{url[:mime]}"
34
+ filename = pid + '.' + url[:mime].split('/')[1].downcase
35
+ h_cd = "filename=""#{CGI.escapeHTML(filename)}"""
36
+ headers.delete "Cache-Control"
37
+ headers["Content-Disposition"] = h_cd
38
+ headers["Content-Type"] = url[:mime]
39
+
40
+ if url[:asset]
41
+ full_path = Rails.application.assets.resolve(url[:asset]).to_path
42
+ render :status => 200, :text => File.read(full_path)
43
+ return
44
+ elsif url[:url].to_s =~ /^https?:/
45
+ cl = http_client
46
+ render :status => 200, :text => cl.get_content(url[:url])
47
+ return
48
+ else
49
+ render :status => 200, :text => File.read(url[:url])
50
+ return
51
+ end
52
+ end
53
+
54
+ def jp2_thumbnail(pid)
55
+ {:url => ActiveFedora.fedora_config.credentials[:url] + '/objects/' + pid + '/methods/ldpd:sdef.Image/getView?max=250', :mime => 'image/jpeg'}
56
+ end
57
+
58
+ def pid_from_uri(uri)
59
+ return uri.sub(/info:fedora\//,'')
60
+ end
61
+
62
+ end
@@ -0,0 +1,119 @@
1
+ module Cul::Hydra::OreProxiesHelperBehavior
2
+ def hasModel_name
3
+ @has_model ||= ActiveFedora::SolrService.solr_name('has_model', :symbol)
4
+ end
5
+
6
+ def publisher_name
7
+ @has_model ||= ActiveFedora::SolrService.solr_name('publisher', :symbol)
8
+ end
9
+
10
+ def facets_for(query, args)
11
+ raw = args.delete(:raw)
12
+ args = args.merge(q:query, qt:'standard',facet:true,rows:0)
13
+ result = ActiveFedora::SolrService.instance.conn.get('select', :params=>args)
14
+ return result if raw
15
+ result['facet_counts']['facet_fields']
16
+ end
17
+ def facet_to_hash(facet_values)
18
+ facet_values ||= []
19
+ hash = {}
20
+ facet_values.each_with_index {|v,ix| hash[v] = facet_values[ix+1] if (ix % 2 == 0)}
21
+ hash
22
+ end
23
+ def proxies(opts=params, &block)
24
+ proxy_in = opts[:id]
25
+ proxy_uri = "info:fedora/#{proxy_in}"
26
+ proxy_id = opts[:proxy_id]
27
+ proxy_in_query = "proxyIn_ssi:#{RSolr.escape(proxy_uri)}"
28
+ f = [proxy_in_query]
29
+ if proxy_id
30
+ f << "belongsToContainer_ssi:#{RSolr.escape(proxy_id)}"
31
+ else
32
+ f << "-belongsToContainer_ssi:*"
33
+ end
34
+ rows = opts[:limit] || '999'
35
+ proxies = ActiveFedora::SolrService.query("*:*",{fq: f,rows:rows})
36
+ if proxies.detect {|p| p["type_ssim"] && p["type_ssim"].include?(RDF::NFO[:'#FileDataObject'])}
37
+ query = "{!join from=proxyFor_ssi to=identifier_ssim}#{f.join(' ')}"
38
+ files = ActiveFedora::SolrService.query(query,rows:'999')
39
+ proxies.each do |proxy|
40
+ file = files.detect {|f| f['identifier_ssim'].include?(proxy['proxyFor_ssi'])}
41
+ if file
42
+ rels_int = file.fetch('rels_int_profile_tesim',[]).first
43
+ props = rels_int ? JSON.load(rels_int) : {}
44
+ props = props["#{proxy_uri}/content"] || {}
45
+ props['pid'] = file['id']
46
+ props['extent'] ||= file['extent_ssim'] if file['extent_ssim']
47
+ proxy.merge!(props)
48
+ end
49
+ end
50
+ end
51
+ if proxies.detect {|p| p["type_ssim"] && p["type_ssim"].include?(RDF::NFO[:'#Folder'])}
52
+ query = "{!join from=id to=belongsToContainer_ssi}#{f.join(' ')}"
53
+ folder_counts = facets_for(query,:"facet.field" => "belongsToContainer_ssi",:"facet.limit" => '999')
54
+ unless ( belongsToContainer = facet_to_hash(folder_counts["belongsToContainer_ssi"])).empty?
55
+ proxies.each do |proxy|
56
+ if proxy["type_ssim"].include?(RDF::NFO[:'#Folder'])
57
+ proxy['extent'] ||= belongsToContainer[proxy['id']]
58
+ end
59
+ end
60
+ end
61
+ end
62
+ if block_given?
63
+ proxies.each &block
64
+ else
65
+ proxies
66
+ end
67
+ end
68
+
69
+ def proxies_file_system(opts=params, &block)
70
+ content_tag(:ul, nil, class: 'file-system') do
71
+ proxies(opts, &block)
72
+ end
73
+ end
74
+
75
+ def download_permitted?(dl_proxy, args={})
76
+ return permitted_to? :fedora_content, dl_proxy, {:context => :download}
77
+ end
78
+
79
+ def proxy_to_download(node, args={})
80
+ dl_proxy = Cul::DownloadProxy.new(args)
81
+ dl_proxy.content_models = node[hasModel_name()]
82
+ dl_proxy.mime_type = node['format']
83
+ dl_proxy.publisher = node[publisher_name()]
84
+ dl_proxy
85
+ end
86
+
87
+ def proxy_extent(node)
88
+ extent = Array(node['extent']).first || '0'
89
+ if node["type_ssim"].include? RDF::NFO[:'#FileDataObject']
90
+ extent = extent.to_i
91
+ if extent > 0
92
+ pow = Math.log(extent,1024).floor
93
+ pow = 3 if pow > 3
94
+ pow = 0 if pow < 0
95
+ else
96
+ pow = 0
97
+ end
98
+ unit = ['B','KiB','MiB','GiB'][pow]
99
+ "#{extent.to_i/(1024**pow)} #{unit}"
100
+ else
101
+ "#{extent.to_i} items"
102
+ end
103
+ end
104
+ def breadcrumbs(opts=params, &block)
105
+ proxy_id = opts[:proxy_id]
106
+ id = opts[:id]
107
+ links = []
108
+ if proxy_id
109
+ parts = proxy_id.split('/')
110
+ id = id.sub('info:fedora/','')
111
+ yield( {id: id, label: 'All Content'})
112
+ # the first three parts are proxied graph prefixes "info:fedora/PID/DSID/..."
113
+ 3.upto(parts.size - 2).each do |ix|
114
+ f_id = parts[0..ix].join('/')
115
+ yield( {id: id, proxy_id: URI.escape(f_id), label: parts[ix]})
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,89 @@
1
+ module Cul::Hydra::StructMetadataHelperBehavior
2
+ METS_NS = {'mets' => 'http://www.loc.gov/METS/'}
3
+ def mime_for_name(filename)
4
+ ext = File.extname(filename).downcase
5
+ mt = MIME::Types.type_for(ext)
6
+ if mt.is_a? Array
7
+ mt = mt.first
8
+ end
9
+ unless mt.nil?
10
+ return mt.content_type
11
+ else
12
+ return nil
13
+ end
14
+ end
15
+
16
+ def html_class_for_filename(filename)
17
+ mime = mime_for_name(filename) || 'application/octet-stream'
18
+ mime.sub(/\//,'_')
19
+ end
20
+
21
+ def struct_metadata_ds(doc)
22
+ pid = base_id_for(doc)
23
+ xml = rubydora.datastream_dissemination(:pid=>pid, :dsid=>'structMetadata')
24
+ Cul::Hydra::Datastreams::StructMetadata.from_xml(xml)
25
+ end
26
+ def struct_metadata_file_system_cache_key(doc)
27
+ File.join(doc['id'],'structMetadata','fs-html',doc['system_modified_dtsi'])
28
+ end
29
+ def struct_metadata_file_system(doc)
30
+ ds = struct_metadata_ds(doc)
31
+ doc = Nokogiri::XML(ds.content)
32
+ node = doc.xpath('mets:structMap',METS_NS).first
33
+ content_tag(:ul, nil, class: 'file-system') do
34
+ children_content = node.xpath('mets:div',METS_NS).reduce('') do |content, child|
35
+ content << struct_metadata_node(child)
36
+ end
37
+ children_content.html_safe
38
+ end
39
+ end
40
+ def struct_metadata_node(node)
41
+ children = node.xpath('mets:div',METS_NS)
42
+ if children.length == 0
43
+ # file
44
+ content_tag(:li,nil, class: ['fs-file',html_class_for_filename(node['LABEL'])]) do
45
+ content_tag(:a, node['LABEL'], href: '#', 'data-id'=>node['CONTENTIDS'])
46
+ end
47
+ else
48
+ # folder
49
+ content_tag(:li, nil, class: 'fs-directory') do
50
+ content_tag(:a, node['LABEL'], href: '#') +
51
+ content_tag(:ul, nil, class: 'fs-children') do
52
+ children_content = children.reduce('') do |content, child|
53
+ content << struct_metadata_node(child)
54
+ end
55
+ children_content.html_safe
56
+ end
57
+ end
58
+ end
59
+ end
60
+ def struct_metadata(doc)
61
+ members = get_members(doc)
62
+
63
+ node_map = {}
64
+ ds = struct_metadata_ds(doc)
65
+ ds.divs_with_attribute(true,'CONTENTIDS').each do |node|
66
+ node_map[node['CONTENTIDS']] = node
67
+ end
68
+
69
+ map = {}
70
+ Rails.logger.warn("No members for doc #{doc[:id]}") unless members.size > 0
71
+ members.each do |member|
72
+ ids = ((member[:identifier_ssim] || []) + (member[:dc_identifier_ssim] || []))
73
+ ids.uniq!
74
+ ids.delete(member[:id])
75
+ node_map.each do |cid, node|
76
+ if ids.include? cid
77
+ node['pid'] = member[:id]
78
+ map[member[:id]] = member
79
+ Rails.logger.info("Mapped child node in structMap: '#{member[:id]}'' -> '#{cid}'")
80
+ break
81
+ end
82
+ end
83
+ if map[member[:id]].nil?
84
+ Rails.logger.warn("Unmapped child node in structMap: #{ids.inspect}")
85
+ end
86
+ end
87
+ [ds, map]
88
+ end
89
+ end