Module: Ghoul::Helpers
- Included in:
- Application
- Defined in:
- lib/ghoul/lib/helpers.rb
Instance Method Summary collapse
- #breadcrumbs_from_splat(repository, commit, splat) ⇒ Object
- #clippy(text, bgcolor = '#FFFFFF') ⇒ Object
- #date_format(datetime) ⇒ Object
- #human_file_size(filesize) ⇒ Object
- #partial(template, locals = {}) ⇒ Object
- #title(title) ⇒ Object
Instance Method Details
#breadcrumbs_from_splat(repository, commit, splat) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ghoul/lib/helpers.rb', line 17 def (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 = " <object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"\n width=\"110\"\n height=\"14\"\n id=\"clippy\" >\n <param name=\"movie\" value=\"\#{url('/flash/clippy.swf')}\"/>\n <param name=\"allowScriptAccess\" value=\"always\" />\n <param name=\"quality\" value=\"high\" />\n <param name=\"scale\" value=\"noscale\" />\n <param NAME=\"FlashVars\" value=\"text=\#{text}\">\n <param name=\"bgcolor\" value=\"\#{bgcolor}\">\n <embed src=\"/flash/clippy.swf\"\n width=\"110\"\n height=\"14\"\n name=\"clippy\"\n quality=\"high\"\n allowScriptAccess=\"always\"\n type=\"application/x-shockwave-flash\"\n pluginspage=\"http://www.macromedia.com/go/getflashplayer\"\n FlashVars=\"text=\#{text}\"\n bgcolor=\"\#{bgcolor}\"\n />\n </object>\n EOF\nend\n" |
#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 |