Skip to content

Commit

Permalink
add auto-generated label to caption
Browse files Browse the repository at this point in the history
  • Loading branch information
dnoneill committed Dec 4, 2024
1 parent 99ac3d3 commit f438f7d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/components/embed/media_tag_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def captions
safe_join(
@resource.caption_files.map.with_index do |caption_file, i|
tag.track(src: caption_file.file_url, kind: 'captions',
srclang: caption_file.language_code, label: caption_file.language_label,
srclang: caption_file.language_code, label: caption_file.media_caption_label,
default: (i.zero? ? '' : nil))
end
)
Expand Down
5 changes: 5 additions & 0 deletions app/models/embed/purl/file_json_deserializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def view
@file.fetch('access').fetch('view')
end

def sdr_generated
@file.fetch('sdrGeneratedText', false)
end

def deserialize # rubocop:disable Metrics/MethodLength
ResourceFile.new(
druid: @druid,
Expand All @@ -52,6 +56,7 @@ def deserialize # rubocop:disable Metrics/MethodLength
stanford_only:,
location_restricted:,
world_downloadable:,
sdr_generated:,
stanford_only_downloadable:
)
end
Expand Down
9 changes: 7 additions & 2 deletions app/models/embed/purl/resource_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ def attributes=(hash)
end
end

attr_accessor :druid, :label, :filename, :mimetype, :size, :language, :role,
attr_accessor :druid, :label, :filename, :mimetype, :size, :language, :role, :sdr_generated,
:world_downloadable, :stanford_only, :location_restricted, :stanford_only_downloadable

alias title filename
alias world_downloadable? world_downloadable
alias stanford_only? stanford_only
alias location_restricted? location_restricted
alias stanford_only_downloadable? stanford_only_downloadable
alias sdr_generated? sdr_generated

##
# Creates a file url for stacks
Expand Down Expand Up @@ -59,8 +60,12 @@ def language_label
Bcp47::Registry.resolve(language_code) || 'Unknown'
end

def media_caption_label
"#{language_label}#{sdr_generated? ? ' (auto-generated)' : ''}"
end

def caption_label
"#{language_label} captions"
"#{language_label} captions#{sdr_generated? ? ' (auto-generated)' : ''}"
end

def downloadable?
Expand Down

0 comments on commit f438f7d

Please sign in to comment.