# 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 |
bivouac/helpers/view/html
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
[ show source ]
# 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
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" />
[ show source ]
# 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
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>
[ show source ]
# 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
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.
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']
[ show source ]
# 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
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" />
[ show source ]
# 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