Module: Integral::SocialHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/integral/social_helper.rb

Overview

Social Helper which contains methods relating to social networking

Instance Method Summary collapse

Instance Method Details

#facebook_share_url(opts = {}) ⇒ String

Facebook social sharing URL snippet built from - sharingbuttons.io/

Parameters:

  • opts (Hash) (defaults to: {})

    the options to create the share URL

Options Hash (opts):

  • :url (String)

    Supply URL if would like to share URL other than the current

Returns:

  • (String)

    Facebook URL to share a page



30
31
32
33
34
35
36
37
# File 'app/helpers/integral/social_helper.rb', line 30

def facebook_share_url(opts = {})
  page_url = opts.fetch(:url, request.original_url)

  page_url = CGI.escape(page_url)
  share_url = "https://facebook.com/sharer/sharer.php?u=#{page_url}"

  share_url
end

#facebook_urlString

Facebook Profile URL set from within Backend Settings area

Returns:

  • (String)

    Facebook URL



75
76
77
# File 'app/helpers/integral/social_helper.rb', line 75

def facebook_url
  Settings.facebook_url
end

#github_urlString

Github URL set from within Backend Settings area

Returns:

  • (String)

    Github URL



61
62
63
# File 'app/helpers/integral/social_helper.rb', line 61

def github_url
  Settings.github_url
end

#instagram_urlString

Instagram Profile URL set from within Backend Settings area

Returns:

  • (String)

    Instagram URL



96
97
98
# File 'app/helpers/integral/social_helper.rb', line 96

def instagram_url
  Settings.instagram_url
end

#linkedin_share_url(opts = {}) ⇒ String

Linkedin social sharing URL snippet built from - sharingbuttons.io/

Parameters:

  • opts (Hash) (defaults to: {})

    the options to create the share URL

Options Hash (opts):

  • :url (String)

    Supply URL if would like to share URL other than the current

  • :message (String)

    The message to provide a message for the tweet.

Returns:

  • (String)

    Linkedin URL to share a page



47
48
49
50
51
52
53
54
55
56
# File 'app/helpers/integral/social_helper.rb', line 47

def linkedin_share_url(opts = {})
  page_url = opts.fetch(:url, request.original_url)
  message = opts.fetch(:message, '')

  page_url = CGI.escape(page_url)
  share_url = "https://www.linkedin.com/shareArticle?mini=true&url=#{page_url}"
  share_url += "&title=#{CGI.escape(message)}" if message.present?

  share_url
end

#linkedin_urlString

Linkedin Profile URL set from within Backend Settings area

Returns:

  • (String)

    Linkedin URL



89
90
91
# File 'app/helpers/integral/social_helper.rb', line 89

def linkedin_url
  Settings.linkedin_url
end

#twitter_share_url(opts = {}) ⇒ String

Twitter social sharing URL snippet built from - sharingbuttons.io/

Parameters:

  • opts (Hash) (defaults to: {})

    the options to create the share URL

Options Hash (opts):

  • :url (String)

    Supply URL if would like to share URL other than the current

  • :message (String)

    The message to provide a message for the tweet.

Returns:

  • (String)

    Twitter URL to share a page



12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/integral/social_helper.rb', line 12

def twitter_share_url(opts = {})
  page_url = opts.fetch(:url, request.original_url)
  message = opts.fetch(:message, '')

  page_url = CGI.escape(page_url)
  share_url = "https://twitter.com/intent/tweet/?url=#{page_url}"
  share_url += "&text=#{CGI.escape(message)}" if message.present?

  share_url
end

#twitter_urlString

Twitter Profile URL set from within Backend Settings area

Returns:

  • (String)

    Twitter URL



68
69
70
# File 'app/helpers/integral/social_helper.rb', line 68

def twitter_url
  Settings.twitter_url
end

#youtube_urlString

Youtube Profile URL set from within Backend Settings area

Returns:

  • (String)

    Youtube URL



82
83
84
# File 'app/helpers/integral/social_helper.rb', line 82

def youtube_url
  Settings.youtube_url
end