Updated code to remove obsolete call on recent version of json library.
Updated upload_image example to use PATH instead of DIRECTORY_NAME or similar. Removed unused local variables.
This commit is contained in:
@@ -30,23 +30,27 @@ feature -- Implementation
|
||||
local
|
||||
o: JSON_OBJECT
|
||||
do
|
||||
create Result.make_array
|
||||
create Result.make_empty
|
||||
across
|
||||
list as c
|
||||
loop
|
||||
if attached {STRING} c.item.item (1) as value and attached {STRING} c.item.item (3) as img and attached {STRING} c.item.item (2) as company then
|
||||
if
|
||||
attached c.item.value as value and
|
||||
attached c.item.img as img and
|
||||
attached c.item.company as company
|
||||
then
|
||||
if value.as_lower.has_substring (input.as_lower) then
|
||||
create o.make
|
||||
o.put (create {JSON_STRING}.make_json (img), "img")
|
||||
o.put (create {JSON_STRING}.make_json (value), "value")
|
||||
o.put (create {JSON_STRING}.make_json (company), "company")
|
||||
o.put (create {JSON_STRING}.make_from_string (img), "img")
|
||||
o.put (create {JSON_STRING}.make_from_string (value), "value")
|
||||
o.put (create {JSON_STRING}.make_from_string (company), "company")
|
||||
Result.add (o)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
list: ITERABLE [TUPLE [STRING, STRING]]
|
||||
list: ITERABLE [TUPLE [value: STRING; company: STRING; img: STRING]]
|
||||
-- List of contacts
|
||||
|
||||
end
|
||||
|
||||
@@ -33,22 +33,22 @@ feature -- Implementation
|
||||
list := <<["AF", {STRING_32} "Afghanistan"], ["AX", {STRING_32} "<22>land Islands"], ["AL", {STRING_32} "Albania"],
|
||||
["DZ", {STRING_32} "Algeria"], ["AS", {STRING_32} "American Samoa"],
|
||||
["AD", {STRING_32} "Andorra"], ["AO", {STRING_32} "Angola"], ["AI", {STRING_32} "Anguilla"],
|
||||
["AQ", {STRING_32} "Antarctica"], ["AG", {STRING_32} "Antigua and Barbuda"],
|
||||
["AQ", {STRING_32} "Antarctica"], ["AG", {STRING_32} "Antigua and Barbuda"],
|
||||
["AR", {STRING_32} "Argentina"], ["AM", {STRING_32} "Armenia"], ["AW", {STRING_32} "Aruba"],
|
||||
["AU", {STRING_32} "Australia"], ["AT", {STRING_32} "Austria"], ["AZ", {STRING_32} "Azerbaijan"],
|
||||
["AU", {STRING_32} "Australia"], ["AT", {STRING_32} "Austria"], ["AZ", {STRING_32} "Azerbaijan"],
|
||||
["BS", {STRING_32} "Bahamas"], ["BH", {STRING_32} "Bahrain"], ["BD", {STRING_32} "Bangladesh"],
|
||||
["BB", {STRING_32} "Barbados"], ["BY", {STRING_32} "Belarus"], ["BE", {STRING_32} "Belgium"],
|
||||
["BZ", {STRING_32} "Belize"], ["BJ", {STRING_32} "Benin"], ["BM", {STRING_32} "Bermuda"],
|
||||
["BT", {STRING_32} "Bhutan"], ["BO", {STRING_32} "Bolivia, Plurinational State of"],
|
||||
["BQ", {STRING_32} "Bonaire, Sint Eustatius and Saba"], ["BA", {STRING_32} "Bosnia and Herzegovina"],
|
||||
["BW", {STRING_32} "Botswana"], ["BV", {STRING_32} "Bouvet Island"],
|
||||
["BR", {STRING_32} "Brazil"], ["IO", {STRING_32} "British Indian Ocean Territory"],
|
||||
["BN", {STRING_32} "Brunei Darussalam"], ["BG", {STRING_32} "Bulgaria"],
|
||||
["BR", {STRING_32} "Brazil"], ["IO", {STRING_32} "British Indian Ocean Territory"],
|
||||
["BN", {STRING_32} "Brunei Darussalam"], ["BG", {STRING_32} "Bulgaria"],
|
||||
["BF", {STRING_32} "Burkina Faso"], ["BI", {STRING_32} "Burundi"], ["KH", {STRING_32} "Cambodia"],
|
||||
["CM", {STRING_32} "Cameroon"], ["CA", {STRING_32} "Canada"], ["CV", {STRING_32} "Cape Verde"],
|
||||
["KY", {STRING_32} "Cayman Islands"], ["CF", {STRING_32} "Central African Republic"],
|
||||
["KY", {STRING_32} "Cayman Islands"], ["CF", {STRING_32} "Central African Republic"],
|
||||
["TD", {STRING_32} "Chad"], ["CL", {STRING_32} "Chile"], ["CN", {STRING_32} "China"],
|
||||
["CX", {STRING_32} "Christmas Island"], ["CC", {STRING_32} "Cocos (Keeling) Islands"],
|
||||
["CX", {STRING_32} "Christmas Island"], ["CC", {STRING_32} "Cocos (Keeling) Islands"],
|
||||
["CO", {STRING_32} "Colombia"], ["KM", {STRING_32} "Comoros"], ["CG", {STRING_32} "Congo"],
|
||||
["CD", {STRING_32} "Congo, the Democratic Republic of the"], ["CK", {STRING_32} "Cook Islands"],
|
||||
["CR", {STRING_32} "Costa Rica"], ["CI", {STRING_32} "C<>te d'Ivoire"],
|
||||
@@ -61,11 +61,11 @@ feature -- Implementation
|
||||
["FO", {STRING_32} "Faroe Islands"], ["FJ", {STRING_32} "Fiji"], ["FI", {STRING_32} "Finland"],
|
||||
["FR", {STRING_32} "France"], ["GF", {STRING_32} "French Guiana"],
|
||||
["PF", {STRING_32} "French Polynesia"], ["TF", {STRING_32} "French Southern Territories"],
|
||||
["GA", {STRING_32} "Gabon"], ["GM", {STRING_32} "Gambia"], ["GE", {STRING_32} "Georgia"],
|
||||
["GA", {STRING_32} "Gabon"], ["GM", {STRING_32} "Gambia"], ["GE", {STRING_32} "Georgia"],
|
||||
["DE", {STRING_32} "Germany"], ["GH", {STRING_32} "Ghana"], ["GI", {STRING_32} "Gibraltar"],
|
||||
["GR", {STRING_32} "Greece"], ["GL", {STRING_32} "Greenland"], ["GD", {STRING_32} "Grenada"],
|
||||
["GP", {STRING_32} "Guadeloupe"], ["GU", {STRING_32} "Guam"], ["GT", {STRING_32} "Guatemala"],
|
||||
["GG", {STRING_32} "Guernsey"], ["GN", {STRING_32} "Guinea"], ["GW", {STRING_32} "Guinea-Bissau"],
|
||||
["GP", {STRING_32} "Guadeloupe"], ["GU", {STRING_32} "Guam"], ["GT", {STRING_32} "Guatemala"],
|
||||
["GG", {STRING_32} "Guernsey"], ["GN", {STRING_32} "Guinea"], ["GW", {STRING_32} "Guinea-Bissau"],
|
||||
["GY", {STRING_32} "Guyana"], ["HT", {STRING_32} "Haiti"], ["HM", {STRING_32} "Heard Island and McDonald Islands"],
|
||||
["VA", {STRING_32} "Holy See (Vatican City State)"],
|
||||
["HN", {STRING_32} "Honduras"], ["HK", {STRING_32} "Hong Kong"], ["HU", {STRING_32} "Hungary"],
|
||||
@@ -92,48 +92,48 @@ feature -- Implementation
|
||||
["NA", {STRING_32} "Namibia"], ["NR", {STRING_32} "Nauru"], ["NP", {STRING_32} "Nepal"],
|
||||
["NL", {STRING_32} "Netherlands"], ["NC", {STRING_32} "New Caledonia"], ["NZ", {STRING_32} "New Zealand"],
|
||||
["NI", {STRING_32} "Nicaragua"], ["NE", {STRING_32} "Niger"],
|
||||
["NG", {STRING_32} "Nigeria"], ["NU", {STRING_32} "Niue"], ["NF", {STRING_32} "Norfolk Island"],
|
||||
["NG", {STRING_32} "Nigeria"], ["NU", {STRING_32} "Niue"], ["NF", {STRING_32} "Norfolk Island"],
|
||||
["MP", {STRING_32} "Northern Mariana Islands"], ["NO", {STRING_32} "Norway"],
|
||||
["OM", {STRING_32} "Oman"], ["PK", {STRING_32} "Pakistan"], ["PW", {STRING_32} "Palau"],
|
||||
["PS", {STRING_32} "Palestinian Territory, Occupied"], ["PA", {STRING_32} "Panama"],
|
||||
["PG", {STRING_32} "Papua New Guinea"], ["PY", {STRING_32} "Paraguay"], ["PE", {STRING_32} "Peru"],
|
||||
["PG", {STRING_32} "Papua New Guinea"], ["PY", {STRING_32} "Paraguay"], ["PE", {STRING_32} "Peru"],
|
||||
["PH", {STRING_32} "Philippines"], ["PN", {STRING_32} "Pitcairn"],
|
||||
["PL", {STRING_32} "Poland"], ["PT", {STRING_32} "Portugal"], ["PR", {STRING_32} "Puerto Rico"],
|
||||
["QA", {STRING_32} "Qatar"], ["RE", {STRING_32} "R<>union"], ["RO", {STRING_32} "Romania"],
|
||||
["RU", {STRING_32} "Russian Federation"], ["RW", {STRING_32} "Rwanda"], ["BL", {STRING_32} "Saint Barth<74>lemy"],
|
||||
["SH", {STRING_32} "Saint Helena, Ascension and Tristan da Cunha"],
|
||||
["KN", {STRING_32} "Saint Kitts and Nevis"], ["LC", {STRING_32} "Saint Lucia"], ["MF", {STRING_32} "Saint Martin (French part)"],
|
||||
["KN", {STRING_32} "Saint Kitts and Nevis"], ["LC", {STRING_32} "Saint Lucia"], ["MF", {STRING_32} "Saint Martin (French part)"],
|
||||
["PM", {STRING_32} "Saint Pierre and Miquelon"],
|
||||
["VC", {STRING_32} "Saint Vincent and the Grenadines"], ["WS", {STRING_32} "Samoa"],
|
||||
["VC", {STRING_32} "Saint Vincent and the Grenadines"], ["WS", {STRING_32} "Samoa"],
|
||||
["SM", {STRING_32} "San Marino"], ["ST", {STRING_32} "Sao Tome and Principe"],
|
||||
["SA", {STRING_32} "Saudi Arabia"], ["SN", {STRING_32} "Senegal"], ["RS", {STRING_32} "Serbia"],
|
||||
["SC", {STRING_32} "Seychelles"], ["SL", {STRING_32} "Sierra Leone"],
|
||||
["SG", {STRING_32} "Singapore"], ["SX", {STRING_32} "Sint Maarten (Dutch part)"], ["SK", {STRING_32} "Slovakia"],
|
||||
["SG", {STRING_32} "Singapore"], ["SX", {STRING_32} "Sint Maarten (Dutch part)"], ["SK", {STRING_32} "Slovakia"],
|
||||
["SI", {STRING_32} "Slovenia"], ["SB", {STRING_32} "Solomon Islands"],
|
||||
["SO", {STRING_32} "Somalia"], ["ZA", {STRING_32} "South Africa"], ["GS", {STRING_32} "South Georgia and the South Sandwich Islands"],
|
||||
["SS", {STRING_32} "South Sudan"],
|
||||
["SO", {STRING_32} "Somalia"], ["ZA", {STRING_32} "South Africa"], ["GS", {STRING_32} "South Georgia and the South Sandwich Islands"],
|
||||
["SS", {STRING_32} "South Sudan"],
|
||||
["ES", {STRING_32} "Spain"], ["LK", {STRING_32} "Sri Lanka"], ["SD", {STRING_32} "Sudan"], ["SR", {STRING_32} "Suriname"],
|
||||
["SJ", {STRING_32} "Svalbard and Jan Mayen"],
|
||||
["SJ", {STRING_32} "Svalbard and Jan Mayen"],
|
||||
["SZ", {STRING_32} "Swaziland"], ["SE", {STRING_32} "Sweden"], ["CH", {STRING_32} "Switzerland"],
|
||||
["SY", {STRING_32} "Syrian Arab Republic"],
|
||||
["SY", {STRING_32} "Syrian Arab Republic"],
|
||||
["TW", {STRING_32} "Taiwan, Province of China"], ["TJ", {STRING_32} "Tajikistan"],
|
||||
["TZ", {STRING_32} "Tanzania, United Republic of"], ["TH", {STRING_32} "Thailand"],
|
||||
["TL", {STRING_32} "Timor-Leste"], ["TG", {STRING_32} "Togo"], ["TK", {STRING_32} "Tokelau"],
|
||||
["TL", {STRING_32} "Timor-Leste"], ["TG", {STRING_32} "Togo"], ["TK", {STRING_32} "Tokelau"],
|
||||
["TO", {STRING_32} "Tonga"], ["TT", {STRING_32} "Trinidad and Tobago"],
|
||||
["TN", {STRING_32} "Tunisia"], ["TR", {STRING_32} "Turkey"], ["TM", {STRING_32} "Turkmenistan"],
|
||||
["TC", {STRING_32} "Turks and Caicos Islands"], ["TV", {STRING_32} "Tuvalu"],
|
||||
["UG", {STRING_32} "Uganda"], ["UA", {STRING_32} "Ukraine"], ["AE", {STRING_32} "United Arab Emirates"],
|
||||
["GB", {STRING_32} "United Kingdom"], ["US", {STRING_32} "United States"],
|
||||
["GB", {STRING_32} "United Kingdom"], ["US", {STRING_32} "United States"],
|
||||
["UM", {STRING_32} "United States Minor Outlying Islands"], ["UY", {STRING_32} "Uruguay"],
|
||||
["UZ", {STRING_32} "Uzbekistan"], ["VU", {STRING_32} "Vanuatu"],
|
||||
["VE", {STRING_32} "Venezuela, Bolivarian Republic of"], ["VN", {STRING_32} "Viet Nam"],
|
||||
["VE", {STRING_32} "Venezuela, Bolivarian Republic of"], ["VN", {STRING_32} "Viet Nam"],
|
||||
["VG", {STRING_32} "Virgin Islands, British"],
|
||||
["VI", {STRING_32} "Virgin Islands, U.S."], ["WF", {STRING_32} "Wallis and Futuna"],
|
||||
["EH", {STRING_32} "Western Sahara"], ["YE", {STRING_32} "Yemen"],
|
||||
["ZM", {STRING_32} "Zambia"], ["ZW", {STRING_32} "Zimbabwe"]
|
||||
>>
|
||||
|
||||
create Result.make_array
|
||||
create Result.make_empty
|
||||
across
|
||||
list as c
|
||||
loop
|
||||
@@ -143,8 +143,8 @@ feature -- Implementation
|
||||
then
|
||||
if second.as_lower.has_substring (input.as_lower) then
|
||||
create o.make
|
||||
o.put (create {JSON_STRING}.make_json (first.as_lower), "flag")
|
||||
o.put (create {JSON_STRING}.make_json_from_string_32 (second), "value")
|
||||
o.put (create {JSON_STRING}.make_from_string (first.as_lower), "flag")
|
||||
o.put (create {JSON_STRING}.make_from_string_32 (second), "value")
|
||||
Result.add (o)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,11 +44,13 @@ feature -- Implementation
|
||||
if attached sess.get ("/complete/search?client=chrome", ctx) as resp and then not resp.error_occurred then
|
||||
l_json := resp.body
|
||||
end
|
||||
create Result.make_array
|
||||
create Result.make_empty
|
||||
if l_json /= Void and then not l_json.is_empty then
|
||||
create json_parser.make_parser (l_json)
|
||||
create json_parser.make_with_string (l_json)
|
||||
json_parser.parse_content
|
||||
if
|
||||
attached {JSON_ARRAY} json_parser.parse_json as data and then
|
||||
json_parser.is_valid and then
|
||||
attached {JSON_ARRAY} json_parser.parsed_json_value as data and then
|
||||
data.valid_index (2) and then
|
||||
attached {JSON_ARRAY} data.i_th (2) as list
|
||||
then
|
||||
@@ -57,7 +59,7 @@ feature -- Implementation
|
||||
loop
|
||||
if attached {JSON_STRING} list.i_th (c.item) as row then
|
||||
create o.make
|
||||
o.put (create {JSON_STRING}.make_with_escaped_json (row.item), "value")
|
||||
o.put (create {JSON_STRING}.make_from_escaped_json_string (row.item), "value")
|
||||
Result.add (o)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -73,8 +73,12 @@ feature -- Access
|
||||
end
|
||||
end
|
||||
if l_json /= Void and then not l_json.is_empty then
|
||||
create json_parser.make_parser (l_json)
|
||||
if attached {JSON_OBJECT} json_parser.parse_json as sp then
|
||||
create json_parser.make_with_string (l_json)
|
||||
json_parser.parse_content
|
||||
if
|
||||
json_parser.is_valid and then
|
||||
attached {JSON_OBJECT} json_parser.parsed_json_value as sp
|
||||
then
|
||||
if
|
||||
attached {JSON_OBJECT} sp.item ("responseData") as responsedata and then
|
||||
attached {JSON_ARRAY} responsedata.item ("results") as results
|
||||
|
||||
@@ -18,7 +18,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
control: detachable WSF_PROGRESS_CONTROL
|
||||
|
||||
make ()
|
||||
make
|
||||
do
|
||||
end
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ feature -- Implementation
|
||||
l_lowered_input: READABLE_STRING_GENERAL
|
||||
l_lowered_item: READABLE_STRING_GENERAL
|
||||
do
|
||||
create Result.make_array
|
||||
create Result.make_empty
|
||||
l_lowered_input := a_input.as_lower
|
||||
across
|
||||
list as c
|
||||
@@ -50,7 +50,7 @@ feature -- Implementation
|
||||
end
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
copyright: "2011-2015, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -43,7 +43,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
update
|
||||
-- Send new renederd control to client on update
|
||||
do
|
||||
state_changes.replace (create {JSON_STRING}.make_json_from_string_32 (render), "_html")
|
||||
state_changes.replace (create {JSON_STRING}.make_from_string_32 (render), "_html")
|
||||
end
|
||||
|
||||
feature --Event handling
|
||||
@@ -100,7 +100,7 @@ feature -- Properties
|
||||
datasource: WSF_PAGABLE_DATASOURCE [G]
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
copyright: "2011-2015, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -39,7 +39,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
update
|
||||
-- Send new rendered control to client on update
|
||||
do
|
||||
state_changes.replace (create {JSON_STRING}.make_json_from_string_32 (render_body), "_body")
|
||||
state_changes.replace (create {JSON_STRING}.make_from_string_32 (render_body), "_body")
|
||||
state_changes.replace (datasource.state, "datasource")
|
||||
end
|
||||
|
||||
@@ -100,7 +100,7 @@ feature -- Access
|
||||
pagination_control: detachable WSF_PAGINATION_CONTROL [G]
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
copyright: "2011-2015, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -100,7 +100,7 @@ feature -- Change
|
||||
do
|
||||
if not t.same_string (text) then
|
||||
text := t
|
||||
state_changes.replace (create {JSON_STRING}.make_json_from_string_32 (t), "text")
|
||||
state_changes.replace (create {JSON_STRING}.make_from_string_32 (t), "text")
|
||||
end
|
||||
ensure
|
||||
text_same_string_as_t: text.same_string (t)
|
||||
@@ -160,7 +160,7 @@ feature -- Properties
|
||||
-- Procedure to be execued on change
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
copyright: "2011-2015, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -65,7 +65,7 @@ feature -- Change
|
||||
else
|
||||
remove_class ("active")
|
||||
end
|
||||
state_changes.replace (create {JSON_BOOLEAN}.make_boolean (a), "active")
|
||||
state_changes.replace (create {JSON_BOOLEAN}.make (a), "active")
|
||||
end
|
||||
ensure
|
||||
active_set: active = a
|
||||
@@ -77,4 +77,14 @@ feature -- Properties
|
||||
active: BOOLEAN
|
||||
-- The active state of this item
|
||||
|
||||
;note
|
||||
copyright: "2011-2015, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ feature {NONE} -- Initialization
|
||||
make_stateless_control (a_tag_name)
|
||||
create control_name_prefix.make_empty
|
||||
create state_changes.make
|
||||
create actions.make_array
|
||||
create actions.make_empty
|
||||
ensure
|
||||
state_changes_attached: attached state_changes
|
||||
end
|
||||
@@ -110,7 +110,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
end
|
||||
if actions.count > 0 then
|
||||
if states.item ("actions") = Void then
|
||||
states.put (create {JSON_ARRAY}.make_array, "actions")
|
||||
states.put (create {JSON_ARRAY}.make_empty, "actions")
|
||||
end
|
||||
if attached {JSON_ARRAY} states.item ("actions") as action_list then
|
||||
across
|
||||
@@ -223,7 +223,7 @@ feature -- Properties
|
||||
-- control state and therefore could have the same name (Stateless multi controls do not add a hierarchy level)
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
copyright: "2011-2015, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -29,7 +29,7 @@ feature {NONE} -- Initialization
|
||||
-- Initialize with specified tag
|
||||
do
|
||||
Precursor (tag)
|
||||
create items.make_array
|
||||
create items.make_empty
|
||||
create pending_removes.make (1)
|
||||
ensure then
|
||||
tag_set: tag_name.same_string (tag)
|
||||
@@ -194,7 +194,7 @@ invariant
|
||||
all_items_exist: items.count = controls.count
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
copyright: "2011-2015, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -148,7 +148,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
validator_description: JSON_ARRAY
|
||||
do
|
||||
create Result.make
|
||||
create validator_description.make_array
|
||||
create validator_description.make_empty
|
||||
across
|
||||
validators as v
|
||||
loop
|
||||
@@ -209,7 +209,7 @@ feature -- Validation
|
||||
-- Set the error message that will be displayed upon failure of client side validation
|
||||
do
|
||||
error := e
|
||||
state_changes.replace (create {JSON_STRING}.make_json_from_string_32 (e), "error")
|
||||
state_changes.replace (create {JSON_STRING}.make_from_string_32 (e), "error")
|
||||
ensure
|
||||
error_set: error.same_string (e)
|
||||
end
|
||||
@@ -257,7 +257,7 @@ feature -- Properties
|
||||
-- The bootstrap column span of the label of this form element control
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
copyright: "2011-2015, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -83,14 +83,22 @@ feature -- Implementation
|
||||
if not event.same_string_general ("uploadfile") then
|
||||
create states.make_empty
|
||||
request.read_input_data_into (states)
|
||||
create json_parser.make_parser (states)
|
||||
if attached {JSON_OBJECT} json_parser.parse_json as sp then
|
||||
create json_parser.make_with_string (states)
|
||||
json_parser.parse_content
|
||||
if
|
||||
json_parser.is_valid and then
|
||||
attached {JSON_OBJECT} json_parser.parsed_json_value as sp
|
||||
then
|
||||
set_state (sp)
|
||||
end
|
||||
else
|
||||
if attached request.form_parameter ("state") as statedata then
|
||||
create json_parser.make_parser (statedata.as_string.value)
|
||||
if attached {JSON_OBJECT} json_parser.parse_json as sp then
|
||||
create json_parser.make_with_string (statedata.as_string.value)
|
||||
json_parser.parse_content
|
||||
if
|
||||
json_parser.is_valid and then
|
||||
attached {JSON_OBJECT} json_parser.parsed_json_value as sp
|
||||
then
|
||||
set_state (sp)
|
||||
end
|
||||
end
|
||||
@@ -259,7 +267,7 @@ feature {NONE} -- Root control
|
||||
-- List containing the additional javascipt files
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
copyright: "2011-2015, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -51,7 +51,7 @@ feature -- Access
|
||||
if attached {JSON_OBJECT} j as jo then
|
||||
l_keys := k.split ('.')
|
||||
l_keys.start
|
||||
create js.make_json_from_string_32 (l_keys.item.as_readable_string_32)
|
||||
create js.make_from_string_general (l_keys.item)
|
||||
v := jo.item (js)
|
||||
l_keys.remove
|
||||
if l_keys.count > 0 then
|
||||
@@ -93,8 +93,9 @@ feature -- Access
|
||||
f.close
|
||||
end
|
||||
|
||||
create p.make_parser (s)
|
||||
json := p.parse
|
||||
create p.make_with_string (s)
|
||||
p.parse_content
|
||||
json := p.parsed_json_value
|
||||
if attached config ("gewf.template_dir") as d then
|
||||
setup.set_template_dir_from_string (d)
|
||||
end
|
||||
@@ -159,7 +160,7 @@ invariant
|
||||
-- invariant_clause: True
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -133,8 +133,9 @@ feature {NONE} -- Initialization
|
||||
|
||||
-- Show the Response body
|
||||
if attached Result.body as m then
|
||||
create j.make_parser (m)
|
||||
if j.is_parsed and attached j.parse_object as j_o then
|
||||
create j.make_with_string (m)
|
||||
j.parse_content
|
||||
if j.is_valid and then attached j.parsed_json_object as j_o then
|
||||
if attached {JSON_STRING} j_o.item ("id") as l_id then
|
||||
id := l_id.item
|
||||
end
|
||||
|
||||
@@ -97,7 +97,7 @@ feature -- Conversion
|
||||
Result.put (json.value (o.location), location_key)
|
||||
Result.put (json.value (o.status), status_key)
|
||||
from
|
||||
create ja.make_array
|
||||
create ja.make_empty
|
||||
o.items.start
|
||||
until
|
||||
o.items.after
|
||||
@@ -117,48 +117,48 @@ feature -- Conversion
|
||||
feature {NONE} -- Implementation
|
||||
id_key: JSON_STRING
|
||||
once
|
||||
create Result.make_json ("id")
|
||||
create Result.make_from_string ("id")
|
||||
end
|
||||
|
||||
location_key: JSON_STRING
|
||||
once
|
||||
create Result.make_json ("location")
|
||||
create Result.make_from_string ("location")
|
||||
end
|
||||
|
||||
status_key: JSON_STRING
|
||||
once
|
||||
create Result.make_json ("status")
|
||||
create Result.make_from_string ("status")
|
||||
end
|
||||
|
||||
items_key : JSON_STRING
|
||||
once
|
||||
create Result.make_json ("items")
|
||||
create Result.make_from_string ("items")
|
||||
end
|
||||
|
||||
|
||||
name_key : JSON_STRING
|
||||
|
||||
once
|
||||
create Result.make_json ("name")
|
||||
create Result.make_from_string ("name")
|
||||
end
|
||||
|
||||
size_key : JSON_STRING
|
||||
|
||||
once
|
||||
create Result.make_json ("size")
|
||||
create Result.make_from_string ("size")
|
||||
end
|
||||
|
||||
quantity_key : JSON_STRING
|
||||
|
||||
once
|
||||
create Result.make_json ("quantity")
|
||||
create Result.make_from_string ("quantity")
|
||||
end
|
||||
|
||||
|
||||
option_key : JSON_STRING
|
||||
|
||||
once
|
||||
create Result.make_json ("option")
|
||||
create Result.make_from_string ("option")
|
||||
end
|
||||
feature -- Validation
|
||||
|
||||
@@ -171,6 +171,6 @@ feature -- Validation
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Javier Velilla and others"
|
||||
copyright: "2011-2015, Javier Velilla and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
|
||||
@@ -559,8 +559,9 @@ feature {NONE} -- Implementation Repository Layer
|
||||
do
|
||||
create joc.make
|
||||
json.add_converter(joc)
|
||||
create parser.make_parser (l_post)
|
||||
if attached parser.parse as jv and parser.is_parsed then
|
||||
create parser.make_with_string (l_post)
|
||||
parser.parse_content
|
||||
if parser.is_valid and then attached parser.parsed_json_value as jv then
|
||||
if attached {like extract_order_request} json.object (jv, "ORDER") as res then
|
||||
Result := res
|
||||
end
|
||||
@@ -568,6 +569,6 @@ feature {NONE} -- Implementation Repository Layer
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Javier Velilla and others"
|
||||
copyright: "2011-2015, Javier Velilla and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
|
||||
@@ -385,8 +385,12 @@ feature {NONE} -- Implementation Repository Layer
|
||||
do
|
||||
create joc.make
|
||||
json.add_converter(joc)
|
||||
create parser.make_parser (l_post)
|
||||
if attached parser.parse as jv and parser.is_parsed then
|
||||
create parser.make_with_string (l_post)
|
||||
parser.parse_content
|
||||
if
|
||||
parser.is_valid and then
|
||||
attached parser.parsed_json_value as jv
|
||||
then
|
||||
if attached {like extract_order_request} json.object (jv, "ORDER") as res then
|
||||
Result := res
|
||||
end
|
||||
@@ -394,6 +398,6 @@ feature {NONE} -- Implementation Repository Layer
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Javier Velilla and others"
|
||||
copyright: "2011-2015, Javier Velilla and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
|
||||
@@ -21,6 +21,8 @@ inherit
|
||||
|
||||
WSF_DEFAULT_SERVICE
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
@@ -46,7 +48,7 @@ feature {NONE} -- Initialization
|
||||
map_uri_template_agent_with_request_methods ("/upload/{name}{?nb}", agent execute_upload_put, router.methods_put)
|
||||
map_uri_template_agent ("/upload{?nb}", agent execute_upload)
|
||||
|
||||
create www.make (document_root)
|
||||
create www.make_with_path (document_root)
|
||||
www.set_directory_index (<<"index.html">>)
|
||||
www.set_not_found_handler (agent execute_not_found)
|
||||
router.handle_with_request_methods ("", www, router.methods_GET)
|
||||
@@ -54,31 +56,18 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Configuration
|
||||
|
||||
document_root: READABLE_STRING_8
|
||||
document_root: PATH
|
||||
-- Document root to look for files or directories
|
||||
local
|
||||
e: EXECUTION_ENVIRONMENT
|
||||
dn: DIRECTORY_NAME
|
||||
once
|
||||
create e
|
||||
create dn.make_from_string (e.current_working_directory)
|
||||
dn.extend ("htdocs")
|
||||
Result := dn.string
|
||||
if Result [Result.count] = Operating_environment.directory_separator then
|
||||
Result := Result.substring (1, Result.count - 1)
|
||||
end
|
||||
Result := execution_environment.current_working_path.extended ("htdocs")
|
||||
ensure
|
||||
not Result.ends_with (Operating_environment.directory_separator.out)
|
||||
not Result.name.ends_with (Operating_environment.directory_separator.out)
|
||||
end
|
||||
|
||||
files_root: READABLE_STRING_8
|
||||
files_root: PATH
|
||||
-- Uploaded files will be stored in `files_root' folder
|
||||
local
|
||||
dn: DIRECTORY_NAME
|
||||
once
|
||||
create dn.make_from_string (document_root)
|
||||
dn.extend ("files")
|
||||
Result := dn.string
|
||||
Result := document_root.extended ("files")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
@@ -114,8 +103,7 @@ feature -- Execution
|
||||
n := 1
|
||||
end
|
||||
if attached {WSF_STRING} req.query_parameter ("demo") as p_demo then
|
||||
create fn.make_from_string (document_root)
|
||||
fn := fn.extended (p_demo.value)
|
||||
fn := document_root.extended (p_demo.value)
|
||||
l_body.append ("File: <input type=%"file%" name=%"uploaded_file[]%" size=%"60%" value=%""+ html_encode (fn.name) +"%"></br>%N")
|
||||
end
|
||||
|
||||
@@ -139,9 +127,8 @@ feature -- Execution
|
||||
n := n + 1
|
||||
l_body.append ("<li>")
|
||||
l_body.append ("<div>" + c.item.name + "=" + html_encode (c.item.filename) + " size=" + c.item.size.out + " type=" + c.item.content_type + "</div>")
|
||||
create fn.make_from_string (files_root)
|
||||
l_safe_filename := c.item.safe_filename
|
||||
fn := fn.extended (l_safe_filename)
|
||||
fn := files_root.extended (l_safe_filename)
|
||||
if c.item.move_to (fn.name) then
|
||||
if c.item.content_type.starts_with ("image") then
|
||||
l_body.append ("%N<a href=%"../files/" + url_encode (l_safe_filename) + "%"><img src=%"../files/"+ l_safe_filename +"%" /></a>")
|
||||
@@ -187,8 +174,7 @@ feature -- Execution
|
||||
if attached new_temporary_output_file ("tmp-uploaded-file_" + n.out) as f then
|
||||
req.read_input_data_into_file (f)
|
||||
f.close
|
||||
create fn.make_from_string (files_root)
|
||||
fn := fn.extended (l_safe_filename)
|
||||
fn := files_root.extended (l_safe_filename)
|
||||
f.rename_file (fn.name)
|
||||
l_body.append ("<li>")
|
||||
l_body.append ("<div>Input data : size=" + f.count.out + " (" + req.content_length_value.out + ")</div>")
|
||||
|
||||
@@ -41,7 +41,7 @@ feature -- Execution
|
||||
rescued: BOOLEAN
|
||||
do
|
||||
if not rescued then
|
||||
create req.make ((create {EXECUTION_ENVIRONMENT}).starting_environment_variables, create {WGI_CGI_INPUT_STREAM}.make, Current)
|
||||
create req.make ((create {EXECUTION_ENVIRONMENT}).starting_environment, create {WGI_CGI_INPUT_STREAM}.make, Current)
|
||||
create res.make (create {WGI_CGI_OUTPUT_STREAM}.make, create {WGI_CGI_ERROR_STREAM}.make)
|
||||
service.execute (req, res)
|
||||
res.push
|
||||
@@ -68,7 +68,7 @@ feature -- Execution
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Eiffel Software and others"
|
||||
copyright: "2011-2015, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -325,7 +325,6 @@ feature -- Header add cookie
|
||||
--| the same response with the same cookie-name.
|
||||
local
|
||||
l_same_cookie_name: BOOLEAN
|
||||
l_nv: STRING
|
||||
do
|
||||
across
|
||||
internal_header.headers as ic
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<library name="rss" location="..\draft\library\protocol\syndication\rss\rss-safe.ecf" readonly="false"/>
|
||||
<library name="upload_image" location="..\examples\upload_image\upload_image-safe.ecf" readonly="false"/>
|
||||
<library name="uri_template" location="..\library\text\parser\uri_template\uri_template-safe.ecf" readonly="false"/>
|
||||
<library name="wizard" location="..\tools\ise_wizard\ewf_ise_wizard-safe.ecf" readonly="false"/>
|
||||
<library name="wizard" location="..\tools\estudio_wizard\ewf_ise_wizard-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="..\library\server\wsf\wsf-safe.ecf" readonly="false"/>
|
||||
<library name="wsf_all" location="..\library\server\wsf\connector\all-safe.ecf" readonly="false"/>
|
||||
<library name="wsf_cgi" location="..\library\server\wsf\connector\cgi-safe.ecf" readonly="false"/>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<library name="restbucks" location="..\examples\restbucksCRUD\restbucks-safe.ecf" readonly="false"/>
|
||||
<library name="upload_image" location="..\examples\upload_image\upload_image-safe.ecf" readonly="false"/>
|
||||
<library name="uri_template" location="..\library\text\parser\uri_template\uri_template-safe.ecf" readonly="false"/>
|
||||
<library name="wizard" location="..\tools\ise_wizard\ewf_ise_wizard-safe.ecf" readonly="false"/>
|
||||
<library name="wizard" location="..\tools\estudio_wizard\ewf_ise_wizard-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="..\library\server\wsf\wsf-safe.ecf" readonly="false"/>
|
||||
<library name="wsf_all" location="..\library\server\wsf\connector\all-safe.ecf" readonly="false"/>
|
||||
<library name="wsf_cgi" location="..\library\server\wsf\connector\cgi-safe.ecf" readonly="false"/>
|
||||
|
||||
@@ -23,7 +23,6 @@ feature {TEMPLATE_ROUTINES}
|
||||
-- If not handled by this inspector, return Void
|
||||
local
|
||||
l_fn: STRING
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
if attached {WIZARD_DATA} obj as wiz then
|
||||
l_fn := field_name.as_lower
|
||||
|
||||
Reference in New Issue
Block a user