Module: FiSeo::ActsAsSeoableInstanceMethods
- Defined in:
- lib/fi_seo.rb
Instance Method Summary collapse
- #canonical_url ⇒ Object
- #create_dynamic_seo_record ⇒ Object
- #description_value ⇒ Object
- #facebook_tags ⇒ Object
- #keywords_value ⇒ Object
- #title_value ⇒ Object
- #to_meta_tags ⇒ Object
- #twitter_tags ⇒ Object
- #update_dynamic_seo_record ⇒ Object
Instance Method Details
#canonical_url ⇒ Object
187 188 189 |
# File 'lib/fi_seo.rb', line 187 def canonical_url FiSeo.initialized_config.default_canonical_url end |
#create_dynamic_seo_record ⇒ Object
150 151 152 153 |
# File 'lib/fi_seo.rb', line 150 def create_dynamic_seo_record DynamicSeo.create(seoable_type: self.class.to_s, seoable_id: id, title: self.title_value, description: self.description_value, keywords: self.keywords_value) end |
#description_value ⇒ Object
195 196 197 |
# File 'lib/fi_seo.rb', line 195 def description_value self.send(self.class.seoable_fields.second) end |
#facebook_tags ⇒ Object
167 168 169 170 171 172 173 174 175 |
# File 'lib/fi_seo.rb', line 167 def { title: FiSeo.initialized_config.default_facebook_title, type: FiSeo.initialized_config.default_facebook_type, url: FiSeo.initialized_config.default_facebook_url, image: FiSeo.initialized_config.default_facebook_image, description: FiSeo.initialized_config.default_facebook_description } end |
#keywords_value ⇒ Object
199 200 201 |
# File 'lib/fi_seo.rb', line 199 def keywords_value self.send(self.class.seoable_fields.third) end |
#title_value ⇒ Object
191 192 193 |
# File 'lib/fi_seo.rb', line 191 def title_value self.send(self.class.seoable_fields.first) end |
#to_meta_tags ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/fi_seo.rb', line 114 def row = DynamicSeo.find_by_seoable_type_and_seoable_id(self.class.to_s, self.id) if row.nil? {} else hash = { title: row.title, description: row.description, keywords: row.keywords, lowercase: self.class.[:lowercase], reverse: self.class.[:reverse], index: self.class.[:index], noindex: self.class.[:noindex], follow: self.class.[:follow], nofollow: self.class.[:nofollow], noarchive: self.class.[:noarchive], separator: self.class.[:separator].html_safe } if self.class.[:social].present? if self.class.[:social].include? :facebook hash.merge!(og: ) end if self.class.[:social].include? :twitter hash.merge!(twitter: ) end end if self.class.[:canonical].present? hash.merge!(canonical: canonical_url) end hash end end |
#twitter_tags ⇒ Object
177 178 179 180 181 182 183 184 185 |
# File 'lib/fi_seo.rb', line 177 def { title: FiSeo.initialized_config.default_twitter_title, card: FiSeo.initialized_config.default_twitter_card, site: FiSeo.initialized_config.default_twitter_site, image: FiSeo.initialized_config.default_twitter_image, description: FiSeo.initialized_config.default_twitter_description } end |
#update_dynamic_seo_record ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/fi_seo.rb', line 155 def update_dynamic_seo_record if self.class.[:check_for_changes] row = DynamicSeo.find_by_seoable_type_and_seoable_id(self.class.to_s, self.id) if row.nil? self.create_dynamic_seo_record else DynamicSeo.where(seoable_type: self.class.to_s).where(seoable_id: self.id) .update_all(title: self.title_value, description: self.description_value, keywords: self.keywords_value) end end end |