cul_scv_hydra 0.12.1 → 0.13.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/controllers/concerns/cul/scv/hydra/thumbnails.rb +67 -0
- data/app/models/concerns/cul/scv/hydra/models/aggregator.rb +3 -3
- data/app/models/concerns/cul/scv/hydra/models/image_resource.rb +1 -1
- data/app/models/generic_resource.rb +1 -1
- data/lib/cul_scv_hydra/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjA3NTcxODBmNDg0YTgyNDk2MjU5OWM1OGVhZmRhZWM5NjUwZDQ4Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDlmN2UxNTg5YzM2ODZkYWU5MzI1ZGZlZTAxN2Y4MDNmMzM4ZjFmNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2EwYzI1MzQ2NzgxMWRiYzQ4ZWI3MWE4ZGEwMjBlMjcxNmU3MjkwYzE0NWNi
|
10
|
+
MTBmZWMyNmQ1NzMwODAyYmM3NmUwYTY3NjFlNzJmZDU2MTg4ZTE2ZDMwOTU3
|
11
|
+
NDRkNDVlZmY0OTBlMDQ0YTk2NWQyODg3ZWRhN2MwYjE3YmYxMTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGM3NGQxZDgxZjJkMjEzZWUzZjg3OGZlYWQ5NzM0MWUyOTAzOWRlNjlkMDRh
|
14
|
+
Y2NmM2VjOWRiYzU4ZTA4MzYxYmY0ZGJlM2M5Y2QzMGEyNjgyYTRmNGIxMDFh
|
15
|
+
N2YyNjYxZWFjMDUyMjk1Njg0ODVmNWMwNDk2Njc3YmYyNmFhYTg=
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Cul::Scv::Hydra::Thumbnails
|
2
|
+
# some thumbnail urls
|
3
|
+
NO_THUMB = "cul_scv_hydra/crystal/file.png"
|
4
|
+
BROKEN_THUMB = "cul_scv_hydra/crystal/file_broken.png"
|
5
|
+
COLLECTION_THUMB = "cul_scv_hydra/crystal/kmultiple.png"
|
6
|
+
AUDIO_THUMB = "cul_scv_hydra/crystal/sound.png"
|
7
|
+
# some rel predicates
|
8
|
+
FORMAT = "http://purl.org/dc/elements/1.1/format"
|
9
|
+
MEMBER_OF = "http://purl.oclc.org/NET/CUL/memberOf"
|
10
|
+
HAS_MODEL = "info:fedora/fedora-system:def/model#hasModel"
|
11
|
+
IMAGE_WIDTH = "http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/imageWidth"
|
12
|
+
IMAGE_LENGTH = "http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/imageLength"
|
13
|
+
|
14
|
+
def show
|
15
|
+
pid = params[:id].split(/@/)[0]
|
16
|
+
get_by_pid(pid)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_by_pid(pid)
|
20
|
+
r_obj = ActiveFedora::Base.find(pid, :cast=>true)
|
21
|
+
|
22
|
+
if r_obj.respond_to? :thumbnail_info
|
23
|
+
url = r_obj.thumbnail_info
|
24
|
+
else
|
25
|
+
url = {:url=>image_url(COLLECTION_THUMB),:mime=>'image/png'}
|
26
|
+
end
|
27
|
+
if url[:asset]
|
28
|
+
url[:url] = asset_path_from_config(url[:asset])
|
29
|
+
end
|
30
|
+
puts "#{url[:url]} #{url[:mime]}"
|
31
|
+
filename = pid + '.' + url[:mime].split('/')[1].downcase
|
32
|
+
h_cd = "filename=""#{CGI.escapeHTML(filename)}"""
|
33
|
+
headers.delete "Cache-Control"
|
34
|
+
headers["Content-Disposition"] = h_cd
|
35
|
+
headers["Content-Type"] = url[:mime]
|
36
|
+
|
37
|
+
if url[:url].to_s =~ /^https?:/
|
38
|
+
cl = http_client
|
39
|
+
render :status => 200, :text => cl.get_content(url[:url])
|
40
|
+
return
|
41
|
+
else
|
42
|
+
render :status => 200, :text => File.read(url[:url])
|
43
|
+
return
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def jp2_thumbnail(pid)
|
48
|
+
{:url => ActiveFedora.fedora_config.credentials[:url] + '/objects/' + pid + '/methods/ldpd:sdef.Image/getView?max=250', :mime => 'image/jpeg'}
|
49
|
+
end
|
50
|
+
|
51
|
+
def pid_from_uri(uri)
|
52
|
+
return uri.sub(/info:fedora\//,'')
|
53
|
+
end
|
54
|
+
|
55
|
+
def asset_path_from_config(asset)
|
56
|
+
Rails.configuration.assets.paths.each do |dir|
|
57
|
+
result = "#{dir}/#{asset}"
|
58
|
+
return result if File.exists?(result)
|
59
|
+
end
|
60
|
+
return nil
|
61
|
+
end
|
62
|
+
|
63
|
+
def image_asset_url(source)
|
64
|
+
URI.join(root_url, ActionController::Base.helpers.asset_path(source))
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -56,7 +56,7 @@ module Cul::Scv::Hydra::Models::Aggregator
|
|
56
56
|
solr_members(opts)
|
57
57
|
end
|
58
58
|
|
59
|
-
def
|
59
|
+
def member_ids(opts={})
|
60
60
|
opts = opts.merge({:response_format=>:id_array})
|
61
61
|
solr_members(opts)
|
62
62
|
end
|
@@ -66,7 +66,7 @@ module Cul::Scv::Hydra::Models::Aggregator
|
|
66
66
|
members = []
|
67
67
|
r.collect {|hit| members << SolrDocument.new(hit) } unless r.blank?
|
68
68
|
if members.length == 0
|
69
|
-
return {:
|
69
|
+
return {:url=>image_url("cul_scv_hydra/crystal/file.png"),:mime=>'image/png'}
|
70
70
|
else
|
71
71
|
thumb = nil
|
72
72
|
unless datastreams['structMetadata'].new?
|
@@ -75,7 +75,7 @@ module Cul::Scv::Hydra::Models::Aggregator
|
|
75
75
|
thumb = thumb_from_members(members)
|
76
76
|
end
|
77
77
|
end
|
78
|
-
return thumb || {:
|
78
|
+
return thumb || {:url=>image_url("cul_scv_hydra/crystal/file.png"),:mime=>'image/png'}
|
79
79
|
end
|
80
80
|
|
81
81
|
private
|
@@ -72,7 +72,7 @@ module Cul::Scv::Hydra::Models::ImageResource
|
|
72
72
|
url = "#{DJATOKA_BASE_URL}?#{options.map { |key, value| "#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}"}.join("&") }"
|
73
73
|
{:url => url, :mime => t_parms["svc.format"]}
|
74
74
|
else
|
75
|
-
return {:
|
75
|
+
return {:url=>image_url("cul_scv_hydra/crystal/file.png",:mime=>'image/png'}
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -79,7 +79,7 @@ class GenericResource < ::ActiveFedora::Base
|
|
79
79
|
url = "#{DJATOKA_BASE_URL}?#{options.map { |key, value| "#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}"}.join("&") }"
|
80
80
|
{:url => url, :mime => t_parms["svc.format"]}
|
81
81
|
else
|
82
|
-
return {:
|
82
|
+
return {:url => image_url("cul_scv_hydra/crystal/file.png",:mime=>'image/png'}
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cul_scv_hydra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Armintor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blacklight
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- app/assets/images/cul_scv_hydra/crystal/mp3.png
|
199
199
|
- app/assets/images/cul_scv_hydra/crystal/multimedia2.png
|
200
200
|
- app/assets/images/cul_scv_hydra/crystal/video.png
|
201
|
+
- app/controllers/concerns/cul/scv/hydra/thumbnails.rb
|
201
202
|
- app/models/bag_aggregator.rb
|
202
203
|
- app/models/concerns/cul/scv/hydra/models.rb
|
203
204
|
- app/models/concerns/cul/scv/hydra/models/aggregator.rb
|