hydra-head 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -1
- data/Gemfile.lock +17 -3
- data/README.textile +32 -15
- data/app/assets/javascripts/jquery.form.js +932 -531
- data/app/helpers/hydra/facets_helper_behavior.rb +1 -1
- data/app/helpers/hydra/hydra_helper_behavior.rb +1 -1
- data/app/helpers/hydra/javascript_includes_helper_behavior.rb +0 -4
- data/app/models/ability.rb +1 -0
- data/app/models/common_metadata_asset.rb +7 -1
- data/app/models/generic_content.rb +5 -1
- data/app/models/generic_image.rb +7 -3
- data/app/models/hydra/ability.rb +2 -0
- data/app/models/hydra/datastream/common_mods_index_methods.rb +2 -0
- data/app/models/hydra/datastream/mods_article.rb +2 -0
- data/app/models/hydra/datastream/mods_dataset.rb +7 -0
- data/app/models/hydra/datastream/mods_generic_content.rb +2 -0
- data/app/models/hydra/datastream/mods_image.rb +1 -0
- data/app/models/hydra/datastream/properties.rb +6 -1
- data/app/models/hydra/datastream/rights_metadata.rb +1 -0
- data/app/models/hydra/role_mapper_behavior.rb +1 -0
- data/app/models/mods_asset.rb +1 -1
- data/app/models/role_mapper.rb +3 -0
- data/app/models/superuser.rb +6 -0
- data/app/models/user_attribute.rb +6 -0
- data/app/models/uses_default_partials.rb +8 -0
- data/app/views/catalog/_delete_partials/_default.html.erb +2 -9
- data/app/views/catalog/_edit_partials/_default.html.erb +0 -1
- data/app/views/catalog/show.html.erb +1 -1
- data/app/views/generic_content_objects/_edit_description.html.erb +1 -1
- data/app/views/generic_content_objects/_show_description.html.erb +0 -2
- data/app/views/generic_contents/_edit.html.erb +10 -1
- data/app/views/generic_contents/_show.html.erb +0 -2
- data/app/views/generic_images/_edit.html.erb +1 -3
- data/app/views/generic_images/_show.html.erb +0 -2
- data/app/views/hydra/file_assets/_result.html.erb +1 -2
- data/config/fedora.yml +1 -1
- data/fedora_conf/conf/development/fedora.fcfg +1 -1
- data/fedora_conf/conf/test/fedora.fcfg +1 -1
- data/hydra-head.gemspec +2 -1
- data/lib/application_helper.rb +1 -0
- data/lib/generators/hydra/templates/config/fedora.yml +1 -1
- data/lib/generators/hydra/templates/config/initializers/hydra_config.rb +1 -12
- data/lib/hydra-head/routes.rb +1 -1
- data/lib/hydra-head/version.rb +1 -1
- data/lib/hydra/access_controls_enforcement.rb +10 -3
- data/lib/hydra/access_controls_evaluation.rb +2 -1
- data/lib/hydra/assets.rb +3 -0
- data/lib/hydra/assets_controller_helper.rb +4 -0
- data/lib/hydra/catalog.rb +1 -0
- data/lib/hydra/common_mods_index_methods.rb +1 -1
- data/lib/hydra/controller.rb +1 -0
- data/lib/hydra/file_assets.rb +7 -5
- data/lib/hydra/file_assets_helper.rb +4 -32
- data/lib/hydra/generic_content.rb +1 -0
- data/lib/hydra/generic_image.rb +2 -0
- data/lib/hydra/generic_user_attributes.rb +5 -0
- data/lib/hydra/model_methods.rb +4 -3
- data/lib/hydra/model_mixins.rb +1 -0
- data/lib/hydra/model_mixins/common_metadata.rb +1 -0
- data/lib/hydra/model_mixins/mods_object.rb +1 -0
- data/lib/hydra/models/file_asset.rb +4 -0
- data/lib/hydra/mods_article.rb +1 -0
- data/lib/hydra/mods_dataset.rb +1 -0
- data/lib/hydra/mods_generic_content.rb +1 -0
- data/lib/hydra/mods_image.rb +1 -0
- data/lib/hydra/repository_controller.rb +2 -0
- data/lib/hydra/rights_metadata.rb +1 -0
- data/lib/hydra/submission_workflow.rb +1 -0
- data/lib/hydra/superuser_attributes.rb +6 -0
- data/lib/hydra/user.rb +1 -0
- data/lib/mediashelf/active_fedora_helper.rb +2 -0
- data/lib/prev_next_links.rb +6 -0
- data/lib/user_attributes_loader.rb +2 -0
- data/lib/uva/mods_index_methods.rb +1 -0
- data/tasks/hydra-head.rake +9 -1
- data/tasks/hyhead_rspec.rake +2 -2
- data/test_support/etc/Gemfile +2 -1
- data/test_support/features/button_delete_asset.feature +13 -0
- data/test_support/features/file_upload.feature +7 -0
- data/test_support/features/step_definitions/file_list_steps.rb +8 -0
- data/test_support/features/step_definitions/html_validity_steps.rb +42 -45
- data/test_support/spec/controllers/file_assets_controller_spec.rb +12 -17
- data/test_support/spec/helpers/access_controls_enforcement_spec.rb +27 -1
- data/test_support/spec/helpers/assets_controller_helper_spec.rb +3 -3
- data/test_support/spec/integration/file_asset_spec.rb +0 -44
- data/test_support/spec/models/hydra_rights_metadata_spec.rb +3 -1
- data/test_support/spec/spec_helper.rb +16 -0
- data/vendor/cache/factory_girl-2.6.4.gem +0 -0
- data/vendor/cache/jquery-rails-2.0.2.gem +0 -0
- metadata +26 -24
- data/BLACKLIGHT_CONFIG.textile +0 -76
- data/HOW_DO_I.textile +0 -107
- data/HOW_TO_GET_STARTED.textile +0 -588
- data/app/models/audio_asset.rb +0 -8
- data/app/models/image_asset.rb +0 -8
- data/app/models/video_asset.rb +0 -8
- data/fedora/conf/fedora.fcfg +0 -1021
- data/lib/application_controller.rb +0 -24
- data/lib/block_mapper.rb +0 -52
- data/lib/ead_mapper.rb +0 -7
- data/lib/field_maps.rb +0 -507
- data/lib/marc_mapper.rb +0 -131
- data/lib/marc_record_ext.rb +0 -97
- data/test_support/spec/models/audio_asset_spec.rb +0 -23
- data/test_support/spec/models/image_asset_spec.rb +0 -23
- data/test_support/spec/models/video_asset_spec.rb +0 -23
- data/vendor/cache/factory_girl-3.1.1.gem +0 -0
data/lib/marc_mapper.rb
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'marc' # ruby gem for working with MARC data in Ruby
|
3
|
-
require 'block_mapper' # the generic mapper class
|
4
|
-
require 'marc_record_ext.rb' # our custom methods
|
5
|
-
require 'base64' # so we can base64 encode the marc21 record
|
6
|
-
|
7
|
-
class MARCMapper
|
8
|
-
|
9
|
-
# pass in a path to a marc file
|
10
|
-
# a block can be used for logging etc..
|
11
|
-
#
|
12
|
-
# mapper.from_marc_file('/path/to/data.mrc') do |mapped_doc|
|
13
|
-
# # do something here... logging etc..
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# this returns an array of documents (hashes)
|
17
|
-
#
|
18
|
-
def self.from_marc_file(marc_file, &blk)
|
19
|
-
|
20
|
-
@mapper = BlockMapper.new
|
21
|
-
|
22
|
-
# add custom methods to each marc record
|
23
|
-
@mapper.before_each_source_item do |rec,index|
|
24
|
-
rec.extend MARCRecordExt
|
25
|
-
end
|
26
|
-
|
27
|
-
# remove ; / . , : and spaces from the end
|
28
|
-
cleanup_regexp = /( |;|\/|\.|,|:)+$/
|
29
|
-
# after_each_mapped_value gets executed for each mapped item
|
30
|
-
# ... after it has been mapped
|
31
|
-
@mapper.after_each_mapped_value do |field,v|
|
32
|
-
#puts "cleaning up #{field} value(s) before adding to solr..."
|
33
|
-
if v.is_a?(String)
|
34
|
-
v.gsub(cleanup_regexp, '') # clean this string and return
|
35
|
-
elsif v.is_a?(Array)
|
36
|
-
v.map{|vv|vv.gsub(cleanup_regexp, '')} # clean each value and return a new array
|
37
|
-
else
|
38
|
-
v # just return whatever it is
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
@mapper.map :id do |rec,index|
|
43
|
-
rec['001'].value.gsub(" ","").gsub("/","")
|
44
|
-
end
|
45
|
-
|
46
|
-
# titles (text)
|
47
|
-
@mapper.map :title_t do |rec,index|
|
48
|
-
rec.values_for '245', 'a'
|
49
|
-
end
|
50
|
-
|
51
|
-
@mapper.map :sub_title_t do |rec,index|
|
52
|
-
rec.values_for '245', 'b'
|
53
|
-
end
|
54
|
-
|
55
|
-
@mapper.map :alt_titles_t do |rec,index|
|
56
|
-
rec.extract '240:b 700:t 710:t 711:t 440:a 490:a 505:a 830:a'
|
57
|
-
end
|
58
|
-
|
59
|
-
@mapper.map :title_added_entry_t do |rec,index|
|
60
|
-
rec.values_for '700', 't'
|
61
|
-
end
|
62
|
-
|
63
|
-
# title sort
|
64
|
-
@mapper.map :title_sort do |rec,index|
|
65
|
-
rec.extract '245:a'
|
66
|
-
end
|
67
|
-
|
68
|
-
@mapper.map :author_t do |rec,index|
|
69
|
-
rec.extract '100:a 110:a 111:a 130:a 700:a 710:a 711:a'
|
70
|
-
end
|
71
|
-
|
72
|
-
@mapper.map :published_t do |rec,index|
|
73
|
-
rec.extract '260:a'
|
74
|
-
end
|
75
|
-
|
76
|
-
@mapper.map :isbn_t do |rec,index|
|
77
|
-
rec.isbn # in MARCRecordExt module
|
78
|
-
end
|
79
|
-
|
80
|
-
@mapper.map :material_type_t do |rec,index|
|
81
|
-
rec.values_for '300', 'a'
|
82
|
-
end
|
83
|
-
|
84
|
-
# subject (text)
|
85
|
-
@mapper.map :subject_t do |rec,index|
|
86
|
-
rec.extract '600:a 610:a 611:a 630:a 650:a 651:a 655:a 690:a'
|
87
|
-
end
|
88
|
-
|
89
|
-
# subject (facets)
|
90
|
-
@mapper.map :subject_era_facet do |rec,index|
|
91
|
-
rec.extract '650:d 650:y 651:y 655:y'
|
92
|
-
end
|
93
|
-
|
94
|
-
@mapper.map :geographic_subject_facet do |rec,index|
|
95
|
-
rec.extract '650:c 650:z 651:a 651:x 651:z 655:z'
|
96
|
-
end
|
97
|
-
|
98
|
-
@mapper.map :language_facet do |rec,index|
|
99
|
-
rec.languages # in MARCRecordExt module
|
100
|
-
end
|
101
|
-
|
102
|
-
# format fields
|
103
|
-
@mapper.map :format_facet do |rec,index|
|
104
|
-
rec.format # in MARCRecordExt module
|
105
|
-
end
|
106
|
-
|
107
|
-
# downcased, format, spaces converted to _
|
108
|
-
# This can be used for the partial view mapping
|
109
|
-
@mapper.map :format_code_t do |rec,index|
|
110
|
-
rec.format.to_s.downcase.gsub(/ _/, ' ').gsub(/ /, '_')
|
111
|
-
end
|
112
|
-
|
113
|
-
# grab some vernacular for demonstration purposes (e.g. "did you mean")
|
114
|
-
@mapper.map :vern_t do |rec,index|
|
115
|
-
rec.extract '880:a 880:b 880:c 880:e 880:f 880:p 880:t'
|
116
|
-
end
|
117
|
-
|
118
|
-
# _display is stored, but not indexed
|
119
|
-
# don't store a string, store marc21 so we can read it back out
|
120
|
-
# into a MARC::Record object
|
121
|
-
@mapper.map :marc_display do |rec,index|
|
122
|
-
rec.to_xml
|
123
|
-
end
|
124
|
-
|
125
|
-
reader = MARC::Reader.new(marc_file)
|
126
|
-
|
127
|
-
@mapper.run(reader, &blk)
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
data/lib/marc_record_ext.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
|
2
|
-
# MARC::Record helpers
|
3
|
-
|
4
|
-
# This module gets mixed into each MARC::Record instance
|
5
|
-
|
6
|
-
require 'field_maps'
|
7
|
-
|
8
|
-
module MARCRecordExt
|
9
|
-
|
10
|
-
# input is a string in the format of: field:subfield
|
11
|
-
# multiple fields can be given, use a single space to separate
|
12
|
-
# example: record.extract '245:a 245:b'
|
13
|
-
def extract(input, regexp=nil)
|
14
|
-
hash = {}
|
15
|
-
input.split(' ').each do |item|
|
16
|
-
k,v = item.split(':')
|
17
|
-
next unless k
|
18
|
-
hash[k]||=[]
|
19
|
-
hash[k] << v if v
|
20
|
-
end
|
21
|
-
hash.map do |field,subfields|
|
22
|
-
values_for(field, subfields, regexp)
|
23
|
-
end.flatten
|
24
|
-
end
|
25
|
-
|
26
|
-
# This methods returns a single dimensional array of values for subfields (it also removes blank values)
|
27
|
-
# if subs is specified, only the matching subfields are returned
|
28
|
-
# if subs is nil, the all subfields are returned
|
29
|
-
# the value_regx can be used to match the value of the subfield
|
30
|
-
#
|
31
|
-
# =example: values_for '045', [:a]
|
32
|
-
#
|
33
|
-
# =parameters
|
34
|
-
# field_name - '045' etc.
|
35
|
-
# subs - [:a, :b] etc.
|
36
|
-
# value_regx - a Regexp
|
37
|
-
def values_for(field_name, subs=nil, value_regx=nil)
|
38
|
-
subs ||= []
|
39
|
-
subs = [subs] unless subs.is_a?(Array)
|
40
|
-
self.fields.collect do |field|
|
41
|
-
if field.tag==field_name and ! field.value.to_s.empty?
|
42
|
-
field.subfields.collect do |subfield|
|
43
|
-
next if ! subs.empty? and ! subs.include?(subfield.code)
|
44
|
-
v = value_regx ? subfield.value.match(value_regx) : subfield.value
|
45
|
-
v.empty? ? nil : v
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end.flatten.uniq.reject{|v|v.to_s.empty?}
|
49
|
-
end
|
50
|
-
|
51
|
-
# http://woss.name/2005/09/09/isbn-validation-part-2
|
52
|
-
def valid_isbn?(isbn, c_map = '0123456789X')
|
53
|
-
sum = 0
|
54
|
-
return unless isbn
|
55
|
-
match = isbn[0..-2].to_s.scan(/\d/)
|
56
|
-
match.each_with_index do |c,i|
|
57
|
-
sum += c.to_i * (i+1)
|
58
|
-
end
|
59
|
-
isbn[-1] == c_map[sum % c_map.length]
|
60
|
-
end
|
61
|
-
|
62
|
-
# extracts valid isbns
|
63
|
-
def isbn
|
64
|
-
values = self.extract('020:a')
|
65
|
-
# go through each value
|
66
|
-
values.select do |v| # "select" collects values only if the last line of this block is true
|
67
|
-
# split on a space, grab the first
|
68
|
-
isbn = v.to_s.split(' ').first
|
69
|
-
# is it valid?
|
70
|
-
valid_isbn?(isbn)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# returns the mapped language value
|
75
|
-
def languages
|
76
|
-
values = [self['008'].value[35..37]]
|
77
|
-
values += self.extract('041:a 041:d')
|
78
|
-
values.uniq!
|
79
|
-
mapped = values.map{|code| FieldMaps::LANGUAGE[code] }
|
80
|
-
mapped.reject{|v| v.to_s.empty? }
|
81
|
-
end
|
82
|
-
|
83
|
-
# http://www.itsmarc.com/crs/Bib0021.htm#Leader_06_Definition
|
84
|
-
def format
|
85
|
-
char_6 = self.leader[6...7]
|
86
|
-
char_7 = self.leader[7...8]
|
87
|
-
if char_6 == 'a' and %W(a c d m).include? char_7
|
88
|
-
code = 'a'
|
89
|
-
elsif %W(b s).include? char_7
|
90
|
-
code = 'serials'
|
91
|
-
else
|
92
|
-
code = char_6
|
93
|
-
end
|
94
|
-
FieldMaps::FORMAT[code] || 'Unknown'
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
require "active_fedora"
|
3
|
-
|
4
|
-
describe AudioAsset do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
# Fedora::Repository.stubs(:instance).returns(stub_everything())
|
8
|
-
@asset = AudioAsset.new
|
9
|
-
@asset.stubs(:create_date).returns("2008-07-02T05:09:42.015Z")
|
10
|
-
@asset.stubs(:modified_date).returns("2008-09-29T21:21:52.892Z")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "Should be a kind of ActiveFedora::Base kind of FileAsset, and instance of AudioAsset" do
|
14
|
-
@asset.should be_kind_of(ActiveFedora::Base)
|
15
|
-
@asset.should be_kind_of(FileAsset)
|
16
|
-
@asset.should be_instance_of(AudioAsset)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should have a conforms_to relationship pointing to FileAsset" do
|
20
|
-
@asset.ids_for_outbound(:has_model).should include("afmodel:FileAsset")
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
require "active_fedora"
|
3
|
-
|
4
|
-
describe ImageAsset do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
# Fedora::Repository.stubs(:instance).returns(stub_everything())
|
8
|
-
@asset = ImageAsset.new
|
9
|
-
@asset.stubs(:create_date).returns("2008-07-02T05:09:42.015Z")
|
10
|
-
@asset.stubs(:modified_date).returns("2008-09-29T21:21:52.892Z")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "Should be a kind of ActiveFedora::Base kind of FileAsset, and instance of ImageAsset" do
|
14
|
-
@asset.should be_kind_of(ActiveFedora::Base)
|
15
|
-
@asset.should be_kind_of(FileAsset)
|
16
|
-
@asset.should be_instance_of(ImageAsset)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should have a conforms_to relationship pointing to FileAsset" do
|
20
|
-
@asset.ids_for_outbound(:has_model).should include("afmodel:FileAsset")
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
require "active_fedora"
|
3
|
-
|
4
|
-
describe VideoAsset do
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
# Fedora::Repository.stubs(:instance).returns(stub_everything())
|
8
|
-
@asset = VideoAsset.new
|
9
|
-
@asset.stubs(:create_date).returns("2008-07-02T05:09:42.015Z")
|
10
|
-
@asset.stubs(:modified_date).returns("2008-09-29T21:21:52.892Z")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "Should be a kind of ActiveFedora::Base kind of FileAsset, and instance of VideoAsset" do
|
14
|
-
@asset.should be_kind_of(ActiveFedora::Base)
|
15
|
-
@asset.should be_kind_of(FileAsset)
|
16
|
-
@asset.should be_instance_of(VideoAsset)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should have a conforms_to relationship pointing to FileAsset" do
|
20
|
-
@asset.ids_for_outbound(:has_model).should include("afmodel:FileAsset")
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
Binary file
|