Skip to content

Commit

Permalink
Merge pull request #2267 from sul-dlss/auto-generated-captions
Browse files Browse the repository at this point in the history
add auto-generated label to caption
  • Loading branch information
peetucket authored Dec 17, 2024
2 parents 64f756f + 75e7789 commit c64ebda
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
6 changes: 6 additions & 0 deletions app/assets/stylesheets/companion_window.scss
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@
}
}

.transcript-header {
background: $color-fog-light;
padding-bottom: 1.5rem;
}

.header-background {
background: $color-fog-light;
display: flex;
Expand All @@ -253,6 +258,7 @@

&.transcript-controls {
font-size: 0.8rem;
flex-direction: column;

input {
margin-left: 0.6rem;
Expand Down
26 changes: 14 additions & 12 deletions app/components/embed/media_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@

<% component.with_drawer_content do %>
<section id="transcript" data-companion-window-target="transcript" role="tabpanel" hidden>
<div class="header-background">
<h3>Transcript</h3>
</div>
<div class="transcript-controls header-background">
<div class="transcript-autoscroll">
<label for="autoscroll">Auto scroll</label>
<input data-transcript-target="autoscroll" type="checkbox" id="autoscroll">
<div class="transcript-header">
<div class="header-background">
<h3>Transcript</h3>
</div>
<div class="transcript-language">
<label class="visually-hidden" for="caption-languages">Select Language</label>
<select name="caption-languages" id="caption-languages" data-transcript-target="captionLanguageSelect" data-action="transcript#selectLanguage">
<option value="">Select Language</option>
</select>
<div class="transcript-controls header-background">
<div class="transcript-autoscroll">
<label for="autoscroll">Auto scroll</label>
<input data-transcript-target="autoscroll" type="checkbox" id="autoscroll">
</div>
<div class="transcript-language">
<label class="visually-hidden" for="caption-languages">Select Language</label>
<select name="caption-languages" id="caption-languages" data-transcript-target="captionLanguageSelect" data-action="transcript#selectLanguage">
<option value="">Select Language</option>
</select>
</div>
</div>
</div>
<div class="left-drawer-content transcript" data-action="media-loaded@window->transcript#persistPlayer media-data-loaded@window->transcript#load time-update@window->transcript#highlightCue">
Expand Down
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
13 changes: 11 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,16 @@ def language_label
Bcp47::Registry.resolve(language_code) || 'Unknown'
end

def media_caption_label
"#{language_label}#{sdr_generated_text}"
end

def caption_label
"#{language_label} captions"
"#{language_label} captions#{sdr_generated_text}"
end

def sdr_generated_text
sdr_generated? ? ' (auto-generated)' : ''
end

def downloadable?
Expand Down

0 comments on commit c64ebda

Please sign in to comment.