Skip to content

Commit

Permalink
making suggest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
atomical committed Mar 29, 2013
1 parent 8d4f7af commit af51fed
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Expand Up @@ -13,8 +13,8 @@ def image_for(item_id)
video_count = 0 video_count = 0
audio_count = 0 audio_count = 0
media_object.parts.each do |part| media_object.parts.each do |part|
video_count = video_count + 1 if "Moving image" == part.file_format video_count = video_count + 1 if MediaType::VIDEO == part.file_format
audio_count = audio_count + 1 if "Sound" == part.file_format audio_count = audio_count + 1 if MediaType::SOUND == part.file_format
end end


logger.debug "<< Object has #{video_count} videos and #{audio_count} audios >>" logger.debug "<< Object has #{video_count} videos and #{audio_count} audios >>"
Expand Down
8 changes: 4 additions & 4 deletions app/models/master_file.rb
Expand Up @@ -119,9 +119,9 @@ def process
"flavor" => "presenter/source", "flavor" => "presenter/source",
"filename" => File.basename(file_location)} "filename" => File.basename(file_location)}


if file_format == 'Sound' if file_format == MediaType::SOUND
args['workflow'] = "fullaudio" args['workflow'] = "fullaudio"
elsif file_format == 'Moving image' elsif file_format == MediaType::VIDEO
args['workflow'] = "avalon" args['workflow'] = "avalon"
end end


Expand Down Expand Up @@ -326,9 +326,9 @@ def determine_format(file, content_type = nil)
# so a case statement should flow in the preferred order # so a case statement should flow in the preferred order
upload_format = case upload_format = case
when media_format.video? when media_format.video?
'Moving image' MediaType::VIDEO
when media_format.audio? when media_format.audio?
'Sound' MediaType::SOUND
else else
'Unknown' 'Unknown'
end end
Expand Down
17 changes: 8 additions & 9 deletions app/models/media_object.rb
Expand Up @@ -342,23 +342,22 @@ def update_attribute_in_metadata(attribute, value = [], attributes = [])
end end


def set_media_types! def set_media_types!
resource_type_names = {
'audio' => 'sound recording',
'video' => 'moving image'
}
mime_types = parts.collect { |mf| mime_types = parts.collect { |mf|
mf.file_location.nil? ? nil : Rack::Mime.mime_type(File.extname(mf.file_location)) mf.file_location.nil? ? nil : Rack::Mime.mime_type(File.extname(mf.file_location))
}.compact.uniq }.compact.uniq

master_file_media_type_map = {'Moving image' => 'moving image', 'Sound' => 'sound recording'} resource_type_to_formatted_text_map = { MediaType::VIDEO => MediaType::VIDEO, MediaType::SOUND => 'Sound recording'}
resource_types = self.parts.collect{|master_file| master_file_media_type_map[master_file.file_format] }.uniq resource_types = self.parts.collect{|master_file| resource_type_to_formatted_text_map[master_file.file_format] }.uniq


mime_types = nil if mime_types.empty? mime_types = nil if mime_types.empty?
resource_types = nil if resource_types.empty? resource_types = nil if resource_types.empty?


descMetadata.find_by_terms(:physical_description).remove descMetadata.ensure_root_term_exists!(:physical_description)
descMetadata.ensure_root_term_exists!(:resource_type)

descMetadata.find_by_terms(:physical_description, :internet_media_type).remove
descMetadata.find_by_terms(:resource_type).remove descMetadata.find_by_terms(:resource_type).remove
descMetadata.ensure_physical_description_exists!
descMetadata.update_values([:physical_description, :internet_media_type] => mime_types, [:resource_type] => resource_types) descMetadata.update_values([:physical_description, :internet_media_type] => mime_types, [:resource_type] => resource_types)
end end


Expand Down
6 changes: 3 additions & 3 deletions app/models/mods_behaviors.rb
Expand Up @@ -89,9 +89,9 @@ def update_change_date!(t=Time.now.iso8601)
self.record_change_date = t self.record_change_date = t
end end


def ensure_physical_description_exists! def ensure_root_term_exists!(term)
if find_by_terms(:physical_description).empty? if find_by_terms(term).empty?
ng_xml.root.add_child('<physicalDescription/>') ng_xml.root.add_child("<#{term.to_s.camelcase(first_letter = :lower)}/>")
end end
end end


Expand Down
4 changes: 2 additions & 2 deletions app/views/media_objects/_file_upload.html.erb
Expand Up @@ -31,9 +31,9 @@
<td>&nbsp;</td> <td>&nbsp;</td>
<td> <td>
<% case part.file_format <% case part.file_format
when 'Sound' %> when MediaType::SOUND %>
<i class="icon-volume-up"></i> <i class="icon-volume-up"></i>
<% when 'Moving image' %> <% when MediaType::VIDEO %>
<i class="icon-film"></i> <i class="icon-film"></i>
<% else %> <% else %>
<i class="icon-question-sign"></i> <i class="icon-question-sign"></i>
Expand Down
4 changes: 2 additions & 2 deletions app/views/media_objects/_structure.html.erb
Expand Up @@ -21,9 +21,9 @@
</td> </td>
<td> <td>
<% case masterfile.file_format <% case masterfile.file_format
when 'Sound' %> when MediaType::SOUND %>
<i class="icon-volume-up"></i> <i class="icon-volume-up"></i>
<% when 'Moving image' %> <% when MediaType::VIDEO %>
<i class="icon-film"></i> <i class="icon-film"></i>
<% else %> <% else %>
<i class="icon-question-sign"></i> <i class="icon-question-sign"></i>
Expand Down
4 changes: 2 additions & 2 deletions app/views/media_objects/mobile.html.erb
Expand Up @@ -15,9 +15,9 @@
you are using a MP4 live stream instead of FLV. All of this needs to go you are using a MP4 live stream instead of FLV. All of this needs to go
into a helper method so the view is not so messy. %> into a helper method so the view is not so messy. %>
<% format = case @currentStream.file_format <% format = case @currentStream.file_format
when "Moving image" when MediaType::VIDEO
'video' 'video'
when "Sound" when MediaType::SOUND
'audio' 'audio'
else else
'other' 'other'
Expand Down

0 comments on commit af51fed

Please sign in to comment.