module AngularRailsSeo::ViewHelpers
Public Instance Methods
seo_data()
click to toggle source
Returns SEO data as defined in in seo.json
# 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()
click to toggle source
# File lib/angular_rails_seo/view_helpers.rb, line 28 def seo_default Rails.configuration.seo["default"] end
seo_dynamic(class_name, matchdata)
click to toggle source
# 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_description()
click to toggle source
Description meta tags
# File lib/angular_rails_seo/view_helpers.rb, line 58 def seo_meta_description tag :meta, name: "description", content: seo_data["description"] end
seo_title()
click to toggle source
Title tag
# File lib/angular_rails_seo/view_helpers.rb, line 70 def seo_title content_tag :title, seo_data["title"], "ng-bind" => "pageTitle" end