# Module: BivouacHelpers::HtmlView
[ "README", "AUTHORS", "COPYING", "lib/bivouac/helpers/view/goh/base.rb", "lib/bivouac/helpers/view/goh/form.rb", "lib/bivouac/helpers/view/goh/html.rb", "lib/bivouac/helpers/view/goh/sound.rb", "lib/bivouac/helpers/view/goh/scriptaculous.rb", "lib/bivouac/helpers/view/goh/javascript.rb", nil].each do
JavaScriptGenerator.view_html
BivouacHelpers.view_html
BivouacHelpers::SoundView.view_html
BivouacHelpers::ScriptAculoUsView.view_html
BivouacHelpers::BaseView.view_html
BivouacHelpers::JavaScriptView.view_html
BivouacHelpers::HtmlView.view_html
BivouacHelpers::FormView.view_html
end

Module BivouacHelpers::HtmlView < Object

(in files lib/bivouac/helpers/view/goh/html.rb )

bivouac/helpers/view/html

Methods

Public Instance method: image_path( source )

Computes the path to an image asset in the public images directory. Full paths from the document root will be passed through. Used internally by image_tag to build the image path.

 image_path("edit")                                         # => /public/images/edit
 image_path("edit.png")                                     # => /public/images/edit.png
 image_path("icons/edit.png")                               # => /public/images/icons/edit.png
 image_path("/icons/edit.png")                              # => /icons/edit.png
 image_path("http://www.railsapplication.com/img/edit.png") # => http://www.railsapplication.com/img/edit.png
    # File lib/bivouac/helpers/view/goh/html.rb, line 89
89:     def image_path( source )
90:       if /^http:\/\//.match( source ) || /^\//.match( source )
91:         return source
92:       else
93:         return "/public/images/#{source}"
94:       end
95:     end

Public Instance method: image_tag( source, options = {} )

Returns an html image tag for the source. The source must be a file that exists in your public images directory (public/images). You can add html attributes using the options. If no alt text is given, the file name part of the source is used (capitalized and without the extension)

 image_tag("icon.png")  # =>
   <img src="/public/images/icon.png" alt="Icon" />

 image_tag("icon.png", :alt => "Edit Entry")  # =>
   <img src="/public/images/icon.png" alt="Edit Entry" />
    # File lib/bivouac/helpers/view/goh/html.rb, line 73
73:     def image_tag( source, options = {} )
74:       options[:src] = "/public/images/#{source}"
75:       options[:alt] ||= File.basename(options[:src], '.*').split('.').first.capitalize
76:       
77:       img( options )
78:     end

Public Instance method: javascript_include_tag( *sources )

Returns an html script tag for each of the sources provided. You can pass in the filename (.js extension is optional) of javascript files that exist in your public/javascripts directory for inclusion into the current page. To include the Prototype and Scriptaculous javascript libraries in your application, pass :defaults as the source.

  javascript_include_tag "xmlhr" # =>
    <script type="text/javascript" src="/public/javascripts/xmlhr.js"></script>

  javascript_include_tag "common.javascript", "elsewhere/cools" # =>
    <script type="text/javascript" src="/public/javascripts/common.javascript"></script>
    <script type="text/javascript" src="/public/javascripts/elsewhere/cools.js"></script>
    # File lib/bivouac/helpers/view/goh/html.rb, line 43
43:     def javascript_include_tag( *sources )
44:       options = sources.last.is_a?(Hash) ? sources.pop : { }
45:       options[:type] = "text/javascript"
46:       
47:       if sources.include?(:defaults) 
48:         sources = sources[0..(sources.index(:defaults))] + 
49:           @@javascript_default_sources.dup + 
50:           sources[(sources.index(:defaults) + 1)..sources.length]
51:       
52:         sources.delete(:defaults) 
53:       end
54:       sources.collect do |file|
55:         file = file.to_s
56:         file << ".js" if File.extname(file).blank?
57:         options[:src] = "/public/javascripts/#{file}"
58:         script( options ) {}
59:       end
60:     end

Public Instance method: link_to(name, address, options = {})

Creates a link tag of the given name using address has the href for the link

The options will accept a hash of html attributes for the link tag. It also accepts 2 modifiers that specialize the link behavior.

  • :confirm => ‘question?‘: This will add a JavaScript confirm prompt with the question specified. If the user accepts, the link is processed normally, otherwise no action is taken.
  • :popup => true || array of window options: This will force the link to open in a popup window. By passing true, a default browser window will be opened with the URL. You can also specify an array of options that are passed-thru to JavaScripts window.open method.

You can mix and match the options.

  link_to "Documentation", "http://camping.rubyforge.org/", :confirm => "Are you sure?"
  link_to "Help", R( Help ), :popup => true
  link_to image_tag( "thumb.png" ), "/public/images/fullsize.png", :popup => ['My house', 'height=300,width=600']
     # File lib/bivouac/helpers/view/goh/html.rb, line 116
116:     def link_to(name, address, options = {})
117:       options = javascript_options( options )
118:       options[:href] = address
119:       
120:       a( options ) do; name; end
121:     end

Public Instance method: stylesheet_link_tag( *data )

Returns a stylesheet link tag for the sources specified as arguments. If you don‘t specify an extension, .css will be appended automatically. You can modify the link attributes by passing a hash as the last argument.

  stylesheet_link_tag "style" # =>
    <link href="/public/stylesheets/style.css" media="screen" rel="Stylesheet" type="text/css" />

  stylesheet_link_tag "style", :media => "all" # =>
    <link href="/public/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css" />

  stylesheet_link_tag "random.styles", "/css/stylish" # =>
    <link href="/public/stylesheets/random.styles" media="screen" rel="Stylesheet" type="text/css" />
    <link href="/public/stylesheets/css/stylish.css" media="screen" rel="Stylesheet" type="text/css" />
    # File lib/bivouac/helpers/view/goh/html.rb, line 20
20:     def stylesheet_link_tag( *data )
21:       options = data.last.is_a?(Hash) ? data.pop : { }
22:       options[:rel]   = "Stylesheet"
23:       options[:type]  = "text/css"
24:       data.collect do |file|
25:         file << ".css" if File.extname(file).blank?
26:         options[:href] = "/public/stylesheets/#{file}"
27:         link( options )
28:       end
29:     end