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.
8 9 10 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 8 def initialize(context) @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 6 def context @context end |
Instance Method Details
#canonical_url(url, options = {}) ⇒ Object
55 56 57 58 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 55 def canonical_url(url, = {}) ('og:url', 'twitter:url', url) << context.tag(:link, rel: "canonical", "href" => url) end |
#card_type(type, options = {}) ⇒ Object
40 41 42 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 40 def card_type(type, = {}) ('twitter:card', type) end |
#description(values, options = {}) ⇒ Object
20 21 22 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 20 def description(values, = {}) ('description', 'og:description', 'twitter:description', values) end |
#iframe_video_url(video_url, options = {}) ⇒ Object
28 29 30 31 32 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 28 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
24 25 26 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 24 def image_url(image_url, = {}) ('og:image', 'twitter:image', image_url) end |
#site_name(name, options = {}) ⇒ Object
51 52 53 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 51 def site_name(name, = {}) ('og:site_name', name) end |
#stream_video_url(video_url, options = {}) ⇒ Object
34 35 36 37 38 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 34 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
12 13 14 15 16 17 18 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 12 def title(values, = {}) title = Helpers::FirstNonBlank.find(values) title += [:title_suffix] if [:title_suffix] context.content_tag(:title, title) << ('og:title', 'twitter:title', values) end |
#video_size(size, options = {}) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/showcase/helpers/seo_meta_builder.rb', line 44 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 |