Module: ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details



94
95
96
97
98
99
100
101
# File 'app/helpers/application_helper.rb', line 94

def footer_copyright
  title = @settings[:general][:website_title]
  year = Date.today.year
  html = "#{title} © #{year}"
  """<div class='footer-copyright'>
       #{html}
     </div>""".html_safe
end

#include_meta_tagsObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/helpers/application_helper.rb', line 2

def include_meta_tags
  name = @settings[:general][:website_title]
  title = @settings[:general][:website_tagline]
  description = @settings[:general][:website_description]
  description = ActionController::Base.helpers.strip_tags(description).
    gsub("\n", "").
    gsub("\r", "")
  url = @settings[:general][:website_url]
  image_url = @settings[:general][:website_logo_url]

  if Rails.env.production?
    unless image_url.include?('//')
      host = ENV.fetch("HOST")
      protocole = Rails.application.config.force_ssl ? "https://" : "http://"
      image_url = "#{protocole}#{host}#{image_url}"
    end
  end

  display_meta_tags({
    site: name,
    title: title,
    description: description,
    canonical: url,
    og: {
      site_name: name,
      url: url,
      title: title,
      description: description,
      image: image_url,
      type: "website"
    },
    twitter: {
      url: url,
      title: title,
      description: description,
      image: image_url,
      card: "summary"
    }
  })
end


43
44
45
46
47
48
49
50
51
# File 'app/helpers/application_helper.rb', line 43

def sidebar_image_tag
  tagline = @settings[:general][:website_tagline].presence
  image_url = @settings[:general][:website_logo_url].presence
  if image_url
    image_tag(image_url, alt: tagline)
  else
    ""
  end
end


53
54
55
56
# File 'app/helpers/application_helper.rb', line 53

def sidebar_tagline
  tagline = @settings[:general][:website_description].presence
  (tagline || "").html_safe
end


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'app/helpers/application_helper.rb', line 58

def social_links
  links = @settings[:general][:social_links] || []
  links.reject! { |l| l.empty? }

  social_icons_map = {
    "facebook.com" => "facebook",
    "vk.com" => "vk",
    "twitter.com" => "twitter",
    "behance.net" => "behance",
    "github.com" => "github",
    "pinterest.com" => "pinterest",
    "instagram.com" => "instagram",
    "youtube.com" => "youtube-play",
    "linkedin.com" => "linkedin",
    "medium.com" => "medium",
    "vimeo.com" => "vimeo",
    "slack.com" => "slack",
    "dribbble.com" => "dribbble",
    "soundcloud.com" => "soundcloud",
    "mailto:" => "envelope"
  }
  social_icons_domains = social_icons_map.keys

  html = links.collect do |l|
    key = social_icons_domains.select { |domain| l.include?(domain) }.first
    icon = social_icons_map[key]

    link_to l, target: "_blank" do
      fa_stacked_icon("#{icon} inverse", base: "circle", class: "fa-1x")
    end
  end
  .join("")

  html.html_safe
end