Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/cgi
File: html.rb
# frozen_string_literal: true
[0] Fix | Delete
class CGI
[1] Fix | Delete
# Base module for HTML-generation mixins.
[2] Fix | Delete
#
[3] Fix | Delete
# Provides methods for code generation for tags following
[4] Fix | Delete
# the various DTD element types.
[5] Fix | Delete
module TagMaker # :nodoc:
[6] Fix | Delete
[7] Fix | Delete
# Generate code for an element with required start and end tags.
[8] Fix | Delete
#
[9] Fix | Delete
# - -
[10] Fix | Delete
def nn_element(element, attributes = {})
[11] Fix | Delete
s = nOE_element(element, attributes)
[12] Fix | Delete
if block_given?
[13] Fix | Delete
s << yield.to_s
[14] Fix | Delete
end
[15] Fix | Delete
s << "</#{element.upcase}>"
[16] Fix | Delete
end
[17] Fix | Delete
[18] Fix | Delete
def nn_element_def(attributes = {}, &block)
[19] Fix | Delete
nn_element(__callee__, attributes, &block)
[20] Fix | Delete
end
[21] Fix | Delete
[22] Fix | Delete
# Generate code for an empty element.
[23] Fix | Delete
#
[24] Fix | Delete
# - O EMPTY
[25] Fix | Delete
def nOE_element(element, attributes = {})
[26] Fix | Delete
attributes={attributes=>nil} if attributes.kind_of?(String)
[27] Fix | Delete
s = "<#{element.upcase}".dup
[28] Fix | Delete
attributes.each do|name, value|
[29] Fix | Delete
next unless value
[30] Fix | Delete
s << " "
[31] Fix | Delete
s << CGI.escapeHTML(name.to_s)
[32] Fix | Delete
if value != true
[33] Fix | Delete
s << '="'
[34] Fix | Delete
s << CGI.escapeHTML(value.to_s)
[35] Fix | Delete
s << '"'
[36] Fix | Delete
end
[37] Fix | Delete
end
[38] Fix | Delete
s << ">"
[39] Fix | Delete
end
[40] Fix | Delete
[41] Fix | Delete
def nOE_element_def(attributes = {}, &block)
[42] Fix | Delete
nOE_element(__callee__, attributes, &block)
[43] Fix | Delete
end
[44] Fix | Delete
[45] Fix | Delete
[46] Fix | Delete
# Generate code for an element for which the end (and possibly the
[47] Fix | Delete
# start) tag is optional.
[48] Fix | Delete
#
[49] Fix | Delete
# O O or - O
[50] Fix | Delete
def nO_element(element, attributes = {})
[51] Fix | Delete
s = nOE_element(element, attributes)
[52] Fix | Delete
if block_given?
[53] Fix | Delete
s << yield.to_s
[54] Fix | Delete
s << "</#{element.upcase}>"
[55] Fix | Delete
end
[56] Fix | Delete
s
[57] Fix | Delete
end
[58] Fix | Delete
[59] Fix | Delete
def nO_element_def(attributes = {}, &block)
[60] Fix | Delete
nO_element(__callee__, attributes, &block)
[61] Fix | Delete
end
[62] Fix | Delete
[63] Fix | Delete
end # TagMaker
[64] Fix | Delete
[65] Fix | Delete
[66] Fix | Delete
# Mixin module providing HTML generation methods.
[67] Fix | Delete
#
[68] Fix | Delete
# For example,
[69] Fix | Delete
# cgi.a("http://www.example.com") { "Example" }
[70] Fix | Delete
# # => "<A HREF=\"http://www.example.com\">Example</A>"
[71] Fix | Delete
#
[72] Fix | Delete
# Modules Html3, Html4, etc., contain more basic HTML-generation methods
[73] Fix | Delete
# (+#title+, +#h1+, etc.).
[74] Fix | Delete
#
[75] Fix | Delete
# See class CGI for a detailed example.
[76] Fix | Delete
#
[77] Fix | Delete
module HtmlExtension
[78] Fix | Delete
[79] Fix | Delete
[80] Fix | Delete
# Generate an Anchor element as a string.
[81] Fix | Delete
#
[82] Fix | Delete
# +href+ can either be a string, giving the URL
[83] Fix | Delete
# for the HREF attribute, or it can be a hash of
[84] Fix | Delete
# the element's attributes.
[85] Fix | Delete
#
[86] Fix | Delete
# The body of the element is the string returned by the no-argument
[87] Fix | Delete
# block passed in.
[88] Fix | Delete
#
[89] Fix | Delete
# a("http://www.example.com") { "Example" }
[90] Fix | Delete
# # => "<A HREF=\"http://www.example.com\">Example</A>"
[91] Fix | Delete
#
[92] Fix | Delete
# a("HREF" => "http://www.example.com", "TARGET" => "_top") { "Example" }
[93] Fix | Delete
# # => "<A HREF=\"http://www.example.com\" TARGET=\"_top\">Example</A>"
[94] Fix | Delete
#
[95] Fix | Delete
def a(href = "") # :yield:
[96] Fix | Delete
attributes = if href.kind_of?(String)
[97] Fix | Delete
{ "HREF" => href }
[98] Fix | Delete
else
[99] Fix | Delete
href
[100] Fix | Delete
end
[101] Fix | Delete
super(attributes)
[102] Fix | Delete
end
[103] Fix | Delete
[104] Fix | Delete
# Generate a Document Base URI element as a String.
[105] Fix | Delete
#
[106] Fix | Delete
# +href+ can either by a string, giving the base URL for the HREF
[107] Fix | Delete
# attribute, or it can be a has of the element's attributes.
[108] Fix | Delete
#
[109] Fix | Delete
# The passed-in no-argument block is ignored.
[110] Fix | Delete
#
[111] Fix | Delete
# base("http://www.example.com/cgi")
[112] Fix | Delete
# # => "<BASE HREF=\"http://www.example.com/cgi\">"
[113] Fix | Delete
def base(href = "") # :yield:
[114] Fix | Delete
attributes = if href.kind_of?(String)
[115] Fix | Delete
{ "HREF" => href }
[116] Fix | Delete
else
[117] Fix | Delete
href
[118] Fix | Delete
end
[119] Fix | Delete
super(attributes)
[120] Fix | Delete
end
[121] Fix | Delete
[122] Fix | Delete
# Generate a BlockQuote element as a string.
[123] Fix | Delete
#
[124] Fix | Delete
# +cite+ can either be a string, give the URI for the source of
[125] Fix | Delete
# the quoted text, or a hash, giving all attributes of the element,
[126] Fix | Delete
# or it can be omitted, in which case the element has no attributes.
[127] Fix | Delete
#
[128] Fix | Delete
# The body is provided by the passed-in no-argument block
[129] Fix | Delete
#
[130] Fix | Delete
# blockquote("http://www.example.com/quotes/foo.html") { "Foo!" }
[131] Fix | Delete
# #=> "<BLOCKQUOTE CITE=\"http://www.example.com/quotes/foo.html\">Foo!</BLOCKQUOTE>
[132] Fix | Delete
def blockquote(cite = {}) # :yield:
[133] Fix | Delete
attributes = if cite.kind_of?(String)
[134] Fix | Delete
{ "CITE" => cite }
[135] Fix | Delete
else
[136] Fix | Delete
cite
[137] Fix | Delete
end
[138] Fix | Delete
super(attributes)
[139] Fix | Delete
end
[140] Fix | Delete
[141] Fix | Delete
[142] Fix | Delete
# Generate a Table Caption element as a string.
[143] Fix | Delete
#
[144] Fix | Delete
# +align+ can be a string, giving the alignment of the caption
[145] Fix | Delete
# (one of top, bottom, left, or right). It can be a hash of
[146] Fix | Delete
# all the attributes of the element. Or it can be omitted.
[147] Fix | Delete
#
[148] Fix | Delete
# The body of the element is provided by the passed-in no-argument block.
[149] Fix | Delete
#
[150] Fix | Delete
# caption("left") { "Capital Cities" }
[151] Fix | Delete
# # => <CAPTION ALIGN=\"left\">Capital Cities</CAPTION>
[152] Fix | Delete
def caption(align = {}) # :yield:
[153] Fix | Delete
attributes = if align.kind_of?(String)
[154] Fix | Delete
{ "ALIGN" => align }
[155] Fix | Delete
else
[156] Fix | Delete
align
[157] Fix | Delete
end
[158] Fix | Delete
super(attributes)
[159] Fix | Delete
end
[160] Fix | Delete
[161] Fix | Delete
[162] Fix | Delete
# Generate a Checkbox Input element as a string.
[163] Fix | Delete
#
[164] Fix | Delete
# The attributes of the element can be specified as three arguments,
[165] Fix | Delete
# +name+, +value+, and +checked+. +checked+ is a boolean value;
[166] Fix | Delete
# if true, the CHECKED attribute will be included in the element.
[167] Fix | Delete
#
[168] Fix | Delete
# Alternatively, the attributes can be specified as a hash.
[169] Fix | Delete
#
[170] Fix | Delete
# checkbox("name")
[171] Fix | Delete
# # = checkbox("NAME" => "name")
[172] Fix | Delete
#
[173] Fix | Delete
# checkbox("name", "value")
[174] Fix | Delete
# # = checkbox("NAME" => "name", "VALUE" => "value")
[175] Fix | Delete
#
[176] Fix | Delete
# checkbox("name", "value", true)
[177] Fix | Delete
# # = checkbox("NAME" => "name", "VALUE" => "value", "CHECKED" => true)
[178] Fix | Delete
def checkbox(name = "", value = nil, checked = nil)
[179] Fix | Delete
attributes = if name.kind_of?(String)
[180] Fix | Delete
{ "TYPE" => "checkbox", "NAME" => name,
[181] Fix | Delete
"VALUE" => value, "CHECKED" => checked }
[182] Fix | Delete
else
[183] Fix | Delete
name["TYPE"] = "checkbox"
[184] Fix | Delete
name
[185] Fix | Delete
end
[186] Fix | Delete
input(attributes)
[187] Fix | Delete
end
[188] Fix | Delete
[189] Fix | Delete
# Generate a sequence of checkbox elements, as a String.
[190] Fix | Delete
#
[191] Fix | Delete
# The checkboxes will all have the same +name+ attribute.
[192] Fix | Delete
# Each checkbox is followed by a label.
[193] Fix | Delete
# There will be one checkbox for each value. Each value
[194] Fix | Delete
# can be specified as a String, which will be used both
[195] Fix | Delete
# as the value of the VALUE attribute and as the label
[196] Fix | Delete
# for that checkbox. A single-element array has the
[197] Fix | Delete
# same effect.
[198] Fix | Delete
#
[199] Fix | Delete
# Each value can also be specified as a three-element array.
[200] Fix | Delete
# The first element is the VALUE attribute; the second is the
[201] Fix | Delete
# label; and the third is a boolean specifying whether this
[202] Fix | Delete
# checkbox is CHECKED.
[203] Fix | Delete
#
[204] Fix | Delete
# Each value can also be specified as a two-element
[205] Fix | Delete
# array, by omitting either the value element (defaults
[206] Fix | Delete
# to the same as the label), or the boolean checked element
[207] Fix | Delete
# (defaults to false).
[208] Fix | Delete
#
[209] Fix | Delete
# checkbox_group("name", "foo", "bar", "baz")
[210] Fix | Delete
# # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
[211] Fix | Delete
# # <INPUT TYPE="checkbox" NAME="name" VALUE="bar">bar
[212] Fix | Delete
# # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
[213] Fix | Delete
#
[214] Fix | Delete
# checkbox_group("name", ["foo"], ["bar", true], "baz")
[215] Fix | Delete
# # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
[216] Fix | Delete
# # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="bar">bar
[217] Fix | Delete
# # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
[218] Fix | Delete
#
[219] Fix | Delete
# checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
[220] Fix | Delete
# # <INPUT TYPE="checkbox" NAME="name" VALUE="1">Foo
[221] Fix | Delete
# # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="2">Bar
[222] Fix | Delete
# # <INPUT TYPE="checkbox" NAME="name" VALUE="Baz">Baz
[223] Fix | Delete
#
[224] Fix | Delete
# checkbox_group("NAME" => "name",
[225] Fix | Delete
# "VALUES" => ["foo", "bar", "baz"])
[226] Fix | Delete
#
[227] Fix | Delete
# checkbox_group("NAME" => "name",
[228] Fix | Delete
# "VALUES" => [["foo"], ["bar", true], "baz"])
[229] Fix | Delete
#
[230] Fix | Delete
# checkbox_group("NAME" => "name",
[231] Fix | Delete
# "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
[232] Fix | Delete
def checkbox_group(name = "", *values)
[233] Fix | Delete
if name.kind_of?(Hash)
[234] Fix | Delete
values = name["VALUES"]
[235] Fix | Delete
name = name["NAME"]
[236] Fix | Delete
end
[237] Fix | Delete
values.collect{|value|
[238] Fix | Delete
if value.kind_of?(String)
[239] Fix | Delete
checkbox(name, value) + value
[240] Fix | Delete
else
[241] Fix | Delete
if value[-1] == true || value[-1] == false
[242] Fix | Delete
checkbox(name, value[0], value[-1]) +
[243] Fix | Delete
value[-2]
[244] Fix | Delete
else
[245] Fix | Delete
checkbox(name, value[0]) +
[246] Fix | Delete
value[-1]
[247] Fix | Delete
end
[248] Fix | Delete
end
[249] Fix | Delete
}.join
[250] Fix | Delete
end
[251] Fix | Delete
[252] Fix | Delete
[253] Fix | Delete
# Generate an File Upload Input element as a string.
[254] Fix | Delete
#
[255] Fix | Delete
# The attributes of the element can be specified as three arguments,
[256] Fix | Delete
# +name+, +size+, and +maxlength+. +maxlength+ is the maximum length
[257] Fix | Delete
# of the file's _name_, not of the file's _contents_.
[258] Fix | Delete
#
[259] Fix | Delete
# Alternatively, the attributes can be specified as a hash.
[260] Fix | Delete
#
[261] Fix | Delete
# See #multipart_form() for forms that include file uploads.
[262] Fix | Delete
#
[263] Fix | Delete
# file_field("name")
[264] Fix | Delete
# # <INPUT TYPE="file" NAME="name" SIZE="20">
[265] Fix | Delete
#
[266] Fix | Delete
# file_field("name", 40)
[267] Fix | Delete
# # <INPUT TYPE="file" NAME="name" SIZE="40">
[268] Fix | Delete
#
[269] Fix | Delete
# file_field("name", 40, 100)
[270] Fix | Delete
# # <INPUT TYPE="file" NAME="name" SIZE="40" MAXLENGTH="100">
[271] Fix | Delete
#
[272] Fix | Delete
# file_field("NAME" => "name", "SIZE" => 40)
[273] Fix | Delete
# # <INPUT TYPE="file" NAME="name" SIZE="40">
[274] Fix | Delete
def file_field(name = "", size = 20, maxlength = nil)
[275] Fix | Delete
attributes = if name.kind_of?(String)
[276] Fix | Delete
{ "TYPE" => "file", "NAME" => name,
[277] Fix | Delete
"SIZE" => size.to_s }
[278] Fix | Delete
else
[279] Fix | Delete
name["TYPE"] = "file"
[280] Fix | Delete
name
[281] Fix | Delete
end
[282] Fix | Delete
attributes["MAXLENGTH"] = maxlength.to_s if maxlength
[283] Fix | Delete
input(attributes)
[284] Fix | Delete
end
[285] Fix | Delete
[286] Fix | Delete
[287] Fix | Delete
# Generate a Form element as a string.
[288] Fix | Delete
#
[289] Fix | Delete
# +method+ should be either "get" or "post", and defaults to the latter.
[290] Fix | Delete
# +action+ defaults to the current CGI script name. +enctype+
[291] Fix | Delete
# defaults to "application/x-www-form-urlencoded".
[292] Fix | Delete
#
[293] Fix | Delete
# Alternatively, the attributes can be specified as a hash.
[294] Fix | Delete
#
[295] Fix | Delete
# See also #multipart_form() for forms that include file uploads.
[296] Fix | Delete
#
[297] Fix | Delete
# form{ "string" }
[298] Fix | Delete
# # <FORM METHOD="post" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
[299] Fix | Delete
#
[300] Fix | Delete
# form("get") { "string" }
[301] Fix | Delete
# # <FORM METHOD="get" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
[302] Fix | Delete
#
[303] Fix | Delete
# form("get", "url") { "string" }
[304] Fix | Delete
# # <FORM METHOD="get" ACTION="url" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
[305] Fix | Delete
#
[306] Fix | Delete
# form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" }
[307] Fix | Delete
# # <FORM METHOD="post" ENCTYPE="enctype">string</FORM>
[308] Fix | Delete
def form(method = "post", action = script_name, enctype = "application/x-www-form-urlencoded")
[309] Fix | Delete
attributes = if method.kind_of?(String)
[310] Fix | Delete
{ "METHOD" => method, "ACTION" => action,
[311] Fix | Delete
"ENCTYPE" => enctype }
[312] Fix | Delete
else
[313] Fix | Delete
unless method.has_key?("METHOD")
[314] Fix | Delete
method["METHOD"] = "post"
[315] Fix | Delete
end
[316] Fix | Delete
unless method.has_key?("ENCTYPE")
[317] Fix | Delete
method["ENCTYPE"] = enctype
[318] Fix | Delete
end
[319] Fix | Delete
method
[320] Fix | Delete
end
[321] Fix | Delete
if block_given?
[322] Fix | Delete
body = yield
[323] Fix | Delete
else
[324] Fix | Delete
body = ""
[325] Fix | Delete
end
[326] Fix | Delete
if @output_hidden
[327] Fix | Delete
body << @output_hidden.collect{|k,v|
[328] Fix | Delete
"<INPUT TYPE=\"HIDDEN\" NAME=\"#{k}\" VALUE=\"#{v}\">"
[329] Fix | Delete
}.join
[330] Fix | Delete
end
[331] Fix | Delete
super(attributes){body}
[332] Fix | Delete
end
[333] Fix | Delete
[334] Fix | Delete
# Generate a Hidden Input element as a string.
[335] Fix | Delete
#
[336] Fix | Delete
# The attributes of the element can be specified as two arguments,
[337] Fix | Delete
# +name+ and +value+.
[338] Fix | Delete
#
[339] Fix | Delete
# Alternatively, the attributes can be specified as a hash.
[340] Fix | Delete
#
[341] Fix | Delete
# hidden("name")
[342] Fix | Delete
# # <INPUT TYPE="hidden" NAME="name">
[343] Fix | Delete
#
[344] Fix | Delete
# hidden("name", "value")
[345] Fix | Delete
# # <INPUT TYPE="hidden" NAME="name" VALUE="value">
[346] Fix | Delete
#
[347] Fix | Delete
# hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo")
[348] Fix | Delete
# # <INPUT TYPE="hidden" NAME="name" VALUE="value" ID="foo">
[349] Fix | Delete
def hidden(name = "", value = nil)
[350] Fix | Delete
attributes = if name.kind_of?(String)
[351] Fix | Delete
{ "TYPE" => "hidden", "NAME" => name, "VALUE" => value }
[352] Fix | Delete
else
[353] Fix | Delete
name["TYPE"] = "hidden"
[354] Fix | Delete
name
[355] Fix | Delete
end
[356] Fix | Delete
input(attributes)
[357] Fix | Delete
end
[358] Fix | Delete
[359] Fix | Delete
# Generate a top-level HTML element as a string.
[360] Fix | Delete
#
[361] Fix | Delete
# The attributes of the element are specified as a hash. The
[362] Fix | Delete
# pseudo-attribute "PRETTY" can be used to specify that the generated
[363] Fix | Delete
# HTML string should be indented. "PRETTY" can also be specified as
[364] Fix | Delete
# a string as the sole argument to this method. The pseudo-attribute
[365] Fix | Delete
# "DOCTYPE", if given, is used as the leading DOCTYPE SGML tag; it
[366] Fix | Delete
# should include the entire text of this tag, including angle brackets.
[367] Fix | Delete
#
[368] Fix | Delete
# The body of the html element is supplied as a block.
[369] Fix | Delete
#
[370] Fix | Delete
# html{ "string" }
[371] Fix | Delete
# # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML>string</HTML>
[372] Fix | Delete
#
[373] Fix | Delete
# html("LANG" => "ja") { "string" }
[374] Fix | Delete
# # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML LANG="ja">string</HTML>
[375] Fix | Delete
#
[376] Fix | Delete
# html("DOCTYPE" => false) { "string" }
[377] Fix | Delete
# # <HTML>string</HTML>
[378] Fix | Delete
#
[379] Fix | Delete
# html("DOCTYPE" => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">') { "string" }
[380] Fix | Delete
# # <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML>string</HTML>
[381] Fix | Delete
#
[382] Fix | Delete
# html("PRETTY" => " ") { "<BODY></BODY>" }
[383] Fix | Delete
# # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
[384] Fix | Delete
# # <HTML>
[385] Fix | Delete
# # <BODY>
[386] Fix | Delete
# # </BODY>
[387] Fix | Delete
# # </HTML>
[388] Fix | Delete
#
[389] Fix | Delete
# html("PRETTY" => "\t") { "<BODY></BODY>" }
[390] Fix | Delete
# # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
[391] Fix | Delete
# # <HTML>
[392] Fix | Delete
# # <BODY>
[393] Fix | Delete
# # </BODY>
[394] Fix | Delete
# # </HTML>
[395] Fix | Delete
#
[396] Fix | Delete
# html("PRETTY") { "<BODY></BODY>" }
[397] Fix | Delete
# # = html("PRETTY" => " ") { "<BODY></BODY>" }
[398] Fix | Delete
#
[399] Fix | Delete
# html(if $VERBOSE then "PRETTY" end) { "HTML string" }
[400] Fix | Delete
#
[401] Fix | Delete
def html(attributes = {}) # :yield:
[402] Fix | Delete
if nil == attributes
[403] Fix | Delete
attributes = {}
[404] Fix | Delete
elsif "PRETTY" == attributes
[405] Fix | Delete
attributes = { "PRETTY" => true }
[406] Fix | Delete
end
[407] Fix | Delete
pretty = attributes.delete("PRETTY")
[408] Fix | Delete
pretty = " " if true == pretty
[409] Fix | Delete
buf = "".dup
[410] Fix | Delete
[411] Fix | Delete
if attributes.has_key?("DOCTYPE")
[412] Fix | Delete
if attributes["DOCTYPE"]
[413] Fix | Delete
buf << attributes.delete("DOCTYPE")
[414] Fix | Delete
else
[415] Fix | Delete
attributes.delete("DOCTYPE")
[416] Fix | Delete
end
[417] Fix | Delete
else
[418] Fix | Delete
buf << doctype
[419] Fix | Delete
end
[420] Fix | Delete
[421] Fix | Delete
buf << super(attributes)
[422] Fix | Delete
[423] Fix | Delete
if pretty
[424] Fix | Delete
CGI.pretty(buf, pretty)
[425] Fix | Delete
else
[426] Fix | Delete
buf
[427] Fix | Delete
end
[428] Fix | Delete
[429] Fix | Delete
end
[430] Fix | Delete
[431] Fix | Delete
# Generate an Image Button Input element as a string.
[432] Fix | Delete
#
[433] Fix | Delete
# +src+ is the URL of the image to use for the button. +name+
[434] Fix | Delete
# is the input name. +alt+ is the alternative text for the image.
[435] Fix | Delete
#
[436] Fix | Delete
# Alternatively, the attributes can be specified as a hash.
[437] Fix | Delete
#
[438] Fix | Delete
# image_button("url")
[439] Fix | Delete
# # <INPUT TYPE="image" SRC="url">
[440] Fix | Delete
#
[441] Fix | Delete
# image_button("url", "name", "string")
[442] Fix | Delete
# # <INPUT TYPE="image" SRC="url" NAME="name" ALT="string">
[443] Fix | Delete
#
[444] Fix | Delete
# image_button("SRC" => "url", "ALT" => "string")
[445] Fix | Delete
# # <INPUT TYPE="image" SRC="url" ALT="string">
[446] Fix | Delete
def image_button(src = "", name = nil, alt = nil)
[447] Fix | Delete
attributes = if src.kind_of?(String)
[448] Fix | Delete
{ "TYPE" => "image", "SRC" => src, "NAME" => name,
[449] Fix | Delete
"ALT" => alt }
[450] Fix | Delete
else
[451] Fix | Delete
src["TYPE"] = "image"
[452] Fix | Delete
src["SRC"] ||= ""
[453] Fix | Delete
src
[454] Fix | Delete
end
[455] Fix | Delete
input(attributes)
[456] Fix | Delete
end
[457] Fix | Delete
[458] Fix | Delete
[459] Fix | Delete
# Generate an Image element as a string.
[460] Fix | Delete
#
[461] Fix | Delete
# +src+ is the URL of the image. +alt+ is the alternative text for
[462] Fix | Delete
# the image. +width+ is the width of the image, and +height+ is
[463] Fix | Delete
# its height.
[464] Fix | Delete
#
[465] Fix | Delete
# Alternatively, the attributes can be specified as a hash.
[466] Fix | Delete
#
[467] Fix | Delete
# img("src", "alt", 100, 50)
[468] Fix | Delete
# # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">
[469] Fix | Delete
#
[470] Fix | Delete
# img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50)
[471] Fix | Delete
# # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">
[472] Fix | Delete
def img(src = "", alt = "", width = nil, height = nil)
[473] Fix | Delete
attributes = if src.kind_of?(String)
[474] Fix | Delete
{ "SRC" => src, "ALT" => alt }
[475] Fix | Delete
else
[476] Fix | Delete
src
[477] Fix | Delete
end
[478] Fix | Delete
attributes["WIDTH"] = width.to_s if width
[479] Fix | Delete
attributes["HEIGHT"] = height.to_s if height
[480] Fix | Delete
super(attributes)
[481] Fix | Delete
end
[482] Fix | Delete
[483] Fix | Delete
[484] Fix | Delete
# Generate a Form element with multipart encoding as a String.
[485] Fix | Delete
#
[486] Fix | Delete
# Multipart encoding is used for forms that include file uploads.
[487] Fix | Delete
#
[488] Fix | Delete
# +action+ is the action to perform. +enctype+ is the encoding
[489] Fix | Delete
# type, which defaults to "multipart/form-data".
[490] Fix | Delete
#
[491] Fix | Delete
# Alternatively, the attributes can be specified as a hash.
[492] Fix | Delete
#
[493] Fix | Delete
# multipart_form{ "string" }
[494] Fix | Delete
# # <FORM METHOD="post" ENCTYPE="multipart/form-data">string</FORM>
[495] Fix | Delete
#
[496] Fix | Delete
# multipart_form("url") { "string" }
[497] Fix | Delete
# # <FORM METHOD="post" ACTION="url" ENCTYPE="multipart/form-data">string</FORM>
[498] Fix | Delete
def multipart_form(action = nil, enctype = "multipart/form-data")
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function