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 = <<-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 (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