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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OThmMDMzYmQxNWU0NTk2OGRlNDI0ZmUwNWZmYWZjYTViNzM2NmU3Yg==
4
+ YjA3NTcxODBmNDg0YTgyNDk2MjU5OWM1OGVhZmRhZWM5NjUwZDQ4Zg==
5
5
  data.tar.gz: !binary |-
6
- ZGU4NTMxODQ0YTZkYjRhMzQ1MjFjYWQ2YzYzZTc5ZTk4NmU3N2ZhMQ==
6
+ MDlmN2UxNTg5YzM2ODZkYWU5MzI1ZGZlZTAxN2Y4MDNmMzM4ZjFmNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWU5NGE1MDcwY2VkOThmZGNlYTVjNjlhYjNjN2QyNDk3Y2UzODE1MjZhNzVi
10
- NzdkMmM3ZDExNDdjZDA1YzNhYjgwYzRjNGY0ZDE1NmI5NDI4ZWQ5YjNkN2Y2
11
- ZjlkMzU0OTk4MTZiNWRkZWMzZmY2OTZmNDRkMjUyMWE2Njc4ZTQ=
9
+ Y2EwYzI1MzQ2NzgxMWRiYzQ4ZWI3MWE4ZGEwMjBlMjcxNmU3MjkwYzE0NWNi
10
+ MTBmZWMyNmQ1NzMwODAyYmM3NmUwYTY3NjFlNzJmZDU2MTg4ZTE2ZDMwOTU3
11
+ NDRkNDVlZmY0OTBlMDQ0YTk2NWQyODg3ZWRhN2MwYjE3YmYxMTQ=
12
12
  data.tar.gz: !binary |-
13
- ZmFkY2VmOTQ5ODVjNzE5Y2M4MWM3OGM3N2NlMzI4YTkxYTdjNTE2MjBkMGE4
14
- MTI5MDhhMDU3YjM2MjA1MzMwYTk3NzM4ZWRjZTY2MGQyYjdiNDQ3MDI3NmY2
15
- ODQ2MTJmY2ZiODFhOGEwNGRjNzQxNzgyNWM2ZTNkOTVlYjI3Zjk=
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 members_ids(opts={})
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 {:asset=>"cul_scv_hydra/crystal/file.png",:mime=>'image/png'}
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 || {:asset=>"cul_scv_hydra/crystal/file.png",:mime=>'image/png'}
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 {:asset=>"cul_scv_hydra/crystal/file.png",:mime=>'image/png'}
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 {:asset=>"crystal/file.png",:mime=>'image/png'}
82
+ return {:url => image_url("cul_scv_hydra/crystal/file.png",:mime=>'image/png'}
83
83
  end
84
84
  end
85
85
 
@@ -1,7 +1,7 @@
1
1
  module Cul
2
2
  module Scv
3
3
  module Hydra
4
- VERSION = '0.12.1'
4
+ VERSION = '0.13.3'
5
5
  def self.version
6
6
  VERSION
7
7
  end
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.12.1
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-01 00:00:00.000000000 Z
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