Module: Integral::BlogHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/integral/blog_helper.rb
Overview
Blog Helper which contains methods used through the blog
Instance Method Summary collapse
-
#display_most_read_posts_widget? ⇒ Boolean
Whether or not to display most read widget.
-
#display_newsletter_signup_widget? ⇒ Boolean
Whether or not to display newsletter signup widget.
-
#display_popular_posts_widget? ⇒ Boolean
Whether or not to display recent posts sidebar widget.
-
#display_post_categories_widget? ⇒ Boolean
Whether or not to display post categories.
-
#display_recent_posts_widget? ⇒ Boolean
Whether or not to display recent posts sidebar widget.
-
#display_share_widget? ⇒ Boolean
Whether or not to display share widget.
-
#display_similar_posts_widget? ⇒ Boolean
Whether or not to display similar posts.
-
#featured_categories ⇒ Relation
Featured categories - currently all which have posts associated to them.
-
#most_read_posts ⇒ Object
TODO: Change this to use GA API through a GoogleAnalyticsService.
-
#render_post_as_json_ld(post) ⇒ String
Javascript snippet containing JSON-LD of the provided post.
-
#render_posts_as_json_ld(posts, title: t('.title'), url: request.original_url, description: t('.description')) ⇒ String
Javascript snippet containing JSON-LD of the provided posts.
Instance Method Details
#display_most_read_posts_widget? ⇒ Boolean
Whether or not to display most read widget
73 74 75 |
# File 'app/helpers/integral/blog_helper.rb', line 73 def Integral::Post.published.where(locale: I18n.locale).count > 10 end |
#display_newsletter_signup_widget? ⇒ Boolean
Whether or not to display newsletter signup widget
39 40 41 |
# File 'app/helpers/integral/blog_helper.rb', line 39 def true end |
#display_popular_posts_widget? ⇒ Boolean
Whether or not to display recent posts sidebar widget
58 59 60 |
# File 'app/helpers/integral/blog_helper.rb', line 58 def Integral::Post.published.where(locale: I18n.locale).count > 4 end |
#display_post_categories_widget? ⇒ Boolean
Whether or not to display post categories
63 64 65 |
# File 'app/helpers/integral/blog_helper.rb', line 63 def true end |
#display_recent_posts_widget? ⇒ Boolean
Whether or not to display recent posts sidebar widget
51 52 53 54 55 |
# File 'app/helpers/integral/blog_helper.rb', line 51 def return false if "#{controller_name}.#{action_name}" == 'posts.index' true end |
#display_share_widget? ⇒ Boolean
Whether or not to display share widget
44 45 46 47 48 |
# File 'app/helpers/integral/blog_helper.rb', line 44 def return true if "#{controller_name}.#{action_name}" == 'posts.show' false end |
#display_similar_posts_widget? ⇒ Boolean
Whether or not to display similar posts
68 69 70 |
# File 'app/helpers/integral/blog_helper.rb', line 68 def true end |
#featured_categories ⇒ Relation
Returns featured categories - currently all which have posts associated to them.
5 6 7 |
# File 'app/helpers/integral/blog_helper.rb', line 5 def featured_categories @featured_categories ||= Integral::Category.where(locale: I18n.locale).where(id: Integral::Post.published.select(:category_id).uniq.map(&:category_id)) end |
#most_read_posts ⇒ Object
TODO: Change this to use GA API through a GoogleAnalyticsService
78 79 80 |
# File 'app/helpers/integral/blog_helper.rb', line 78 def most_read_posts popular_blog_posts.decorate end |
#render_post_as_json_ld(post) ⇒ String
Returns Javascript snippet containing JSON-LD of the provided post.
12 13 14 15 16 |
# File 'app/helpers/integral/blog_helper.rb', line 12 def render_post_as_json_ld(post) render_json_ld do post.to_json_ld.merge("@context": 'http://schema.org') end end |
#render_posts_as_json_ld(posts, title: t('.title'), url: request.original_url, description: t('.description')) ⇒ String
Returns Javascript snippet containing JSON-LD of the provided posts.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/integral/blog_helper.rb', line 21 def render_posts_as_json_ld(posts, title: t('.title'), url: request.original_url, description: t('.description')) render_json_ld do { "@context": 'http://schema.org', "@type": 'Blog', "name": title, "url": url, "description": description, "publisher": { "@type": 'Organization', "name": Integral::Settings.website_title }, "blogPosts": posts.map(&:to_json_ld) } end end |