hydra-head 3.1.5 → 3.2.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/.gitignore +1 -0
  2. data/CREATE_RAILS_APP.textile +2 -3
  3. data/Gemfile.lock +34 -32
  4. data/HISTORY.textile +8 -0
  5. data/app/models/file_asset.rb +1 -111
  6. data/app/models/mods_asset.rb +1 -1
  7. data/hydra-head.gemspec +2 -2
  8. data/lib/hydra-head.rb +1 -0
  9. data/lib/hydra-head/railtie.rb +11 -0
  10. data/lib/hydra-head/version.rb +1 -1
  11. data/lib/hydra.rb +2 -0
  12. data/lib/hydra/assets.rb +1 -1
  13. data/lib/hydra/assets_controller_helper.rb +1 -0
  14. data/lib/hydra/catalog.rb +7 -4
  15. data/lib/hydra/file_assets.rb +6 -17
  16. data/lib/hydra/image.rb +3 -0
  17. data/lib/hydra/model_methods.rb +6 -0
  18. data/lib/hydra/models/file_asset.rb +74 -0
  19. data/lib/railties/hydra-fixtures.rake +1 -3
  20. data/lib/railties/hydra_jetty.rake +1 -1
  21. data/tasks/hydra-head-fixtures.rake +1 -2
  22. data/test_support/features/step_definitions/edit_metadata_steps.rb +4 -4
  23. data/test_support/features/step_definitions/file_list_steps.rb +5 -5
  24. data/test_support/features/step_definitions/user_steps.rb +4 -4
  25. data/test_support/spec/helpers/hydra_assets_helper_spec.rb +5 -57
  26. data/test_support/spec/integration/file_asset_spec.rb +5 -56
  27. data/test_support/spec/models/file_asset_spec.rb +0 -17
  28. data/vendor/cache/{active-fedora-3.1.4.gem → active-fedora-3.2.0.pre5.gem} +0 -0
  29. data/vendor/cache/columnize-0.3.6.gem +0 -0
  30. data/vendor/cache/cucumber-1.1.4.gem +0 -0
  31. data/vendor/cache/{cucumber-rails-1.2.0.gem → cucumber-rails-1.2.1.gem} +0 -0
  32. data/vendor/cache/daemons-1.1.5.gem +0 -0
  33. data/vendor/cache/gherkin-2.7.1.gem +0 -0
  34. data/vendor/cache/haml-3.1.4.gem +0 -0
  35. data/vendor/cache/jettywrapper-1.2.0.gem +0 -0
  36. data/vendor/cache/json-1.6.3.gem +0 -0
  37. data/vendor/cache/json_pure-1.6.4.gem +0 -0
  38. data/vendor/cache/kaminari-0.13.0.gem +0 -0
  39. data/vendor/cache/om-1.4.4.gem +0 -0
  40. data/vendor/cache/rdoc-3.12.gem +0 -0
  41. data/vendor/cache/rubydora-0.3.1.gem +0 -0
  42. data/vendor/cache/selenium-webdriver-2.15.0.gem +0 -0
  43. data/vendor/cache/solrizer-fedora-1.2.2.gem +0 -0
  44. data/vendor/cache/stomp-1.2.0.gem +0 -0
  45. data/vendor/cache/yard-0.7.4.gem +0 -0
  46. metadata +43 -36
  47. data/app/views/catalog/_email_form.html.erb +0 -9
  48. data/vendor/cache/columnize-0.3.5.gem +0 -0
  49. data/vendor/cache/cucumber-1.1.3.gem +0 -0
  50. data/vendor/cache/daemons-1.1.4.gem +0 -0
  51. data/vendor/cache/gherkin-2.6.8.gem +0 -0
  52. data/vendor/cache/haml-3.1.3.gem +0 -0
  53. data/vendor/cache/jettywrapper-1.1.0.gem +0 -0
  54. data/vendor/cache/json-1.6.2.gem +0 -0
  55. data/vendor/cache/json_pure-1.6.2.gem +0 -0
  56. data/vendor/cache/kaminari-0.12.4.gem +0 -0
  57. data/vendor/cache/om-1.4.3.gem +0 -0
  58. data/vendor/cache/rdoc-3.11.gem +0 -0
  59. data/vendor/cache/rubydora-0.2.6.gem +0 -0
  60. data/vendor/cache/selenium-webdriver-2.13.0.gem +0 -0
  61. data/vendor/cache/solrizer-fedora-1.2.0.gem +0 -0
  62. data/vendor/cache/stomp-1.1.10.gem +0 -0
  63. data/vendor/cache/yard-0.7.3.gem +0 -0
data/.gitignore CHANGED
@@ -12,6 +12,7 @@ tmtags
12
12
 
13
13
  ## VIM
14
14
  *.swp
15
+ *.swo
15
16
 
16
17
  ## OSX
17
18
  .DS_Store
@@ -299,7 +299,6 @@ git commit -m "Adding hydra-jetty submodule"
299
299
  h4. (3) Run Jetty
300
300
 
301
301
  _Stop any copies of jetty (or anything else using port 8983) before running this command._
302
- (Note that java 1.6 must be invoked by the "java" command or Fedora won't work.)
303
302
 
304
303
  The following will copy Solr and Fedora configuration files over to jetty in addition to starting it:
305
304
 
@@ -310,7 +309,7 @@ rake hydra:jetty:load
310
309
  h2. XI. Run Your New Hydra Application
311
310
 
312
311
  <pre>
313
- script/server
312
+ rails server
314
313
  </pre>
315
314
 
316
315
  You should now be able to go to your application at http://localhost:3000.
@@ -319,5 +318,5 @@ Note that there are no objects pre-installed into Fedora (or Solr).
319
318
 
320
319
  h2. XII. Develop your Hydra Application with ActiveFedora and OM
321
320
 
322
- See "HOW_TO_GET_STARTED":https://github.com/mediashelf/om/blob/master/HOW_TO_GET_STARTED.textile.
321
+ See "GETTING_STARTED":https://github.com/mediashelf/om/blob/master/GETTING_STARTED.textile.
323
322
 
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hydra-head (3.1.5)
4
+ hydra-head (3.2.0.pre1)
5
5
  RedCloth (= 4.2.3)
6
- active-fedora (~> 3.1.4)
6
+ active-fedora (>= 3.2.0.pre5)
7
7
  blacklight (= 3.0.0)
8
8
  block_helpers
9
9
  builder (= 2.1.2)
@@ -32,7 +32,7 @@ PATH
32
32
  sanitize
33
33
  solr-ruby
34
34
  solrizer (>= 1.1.0)
35
- solrizer-fedora (>= 1.2.0)
35
+ solrizer-fedora (>= 1.2.2)
36
36
  term-ansicolor
37
37
  trollop
38
38
  will_paginate
@@ -56,19 +56,19 @@ GEM
56
56
  rack-mount (~> 0.6.14)
57
57
  rack-test (~> 0.5.7)
58
58
  tzinfo (~> 0.3.23)
59
- active-fedora (3.1.4)
60
- activeresource (~> 3.0.0)
61
- activesupport (~> 3.0.0)
59
+ active-fedora (3.2.0.pre5)
60
+ activeresource (>= 3.0.0)
61
+ activesupport (>= 3.0.0)
62
62
  equivalent-xml
63
63
  facets
64
64
  mediashelf-loggable
65
65
  mime-types (>= 1.16)
66
66
  multipart-post (= 1.1.2)
67
67
  nokogiri
68
- om (>= 1.4.3)
68
+ om (>= 1.4.4)
69
69
  rdf
70
70
  rdf-rdfxml
71
- rubydora (~> 0.2.6)
71
+ rubydora (~> 0.3.0)
72
72
  solr-ruby (>= 0.0.6)
73
73
  solrizer (> 1.0.0)
74
74
  xml-simple (>= 1.0.12)
@@ -109,20 +109,20 @@ GEM
109
109
  xpath (~> 0.1.4)
110
110
  childprocess (0.2.3)
111
111
  ffi (~> 1.0.6)
112
- columnize (0.3.5)
112
+ columnize (0.3.6)
113
113
  crack (0.3.1)
114
- cucumber (1.1.3)
114
+ cucumber (1.1.4)
115
115
  builder (>= 2.1.2)
116
116
  diff-lcs (>= 1.1.2)
117
- gherkin (~> 2.6.7)
117
+ gherkin (~> 2.7.1)
118
118
  json (>= 1.4.6)
119
119
  term-ansicolor (>= 1.0.6)
120
- cucumber-rails (1.2.0)
121
- capybara (>= 1.1.1)
122
- cucumber (>= 1.1.1)
120
+ cucumber-rails (1.2.1)
121
+ capybara (>= 1.1.2)
122
+ cucumber (>= 1.1.3)
123
123
  nokogiri (>= 1.5.0)
124
124
  curb (0.7.15)
125
- daemons (1.1.4)
125
+ daemons (1.1.5)
126
126
  database_cleaner (0.7.0)
127
127
  diff-lcs (1.1.3)
128
128
  equivalent-xml (0.2.8)
@@ -134,27 +134,29 @@ GEM
134
134
  activesupport
135
135
  fastercsv (1.5.4)
136
136
  ffi (1.0.11)
137
- gherkin (2.6.8)
137
+ gherkin (2.7.1)
138
138
  json (>= 1.4.6)
139
139
  gyoku (0.4.4)
140
140
  builder (>= 2.1.2)
141
- haml (3.1.3)
141
+ haml (3.1.4)
142
142
  httparty (0.8.1)
143
143
  multi_json
144
144
  multi_xml
145
145
  httpi (0.9.5)
146
146
  rack
147
147
  i18n (0.5.0)
148
- jettywrapper (1.1.0)
148
+ jettywrapper (1.2.0)
149
149
  activesupport (>= 3.0.0)
150
150
  childprocess
151
151
  i18n
152
152
  logger
153
153
  mediashelf-loggable
154
- json (1.6.2)
155
- json_pure (1.6.2)
156
- kaminari (0.12.4)
157
- rails (>= 3.0.0)
154
+ json (1.6.3)
155
+ json_pure (1.6.4)
156
+ kaminari (0.13.0)
157
+ actionpack (>= 3.0.0)
158
+ activesupport (>= 3.0.0)
159
+ railties (>= 3.0.0)
158
160
  launchy (2.0.5)
159
161
  addressable (~> 2.2.6)
160
162
  linecache (0.46)
@@ -176,7 +178,7 @@ GEM
176
178
  multipart-post (1.1.2)
177
179
  nokogiri (1.5.0)
178
180
  nori (1.0.2)
179
- om (1.4.3)
181
+ om (1.4.4)
180
182
  mediashelf-loggable
181
183
  nokogiri (>= 1.4.2)
182
184
  polyglot (0.3.3)
@@ -206,7 +208,7 @@ GEM
206
208
  rdf-rdfxml (0.3.5)
207
209
  nokogiri (>= 1.4.4)
208
210
  rdf (>= 0.3.4)
209
- rdoc (3.11)
211
+ rdoc (3.12)
210
212
  json (~> 1.4)
211
213
  rest-client (1.6.7)
212
214
  mime-types (>= 1.16)
@@ -232,7 +234,7 @@ GEM
232
234
  ruby-debug-base (~> 0.10.4.0)
233
235
  ruby-debug-base (0.10.4)
234
236
  linecache (>= 0.3)
235
- rubydora (0.2.6)
237
+ rubydora (0.3.1)
236
238
  activemodel
237
239
  activesupport
238
240
  fastercsv
@@ -251,10 +253,10 @@ GEM
251
253
  nokogiri (>= 1.4.0)
252
254
  nori (~> 1.0)
253
255
  wasabi (~> 2.0)
254
- selenium-webdriver (2.13.0)
256
+ selenium-webdriver (2.15.0)
255
257
  childprocess (>= 0.2.1)
256
258
  ffi (~> 1.0.9)
257
- json_pure
259
+ multi_json (~> 1.0.4)
258
260
  rubyzip
259
261
  solr-ruby (0.0.8)
260
262
  solrizer (1.1.2)
@@ -264,15 +266,15 @@ GEM
264
266
  om (>= 1.4.0)
265
267
  stomp
266
268
  xml-simple
267
- solrizer-fedora (1.2.0)
268
- active-fedora (~> 3.1.0)
269
+ solrizer-fedora (1.2.2)
270
+ active-fedora (>= 3.1.0)
269
271
  activesupport
270
272
  fastercsv
271
- jettywrapper (~> 1.1.0)
273
+ jettywrapper (>= 1.1.0)
272
274
  rsolr
273
275
  solr-ruby (>= 0.0.6)
274
276
  solrizer (>= 1.0.0)
275
- stomp (1.1.10)
277
+ stomp (1.2.0)
276
278
  term-ansicolor (1.0.7)
277
279
  thor (0.14.6)
278
280
  treetop (1.4.10)
@@ -287,7 +289,7 @@ GEM
287
289
  xml-simple (1.1.1)
288
290
  xpath (0.1.4)
289
291
  nokogiri (~> 1.3)
290
- yard (0.7.3)
292
+ yard (0.7.4)
291
293
 
292
294
  PLATFORMS
293
295
  ruby
data/HISTORY.textile CHANGED
@@ -1,5 +1,13 @@
1
+ h3. 3.2.0
2
+ * Update to ActiveFedora 3.2.0
3
+ * Update to solrizer-fedora 1.2.2
4
+ * Remove calls to has_relationship
5
+ * File assets no longer check collection_member relationship (for container)
6
+
1
7
  h3. 3.1.5
2
8
  * Update to ActiveFedora 3.1.4
9
+ * Update to solrizer-fedora 1.2.0
10
+ * Fix problems where Datastreamr#attributes["mimeType"] was being called (changed to Datastream#mimeType)
3
11
 
4
12
 
5
13
  h3. 3.1.4
@@ -1,115 +1,5 @@
1
1
  # model for a FileAsset ActiveFedora object
2
2
  # a file asset is a generic notion of a file, which could have, for example, image or text or video behaviors.
3
3
  class FileAsset < ActiveFedora::Base
4
-
5
- include Hydra::ModelMethods
6
-
7
- has_relationship "is_member_of_collection", :has_collection_member, :inbound => true
8
- has_bidirectional_relationship "part_of", :is_part_of, :has_part
9
-
10
- # deletes the object identified by pid if it does not have any objects asserting has_collection_member
11
- def self.garbage_collect(pid)
12
- begin
13
- obj = FileAsset.load_instance(pid)
14
- if obj.containers.empty?
15
- obj.delete
16
- end
17
- rescue
18
- end
19
- end
20
-
21
- # Returns a human readable filesize appropriate for the given number of bytes (ie. automatically chooses 'bytes','KB','MB','GB','TB')
22
- # Based on a bit of python code posted here: http://blogmag.net/blog/read/38/Print_human_readable_file_size
23
- # @param [Numeric] file size in bits
24
- def bits_to_human_readable(num)
25
- ['bytes','KB','MB','GB','TB'].each do |x|
26
- if num < 1024.0
27
- return "#{num.to_i} #{x}"
28
- else
29
- num = num/1024.0
30
- end
31
- end
32
- end
33
-
34
- has_metadata :name => "descMetadata", :type => ActiveFedora::QualifiedDublinCoreDatastream do |m|
35
- end
36
-
37
- def label
38
- descMetadata.title_values.first
39
- end
40
-
41
- def label=(label)
42
- super
43
- descMetadata.title_values = label
44
- end
45
-
46
- # augments add_file_datastream to also put file size (in bytes/KB/MB/GB/TB) in dc:extent
47
- def add_file_datastream(file, opts={})
48
- super
49
- if file.respond_to?(:size)
50
- size = bits_to_human_readable(file.size)
51
- elsif file.kind_of?(File)
52
- size = bits_to_human_readable(File.size(file))
53
- else
54
- size = ""
55
- end
56
- datastreams["descMetadata"].extent_values = size
57
- end
58
-
59
- # Mimic the relationship accessor that would be created if a containers relationship existed
60
- # Decided to create this method instead because it combines more than one relationship list
61
- # from is_member_of_collection and part_of
62
- # @param [Hash] opts The options hash that can contain a :response_format value of :id_array, :solr, or :load_from_solr
63
- # @return [Array] Objects found through inbound has_collection_member and part_of relationships
64
- def containers(opts={})
65
- is_member_array = is_member_of_collection(:response_format=>:id_array)
66
-
67
- if !is_member_array.empty?
68
- logger.warn "This object has inbound collection member assertions. hasCollectionMember will no longer be used to track file_object relationships after active_fedora 1.3. Use isPartOf assertions in the RELS-EXT of child objects instead."
69
- if opts[:response_format] == :solr || opts[:response_format] == :load_from_solr
70
- logger.warn ":solr and :load_from_solr response formats for containers search only uses parts relationships (usage of hasCollectionMember is no longer supported)"
71
- result = part_of(opts)
72
- else
73
- con_result = is_member_of_collection(opts)
74
- part_of_result = part_of(opts)
75
- ary = con_result+part_of_result
76
- result = ary.uniq
77
- end
78
- else
79
- result = part_of(opts)
80
- end
81
- return result
82
- end
83
-
84
- # Calls +containers+ with the :id_array option to return a list of pids for containers found.
85
- # @return [Array] Container ids (via is_member_of_collection and part_of relationships)
86
- def containers_ids
87
- containers(:response_format => :id_array)
88
- end
89
-
90
- # Calls +containers+ with the option to load objects found from solr instead of Fedora.
91
- # @return [Array] ActiveFedora::Base objects populated via solr
92
- def containers_from_solr
93
- containers(:response_format => :load_from_solr)
94
- end
95
-
96
- # Override ActiveFedora::Base.to_solr to...
97
- # Check if we are dealing with a child of FileAsset and if so when calling to_solr from Solrizer indexer we want to skip loading parent metadata again
98
- #
99
- # if known models greater than one (without ActiveFedora::Base) and
100
- # known models contains a child of FileAsset and
101
- # opts[:model_only] == true and
102
- # current object class is FileAsset
103
- # that means that the child already has had to_solr called which included metadata from FileAsset
104
- # if any of the above is false then call to_solr as normal
105
- def to_solr(solr_doc=Hash.new, opts={})
106
-
107
- active_fedora_model_s = solr_doc["active_fedora_model_s"] if solr_doc["active_fedora_model_s"]
108
- actual_class = active_fedora_model_s.constantize if active_fedora_model_s
109
- if actual_class && actual_class != self.class && actual_class.superclass == FileAsset
110
- solr_doc
111
- else
112
- super(solr_doc,opts)
113
- end
114
- end
4
+ include Hydra::Models::FileAsset
115
5
  end
@@ -14,4 +14,4 @@ class ModsAsset < ActiveFedora::Base
14
14
  # adds helpful methods for basic hydra objects
15
15
  include Hydra::ModelMethods
16
16
 
17
- end
17
+ end
data/hydra-head.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.add_dependency "rails", '~> 3.0.10'
16
16
  s.add_dependency "rsolr", '1.0.2' ## version 1.0.6 breaks when using blacklight 3.0.0
17
17
  s.add_dependency "blacklight", '3.0.0'
18
- s.add_dependency "active-fedora", '~>3.1.4'
18
+ s.add_dependency "active-fedora", '>=3.2.0.pre5'
19
19
  s.add_dependency 'builder', '2.1.2'
20
20
  s.add_dependency 'columnize'
21
21
  s.add_dependency 'crack'
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
40
40
  s.add_dependency 'solr-ruby'
41
41
  s.add_dependency 'mediashelf-loggable', '>=0.4.7' ##This can be removed once this dependency is declared in solrizer
42
42
  s.add_dependency 'solrizer', '>=1.1.0'
43
- s.add_dependency 'solrizer-fedora', '>=1.2.0'
43
+ s.add_dependency 'solrizer-fedora', '>=1.2.2'
44
44
  s.add_dependency 'term-ansicolor'
45
45
  s.add_dependency 'trollop'
46
46
  s.add_dependency 'will_paginate'
data/lib/hydra-head.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module HydraHead
2
2
  require 'hydra-head/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
3
+ require 'hydra-head/railtie' if defined? Rails
3
4
  require 'hydra-head/controller'
4
5
 
5
6
  require 'hydra-head/version'
@@ -0,0 +1,11 @@
1
+ require 'active-fedora'
2
+ require 'rails'
3
+
4
+ module HydraHead
5
+ class Railtie < Rails::Railtie
6
+ initializer "hydra-head.configure_rails_initialization" do
7
+ ActiveFedora.init
8
+ end
9
+ end
10
+ end
11
+
@@ -1,4 +1,4 @@
1
1
  module HydraHead
2
- VERSION = "3.1.5"
2
+ VERSION = "3.2.0.pre1"
3
3
  end
4
4
 
data/lib/hydra.rb CHANGED
@@ -3,6 +3,7 @@ require "blacklight"
3
3
  module Hydra
4
4
  extend Blacklight::Configurable
5
5
  extend ActiveSupport::Autoload
6
+ ## Matz says that autoload is going away, so we ought to discontinue this.
6
7
  autoload :Configurable, 'blacklight/configurable'
7
8
  autoload :Assets
8
9
  autoload :FileAssets
@@ -21,5 +22,6 @@ require 'hydra/rights_metadata'
21
22
  require 'hydra/common_mods_index_methods'
22
23
  require 'hydra/mods_article'
23
24
  require 'hydra/model_methods'
25
+ require 'hydra/models/file_asset'
24
26
 
25
27
  Dir[File.join(File.dirname(__FILE__), "hydra", "*.rb")].each {|f| require f}
data/lib/hydra/assets.rb CHANGED
@@ -62,7 +62,7 @@ module Hydra::Assets
62
62
  @document.save
63
63
  flash[:notice] = "Your changes have been saved."
64
64
 
65
- logger.debug("returning #{response.inspect}")
65
+ logger.debug("returning #{@response.inspect}")
66
66
 
67
67
  respond_to do |want|
68
68
  want.html {
@@ -110,6 +110,7 @@ module Hydra::AssetsControllerHelper
110
110
 
111
111
 
112
112
  # Updates the document based on the provided parameters
113
+ # This method can be overridden to perform additional update work in the hydra head.
113
114
  # @param [ActiveFedora::Base] document
114
115
  # @param [Hash] params should be the type expected by ActiveFedora::Base.update_datastream_attributes
115
116
  def update_document(document, params)
data/lib/hydra/catalog.rb CHANGED
@@ -48,11 +48,14 @@ module Hydra::Catalog
48
48
  def load_fedora_document
49
49
  af_base = ActiveFedora::Base.load_instance(params[:id])
50
50
  the_model = ActiveFedora::ContentModel.known_models_for( af_base ).first
51
- if the_model.nil?
52
- @document_fedora = af_base
53
- else
54
- @document_fedora = the_model.load_instance(params[:id])
51
+ unless the_model.include?(ActiveFedora::Relationships)
52
+ the_model.send :include, ActiveFedora::Relationships
55
53
  end
54
+ unless the_model.include?(ActiveFedora::FileManagement)
55
+ the_model.send :include, ActiveFedora::FileManagement
56
+ end
57
+
58
+ @document_fedora = af_base.adapt_to(the_model)
56
59
  @file_assets = @document_fedora.file_objects(:response_format=>:solr)
57
60
  end
58
61