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
|
# File 'app/helpers/rrssb/rails/buttons_helper.rb', line 4
def (opts={})
buttons = opts[:buttons] || []
contents = opts[:contents] || {}
html = []
html << "<ul class='rrssb-buttons clearfix' id='#{opts[:id]}'>"
buttons.each do |button|
content = contents[button.to_sym] || {}
html << "<li class='rrssb-#{button.gsub(/[_-]/,'')}'>"
html << case button
when 'email'
label = content[:label] || button
subject = content[:subject]
cc = content[:cc]
to = content[:to]
link_content = "<span class='rrssb-icon'>#{image_tag('mail.min.svg')}</span><span class='rrssb-text'>#{label}</span>"
mail_to(to, link_content.html_safe, subject: subject, cc: cc)
else
label = content[:label] || (button == 'hackernews' ? 'hacker news' : button.humanize)
image_name = "#{button}.min.svg"
link_content = "<span class='rrssb-icon'>#{image_tag(image_name)}</span><span class='rrssb-text'>#{label}</span>"
html_options = button == 'github' ? {} : { 'class' => 'popup' }
link_to(link_content.html_safe, social_url(button, content, opts), html_options)
end
html << "</li>"
end
html << '</ul>'
raw html.join("\n")
end
|