Class: Www::VideoPresenter
- Inherits:
-
VideoBasePresenter
- Object
- SimpleDelegator
- BasePresenter
- VideoBasePresenter
- Www::VideoPresenter
- Defined in:
- app/presenters/www/video_presenter.rb
Overview
Presenter: video presenter.
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
- #breadcrumb_links_array(_params) ⇒ Object
- #cloudflare_stream_url ⇒ Object
-
#expanded_description ⇒ Object
Localize.
-
#id_iri ⇒ Object
Provide a stable @id IRI for the VideoObject so WebPage mainEntity can reference it.
-
#initialize(model, view = nil, options = nil) ⇒ VideoPresenter
constructor
A new instance of VideoPresenter.
- #page_description ⇒ Object
- #page_title ⇒ Object
-
#path ⇒ Object
Absolute canonical URL.
- #primary_product_line ⇒ Object
-
#render_transcript ⇒ Object
Transcript rendering methods for public pages.
- #sub_header ⇒ Object
- #text_description ⇒ Object
- #to_json_ld ⇒ Object
- #transcript ⇒ Object
Methods inherited from VideoBasePresenter
#build_transcript_schema, #cf_poster_url, #chapter_clips, #cloudflare_embed_url, #cloudflare_mp4_url, #cloudflare_video_url, #created_at, #format_duration, #format_duration_for_display, #format_paragraphs_as_text, #format_sentences_as_text, #format_structured_paragraphs_as_text, #format_timestamp, #has_assemblyai_transcript_id?, #has_audio_extraction?, #has_cloudflare_captions?, #has_html_transcript?, #has_structured_transcript_json?, #published_on, #schema_dot_org_structure, #title, #transcript_display, #transcript_duration, #transcript_language, #video_medias_url
Methods inherited from BasePresenter
#can?, #capture, #concat, #content_tag, #fa_icon, #h, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u
Constructor Details
#initialize(model, view = nil, options = nil) ⇒ VideoPresenter
Returns a new instance of VideoPresenter.
5 6 7 8 |
# File 'app/presenters/www/video_presenter.rb', line 5 def initialize(model, view = nil, = nil) @url_helper = Www::Router.new super end |
Instance Method Details
#breadcrumb_links_array(_params) ⇒ Object
14 15 16 17 18 19 |
# File 'app/presenters/www/video_presenter.rb', line 14 def (_params) b_arr = [{ name: 'Video Library', url: h.cms_link('/videos') }] b_arr += h.(primary_product_line) if primary_product_line b_arr << { name: video.title } b_arr end |
#cloudflare_stream_url ⇒ Object
43 44 45 |
# File 'app/presenters/www/video_presenter.rb', line 43 def cloudflare_stream_url cloudflare_video_url end |
#expanded_description ⇒ Object
Localize
22 23 24 |
# File 'app/presenters/www/video_presenter.rb', line 22 def h.localize_content video. end |
#id_iri ⇒ Object
Provide a stable @id IRI for the VideoObject so WebPage mainEntity can reference it
68 69 70 |
# File 'app/presenters/www/video_presenter.rb', line 68 def id_iri path end |
#page_description ⇒ Object
39 40 41 |
# File 'app/presenters/www/video_presenter.rb', line 39 def page_description h.localize_content(super) end |
#page_title ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'app/presenters/www/video_presenter.rb', line 47 def page_title t = +'' t << (video..presence || video.title.presence) # We append the company locale, unless the company name is already in the title t << " | #{h.company_locale}" unless t.include?(h.company_locale) t.prepend('Video: ') unless t.start_with?('Video:') t end |
#path ⇒ Object
Absolute canonical URL. Used as the VideoObject/WebPage @id and in schema
URLs (Clip #t= links), which must be absolute IRIs — not a relative
cms_link path — so cross-node entity-graph references resolve.
63 64 65 |
# File 'app/presenters/www/video_presenter.rb', line 63 def path video.cms_url end |
#primary_product_line ⇒ Object
10 11 12 |
# File 'app/presenters/www/video_presenter.rb', line 10 def primary_product_line video.product_lines.first end |
#render_transcript ⇒ Object
Transcript rendering methods for public pages
73 74 75 76 77 78 79 80 81 82 |
# File 'app/presenters/www/video_presenter.rb', line 73 def render_transcript return '' if video.transcript.blank? h.content_tag(:div, class: 'transcript') do h.safe_join([ render_transcript_header, render_transcript_content ]) end end |
#sub_header ⇒ Object
30 31 32 |
# File 'app/presenters/www/video_presenter.rb', line 30 def sub_header h.localize_content video.sub_header end |
#text_description ⇒ Object
34 35 36 37 |
# File 'app/presenters/www/video_presenter.rb', line 34 def text_description d = video..presence || (Nokogiri::HTML(video.).text if video..present?) || video.sub_header.presence || video..presence || video.title.presence h.localize_content(d.squeeze(' ').strip) end |
#to_json_ld ⇒ Object
56 57 58 |
# File 'app/presenters/www/video_presenter.rb', line 56 def to_json_ld schema_dot_org_structure.to_s end |
#transcript ⇒ Object
26 27 28 |
# File 'app/presenters/www/video_presenter.rb', line 26 def transcript h.localize_content video.transcript end |