Module: Ghoul::Helpers

Included in:
Application
Defined in:
lib/ghoul/lib/helpers.rb

Instance Method Summary collapse

Instance Method Details



17
18
19
20
21
22
23
24
25
26
# File 'lib/ghoul/lib/helpers.rb', line 17

def breadcrumbs_from_splat(repository, commit, splat)
  crumbs = splat.split("/")
  html = []
  path = []
  crumbs.each do |crumb|
    path << crumb
    html << "#{link_to( crumb, tree_for_commit_path(repository, commit, path.join('/'), nil ) )}"
  end
  return html.join("/")
end

#clippy(text, bgcolor = '#FFFFFF') ⇒ Object



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
# File 'lib/ghoul/lib/helpers.rb', line 37

def clippy(text, bgcolor='#FFFFFF')
  html = <<-EOF
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
            width="110"
            height="14"
            id="clippy" >
    <param name="movie" value="#{url('/flash/clippy.swf')}"/>
    <param name="allowScriptAccess" value="always" />
    <param name="quality" value="high" />
    <param name="scale" value="noscale" />
    <param NAME="FlashVars" value="text=#{text}">
    <param name="bgcolor" value="#{bgcolor}">
    <embed src="/flash/clippy.swf"
           width="110"
           height="14"
           name="clippy"
           quality="high"
           allowScriptAccess="always"
           type="application/x-shockwave-flash"
           pluginspage="http://www.macromedia.com/go/getflashplayer"
           FlashVars="text=#{text}"
           bgcolor="#{bgcolor}"
    />
    </object>
  EOF
end

#date_format(datetime) ⇒ Object



33
34
35
# File 'lib/ghoul/lib/helpers.rb', line 33

def date_format(datetime)
  datetime.strftime("%d %b %Y @ %H:%M")
end

#human_file_size(filesize) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/ghoul/lib/helpers.rb', line 3

def human_file_size(filesize)
  if filesize <= 1023
    return "#{filesize} bytes"
  elsif filesize <= 1024*1024
    return "#{filesize/1024} KB"
  else
    return "#{filesize/1024/1024} MB"
  end
end

#partial(template, locals = {}) ⇒ Object



28
29
30
31
# File 'lib/ghoul/lib/helpers.rb', line 28

def partial(template, locals = {})
  template = ('partials/_' + template.to_s).to_sym
  erb(template, :layout => false, :locals => locals)      
end

#title(title) ⇒ Object



13
14
15
# File 'lib/ghoul/lib/helpers.rb', line 13

def title(title)
  @title = title
end