Module: AngularRailsSeo::ViewHelpers
- Defined in:
- lib/angular_rails_seo/view_helpers.rb
Instance Method Summary collapse
-
#seo_data ⇒ Object
Returns SEO data as defined in in seo.json.
- #seo_default ⇒ Object
- #seo_dynamic(class_name, matchdata) ⇒ Object
-
#seo_meta_author ⇒ Object
Author meta tags.
-
#seo_meta_description ⇒ Object
Description meta tags.
-
#seo_tags ⇒ Object
Inserts all SEO tags.
-
#seo_title ⇒ Object
Title tag.
Instance Method Details
#seo_data ⇒ Object
Returns SEO data as defined in in seo.json
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/angular_rails_seo/view_helpers.rb', line 6 def seo_data if @seo_data.nil? Rails.configuration.seo.each do |key, value| regex = Regexp.new(value["regex"]).match(request.path) unless regex.nil? data = Rails.configuration.seo[key] fallback = data["parent"].blank? ? seo_default : seo_default.merge(Rails.configuration.seo[data["parent"]]) unless data["model"].blank? response = seo_dynamic(data["model"], regex[1..(regex.size - 1)]) data = response.nil? ? {} : response end @seo_data = fallback.merge(data) end end end @seo_data ||= seo_default end |
#seo_default ⇒ Object
28 29 30 |
# File 'lib/angular_rails_seo/view_helpers.rb', line 28 def seo_default Rails.configuration.seo["default"] end |
#seo_dynamic(class_name, matchdata) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/angular_rails_seo/view_helpers.rb', line 32 def seo_dynamic(class_name, matchdata) begin klass = class_name.constantize rescue logger.warn "SEO: unable to retrieve SEO data for #{class_name}" return nil end begin response = klass.send(:seo_match, matchdata) rescue logger.warn "SEO: couldn't call seo_match method of #{class_name}" return nil end return response end |
#seo_meta_author ⇒ Object
Author meta tags
52 53 54 |
# File 'lib/angular_rails_seo/view_helpers.rb', line 52 def tag :meta, name: "author", content: seo_data["author"] end |
#seo_meta_description ⇒ Object
Description meta tags
58 59 60 |
# File 'lib/angular_rails_seo/view_helpers.rb', line 58 def tag :meta, name: "description", content: seo_data["description"] end |
#seo_tags ⇒ Object
Inserts all SEO tags
64 65 66 |
# File 'lib/angular_rails_seo/view_helpers.rb', line 64 def seo_title + + end |
#seo_title ⇒ Object
Title tag
70 71 72 |
# File 'lib/angular_rails_seo/view_helpers.rb', line 70 def seo_title content_tag :title, seo_data["title"], "ng-bind" => "pageTitle" end |