- Web::escape(string)
-
URL-encode a string. (from cgi.rb)
url_encoded_string = Web::escape("'Stop!' said Fred")
# => "%27Stop%21%27+said+Fred" - Web::escape_element(string, *elements)
-
Escape only the tags of certain HTML elements in string. Takes an element or elements or array of elements. Each element is specified by the name of the element, without angle brackets. This matches both the start and the end tag of that element. The attribute list of the open tag will also be escaped (for instance, the double-quotes surrounding attribute values). (from cgi.rb)
print Web::escape_element('<BR><A HREF="url"></A>', "A", "IMG")
# "<BR><A HREF="url"></A>"
print Web::escape_element('<BR><A HREF="url"></A>', ["A", "IMG"])
# "<BR><A HREF="url"></A>" - Web::escape_html(string)
-
Escape special characters in HTML, namely &\"<> (from cgi.rb)
Web::escape_html('Usage: foo "bar" <baz>')
# => "Usage: foo "bar" <baz>" - Web::get_mime_type(filename)
-
Guess the mimetype for the filename from the file extension.
- Web::lib_file_contents( filename )
-
Get the contents of a file in the ruby libraries. Filename is relative to Kernel::caller
template = Web::lib_file_contents('resources/template.html') - Web::lib_filename( resource )
-
This function is for apps that want to store resources with the source files in the ruby lib directories. Filename is relative to Kernel::caller
Web::lib_filename('resources/logo.gif')
# => ".../ruby/site_lib/1.8/web/resources/logo.gif" - Web::rfc1123_date(time)
-
Make RFC1123 date string
Web::rfc1123_date(Time.now) # => Sat, 01 Jan 2000 00:00:00 GMT
- Web::unescape(string)
-
URL-decode a string. (from cgi.rb)
string = Web::unescape("%27Stop%21%27+said+Fred")
# => "'Stop!' said Fred" - Web::unescape_element(string, *elements)
-
Undo escaping such as that done by Web::escape_element. (from cgi.rb)
print Web::unescape_element(
Web::escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
# "<BR><A HREF="url"></A>"
print Web::unescape_element(
Web::escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
# "<BR><A HREF="url"></A>" - Web::unescape_html(string)
-
Unescape a string that has been HTML-escaped (from cgi.rb)
Web::unescape_html("Usage: foo "bar" <baz>")
# => "Usage: foo \"bar\" <baz>"