Module: Pageflow::SocialShareHelper

Defined in:
app/helpers/pageflow/social_share_helper.rb

Instance Method Summary collapse

Instance Method Details

#social_share_entry_image_tags(entry) ⇒ Object


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/helpers/pageflow/social_share_helper.rb', line 32

def social_share_entry_image_tags(entry)
  image_urls = []

  image_urls << ImageFile.find(entry.share_image_id).thumbnail_url(:medium) if entry.share_image_id.present?

  entry.pages.each do |page|
    if image_urls.size >= 4
      break
    else
      image_urls << page.thumbnail_url(:medium)
      image_urls.uniq!
    end
  end

  render 'pageflow/social_share/image_tags', :image_urls => image_urls
end

#social_share_meta_tags_for(target) ⇒ Object


3
4
5
6
7
8
9
# File 'app/helpers/pageflow/social_share_helper.rb', line 3

def social_share_meta_tags_for(target)
  if target.is_a?(Page)
    render('pageflow/social_share/page_meta_tags', entry: @entry, page: @entry.share_target)
  else
    render('pageflow/social_share/entry_meta_tags', entry: @entry)
  end
end

#social_share_normalize_protocol(url) ⇒ Object


49
50
51
# File 'app/helpers/pageflow/social_share_helper.rb', line 49

def social_share_normalize_protocol(url)
  url.gsub(/^(\/\/|https:\/\/)/, 'http://')
end

#social_share_page_description(page) ⇒ Object


26
27
28
29
30
# File 'app/helpers/pageflow/social_share_helper.rb', line 26

def social_share_page_description(page)
  return page.configuration['text'] if page.configuration['text'].present?
  return page.configuration['description'] if page.configuration['description'].present?
  ''
end

#social_share_page_title(page) ⇒ Object


15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/pageflow/social_share_helper.rb', line 15

def social_share_page_title(page)
  entry = page.chapter.entry

  title = ["#{entry.title}:"]
  title << page.title
  title << '-' if entry.theming.cname_domain.present?
  title << entry.theming.cname_domain

  title.join(' ')
end

#social_share_page_url(page) ⇒ Object


11
12
13
# File 'app/helpers/pageflow/social_share_helper.rb', line 11

def social_share_page_url(page)
  "#{pretty_entry_url(page.chapter.entry)}?page=#{page.perma_id}"
end