Module: Gembox::ViewHelpers
- Included in:
- App
- Defined in:
- lib/gembox/view_helpers.rb
Instance Method Summary collapse
- #clippy(text, bgcolor = '#FFFFFF') ⇒ Object
- #content_tag(name, content, options, escape = true) ⇒ Object
- #link_to(text, link = nil, options = {}) ⇒ Object
- #link_to_gem(gem, options = {}) ⇒ Object
- #rdocify(text) ⇒ Object
- #tag_options(options, escape = true) ⇒ Object
- #ts(time) ⇒ Object
- #url_for(link_options) ⇒ Object
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 = <<-EOF <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="110" height="14" id="clippy" > <param name="movie" value="/swf/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="/swf/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 |
#content_tag(name, content, options, escape = true) ⇒ Object
9 10 11 12 |
# File 'lib/gembox/view_helpers.rb', line 9 def content_tag(name, content, , escape = true) = (, escape) if "<#{name}#{}>#{content}</#{name}>" end |
#link_to(text, link = nil, options = {}) ⇒ Object
14 15 16 17 18 |
# File 'lib/gembox/view_helpers.rb', line 14 def link_to(text, link = nil, = {}) link ||= text link = url_for(link) "<a href=\"#{link}\">#{text}</a>" end |
#link_to_gem(gem, options = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/gembox/view_helpers.rb', line 20 def link_to_gem(gem, = {}) text = [:text] || gem.name version = gem.version if [: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 (, escape = true) option_string = .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() case when Hash path = .delete(:path) || request.path_info params.delete('captures') path + '?' + build_query(params.merge()) else end end |