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

Instance Method Details

#display_newsletter_signup_widget?Boolean

Whether or not to display newsletter signup widget

Returns:

  • (Boolean)


34
35
36
# File 'app/helpers/integral/blog_helper.rb', line 34

def 
  true
end

Whether or not to display recent posts sidebar widget

Returns:

  • (Boolean)


51
52
53
# File 'app/helpers/integral/blog_helper.rb', line 51

def display_popular_posts_widget?
  Integral::Post.published.count > 4
end

#display_recent_posts_widget?Boolean

Whether or not to display recent posts sidebar widget

Returns:

  • (Boolean)


45
46
47
48
# File 'app/helpers/integral/blog_helper.rb', line 45

def display_recent_posts_widget?
  return false if "#{controller_name}.#{action_name}" == 'posts.index'
  true
end

#display_share_widget?Boolean

Whether or not to display share widget

Returns:

  • (Boolean)


39
40
41
42
# File 'app/helpers/integral/blog_helper.rb', line 39

def display_share_widget?
  return true if "#{controller_name}.#{action_name}" == 'posts.show'
  false
end

#render_post_as_json_ld(post) ⇒ String

Returns Javascript snippet containing JSON-LD of the provided post.

Parameters:

Returns:

  • (String)

    Javascript snippet containing JSON-LD of the provided post



7
8
9
10
11
# File 'app/helpers/integral/blog_helper.rb', line 7

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) ⇒ String

Returns Javascript snippet containing JSON-LD of the provided posts.

Parameters:

  • posts (Integral::Post)

    collection of posts to convert to JSON-LD

Returns:

  • (String)

    Javascript snippet containing JSON-LD of the provided posts



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/integral/blog_helper.rb', line 16

def render_posts_as_json_ld(posts)
  render_json_ld do
    {
      "@context": 'http://schema.org',
      "@type": 'Blog',
      "name": t('.title'),
      "url": request.original_url,
      "description": t('.description'),
      "publisher": {
        "@type": 'Organization',
        "name": Integral::Settings.website_title
      },
      "blogPosts": posts.map(&:to_json_ld)
    }
  end
end