Class: Showcase::Helpers::SeoMetaBuilder
- Inherits:
-
Object
- Object
- Showcase::Helpers::SeoMetaBuilder
- Defined in:
- lib/showcase/helpers/seo_meta_builder.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #canonical_url(url, options = {}) ⇒ Object
- #card_type(type, options = {}) ⇒ Object
- #description(values, options = {}) ⇒ Object
- #iframe_video_url(video_url, options = {}) ⇒ Object
- #image_url(image_url, options = {}) ⇒ Object
-
#initialize(context) ⇒ SeoMetaBuilder
constructor
A new instance of SeoMetaBuilder.
- #site_name(name, options = {}) ⇒ Object
- #stream_video_url(video_url, options = {}) ⇒ Object
- #title(values, options = {}) ⇒ Object
- #video_size(size, options = {}) ⇒ Object
Constructor Details
#initialize(context) ⇒ SeoMetaBuilder
Returns a new instance of SeoMetaBuilder.
6 7 8 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 6 def initialize(context) @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 4 def context @context end |
Instance Method Details
#canonical_url(url, options = {}) ⇒ Object
53 54 55 56 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 53 def canonical_url(url, = {}) ('og:url', 'twitter:url', url) << context.tag(:link, rel: "canonical", "href" => url) end |
#card_type(type, options = {}) ⇒ Object
38 39 40 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 38 def card_type(type, = {}) ('twitter:card', type) end |
#description(values, options = {}) ⇒ Object
18 19 20 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 18 def description(values, = {}) ('description', 'og:description', 'twitter:description', values) end |
#iframe_video_url(video_url, options = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 26 def iframe_video_url(video_url, = {}) ('og:video:url', video_url) << ('og:video:type', 'text/html') << ('twitter:player', video_url) end |
#image_url(image_url, options = {}) ⇒ Object
22 23 24 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 22 def image_url(image_url, = {}) ('og:image', 'twitter:image', image_url) end |
#site_name(name, options = {}) ⇒ Object
49 50 51 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 49 def site_name(name, = {}) ('og:site_name', name) end |
#stream_video_url(video_url, options = {}) ⇒ Object
32 33 34 35 36 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 32 def stream_video_url(video_url, = {}) ('og:video:url', video_url) << ('og:video:type', 'video/mp4') << ('twitter:player:stream', video_url) end |
#title(values, options = {}) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 10 def title(values, = {}) title = first_nonblank(values) title += [:title_suffix] if [:title_suffix] context.content_tag(:title, title) << ('og:title', 'twitter:title', values) end |
#video_size(size, options = {}) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 42 def video_size(size, = {}) ('twitter:player:width', size.first) << ('twitter:player:height', size.last) << ('og:video:width', size.first) << ('og:video:height', size.last) end |