Module: Gembox::ViewHelpers

Included in:
App
Defined in:
lib/gembox/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

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



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
# File 'lib/gembox/view_helpers.rb', line 46

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=\"/swf/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=\"/swf/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"

#content_tag(name, content, options, escape = true) ⇒ Object



9
10
11
12
# File 'lib/gembox/view_helpers.rb', line 9

def (name, content, options, escape = true)
  tag_options = tag_options(options, escape) if options
  "<#{name}#{tag_options}>#{content}</#{name}>"
end


14
15
16
17
18
# File 'lib/gembox/view_helpers.rb', line 14

def link_to(text, link = nil, options = {})         
  link ||= text
  link = url_for(link)
  "<a href=\"#{link}\">#{text}</a>"
end


20
21
22
23
24
# File 'lib/gembox/view_helpers.rb', line 20

def link_to_gem(gem, options = {})
  text    = options[:text] || gem.name
  version = gem.version if options[:show_version]
  link_to(text, "/gems/#{gem.name}/#{gem.version}")
end

#rdocify(text) ⇒ Object



41
42
43
44
# File 'lib/gembox/view_helpers.rb', line 41

def rdocify(text)
  @_rdoc ||= RDoc::Markup::ToHtml.new
  @_rdoc.convert(text)
end

#tag_options(options, escape = true) ⇒ Object



4
5
6
7
# File 'lib/gembox/view_helpers.rb', line 4

def tag_options(options, escape = true)
  option_string = options.collect {|k,v| %{#{k}="#{v}"}}.join(' ')
  option_string = " " + option_string unless option_string.blank?
end

#ts(time) ⇒ Object



37
38
39
# File 'lib/gembox/view_helpers.rb', line 37

def ts(time)
  time.strftime('%b %d, %Y') if time
end

#url_for(link_options) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/gembox/view_helpers.rb', line 26

def url_for(link_options)
  case link_options
  when Hash
    path = link_options.delete(:path) || request.path_info
    params.delete('captures')
    path + '?' + build_query(params.merge(link_options))
  else
    link_options
  end
end