Module: Goldencobra::ArticleConcerns::MetaTag
- Extended by:
- ActiveSupport::Concern
- Included in:
- Goldencobra::Article
- Defined in:
- app/models/goldencobra/article_concerns/meta_tag.rb
Overview
Meta Tags fuer einen Goldencobra::Article
Ueber diese Methoden kann einheitlich auf die Metatags zugegriffen werden. Die Regeln zur Erstellung der MetaTags und deren Fallbacks koennen so zentral gesteuert werden
Instance Method Summary collapse
- #combined_meta_tags ⇒ Object
- #combined_open_graph_tags ⇒ Object
- #meta_tag_canonical_url ⇒ Object
- #meta_tag_meta_description ⇒ Object
- #meta_tag_open_graph_description ⇒ Object
- #meta_tag_open_graph_image ⇒ Object
- #meta_tag_open_graph_title ⇒ Object
- #meta_tag_open_graph_type ⇒ Object
- #meta_tag_open_graph_url ⇒ Object
- #meta_tag_site ⇒ Object
-
#meta_tag_static_custom ⇒ Hash
Generate a hash of custom_tags in settings every children in goldencobra.page.custom_tags will by a custom meta_tag.
- #meta_tag_title_tag ⇒ Object
Instance Method Details
#combined_meta_tags ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 67 def { site: , title: , separator: " ", reverse: true, description: , canonical: , open_graph: , noindex: robots_no_index }.merge() end |
#combined_open_graph_tags ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 80 def { title: , description: , type: , url: , image: } end |
#meta_tag_canonical_url ⇒ Object
49 50 51 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 49 def (:canonical_url, :absolute_public_url) end |
#meta_tag_meta_description ⇒ Object
19 20 21 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 19 def (:metatag_meta_description, :teaser) end |
#meta_tag_open_graph_description ⇒ Object
27 28 29 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 27 def (:metatag_open_graph_description, :metatag_meta_description, :teaser) end |
#meta_tag_open_graph_image ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 39 def if .present? og_image_url = else og_image_url = images.first.try(:image).try(:url) end og_image_fallback = Goldencobra::Setting.for_key("goldencobra.facebook.opengraph_default_image") og_image_url.present? ? og_image_url : og_image_fallback end |
#meta_tag_open_graph_title ⇒ Object
23 24 25 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 23 def (:metatag_open_graph_title, :metatag_title_tag, :breadcrumb, :title) end |
#meta_tag_open_graph_type ⇒ Object
31 32 33 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 31 def .present? ? : "website" end |
#meta_tag_open_graph_url ⇒ Object
35 36 37 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 35 def (:metatag_open_graph_url, :absolute_public_url) end |
#meta_tag_site ⇒ Object
11 12 13 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 11 def Goldencobra::Setting.for_key("goldencobra.page.default_title_tag") end |
#meta_tag_static_custom ⇒ Hash
Generate a hash of custom_tags in settings every children in goldencobra.page.custom_tags will by a custom meta_tag. Esisting tags (canonical, noindex,… ) will be overwritten by custom tags with the same name
59 60 61 62 63 64 65 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 59 def custom_tag_settings = Goldencobra::Setting.where(title: "custom_tags").first return {} if custom_tag_settings.blank? if custom_tag_settings.present? && custom_tag_settings.parent_names == "goldencobra.page" Hash[custom_tag_settings.children.map { |s| [s.title.to_sym, s.value] }] end end |
#meta_tag_title_tag ⇒ Object
15 16 17 |
# File 'app/models/goldencobra/article_concerns/meta_tag.rb', line 15 def (:metatag_title_tag, :breadcrumb) end |