-
Notifications
You must be signed in to change notification settings - Fork 1
/
helpers.rb
60 lines (50 loc) · 1.38 KB
/
helpers.rb
1
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module Helpers
class << self
def included(base)
base.extend ClassMethods
end
end
module ClassMethods
helpers do
def itunes
ITUNES
end
def link_to(label, options = {})
url = options.delete(:url) || '/'
html_options = begin
if options.has_key?(:html)
(options.delete(:html).map do |k,v|
"#{k}=\"#{CGI.escapeHTML(v)}\""
end).join(' ')
else
''
end
end
if options.any?
url << '?' + options.to_param
end
"<a href=\"#{URI.escape(url)}\" #{html_options}>#{label}</a>"
end
def partial(page, options={})
haml "_#{page.to_s}".to_sym, options.merge!(:layout => false)
end
def link_to_anchor(label, name)
url = "##{name}"
link_to label, url
end
def javascript_include_tag(*names)
(names.flatten.map do |name|
"<script src='/javascripts/#{name.to_s}.js?#{Time.now.to_i}' type='text/javascript'></script>"
end) * "\n"
end
def stylesheet_link_tag(*names)
(names.flatten.map do |name|
"<link href='/#{name.to_s}.css' media='all' rel='stylesheet' type='text/css' />"
end) * "\n"
end
def current_artist
URI.unescape(params[:artist] || '')
end
end
end
end