22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
|
# File 'lib/fuji.rb', line 22
def self.render(options={})
options[:gravatar_fallback_url] ||= "https://s3.amazonaws.com/assets.heroku.com/addons.heroku.com/gravatar_default.png"
options[:logo_text] ||= "heroku"
options[:logo_subtext] ||= nil
options[:logo_url] ||= "https://www.heroku.com"
options[:user] ||= nil
options[:links] ||= nil
links = options[:links]
if links.nil?
links = [
{id: :apps, name: 'Apps', url: 'https://dashboard.heroku.com'},
{id: :addons, name: 'Add-ons', url: 'https://addons.heroku.com'},
{id: :documentation, name: 'Documentation', url: 'https://devcenter.heroku.com'},
{id: :support, name: 'Support', url: 'https://help.heroku.com'},
{id: :blog, name: 'Blog', url: 'https://blog.heroku.com'},
{id: :account, name: 'Account', url: "https://dashboard.heroku.com/account"}
]
if options[:user] && options[:user].email
gravatar_url = [
"https://secure.gravatar.com/avatar/",
Digest::MD5.hexdigest(options[:user].email),
"?default=",
URI.escape(options[:gravatar_fallback_url])
].join("")
links << {
id: :gravatar,
name: Fuji::Helper.image_tag(gravatar_url),
url: 'https://dashboard.heroku.com/account'
}
end
end
links = links.map do |link|
Fuji::Helper.link_to(link[:name], link[:url], link[:id])
end.join("\n")
out = "
<div id='fuji' class='fuji'>
<div class='fuji-container'>
<h1 class='fuji-brand'>
<a class='fuji-logo' href='#{options[:logo_url]}'>
#{options[:logo_text]} <span class='fuji-logo-subtext'>#{options[:logo_subtext]}</span>
</a>
</h1>
<ul class='fuji-links'>#{links}</ul>
</div>
</div>
"
out.respond_to?(:html_safe) ? out.html_safe : out
end
|