cul_hydra 1.9.4 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/cul/hydra/application_id_behavior.rb +3 -3
- data/app/controllers/concerns/cul/hydra/controller.rb +2 -14
- data/app/controllers/concerns/cul/hydra/resolver.rb +5 -9
- data/app/models/administrative_set.rb +0 -38
- data/app/models/concerns/cul/hydra/models/aggregator.rb +0 -57
- data/app/models/concerns/cul/hydra/models/common.rb +0 -4
- data/app/models/concerns/cul/hydra/models/image_resource.rb +0 -41
- data/app/models/concerns/cul/hydra/models/resource.rb +0 -49
- data/app/models/concerns/cul/hydra/models.rb +0 -1
- data/app/models/cul/hydra/datastreams/rels_int.rb +3 -3
- data/app/models/generic_resource.rb +0 -37
- data/fixtures/spec/CUL_MODS/mods-titles-extended.xml +2 -0
- data/fixtures/spec/CUL_SOLR/mods-001.xml +1 -1
- data/fixtures/spec/CUL_SOLR/mods-001.yml +1 -1
- data/lib/cul_hydra/risearch_members.rb +8 -10
- data/lib/cul_hydra/solrizer/mods_fieldable.rb +12 -2
- data/lib/cul_hydra/version.rb +1 -1
- metadata +23 -32
- data/app/controllers/concerns/cul/hydra/thumbnails.rb +0 -62
- data/app/models/concerns/cul/hydra/models/linkable_resources.rb +0 -108
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a00f8ff9e61a56af80a27f48225517956a370d24243a5dcb090e803f78c35d98
|
4
|
+
data.tar.gz: bfa3132fbf567bda31f498411a52cdd2995864223c93aa07acd4aeb37aecaf9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 065a2f0a6ac2d6619d5e5c09274b5a218900628ae252149e9cc2d65e9d575e0fdad570399775b9c350f35450bdfdbd3392f7440418c26be3a066be4733720a5f
|
7
|
+
data.tar.gz: 71692ab2aa1668090b8d18412a36c5a0d45024a941340a62bb1ee62acf5d165cdf1ca16ee960738cd5512946f409a24c3a11407ed6b24db964f347adf97ff478
|
@@ -3,7 +3,7 @@ module Cul::Hydra::ApplicationIdBehavior
|
|
3
3
|
|
4
4
|
def find_for_params(path,solr_params)
|
5
5
|
res = blacklight_config.repository.send_and_receive(path, {key=>solr_params.to_hash, method:blacklight_config.http_method})
|
6
|
-
Blacklight::SolrResponse.new(res, solr_params,
|
6
|
+
Blacklight::SolrResponse.new(res, solr_params, blacklight_config: blacklight_config)
|
7
7
|
end
|
8
8
|
|
9
9
|
def get_solr_response_for_app_id(id=nil, extra_controller_params={})
|
@@ -18,7 +18,7 @@ module Cul::Hydra::ApplicationIdBehavior
|
|
18
18
|
#p[:qt] ||= blacklight_config.document_solr_request_handler
|
19
19
|
repository = blacklight_config.repository_class.new(blacklight_config)
|
20
20
|
solr_response = repository.search(p)
|
21
|
-
raise Blacklight::Exceptions::
|
21
|
+
raise Blacklight::Exceptions::RecordNotFound.new(id) if solr_response.docs.empty?
|
22
22
|
document = SolrDocument.new(solr_response.docs.first, solr_response)
|
23
23
|
@response, @document = [solr_response, document]
|
24
24
|
end
|
@@ -35,7 +35,7 @@ module Cul::Hydra::ApplicationIdBehavior
|
|
35
35
|
#p[:qt] ||= blacklight_config.document_solr_request_handler
|
36
36
|
repository = blacklight_config.repository_class.new(blacklight_config)
|
37
37
|
solr_response = repository.search(p)
|
38
|
-
raise Blacklight::Exceptions::
|
38
|
+
raise Blacklight::Exceptions::RecordNotFound.new(id) if solr_response.docs.empty?
|
39
39
|
document = SolrDocument.new(solr_response.docs.first, solr_response)
|
40
40
|
@response, @document = [solr_response, document]
|
41
41
|
end
|
@@ -1,22 +1,10 @@
|
|
1
1
|
module Cul::Hydra::Controller
|
2
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
3
|
def asset_url(source)
|
12
4
|
URI.join(root_url, ActionController::Base.helpers.asset_path(source))
|
13
5
|
end
|
14
6
|
|
15
7
|
def http_client
|
16
|
-
|
17
|
-
@http_client ||= HTTPClient.new
|
18
|
-
end
|
19
|
-
@http_client
|
8
|
+
@http_client ||= HTTPClient.new
|
20
9
|
end
|
21
|
-
|
22
|
-
end
|
10
|
+
end
|
@@ -4,10 +4,10 @@ module Cul::Hydra::Resolver
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
# Whenever an action raises SolrHelper::
|
7
|
+
# Whenever an action raises SolrHelper::RecordNotFound, this block gets executed.
|
8
8
|
# Hint: the SolrHelper #get_solr_response_for_doc_id method raises this error,
|
9
9
|
# which is used in the #show action here.
|
10
|
-
self.rescue_from Blacklight::Exceptions::
|
10
|
+
self.rescue_from Blacklight::Exceptions::RecordNotFound, :with => :invalid_solr_id_error
|
11
11
|
# When RSolr::RequestError is raised, the rsolr_request_error method is executed.
|
12
12
|
# The index action will more than likely throw this one.
|
13
13
|
# Example, when the standard query parser is used, and a user submits a "bad" query.
|
@@ -19,7 +19,7 @@ module Cul::Hydra::Resolver
|
|
19
19
|
solr_params = blacklight_config.default_document_solr_params.merge!(extra_controller_params)
|
20
20
|
solr_params[:fq] = "identifier_ssim:#{(id)}"
|
21
21
|
solr_response = find((blacklight_config.document_solr_request_handler || blacklight_config.qt), solr_params)
|
22
|
-
raise Blacklight::Exceptions::
|
22
|
+
raise Blacklight::Exceptions::RecordNotFound.new if solr_response.docs.empty?
|
23
23
|
document = SolrDocument.new(solr_response.docs.first, solr_response)
|
24
24
|
@response, @document = [solr_response, document]
|
25
25
|
end
|
@@ -51,7 +51,7 @@ module Cul::Hydra::Resolver
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
# when a request for /resolve/:action/BAD_SOLR_ID is made, this method is executed...
|
56
56
|
def invalid_solr_id_error
|
57
57
|
id = params.delete(:id)
|
@@ -60,10 +60,6 @@ module Cul::Hydra::Resolver
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def blacklight_solr
|
63
|
-
@solr ||=
|
64
|
-
end
|
65
|
-
|
66
|
-
def blacklight_solr_config
|
67
|
-
Blacklight.solr_config
|
63
|
+
@solr ||= Blacklight.default_index
|
68
64
|
end
|
69
65
|
end
|
@@ -30,42 +30,4 @@ class AdministrativeSet < ::ActiveFedora::Base
|
|
30
30
|
r.collect {|hit| members << SolrDocument.new(hit) } unless r.blank?
|
31
31
|
members
|
32
32
|
end
|
33
|
-
|
34
|
-
def thumbnail_info
|
35
|
-
members = solr_members
|
36
|
-
if members.length == 0
|
37
|
-
thumb = {:asset=>"cul_hydra/crystal/file.png",:mime=>'image/png'}
|
38
|
-
else
|
39
|
-
thumb = thumb_from_members(members)
|
40
|
-
end
|
41
|
-
return thumb || {:asset=>"cul_hydra/crystal/file.png",:mime=>'image/png'}
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
def thumb_from_members(members)
|
46
|
-
sorted = members.sort do |a,b|
|
47
|
-
c = a['title_si'] <=> b['title_si']
|
48
|
-
if c == 0 && a['identifier_ssim']
|
49
|
-
if b['identifier_ssim']
|
50
|
-
a['identifier_ssim'].delete(a.id) unless a['identifier_ssim'].length == 1
|
51
|
-
b['identifier_ssim'].delete(a.id) unless b['identifier_ssim'].length == 1
|
52
|
-
a['identifier_ssim'][0] <=> b['identifier_ssim'][0]
|
53
|
-
else
|
54
|
-
-1
|
55
|
-
end
|
56
|
-
else
|
57
|
-
c
|
58
|
-
end
|
59
|
-
end
|
60
|
-
thumb_from_solr_doc(sorted[0])
|
61
|
-
end
|
62
|
-
|
63
|
-
def thumb_from_solr_doc(solr_doc)
|
64
|
-
if solr_doc and (member = ActiveFedora::Base.find(solr_doc.id, :cast=>true)).respond_to? :thumbnail_info
|
65
|
-
member.thumbnail_info
|
66
|
-
else
|
67
|
-
return nil
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
33
|
end
|
@@ -41,21 +41,6 @@ module Cul::Hydra::Models::Aggregator
|
|
41
41
|
solr_members(opts).collect {|hit| hit.id}
|
42
42
|
end
|
43
43
|
|
44
|
-
def thumbnail_info
|
45
|
-
members = solr_members
|
46
|
-
if members.length == 0
|
47
|
-
thumb = {:asset=>"cul_hydra/crystal/file.png",:mime=>'image/png'}
|
48
|
-
else
|
49
|
-
thumb = nil
|
50
|
-
unless datastreams['structMetadata'].new?
|
51
|
-
thumb = thumb_from_struct(members)
|
52
|
-
else
|
53
|
-
thumb = thumb_from_members(members)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
return thumb || {:asset=>"cul_hydra/crystal/file.png",:mime=>'image/png'}
|
57
|
-
end
|
58
|
-
|
59
44
|
# a representative image URI for this object
|
60
45
|
# defined by the predicate https://schema.org/image
|
61
46
|
# @return [String, URI]
|
@@ -68,48 +53,6 @@ module Cul::Hydra::Models::Aggregator
|
|
68
53
|
end
|
69
54
|
|
70
55
|
private
|
71
|
-
def thumb_from_struct(members)
|
72
|
-
puts "thumb thumb_from_struct"
|
73
|
-
sm = datastreams['structMetadata']
|
74
|
-
first = sm.divs_with_attribute(false,'ORDER','1').first
|
75
|
-
if first
|
76
|
-
members.each do |member|
|
77
|
-
puts "looking for #{first["CONTENTIDS"]} in #{member["identifier_ssim"].inspect}"
|
78
|
-
if member["identifier_ssim"].include? first["CONTENTIDS"]
|
79
|
-
return thumb_from_solr_doc(member)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
return thumb_from_solr_doc(members.first) if members.first
|
83
|
-
else
|
84
|
-
return nil
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def thumb_from_members(members)
|
89
|
-
sorted = members.sort do |a,b|
|
90
|
-
c = a['title_si'] <=> b['title_si']
|
91
|
-
if c == 0 && a['identifier_ssim']
|
92
|
-
if b['identifier_ssim']
|
93
|
-
a['identifier_ssim'].delete(a.id) unless a['identifier_ssim'].length == 1
|
94
|
-
b['identifier_ssim'].delete(a.id) unless b['identifier_ssim'].length == 1
|
95
|
-
a['identifier_ssim'][0] <=> b['identifier_ssim'][0]
|
96
|
-
else
|
97
|
-
-1
|
98
|
-
end
|
99
|
-
else
|
100
|
-
c
|
101
|
-
end
|
102
|
-
end
|
103
|
-
thumb_from_solr_doc(sorted[0])
|
104
|
-
end
|
105
|
-
|
106
|
-
def thumb_from_solr_doc(solr_doc)
|
107
|
-
if solr_doc and (member = ActiveFedora::Base.find(solr_doc.id, :cast=>true)).respond_to? :thumbnail_info
|
108
|
-
member.thumbnail_info
|
109
|
-
else
|
110
|
-
return nil
|
111
|
-
end
|
112
|
-
end
|
113
56
|
|
114
57
|
def to_uri(obj)
|
115
58
|
if obj.respond_to? :internal_uri
|
@@ -284,10 +284,6 @@ module Cul::Hydra::Models::Common
|
|
284
284
|
return result
|
285
285
|
end
|
286
286
|
|
287
|
-
def thumbnail_info
|
288
|
-
{:asset=>("cul_hydra/crystal/kmultiple.png"),:mime_type=>"image/png"}
|
289
|
-
end
|
290
|
-
|
291
287
|
def get_singular_rel(predicate)
|
292
288
|
property = relationships(predicate).first
|
293
289
|
return nil unless property
|
@@ -8,19 +8,6 @@ module Cul::Hydra::Models::ImageResource
|
|
8
8
|
FORMAT_OF_PREDICATE = ActiveFedora::Predicates.short_predicate("http://purl.org/dc/terms/isFormatOf").to_s
|
9
9
|
FORMAT_URI = RDF::URI("http://purl.org/dc/terms/format")
|
10
10
|
|
11
|
-
DJATOKA_THUMBNAIL_PARMS = {
|
12
|
-
"url_ver" => "Z39.88-2004",
|
13
|
-
"svc_id" => "info:lanl-repo/svc/getRegion",
|
14
|
-
"svc_val_fmt" => "info:ofi/fmt:kev:mtx:jpeg2000",
|
15
|
-
"svc.format" => "image/jpeg",
|
16
|
-
"svc.level" => "",
|
17
|
-
"svc.rotate" => "0",
|
18
|
-
"svc.scale" => "200",
|
19
|
-
"svc.clayers" => ""
|
20
|
-
}
|
21
|
-
|
22
|
-
DJATOKA_BASE_URL = "http://iris.cul.columbia.edu:8888/resolve"
|
23
|
-
|
24
11
|
EXIF_ORIENTATION_TO_DEGREES = {
|
25
12
|
'top-left' => 0,
|
26
13
|
'left-bottom' => 90,
|
@@ -57,33 +44,6 @@ module Cul::Hydra::Models::ImageResource
|
|
57
44
|
end
|
58
45
|
end
|
59
46
|
|
60
|
-
def zooming?
|
61
|
-
zoom = rels_int.relationships(datastreams['content'],:foaf_zooming).first
|
62
|
-
return zoom.object.to_s if zoom
|
63
|
-
datastreams.each do |k,v|
|
64
|
-
if v.mimeType =~ /image\/jp2$/i
|
65
|
-
zoom = "info:fedora/#{k.dsid}"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
return zoom
|
69
|
-
end
|
70
|
-
|
71
|
-
def thumbnail_info
|
72
|
-
thumb = rels_int.relationships(datastreams['content'],:foaf_thumbnail).first
|
73
|
-
if thumb
|
74
|
-
t_dsid = thumb.object.to_s.split('/')[-1]
|
75
|
-
t_url = "#{ActiveFedora.fedora_config.credentials[:url]}/objects/#{pid}/datastreams/#{t_dsid}/content"
|
76
|
-
return {:url=>t_url,:mime=>datastreams[t_dsid].mimeType}
|
77
|
-
elsif (zoom = self.zooming?)
|
78
|
-
t_dsid = zoom.split('/')[-1]
|
79
|
-
t_parms = DJATOKA_THUMBNAIL_PARMS.merge({"rft_id" => datastreams[t_dsid].dsLocation})
|
80
|
-
url = "#{DJATOKA_BASE_URL}?#{options.map { |key, value| "#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}"}.join("&") }"
|
81
|
-
{:url => url, :mime => t_parms["svc.format"]}
|
82
|
-
else
|
83
|
-
return {:asset=>"cul_hydra/crystal/file.png",:mime=>'image/png'}
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
47
|
# The number of rotational degrees required to display this image as upright
|
88
48
|
def required_rotation_for_upright_display
|
89
49
|
required_rotation_orientation_in_degrees = (360 - self.orientation) % 360
|
@@ -102,5 +62,4 @@ module Cul::Hydra::Models::ImageResource
|
|
102
62
|
def orientation
|
103
63
|
self.relationships(:orientation).present? ? EXIF_ORIENTATION_TO_DEGREES[self.relationships(:orientation).first.to_s] : 0
|
104
64
|
end
|
105
|
-
|
106
65
|
end
|
@@ -28,9 +28,6 @@ module Cul::Hydra::Models::Resource
|
|
28
28
|
|
29
29
|
after_create :resource!
|
30
30
|
end
|
31
|
-
if self.respond_to? :has_datastream
|
32
|
-
has_datastream :name => "CONTENT", :type=>::ActiveFedora::Datastream, :versionable => true
|
33
|
-
end
|
34
31
|
end
|
35
32
|
|
36
33
|
def resource!
|
@@ -39,50 +36,4 @@ module Cul::Hydra::Models::Resource
|
|
39
36
|
@metadata_is_dirty = true
|
40
37
|
update
|
41
38
|
end
|
42
|
-
|
43
|
-
def add_content_blob(blob, opts)
|
44
|
-
file_name = opts[:file_name]
|
45
|
-
mime = opts[:mime_type].nil? ? mime_type(file_name) : opts[:mime_type]
|
46
|
-
add_file_datastream(blob, :label=>file_name, :mimeType=>mime, :dsid => 'CONTENT')
|
47
|
-
set_title_and_label( file_name, :only_if_blank=>true )
|
48
|
-
if IMAGE_MIME_TYPES.include? mime
|
49
|
-
blob.rewind
|
50
|
-
# retrieve Nokogiri of image property RDF
|
51
|
-
image_properties = Cul::Image::Properties.identify(blob)
|
52
|
-
if image_properties
|
53
|
-
image_prop_nodes = image_properties.nodeset
|
54
|
-
relsext = datastreams['RELS-EXT']
|
55
|
-
image_prop_nodes.each { |node|
|
56
|
-
if node["resource"]
|
57
|
-
is_literal = false
|
58
|
-
object = RDF::URI.new(node["resource"])
|
59
|
-
else
|
60
|
-
is_literal = true
|
61
|
-
object = RDF::Literal(node.text)
|
62
|
-
end
|
63
|
-
subject = RDF::URI(internal_uri)
|
64
|
-
predicate = RDF::URI("#{node.namespace.href}#{node.name}")
|
65
|
-
query = RDF::Query.new({ :subject => {predicate => :object}})
|
66
|
-
relationships(predicate).dup.each { |stmt|
|
67
|
-
relationships.delete(stmt)
|
68
|
-
}
|
69
|
-
add_relationship(predicate,object, is_literal)
|
70
|
-
relationships_are_dirty=true
|
71
|
-
}
|
72
|
-
# add mimetype to DC:format values
|
73
|
-
self.datastreams['DC'].update_values({[:format] => mime})
|
74
|
-
end
|
75
|
-
end
|
76
|
-
blob.rewind
|
77
|
-
end
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
# Return the mimeType for a given file name
|
82
|
-
# @param [String] file_name The filename to use to get the mimeType
|
83
|
-
# @return [String] mimeType for filename passed in. Default: application/octet-stream if mimeType cannot be determined
|
84
|
-
def mime_type file_name
|
85
|
-
mime_types = MIME::Types.of(file_name)
|
86
|
-
mime_type = mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
|
87
|
-
end
|
88
39
|
end
|
@@ -17,7 +17,6 @@ module Hydra
|
|
17
17
|
autoload :Aggregator, 'cul/hydra/models/aggregator'
|
18
18
|
autoload :Common, 'cul/hydra/models/common'
|
19
19
|
autoload :ImageResource, 'cul/hydra/models/image_resource'
|
20
|
-
autoload :LinkableResources, 'cul/hydra/models/linkable_resources'
|
21
20
|
autoload :RelsInt, 'cul/hydra/models/rels_int'
|
22
21
|
autoload :Resource, 'cul/hydra/models/resource'
|
23
22
|
end
|
@@ -13,11 +13,11 @@ module Hydra
|
|
13
13
|
|
14
14
|
def serialize!
|
15
15
|
self.content = to_rels_int() if changed_attributes.include? 'relationships'
|
16
|
-
clear_attribute_changes 'relationships'
|
16
|
+
clear_attribute_changes ['relationships']
|
17
17
|
end
|
18
18
|
|
19
19
|
def relationships_will_change!
|
20
|
-
|
20
|
+
attribute_will_change!('relationships')
|
21
21
|
end
|
22
22
|
|
23
23
|
def content
|
@@ -114,7 +114,7 @@ module Hydra
|
|
114
114
|
g << stmt
|
115
115
|
end
|
116
116
|
self.relationships_loaded = true
|
117
|
-
clear_attribute_changes 'relationships'
|
117
|
+
clear_attribute_changes ['relationships']
|
118
118
|
@graph = g
|
119
119
|
end
|
120
120
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "cul_image_props"
|
2
1
|
require "mime/types"
|
3
2
|
require "uri"
|
4
3
|
require "open-uri"
|
@@ -53,15 +52,6 @@ class GenericResource < ::ActiveFedora::Base
|
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
56
|
-
if self.zooming?
|
57
|
-
fz = rels_int.relationships(datastreams['content'], :foaf_zooming).first.object.to_s.split('/')[-1]
|
58
|
-
ds = datastreams[fz]
|
59
|
-
unless ds.nil?
|
60
|
-
rft_id = ds.controlGroup == 'E' ? datastreams[fz].dsLocation : legacy_content_path(ds,'info:fedora/datastreams/')
|
61
|
-
solr_doc['rft_id_ss'] = rft_id
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
55
|
if (service_ds = self.service_datastream)
|
66
56
|
solr_doc['service_dslocation_ss'] = service_ds.dsLocation
|
67
57
|
end
|
@@ -82,22 +72,6 @@ class GenericResource < ::ActiveFedora::Base
|
|
82
72
|
solr_doc
|
83
73
|
end
|
84
74
|
|
85
|
-
def thumbnail_info
|
86
|
-
thumb = rels_int.relationships(datastreams['content'],:foaf_thumbnail).first
|
87
|
-
if thumb
|
88
|
-
t_dsid = thumb.object.to_s.split('/')[-1]
|
89
|
-
t_url = "#{ActiveFedora.fedora_config.credentials[:url]}/objects/#{pid}/datastreams/#{t_dsid}/content"
|
90
|
-
return {:url=>t_url,:mime=>datastreams[t_dsid].mimeType}
|
91
|
-
elsif self.zooming?
|
92
|
-
t_dsid = rels_int.relationships(dsuri, :foaf_zooming).first.object.to_s.split('/')[-1]
|
93
|
-
t_parms = DJATOKA_THUMBNAIL_PARMS.merge({"rft_id" => datastreams[t_dsid].dsLocation})
|
94
|
-
url = "#{DJATOKA_BASE_URL}?#{options.map { |key, value| "#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}"}.join("&") }"
|
95
|
-
{:url => url, :mime => t_parms["svc.format"]}
|
96
|
-
else
|
97
|
-
return {:asset => "cul_hydra/crystal/file.png",:mime=>'image/png'}
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
75
|
def linkable_resources
|
102
76
|
# let's start with the known DSIDs from lindquist, then work our way back to parsing the solrized relsint
|
103
77
|
results = []
|
@@ -135,17 +109,6 @@ class GenericResource < ::ActiveFedora::Base
|
|
135
109
|
results
|
136
110
|
end
|
137
111
|
|
138
|
-
def zooming?
|
139
|
-
content = datastreams['content']
|
140
|
-
return false unless content
|
141
|
-
zr = rels_int.relationships(content, :foaf_zooming)
|
142
|
-
if (zr && zr.first)
|
143
|
-
return !zr.first.blank?
|
144
|
-
else
|
145
|
-
false
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
112
|
def closed?
|
150
113
|
return access_levels.map(&:downcase).include?('closed')
|
151
114
|
end
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
2
|
+
<mods xmlns='http://www.loc.gov/mods/v3' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-4.xsd'><titleInfo><nonSort>The </nonSort><title xml:lang="eng">(ġhotogråphs) ゐ </title></titleInfo></mods>
|
@@ -1 +1 @@
|
|
1
|
-
<doc xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:mods="http://www.loc.gov/mods/v3" xmlns="http://solr.apache.org" xmlns:index="http://repository.cul.columbia.edu/namespace/index/1_0/" xmlns:local="http://local.org/custom"><field name="format">multipartitem</field><field name="collection_h">Columbia University Libraries Content/Online Projects/PRD Customer Orders/</field><field name="internal_h">ldpd:91655/ldpd:91656/ldpd:101479/ldpd:102275/</field><field name="format_h">multipartitem/</field><field name="id">ldpd:102275@ldpd:103434</field><field name="pid_ssi">ldpd:102275</field><field name="descriptor">mods</field><field name="object_ssm">https://repository2.cul.columbia.edu:8443/fedora/get/ldpd:102275</field><field name="identifier_ssi">prd.custord.070017</field><field name="all_text_teim">AN070017</field><field name="all_text_teim">prd.custord.070017</field><field name="lib_collection_sim">Pulitzer Prizes</field><field name="lib_collection_ssm">Pulitzer Prizes</field><field name="lib_project_sim">Pres Orders</field><field name="lib_project_ssm">Customer Order Collection</field><field name="lib_project_teim">Customer Order Collection</field><field name="title_sort">
|
1
|
+
<doc xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:mods="http://www.loc.gov/mods/v3" xmlns="http://solr.apache.org" xmlns:index="http://repository.cul.columbia.edu/namespace/index/1_0/" xmlns:local="http://local.org/custom"><field name="format">multipartitem</field><field name="collection_h">Columbia University Libraries Content/Online Projects/PRD Customer Orders/</field><field name="internal_h">ldpd:91655/ldpd:91656/ldpd:101479/ldpd:102275/</field><field name="format_h">multipartitem/</field><field name="id">ldpd:102275@ldpd:103434</field><field name="pid_ssi">ldpd:102275</field><field name="descriptor">mods</field><field name="object_ssm">https://repository2.cul.columbia.edu:8443/fedora/get/ldpd:102275</field><field name="identifier_ssi">prd.custord.070017</field><field name="all_text_teim">AN070017</field><field name="all_text_teim">prd.custord.070017</field><field name="lib_collection_sim">Pulitzer Prizes</field><field name="lib_collection_ssm">Pulitzer Prizes</field><field name="lib_project_sim">Pres Orders</field><field name="lib_project_ssm">Customer Order Collection</field><field name="lib_project_teim">Customer Order Collection</field><field name="title_sort">PHOTOGRAPHS</field><field name="title_ssm">Photographs</field><field name="title_teim">Photographs</field><field name="lib_name_sim">Kennerly, David</field><field name="lib_name_teim">Kennerly, David</field><field name="lib_name_ssm">Kennerly, David</field><field name="lib_repo_long_ssim">Rare Book and Manuscript Library</field><field name="lib_repo_sim">RBML</field><field name="lib_repo_teim">RBML</field><field name="lib_format_ssm">photographs</field><field name="lib_format_sim">photographs</field><field name="all_text_teim">Original PRD customer order number: 070017</field><field name="extent_teim">2 items</field><field name="access_condition_ssi">Columbia Libraries Staff Use Only</field><field name="all_text_teim">Box 8, JP2 Feature Photography</field></doc>
|
@@ -19,7 +19,7 @@ lib_collection_sim: ['Pulitzer Prizes']
|
|
19
19
|
lib_collection_ssm: ['Pulitzer Prizes']
|
20
20
|
lib_project_short_ssim: ['Pres Orders']
|
21
21
|
lib_project_full_ssim: ['Customer Order Collection']
|
22
|
-
title_si: '
|
22
|
+
title_si: 'PHOTOGRAPHS'
|
23
23
|
title_display_ssm: ['The Photographs']
|
24
24
|
lib_format_sim: ['photographs']
|
25
25
|
lib_format_ssm: ['photographs']
|
@@ -13,8 +13,7 @@ module ClassMethods
|
|
13
13
|
recursive_member_query += ' and $cmodel <mulgara:is> <info:fedora/ldpd:' + cmodel_type + '>'
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
puts recursive_member_query if verbose_output
|
16
|
+
log_risearch_query(recursive_member_query, verbose_output)
|
18
17
|
|
19
18
|
search_response = JSON(Cul::Hydra::Fedora.repository.find_by_itql(recursive_member_query, {
|
20
19
|
:type => 'tuples',
|
@@ -35,8 +34,7 @@ module ClassMethods
|
|
35
34
|
'select $pid from <#ri>
|
36
35
|
where $pid <http://purl.oclc.org/NET/CUL/memberOf> <fedora:' + pid + '>'
|
37
36
|
|
38
|
-
|
39
|
-
puts direct_member_query if verbose_output
|
37
|
+
log_risearch_query(direct_member_query, verbose_output)
|
40
38
|
|
41
39
|
search_response = JSON(Cul::Hydra::Fedora.repository.find_by_itql(direct_member_query, {
|
42
40
|
:type => 'tuples',
|
@@ -72,8 +70,7 @@ module ClassMethods
|
|
72
70
|
where $pid <http://purl.oclc.org/NET/CUL/memberOf> <info:fedora/#{pid}>
|
73
71
|
having $k0 <http://mulgara.org/mulgara#occursMoreThan> '0.0'^^<http://www.w3.org/2001/XMLSchema#double>;"
|
74
72
|
|
75
|
-
|
76
|
-
puts direct_members_with_ds_query if verbose_output
|
73
|
+
log_risearch_query(direct_members_with_ds_query, verbose_output)
|
77
74
|
|
78
75
|
search_response = JSON.parse(Cul::Hydra::Fedora.repository.find_by_itql(direct_members_with_ds_query, {
|
79
76
|
:type => 'tuples',
|
@@ -99,8 +96,7 @@ module ClassMethods
|
|
99
96
|
'select $pid from <#ri>
|
100
97
|
where $pid <info:fedora/fedora-system:def/relations-external#isConstituentOf> <fedora:' + pid + '>'
|
101
98
|
|
102
|
-
|
103
|
-
puts project_constituent_query if verbose_output
|
99
|
+
log_risearch_query(project_constituent_query, verbose_output)
|
104
100
|
|
105
101
|
search_response = JSON(Cul::Hydra::Fedora.repository.find_by_itql(project_constituent_query, {
|
106
102
|
:type => 'tuples',
|
@@ -130,8 +126,7 @@ module ClassMethods
|
|
130
126
|
'select $pid from <#ri>
|
131
127
|
where $pid <http://purl.org/dc/terms/publisher> <fedora:' + pid + '>'
|
132
128
|
|
133
|
-
|
134
|
-
puts project_constituent_query if verbose_output
|
129
|
+
log_risearch_query(project_constituent_query, verbose_output)
|
135
130
|
|
136
131
|
search_response = JSON(Cul::Hydra::Fedora.repository.find_by_itql(project_constituent_query, {
|
137
132
|
:type => 'tuples',
|
@@ -199,6 +194,9 @@ module ClassMethods
|
|
199
194
|
return pids_to_return
|
200
195
|
end
|
201
196
|
|
197
|
+
def log_risearch_query(query, verbose_output = false)
|
198
|
+
puts "Performing query:\n#{query}" if verbose_output
|
199
|
+
end
|
202
200
|
end
|
203
201
|
extend ClassMethods
|
204
202
|
end
|
@@ -39,7 +39,11 @@ module Cul::Hydra::Solrizer
|
|
39
39
|
n_t = n_t.sub(/^"(.*)"$/, "\\1")
|
40
40
|
n_t = n_t.sub(/^'(.*)'$/, "\\1")
|
41
41
|
is_negative_number = n_t =~ /^-\d+$/
|
42
|
-
|
42
|
+
if strip_punctuation == :all
|
43
|
+
n_t = n_t.gsub(/[[:punct:]]/, '')
|
44
|
+
else
|
45
|
+
n_t = n_t.sub(/^[[:punct:]]+/, '')
|
46
|
+
end
|
43
47
|
# this may have 'created' leading/trailing space, so strip
|
44
48
|
n_t.strip!
|
45
49
|
n_t = '-' + n_t if is_negative_number
|
@@ -92,7 +96,13 @@ module Cul::Hydra::Solrizer
|
|
92
96
|
base_text << child.text unless child.name == 'nonSort'
|
93
97
|
end
|
94
98
|
end
|
95
|
-
base_text = ModsFieldable.normalize(base_text,
|
99
|
+
base_text = ModsFieldable.normalize(base_text, :all)
|
100
|
+
# decompose and strip unicode combining characters
|
101
|
+
base_text = base_text.unicode_normalize(:nfd)
|
102
|
+
base_text.gsub!(/[\u0300-\u036F]/,'')
|
103
|
+
# uppercase per Unicode, for ASCII/Latin
|
104
|
+
# TODO: decide whether to use full Unicode case, other language options (Turkish, Lithuanian, etc.)
|
105
|
+
base_text = base_text.upcase(:ascii)
|
96
106
|
base_text = nil if base_text.empty?
|
97
107
|
base_text
|
98
108
|
end
|
data/lib/cul_hydra/version.rb
CHANGED
metadata
CHANGED
@@ -1,58 +1,64 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cul_hydra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Armintor
|
8
8
|
- Eric O'Hanlon
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '5.2'
|
21
|
+
- - "<"
|
19
22
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
23
|
+
version: '6.0'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- - "
|
28
|
+
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
30
|
+
version: '5.2'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6.0'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: bootstrap-sass
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
31
37
|
requirements:
|
32
38
|
- - "~>"
|
33
39
|
- !ruby/object:Gem::Version
|
34
|
-
version: 3.
|
40
|
+
version: 3.4.1
|
35
41
|
type: :runtime
|
36
42
|
prerelease: false
|
37
43
|
version_requirements: !ruby/object:Gem::Requirement
|
38
44
|
requirements:
|
39
45
|
- - "~>"
|
40
46
|
- !ruby/object:Gem::Version
|
41
|
-
version: 3.
|
47
|
+
version: 3.4.1
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
49
|
name: blacklight
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
45
51
|
requirements:
|
46
52
|
- - "~>"
|
47
53
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
54
|
+
version: '7.0'
|
49
55
|
type: :runtime
|
50
56
|
prerelease: false
|
51
57
|
version_requirements: !ruby/object:Gem::Requirement
|
52
58
|
requirements:
|
53
59
|
- - "~>"
|
54
60
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
61
|
+
version: '7.0'
|
56
62
|
- !ruby/object:Gem::Dependency
|
57
63
|
name: httpclient
|
58
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,20 +121,6 @@ dependencies:
|
|
115
121
|
- - ">="
|
116
122
|
- !ruby/object:Gem::Version
|
117
123
|
version: 0.5.0
|
118
|
-
- !ruby/object:Gem::Dependency
|
119
|
-
name: cul_image_props
|
120
|
-
requirement: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
type: :runtime
|
126
|
-
prerelease: false
|
127
|
-
version_requirements: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
124
|
- !ruby/object:Gem::Dependency
|
133
125
|
name: mods
|
134
126
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,14 +211,14 @@ dependencies:
|
|
219
211
|
requirements:
|
220
212
|
- - "~>"
|
221
213
|
- !ruby/object:Gem::Version
|
222
|
-
version: 2.
|
214
|
+
version: 2.1.0
|
223
215
|
type: :runtime
|
224
216
|
prerelease: false
|
225
217
|
version_requirements: !ruby/object:Gem::Requirement
|
226
218
|
requirements:
|
227
219
|
- - "~>"
|
228
220
|
- !ruby/object:Gem::Version
|
229
|
-
version: 2.
|
221
|
+
version: 2.1.0
|
230
222
|
- !ruby/object:Gem::Dependency
|
231
223
|
name: sprockets
|
232
224
|
requirement: !ruby/object:Gem::Requirement
|
@@ -359,7 +351,6 @@ files:
|
|
359
351
|
- app/controllers/concerns/cul/hydra/application_id_behavior.rb
|
360
352
|
- app/controllers/concerns/cul/hydra/controller.rb
|
361
353
|
- app/controllers/concerns/cul/hydra/resolver.rb
|
362
|
-
- app/controllers/concerns/cul/hydra/thumbnails.rb
|
363
354
|
- app/helpers/cul/hydra/ore_proxies_helper_behavior.rb
|
364
355
|
- app/helpers/cul/hydra/struct_metadata_helper_behavior.rb
|
365
356
|
- app/models/administrative_set.rb
|
@@ -370,7 +361,6 @@ files:
|
|
370
361
|
- app/models/concerns/cul/hydra/models/aggregator.rb
|
371
362
|
- app/models/concerns/cul/hydra/models/common.rb
|
372
363
|
- app/models/concerns/cul/hydra/models/image_resource.rb
|
373
|
-
- app/models/concerns/cul/hydra/models/linkable_resources.rb
|
374
364
|
- app/models/concerns/cul/hydra/models/rels_int.rb
|
375
365
|
- app/models/concerns/cul/hydra/models/resource.rb
|
376
366
|
- app/models/concerns/nfo/common.rb
|
@@ -492,6 +482,7 @@ files:
|
|
492
482
|
- fixtures/spec/CUL_MODS/mods-subjects.xml
|
493
483
|
- fixtures/spec/CUL_MODS/mods-textual-date.xml
|
494
484
|
- fixtures/spec/CUL_MODS/mods-textual-dates-with-unusual-chars.xml
|
485
|
+
- fixtures/spec/CUL_MODS/mods-titles-extended.xml
|
495
486
|
- fixtures/spec/CUL_MODS/mods-titles.xml
|
496
487
|
- fixtures/spec/CUL_MODS/mods-top-level-location-vs-relateditem-location.xml
|
497
488
|
- fixtures/spec/CUL_MODS/mods-unmapped-project.xml
|
@@ -547,7 +538,7 @@ files:
|
|
547
538
|
homepage: https://github.com/cul/cul_hydra
|
548
539
|
licenses: []
|
549
540
|
metadata: {}
|
550
|
-
post_install_message:
|
541
|
+
post_install_message:
|
551
542
|
rdoc_options: []
|
552
543
|
require_paths:
|
553
544
|
- app
|
@@ -565,8 +556,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
565
556
|
- !ruby/object:Gem::Version
|
566
557
|
version: '0'
|
567
558
|
requirements: []
|
568
|
-
rubygems_version: 3.
|
569
|
-
signing_key:
|
559
|
+
rubygems_version: 3.0.9
|
560
|
+
signing_key:
|
570
561
|
specification_version: 4
|
571
562
|
summary: ActiveFedora, OM, and Solrizer implementations for CUL repository apps
|
572
563
|
test_files: []
|
@@ -1,62 +0,0 @@
|
|
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
|
@@ -1,108 +0,0 @@
|
|
1
|
-
module Cul::Hydra::Models::LinkableResources
|
2
|
-
include Cul::Hydra::Fedora::UrlHelperBehavior
|
3
|
-
# so as to avoid including all the url hepers via:
|
4
|
-
## include Rails.application.routes.url_helpers
|
5
|
-
# we are just going to delegate
|
6
|
-
delegate :fedora_content_path, :to => 'Rails.application.routes.url_helpers'
|
7
|
-
delegate :cache_path, :to => 'Rails.application.routes.url_helpers'
|
8
|
-
|
9
|
-
def http_client
|
10
|
-
unless @http_client
|
11
|
-
@http_client ||= HTTPClient.new
|
12
|
-
@http_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
13
|
-
uname = Cul::Hydra::Fedora.repository.config[:user]
|
14
|
-
pwd = Cul::Hydra::Fedora.repository.config[:password]
|
15
|
-
@http_client.set_auth(nil, uname, pwd)
|
16
|
-
end
|
17
|
-
@http_client
|
18
|
-
end
|
19
|
-
|
20
|
-
def linkable_resources
|
21
|
-
r = self.parts(:response_format => :solr)
|
22
|
-
return [] if r.blank?
|
23
|
-
members = r.collect {|hit|
|
24
|
-
SolrDocument.new(hit)
|
25
|
-
}
|
26
|
-
members.delete_if { |sd| (sd[:has_model_ssim] & ["info:fedora/ldpd:Resource"]).blank? }
|
27
|
-
case self.route_as
|
28
|
-
when "zoomingimage"
|
29
|
-
results = members.collect {|doc| image_resource(doc)}
|
30
|
-
base_id = self.pid
|
31
|
-
url = fedora_ds_url(base_id, 'SOURCE') + '/content'
|
32
|
-
head_req = http_client().head(url)
|
33
|
-
file_size = head_req.header["Content-Length"].first.to_i
|
34
|
-
results << {
|
35
|
-
:dimensions => "Original",
|
36
|
-
:mime_type => "image/jp2",
|
37
|
-
:uri=>base_id, :block=>"SOURCE", :filename=>base_id + "_source.jp2",
|
38
|
-
:content_models=>[]}
|
39
|
-
when "audio"
|
40
|
-
results = members.collect {|doc| audio_resource(doc)}
|
41
|
-
when "image"
|
42
|
-
results = members.collect {|doc| image_resource(doc)}
|
43
|
-
else
|
44
|
-
raise "Unknown format #{self.route_as}"
|
45
|
-
end
|
46
|
-
return results
|
47
|
-
end
|
48
|
-
|
49
|
-
def basic_resource(document)
|
50
|
-
res = {}
|
51
|
-
res[:pid] = document["id"]
|
52
|
-
res[:dsid] = "CONTENT"
|
53
|
-
res[:mime_type] = document["dc_format_ssm"] ? document["dc_format_ssm"].first : "application/octect-stream"
|
54
|
-
res[:content_models] = document["has_model_ssim"]
|
55
|
-
res[:file_size] = document["extent_ssim"].first.to_i
|
56
|
-
res[:size] = (document["extent_ssim"].first.to_i / 1024).to_s + " Kb"
|
57
|
-
res
|
58
|
-
end
|
59
|
-
|
60
|
-
def image_resource(document)
|
61
|
-
res = basic_resource(document)
|
62
|
-
if document["image_width_ssim"]
|
63
|
-
res[:dimensions] = document["image_width_ssim"].first + " x " + document["image_length_ssim"].first
|
64
|
-
res[:width] = document["image_width_ssim"].first
|
65
|
-
res[:height] = document["image_length_ssim"].first
|
66
|
-
else
|
67
|
-
res[:dimensions] = "? x ?"
|
68
|
-
res[:width] = "0"
|
69
|
-
res[:height] = "0"
|
70
|
-
end
|
71
|
-
base_id = document["id"]
|
72
|
-
base_filename = base_id.gsub(/\:/,"")
|
73
|
-
img_filename = base_filename + "." + document["dc_format_ssm"].first.gsub(/^[^\/]+\//,"")
|
74
|
-
res[:filename] = img_filename
|
75
|
-
res[:block] = "CONTENT"
|
76
|
-
res[:mime_type] = document["dc_format_ssm"] ? document["dc_format_ssm"].first : "application/octect-stream"
|
77
|
-
res[:content_models] = document["has_model_ssim"]
|
78
|
-
res[:file_size] = document["extent_ssim"].first.to_i
|
79
|
-
res[:size] = (document["extent_ssim"].first.to_i / 1024).to_s + " Kb"
|
80
|
-
res[:uri] = base_id
|
81
|
-
res
|
82
|
-
end
|
83
|
-
|
84
|
-
def audio_resource(document)
|
85
|
-
res = basic_resource(document)
|
86
|
-
base_id = document["id"]
|
87
|
-
base_filename = base_id.gsub(/\:/,"")
|
88
|
-
if res[:mime_type] =~ /wav/
|
89
|
-
ext = 'wav'
|
90
|
-
elsif res[:mime_type] =~ /mpeg/
|
91
|
-
ext = 'mp3'
|
92
|
-
else
|
93
|
-
ext = 'bin'
|
94
|
-
end
|
95
|
-
filename = base_filename + "." + ext
|
96
|
-
dc_filename = base_filename + "_dc.xml"
|
97
|
-
res[:uri] = base_id
|
98
|
-
res[:block] = "CONTENT"
|
99
|
-
res[:filename] = filename
|
100
|
-
res[:dc_path] = fedora_content_path(:download_method=>"show_pretty", :uri=>base_id, :block=>"DC", :filename=>dc_filename)
|
101
|
-
res[:mime_type] = document["dc_format_ssm"] ? document["dc_format_ssm"].first : "application/octect-stream"
|
102
|
-
res[:content_models] = document["has_model_ssim"]
|
103
|
-
res[:file_size] = document["extent_ssim"].first.to_i
|
104
|
-
res[:size] = (document["extent_ssim"].first.to_i / 1024).to_s + " Kb"
|
105
|
-
res
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|