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



52
53
54
55
56
57
58
59
# File 'app/helpers/integral/social_helper.rb', line 52

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



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

def facebook_url
  Settings.facebook_url
end

#github_urlString

Github URL set from within Backend Settings area

Returns:

  • (String)

    Github URL



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

def github_url
  Settings.github_url
end

#instagram_urlString

Instagram Profile URL set from within Backend Settings area

Returns:

  • (String)

    Instagram URL



118
119
120
# File 'app/helpers/integral/social_helper.rb', line 118

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



69
70
71
72
73
74
75
76
77
78
# File 'app/helpers/integral/social_helper.rb', line 69

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



111
112
113
# File 'app/helpers/integral/social_helper.rb', line 111

def linkedin_url
  Settings.linkedin_url
end

#mail_share_url(opts = {}, escape: true) ⇒ String

Mail link sharing

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



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

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

  if escape
    page_url = CGI.escape(page_url)
    message = CGI.escape(message) if message.present?
  end

  share_url = "mailto:?body=#{page_url}"
  share_url += "&subject=#{message}" if message.present?

  share_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



34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/integral/social_helper.rb', line 34

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



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

def twitter_url
  Settings.twitter_url
end

#youtube_urlString

Youtube Profile URL set from within Backend Settings area

Returns:

  • (String)

    Youtube URL



104
105
106
# File 'app/helpers/integral/social_helper.rb', line 104

def youtube_url
  Settings.youtube_url
end