Module: RailsConnector::SEO::InstanceMethods
- Defined in:
- lib/rails_connector/seo.rb
Overview
The methods contained herein are included in the Obj model.
Instance Method Summary collapse
-
#included_in_seo_sitemap? ⇒ Boolean
Default implementation: objects have to be
active?
and at least of one of: permitted for anyone (permitted_groups = []
),readable_for_googlebots?
. -
#readable_for_googlebots? ⇒ Boolean
Returns
true
by default. -
#seo_description ⇒ Object
Returns an html-stripped
Obj#body
, truncated to 300 chars. -
#seo_keywords ⇒ Object
Returns
nil
by default.
Instance Method Details
#included_in_seo_sitemap? ⇒ Boolean
Default implementation: objects have to be active?
and at least of one of: permitted for anyone (permitted_groups = []
), readable_for_googlebots?
. Overwrite in your ObjExtensions as you like.
35 36 37 |
# File 'lib/rails_connector/seo.rb', line 35 def included_in_seo_sitemap? (permitted_groups.empty? || readable_for_googlebots?) && active? end |
#readable_for_googlebots? ⇒ Boolean
Returns true
by default. Overwrite in your ObjExtensions as you like.
28 29 30 |
# File 'lib/rails_connector/seo.rb', line 28 def readable_for_googlebots? true end |
#seo_description ⇒ Object
Returns an html-stripped Obj#body
, truncated to 300 chars. Overwrite in your ObjExtensions as you like. For example, point to a CMS field.
42 43 44 |
# File 'lib/rails_connector/seo.rb', line 42 def seo_description HTML::FullSanitizer.new.sanitize(body.strip.gsub(%r{[\n|\r]}, " ")).mb_chars[0,300] if body end |
#seo_keywords ⇒ Object
Returns nil
by default. Overwrite in your ObjExtensions as you like. For example, point to a CMS field of your objects.
49 50 51 |
# File 'lib/rails_connector/seo.rb', line 49 def seo_keywords nil end |