hydra-core 6.1.0 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b7bbd65400b9e3173824a1cb57422323c4f04a0
4
- data.tar.gz: 989d029fd3bf0481304766bf8ccc6dbd32a3384f
3
+ metadata.gz: d0bab92197a631330fa21a7a548ce74eac3b6c1b
4
+ data.tar.gz: e93594e35f3912e8bb315c896a2d1b9bfeeca262
5
5
  SHA512:
6
- metadata.gz: 4ce648f2cbd0c653c658d1dad402c372ce149d9e66f00c011baf328dee6f4cbfd3e1c566662fd040c758dfb9b70516205683c89e4701eb558cbfdb6cecfc9200
7
- data.tar.gz: 22c9cfe1972f18b3c581ea8f058075d4f06c6532e77bb3e8377e85fc2d6d26f9b57d6e5752352920ec325b3eeef128350a73cd3039dc165d64fa7734a436b06a
6
+ metadata.gz: 6acbd061cda6f61cac8be5a275936e92e169d4f07e3491a475116cf5dd829b08be8b7150f1e37316c4a523910637734f26632755935b9ef0290ef5d55b3ad807
7
+ data.tar.gz: 009fdf265cf9e97ea3bc8e7ef900bc1c705eea7f2cb0826cdf31769c76200e98e4f3a378783f660d2af95a0f0f274ddb5ab7e1ffdce721f6b64e9020934d30fa
@@ -3,12 +3,20 @@ module Hydra
3
3
  include Blacklight::BlacklightHelperBehavior
4
4
 
5
5
  # Given a Fedora uri, generate a reasonable partial name
6
+ # Rails thinks that periods indicate a filename, so escape them with slashes.
7
+ # @param [Hash] document the solr document (hash of fields & values)
8
+ # @return [String] the name for the display partial
9
+ # @example
10
+ # document_partial_name('has_model_s' => ["info:fedora/hull-cModel:genericContent"])
11
+ # => "generic_content"
12
+ # document_partial_name('has_model_s' => ["info:fedora/hull-cModel:text.pdf"])
13
+ # => "text_pdf"
6
14
  def document_partial_name(document)
7
15
  display_type = document[blacklight_config.show.display_type]
8
16
 
9
17
  return 'default' unless display_type
10
18
 
11
- display_type.first.gsub(/^[^\/]+\/[^:]+:/,"").underscore
19
+ Array(display_type).first.gsub(/^[^\/]+\/[^:]+:/,"").gsub(/\./, '_').underscore
12
20
  end
13
21
 
14
22
  # COPIED from vendor/plugins/blacklight/app/helpers/application_helper.rb
@@ -21,7 +21,7 @@ class CatalogController < ApplicationController
21
21
 
22
22
  # solr field configuration for search results/index views
23
23
  config.index.show_link = 'title_tesim'
24
- config.index.record_tsim_type = 'has_model_ssim'
24
+ config.index.record_display_type = 'has_model_ssim'
25
25
 
26
26
  # solr field configuration for document/show views
27
27
  config.show.html_title = 'title_tesim'
@@ -22,7 +22,7 @@ module Hydra
22
22
  protected
23
23
 
24
24
  def load_asset
25
- @asset = ActiveFedora::Base.find(params[:id], :cast=>true)
25
+ @asset = ActiveFedora::Base.load_instance_from_solr(params[:id])
26
26
  end
27
27
 
28
28
  def load_datastream
@@ -53,6 +53,7 @@ module Hydra
53
53
  def datastream_to_show
54
54
  ds = asset.datastreams[params[:datastream_id]] if params.has_key?(:datastream_id)
55
55
  ds = default_content_ds if ds.nil?
56
+ raise "Unable to find a datastream for #{asset}" if ds.nil?
56
57
  ds
57
58
  end
58
59
 
@@ -107,7 +108,7 @@ module Hydra
107
108
 
108
109
  def default_content_ds
109
110
  ActiveFedora::ContentModel.known_models_for(asset).each do |model_class|
110
- return model_class.default_content_ds if model_class.respond_to?(:default_content_ds)
111
+ return asset.datastreams[model_class.default_content_ds] if model_class.respond_to?(:default_content_ds)
111
112
  end
112
113
  if asset.datastreams.keys.include?(DownloadsController.default_content_dsid)
113
114
  return asset.datastreams[DownloadsController.default_content_dsid]
@@ -1,4 +1,4 @@
1
1
  module HydraHead
2
- VERSION = "6.1.0"
2
+ VERSION = "6.1.1"
3
3
  end
4
4
 
@@ -19,6 +19,7 @@ describe DownloadsController do
19
19
  @obj = ActiveFedora::Base.new
20
20
  @obj = ModsAsset.new
21
21
  @obj.label = "world.png"
22
+ @obj.add_file_datastream('fizz', :dsid=>'buzz', :mimeType => 'image/png')
22
23
  @obj.add_file_datastream('foobarfoobarfoobar', :dsid=>'content', :mimeType => 'image/png')
23
24
  @obj.add_file_datastream("It's a stream", :dsid=>'descMetadata', :mimeType => 'text/plain')
24
25
  @obj.read_users = [@user.user_key]
@@ -33,7 +34,15 @@ describe DownloadsController do
33
34
  User.any_instance.stub(:groups).and_return([])
34
35
  end
35
36
  describe "show" do
36
- it "should default to returning configured default download" do
37
+ it "should default to returning default download configured by object" do
38
+ ModsAsset.stub(:default_content_ds).and_return('buzz')
39
+ get "show", :id => @obj.pid
40
+ response.should be_success
41
+ response.headers['Content-Type'].should == "image/png"
42
+ response.headers["Content-Disposition"].should == "inline; filename=\"world.png\""
43
+ response.body.should == 'fizz'
44
+ end
45
+ it "should default to returning default download configured by controller" do
37
46
  DownloadsController.default_content_dsid.should == "content"
38
47
  get "show", :id => @obj.pid
39
48
  response.should be_success
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe BlacklightHelper do
4
4
  describe "document_partial_name" do
5
- it "Should lop off everything before the first colin after the slash" do
5
+ it "should lop off everything before the first colin after the slash" do
6
6
  @config = Blacklight::Configuration.new.configure do |config|
7
7
  config.show.display_type = 'has_model_s'
8
8
  end
@@ -10,6 +10,21 @@ describe BlacklightHelper do
10
10
  helper.document_partial_name('has_model_s' => ["info:fedora/afmodel:Presentation"]).should == "presentation"
11
11
  helper.document_partial_name('has_model_s' => ["info:fedora/hull-cModel:genericContent"]).should == "generic_content"
12
12
  end
13
+ it "should support single valued fields" do
14
+ @config = Blacklight::Configuration.new.configure do |config|
15
+ config.show.display_type = 'active_fedora_model_ssi'
16
+ end
17
+ helper.stub(:blacklight_config).and_return(@config)
18
+ helper.document_partial_name('active_fedora_model_ssi' => "Chicken").should == "chicken"
19
+ end
20
+
21
+ it "should handle periods" do
22
+ @config = Blacklight::Configuration.new.configure do |config|
23
+ config.show.display_type = 'has_model_s'
24
+ end
25
+ helper.stub(:blacklight_config).and_return(@config)
26
+ helper.document_partial_name('has_model_s' => ["info:fedora/afmodel:text.PDF"]).should == "text_pdf"
27
+ end
13
28
  end
14
29
 
15
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0
4
+ version: 6.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt, Bess Sadler, Julie Meloni, Naomi Dushay, Jessie Keck, John Scofield,
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-29 00:00:00.000000000 Z
12
+ date: 2013-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -87,14 +87,14 @@ dependencies:
87
87
  requirements:
88
88
  - - '='
89
89
  - !ruby/object:Gem::Version
90
- version: 6.1.0
90
+ version: 6.1.1
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - '='
96
96
  - !ruby/object:Gem::Version
97
- version: 6.1.0
97
+ version: 6.1.1
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: jettywrapper
100
100
  requirement: !ruby/object:Gem::Requirement