Commit fa3d214cd4cc77e7aa6f5b5cc0a0361f55bdc1ba
1 parent
c2a99964
Remove files was mistaken added (.bak, .rej, etc)
Showing
5 changed files
with
0 additions
and
7755 deletions
Show diff stats
obj/unit_test.aproj.FileListAbsolute.txt deleted
web/form.anubis.bak deleted
| 1 | -/* | |
| 2 | - * Created by PyramIDE. | |
| 3 | - * User: フランスのトトロ | |
| 4 | - * Date: 07/12/2014 | |
| 5 | - * Time: 16:49 | |
| 6 | - * © David RENÉ | |
| 7 | - */ | |
| 8 | - | |
| 9 | -// ************************************************************************************* | |
| 10 | -// *** Generic form | |
| 11 | -// ************************************************************************************* | |
| 12 | -read tools/basis.anubis | |
| 13 | -read system/string.anubis | |
| 14 | -read xlib/web/common.anubis | |
| 15 | -read xlib/web/web_arg_utils.anubis | |
| 16 | -read xlib/web/making_a_web_site.anubis | |
| 17 | -read xlib/web/html_tooltip.anubis | |
| 18 | -read xlib/web/widgets.anubis | |
| 19 | -read xlib/web/widgets/specialized_elements.anubis | |
| 20 | - | |
| 21 | -public type Mandatory: // used to mark fields as mandatory. | |
| 22 | - mandatory, | |
| 23 | - non_mandatory. | |
| 24 | - | |
| 25 | -public type Width: | |
| 26 | - small, //10 char | |
| 27 | - narrow_small, //20 char | |
| 28 | - narrow, //50 char | |
| 29 | - wide, //70 char | |
| 30 | - custom(Int). | |
| 31 | - | |
| 32 | -public type FormFieldWidth: | |
| 33 | - auto, | |
| 34 | - custom(Int). | |
| 35 | - | |
| 36 | -public type CXM_Form_Field: | |
| 37 | - no_field, // empty field | |
| 38 | - | |
| 39 | - //--- title field --------------------------------------------------------------------- | |
| 40 | - title( | |
| 41 | - String text | |
| 42 | - ), | |
| 43 | - | |
| 44 | - //--- message field ------------------------------------------------------------------- | |
| 45 | - message( | |
| 46 | - String text | |
| 47 | - ), | |
| 48 | - | |
| 49 | - //--- text input field ---------------------------------------------------------------- | |
| 50 | - input( | |
| 51 | - List(CoreAttrs) options, | |
| 52 | - HTML_Label label, | |
| 53 | - HTML_Id id, | |
| 54 | - WebArgName web_arg_name, | |
| 55 | - InitialValue init_value, | |
| 56 | - Width width, | |
| 57 | - Mandatory mandatory | |
| 58 | - ), | |
| 59 | - | |
| 60 | - input_readonly( | |
| 61 | - List(CoreAttrs) options, | |
| 62 | - HTML_Label label, | |
| 63 | - HTML_Id id, | |
| 64 | - WebArgName web_arg_name, | |
| 65 | - InitialValue init_value, | |
| 66 | - Width width | |
| 67 | - ), | |
| 68 | - | |
| 69 | - //--- text area field ----------------------------------------------------------------- | |
| 70 | - text_area( | |
| 71 | - List(TextAreaOption) options, | |
| 72 | - HTML_Label label, | |
| 73 | - HTML_Id id, | |
| 74 | - WebArgName web_arg_name, | |
| 75 | - InitialValue init_value, | |
| 76 | - Width width, | |
| 77 | - Int height, | |
| 78 | - Mandatory mandatory | |
| 79 | - ), | |
| 80 | - | |
| 81 | - //--- password input field ------------------------------------------------------------ | |
| 82 | - password_input( | |
| 83 | - List(CoreAttrs) options, | |
| 84 | - HTML_Label label, | |
| 85 | - HTML_Id id, | |
| 86 | - WebArgName web_arg_name, | |
| 87 | - InitialValue init_value, | |
| 88 | - Width width, | |
| 89 | - Mandatory mandatory), | |
| 90 | - | |
| 91 | - //--- phone field ------------------------------------------------------------ | |
| 92 | - phone_input( | |
| 93 | - Maybe(List(CoreAttrs)) sms_icon_options, //if there is sms available it's success with the options (generally the js call to edit sms) | |
| 94 | - List(CoreAttrs) phone_icon_options, | |
| 95 | - List(CoreAttrs) text_options, | |
| 96 | - HTML_Label label, | |
| 97 | - HTML_Id id, | |
| 98 | - WebArgName web_arg_name, | |
| 99 | - InitialValue init_value, | |
| 100 | - Phone_Type phone_type, | |
| 101 | - Width width, | |
| 102 | - Mandatory mandatory), | |
| 103 | - | |
| 104 | - //--- email field ------------------------------------------------------------ | |
| 105 | - email_input( | |
| 106 | - List(CoreAttrs) icon_options, | |
| 107 | - List(CoreAttrs) options, | |
| 108 | - HTML_Label label, | |
| 109 | - HTML_Id id, | |
| 110 | - WebArgName web_arg_name, | |
| 111 | - InitialValue init_value, | |
| 112 | - Width width, | |
| 113 | - Mandatory mandatory), | |
| 114 | - | |
| 115 | - //--- url field ------------------------------------------------------------ | |
| 116 | - url_input( | |
| 117 | - List(CoreAttrs) icon_options, | |
| 118 | - List(CoreAttrs) options, | |
| 119 | - HTML_Label label, | |
| 120 | - HTML_Id id, | |
| 121 | - WebArgName web_arg_name, | |
| 122 | - InitialValue init_value, | |
| 123 | - Width width, | |
| 124 | - Mandatory mandatory), | |
| 125 | - | |
| 126 | - //--- hidden field ------------------------------------------------------------ | |
| 127 | - hidden( | |
| 128 | - HTML_Id id, | |
| 129 | - WebArgName web_arg_name, | |
| 130 | - WebArgValue init_value | |
| 131 | - ), | |
| 132 | - //--- explanation field --------------------------------------------------------------- | |
| 133 | - explain( | |
| 134 | - String text | |
| 135 | - ), | |
| 136 | - | |
| 137 | - //--- selector field ------------------------------------------------------------------ | |
| 138 | - selector( | |
| 139 | - List(CoreAttrs) options, | |
| 140 | - HTML_Label label, | |
| 141 | - HTML_Id id, | |
| 142 | - WebArgName web_arg_name, | |
| 143 | - Int size, | |
| 144 | - List(String) items, | |
| 145 | - Maybe(InitialValue) selected, | |
| 146 | - Mandatory mandatory | |
| 147 | - ), | |
| 148 | - | |
| 149 | - selector_c( | |
| 150 | - List(CoreAttrs) options, | |
| 151 | - HTML_Label label, | |
| 152 | - HTML_Id id, | |
| 153 | - WebArgName web_arg_name, | |
| 154 | - Int size, | |
| 155 | - List((List(CoreAttrs), WebArgValue, String)) items, | |
| 156 | - Maybe(InitialValue) selected, | |
| 157 | - Mandatory mandatory | |
| 158 | - ), | |
| 159 | - | |
| 160 | - selector_hide_show (List(CoreAttrs) options, | |
| 161 | - HTML_Label label, | |
| 162 | - HTML_Id id, | |
| 163 | - WebArgName web_arg_name, | |
| 164 | - Int size, | |
| 165 | - List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items, | |
| 166 | - Maybe(InitialValue) selected, | |
| 167 | - Mandatory mandatory), | |
| 168 | - | |
| 169 | - //--- checkbox field ------------------------------------------------------------------ | |
| 170 | - checkbox (List(CoreAttrs) options, | |
| 171 | - HTML_Label label, | |
| 172 | - HTML_Id id, | |
| 173 | - WebArgName web_arg_name, | |
| 174 | - Bool checked, | |
| 175 | - Mandatory mandatory), | |
| 176 | - | |
| 177 | - // the same one, but with the tag on the right of the checkbox | |
| 178 | - checkboxr( | |
| 179 | - List(CoreAttrs) options, | |
| 180 | - HTML_Label label, | |
| 181 | - HTML_Id id, | |
| 182 | - WebArgName web_arg_name, | |
| 183 | - Bool checked, | |
| 184 | - Mandatory mandatory | |
| 185 | - ), | |
| 186 | - | |
| 187 | - //checkbox_hide_show | |
| 188 | - checkbox_hide_show( | |
| 189 | - List(CoreAttrs) options, | |
| 190 | - HTML_Label label, | |
| 191 | - WebArgName web_arg_name, | |
| 192 | - Bool checked, | |
| 193 | - List(CXM_Form_Field) fields | |
| 194 | - ), | |
| 195 | - | |
| 196 | - //--- radio-button field -------------------------------------------------------------- | |
| 197 | - radio_button( | |
| 198 | - List(CoreAttrs) options, | |
| 199 | - HTML_Label label, | |
| 200 | - HTML_Id id, | |
| 201 | - WebArgName web_arg_name, | |
| 202 | - WebArgValue web_arg_value, | |
| 203 | - Bool checked, | |
| 204 | - Mandatory mandatory | |
| 205 | - ), | |
| 206 | - //radio_button_hide_show | |
| 207 | - radio_button_hide_show( | |
| 208 | - List(CoreAttrs) options, | |
| 209 | - HTML_Label label, | |
| 210 | - WebArgName web_arg_name, | |
| 211 | - WebArgValue web_arg_value, | |
| 212 | - Bool checked, | |
| 213 | - List(CXM_Form_Field) fields | |
| 214 | - ), | |
| 215 | - // the same one, but with the tag on the right of the radio_button | |
| 216 | - radio_buttonr (List(CoreAttrs) options, | |
| 217 | - HTML_Label label, | |
| 218 | - HTML_Id id, | |
| 219 | - WebArgName web_arg_name, | |
| 220 | - WebArgValue web_arg_value, | |
| 221 | - Bool checked, | |
| 222 | - Mandatory mandatory), | |
| 223 | - | |
| 224 | - radio_button_list( | |
| 225 | - List(CoreAttrs) options, | |
| 226 | - HTML_Label label, | |
| 227 | - HTML_Id id, | |
| 228 | - WebArgName web_arg_name, | |
| 229 | - List((WebArgValue, String)) web_arg_value, | |
| 230 | - Maybe(InitialValue) selected, | |
| 231 | - Mandatory mandatory, | |
| 232 | - Bool is_wide), | |
| 233 | - | |
| 234 | -// //--- fields table -------------------------------------------------------------------- | |
| 235 | -// fields_table (String tag, | |
| 236 | -// List(FormField) fields), | |
| 237 | -// | |
| 238 | -// //--- fields line --------------------------------------------------------------------- | |
| 239 | -// fields_line (String tag, | |
| 240 | -// List(FormField) fields), | |
| 241 | - one_line_fields (List(CXM_Form_Field) fields), | |
| 242 | - | |
| 243 | -// | |
| 244 | -// //--- preview field ------------------------------------------------------------------- | |
| 245 | -// preview (String html_text), | |
| 246 | - | |
| 247 | - //--- upload field ------------------------------------------------------------------- | |
| 248 | - upload (List(CoreAttrs) options, | |
| 249 | - HTML_Label label, | |
| 250 | - HTML_Id id, | |
| 251 | - WebArgName name, | |
| 252 | - Width width, | |
| 253 | - Mandatory mandatory), | |
| 254 | - | |
| 255 | - raw_in_form (HTML_Off_Form html), | |
| 256 | - label_for ( String label, | |
| 257 | - HTML_Id id, | |
| 258 | - HTML_Off_Form input), | |
| 259 | - div (List(CoreAttrs), List(HTML_Off_Form) contents), | |
| 260 | - div (List(CoreAttrs), List(CXM_Form_Field) fields), | |
| 261 | - partial (HTML_Partial_Content p_content), | |
| 262 | - br, | |
| 263 | - hr (List(CoreAttrs) options), | |
| 264 | -// input_with_help (CXM_Form_Field field, | |
| 265 | -// Maybe(String) help_title, | |
| 266 | -// String help_text, | |
| 267 | -// Int width), | |
| 268 | - | |
| 269 | - fieldset (List(CoreAttrs) options, | |
| 270 | - String legend, | |
| 271 | - List(CXM_Form_Field) fields), | |
| 272 | - | |
| 273 | - blank_space, | |
| 274 | - blank_space (HtmlClass class), | |
| 275 | - | |
| 276 | - //--- submit button ------------------------------------------------------------------- | |
| 277 | - submit (List(CoreAttrs) options, | |
| 278 | - HtmlClass class, | |
| 279 | - WEB_Action_Name action_name, | |
| 280 | - Maybe(String) label, | |
| 281 | - String button_text, | |
| 282 | - List((String,String)) extra_operands), | |
| 283 | - empty. | |
| 284 | - | |
| 285 | -// ////////////////////////////////////////////// | |
| 286 | -// Alternate constructors: | |
| 287 | - | |
| 288 | -public define CXM_Form_Field | |
| 289 | - fieldset | |
| 290 | - ( | |
| 291 | - HTML_Id fieldSetId, | |
| 292 | - List(CXM_Form_Field) fields | |
| 293 | - ) = | |
| 294 | - fieldset([id(fieldSetId.id)], "", fields). | |
| 295 | - | |
| 296 | -public define CXM_Form_Field | |
| 297 | - fieldset | |
| 298 | - ( | |
| 299 | - List(CXM_Form_Field) fields | |
| 300 | - ) = | |
| 301 | - fieldset([], "", fields). | |
| 302 | - | |
| 303 | -public define CXM_Form_Field | |
| 304 | - fieldset | |
| 305 | - ( | |
| 306 | - String legend, | |
| 307 | - List(CXM_Form_Field) fields | |
| 308 | - ) = | |
| 309 | - fieldset([], legend, fields). | |
| 310 | - | |
| 311 | -public define CXM_Form_Field | |
| 312 | - input(WebArgName n, InitialValue init_value, Width width) | |
| 313 | - = input([], no_label, html_Id(n.name), n, init_value, width, non_mandatory). | |
| 314 | - | |
| 315 | -public define CXM_Form_Field | |
| 316 | - input(HTML_Label label, WebArgName n, InitialValue init_value, Width width) | |
| 317 | - = input([], label, html_Id(n.name), n, init_value, width, non_mandatory). | |
| 318 | - | |
| 319 | -public define CXM_Form_Field | |
| 320 | - input(HTML_Label label, WebArgName n, InitialValue init_value, Width width, Mandatory mand) | |
| 321 | - = input([], label, html_Id(n.name), n, init_value, width, mand). | |
| 322 | - | |
| 323 | -public define CXM_Form_Field | |
| 324 | - input(HTML_Label label, HTML_Id id, WebArgName n, InitialValue init_value, Width width, Mandatory mand) | |
| 325 | - = input([], label, id, n, init_value, width, mand). | |
| 326 | - | |
| 327 | -public define CXM_Form_Field | |
| 328 | - input(List(CoreAttrs) options, HTML_Label label, WebArgName n, InitialValue init_value, Width width, Mandatory mand) | |
| 329 | - = input(options, label, html_Id(n.name), n, init_value, width, mand). | |
| 330 | - | |
| 331 | -public define CXM_Form_Field | |
| 332 | - input_readonly(HTML_Label label, WebArgName n, InitialValue init_value, Width width) | |
| 333 | - = input_readonly([], label, html_Id(n.name), n, init_value, width). | |
| 334 | - | |
| 335 | -public define CXM_Form_Field | |
| 336 | - password_input(HTML_Label label, WebArgName n, InitialValue init_value, Width width, Mandatory mand) | |
| 337 | - = password_input([], label, html_Id(n.name), n, init_value, width, mand). | |
| 338 | - | |
| 339 | -public define CXM_Form_Field | |
| 340 | - checkbox(HTML_Label label, WebArgName n, Bool checked, Mandatory mand) | |
| 341 | - = checkbox([], label, html_Id(n.name), n, checked, mand). | |
| 342 | - | |
| 343 | -public define CXM_Form_Field | |
| 344 | - checkboxr(HTML_Label label, WebArgName n, Bool checked, Mandatory mand) | |
| 345 | - = checkboxr([], label, html_Id(n.name), n, checked, mand). | |
| 346 | - | |
| 347 | -public define CXM_Form_Field | |
| 348 | - radio_button(HTML_Label label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) | |
| 349 | - = radio_button([], label, html_Id(n.name), n, value, checked, mand). | |
| 350 | - | |
| 351 | -public define CXM_Form_Field | |
| 352 | - radio_buttonr(HTML_Label label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) | |
| 353 | - = radio_buttonr([], label, html_Id(n.name), n, value, checked, mand). | |
| 354 | - | |
| 355 | -public define CXM_Form_Field | |
| 356 | - submit(WEB_Action_Name action_name, HtmlClass class, Maybe(String) label, String button_text, List((String,String)) extra_operands) | |
| 357 | - = submit([], class, action_name, label, button_text, extra_operands). | |
| 358 | - | |
| 359 | -public define CXM_Form_Field | |
| 360 | - submit(WEB_Action_Name action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands) | |
| 361 | - = submit([], htmlClass(""), action_name, label, button_text, extra_operands). | |
| 362 | - | |
| 363 | -public define CXM_Form_Field | |
| 364 | - submit(WEB_Action_Name action_name, Maybe(String) label, String button_text) | |
| 365 | - = submit([], htmlClass(""), action_name, label, button_text, []). | |
| 366 | - | |
| 367 | -public define CXM_Form_Field //Helper for older project wich use only String as Action name | |
| 368 | - submit(String _action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands) | |
| 369 | - = submit([], htmlClass(""), action_name(_action_name), label, button_text, extra_operands). | |
| 370 | - | |
| 371 | - | |
| 372 | -public define CXM_Form_Field | |
| 373 | - upload(HTML_Label label, HTML_Id id, WebArgName name, Width width) | |
| 374 | - = upload([], label, id, name, width, non_mandatory). | |
| 375 | - | |
| 376 | -public define CXM_Form_Field | |
| 377 | - upload(HTML_Label label, HTML_Id id, WebArgName name, Width width, Mandatory mand) | |
| 378 | - = upload([], label, id, name, width, mand). | |
| 379 | - | |
| 380 | -public define CXM_Form_Field | |
| 381 | - ip_input | |
| 382 | - ( | |
| 383 | - String label, | |
| 384 | - HTML_Id id, | |
| 385 | - WebArgName wan_prefix, | |
| 386 | - String ip | |
| 387 | - )= | |
| 388 | - label_for( | |
| 389 | - label, | |
| 390 | - id, | |
| 391 | - ip_input(id, wan_prefix, ip) | |
| 392 | - ). | |
| 393 | - | |
| 394 | - | |
| 395 | -public define CXM_Form_Field | |
| 396 | - partial_ip_input | |
| 397 | - ( | |
| 398 | - String label, | |
| 399 | - HTML_Id id, | |
| 400 | - WebArgName wan_prefix, | |
| 401 | - List(String) ip_fixed_part, | |
| 402 | - String ip | |
| 403 | - )= | |
| 404 | - label_for( | |
| 405 | - label, | |
| 406 | - id, | |
| 407 | - partial_ip_input(id, wan_prefix, ip_fixed_part, ip) | |
| 408 | - ). | |
| 409 | - | |
| 410 | -public define CXM_Form_Field | |
| 411 | - hidden | |
| 412 | - ( | |
| 413 | - WebArgName web_arg_name, | |
| 414 | - WebArgValue value | |
| 415 | - )= | |
| 416 | - hidden(html_Id(""), web_arg_name, value). | |
| 417 | - | |
| 418 | -public define CXM_Form_Field | |
| 419 | - hr | |
| 420 | - = | |
| 421 | - hr([]) | |
| 422 | -. | |
| 423 | - | |
| 424 | -public define CXM_Form_Field | |
| 425 | - div | |
| 426 | - ( | |
| 427 | - List(CoreAttrs) attrs, | |
| 428 | - HTML_Off_Form content | |
| 429 | - )= | |
| 430 | - div(attrs, [content]) | |
| 431 | -. | |
| 432 | - | |
| 433 | -public define CXM_Form_Field | |
| 434 | - div | |
| 435 | - ( | |
| 436 | - HTML_Off_Form content | |
| 437 | - )= | |
| 438 | - div([], [content]) | |
| 439 | -. | |
| 440 | - //--- explanation field --------------------- | |
| 441 | - | |
| 442 | -// ////////////////////////////////////////////////////////// | |
| 443 | - | |
| 444 | -define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content)) | |
| 445 | - construct_selector_hide_show | |
| 446 | - ( | |
| 447 | - String div_id, | |
| 448 | - List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items, | |
| 449 | - List((List(CoreAttrs), WebArgValue, String)) so_far_1, | |
| 450 | - List(HTML_Partial_Content) so_far_2, | |
| 451 | - Int n | |
| 452 | - ) = | |
| 453 | - if items is | |
| 454 | - { | |
| 455 | - [] then (so_far_1, so_far_2), | |
| 456 | - [h . t] then | |
| 457 | - since h is (cores, wav, label, content), | |
| 458 | - with linked_element = div_id + n, | |
| 459 | - construct_selector_hide_show(div_id, t, [([data("linked_element", linked_element) . cores], wav, label) . so_far_1], [ partial_content([], div([id(linked_element), style("display: none")], content)) . so_far_2 ], n + 1) | |
| 460 | - }. | |
| 461 | - | |
| 462 | -define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content)) | |
| 463 | - construct_selector_hide_show | |
| 464 | - ( | |
| 465 | - String div_id, | |
| 466 | - List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items | |
| 467 | - ) = construct_selector_hide_show(div_id, items, [], [], 0). | |
| 468 | - | |
| 469 | -public define HTML_Off_Form | |
| 470 | - format_div_CXM_Form_Field | |
| 471 | - ( | |
| 472 | - List(CXM_Form_Field) field, | |
| 473 | - List(Web_arg) lwa, | |
| 474 | - String _class, | |
| 475 | - Bool b_with_label | |
| 476 | - ). | |
| 477 | - | |
| 478 | - | |
| 479 | -public define HTML_Off_Form | |
| 480 | - format_CXM_Form_Field | |
| 481 | - ( | |
| 482 | - CXM_Form_Field ff, //CXM_Form_Field to format | |
| 483 | - List(Web_arg) lwa, //web arguments of the session, can be useful for the current drawing | |
| 484 | - String _class, | |
| 485 | - Bool b_with_label //if false, no need to show/generate label | |
| 486 | - ) = | |
| 487 | - with star = (HTML_Label l, Mandatory m) | |
| 488 | - |-> | |
| 489 | - (HTML_Label) | |
| 490 | - if b_with_label then | |
| 491 | - if m is | |
| 492 | - { | |
| 493 | - mandatory then | |
| 494 | - if l is | |
| 495 | - { | |
| 496 | - no_label then l, | |
| 497 | - label(str, help) then label(str + "<span>*</span>", help), | |
| 498 | - } | |
| 499 | - non_mandatory then l | |
| 500 | - } | |
| 501 | - else | |
| 502 | - no_label | |
| 503 | - , | |
| 504 | - pixels = (Width width) | |
| 505 | - |-> | |
| 506 | - if width is | |
| 507 | - { | |
| 508 | - small then 10, | |
| 509 | - narrow_small then 20, | |
| 510 | - narrow then 50, | |
| 511 | - wide then 70, | |
| 512 | - custom(n) then n | |
| 513 | - }, | |
| 514 | - | |
| 515 | - | |
| 516 | - if ff is | |
| 517 | - { | |
| 518 | - no_field then empty, | |
| 519 | - | |
| 520 | - title(t) then h3(t), | |
| 521 | - | |
| 522 | - message(t) then literal(t), | |
| 523 | - | |
| 524 | - input(options, _label, id, wan, default, w, mand) then | |
| 525 | - text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)), | |
| 526 | - | |
| 527 | - input_readonly(options, _label, id, name, init, w) then | |
| 528 | - text_input_ro([class("in") . options], _label, id, name, init, pixels(w)), | |
| 529 | - | |
| 530 | - text_area(options, _label, id, wan, default, w, height, mand) then | |
| 531 | - text_area([input_attrs([class("in")]) . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w), height), | |
| 532 | - | |
| 533 | - password_input(options, _label, id, name, init, w, mand) then | |
| 534 | - password_input([class("in") . options], star(_label, mand), id, name, init, pixels(w)), | |
| 535 | - | |
| 536 | - phone_input(mb_sms_options, icon_options, options, _label, _id, wan, default, phone_type, w, mand) then | |
| 537 | - sequence([ | |
| 538 | - if mb_sms_options is | |
| 539 | - { | |
| 540 | - failure then empty, | |
| 541 | - success(sms_options) then img([event(onmouseover, "/icons/16x16/send_sms.png")]+sms_options, "/icons/16x16/sms.png") | |
| 542 | - }, | |
| 543 | - img(icon_options, "/icons/16x16/"+to_Icon(phone_type)), | |
| 544 | - input([class("in"), id(_id.id), name(wan.name), init(get_String(lwa, wan.name, default.value)), size(pixels(w)). options]), | |
| 545 | - ]), | |
| 546 | - | |
| 547 | - email_input(icon_options, options, _label, id, wan, default, w, mand) then | |
| 548 | - sequence([ | |
| 549 | - img(icon_options, "/icons/16x16/email_edit.png"), | |
| 550 | - text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)), | |
| 551 | - ]), | |
| 552 | - | |
| 553 | - url_input(icon_options, options, _label, id, wan, default, w, mand) then | |
| 554 | - sequence([ | |
| 555 | - img(icon_options, "/icons/16x16/url.png"), | |
| 556 | - text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)), | |
| 557 | - ]), | |
| 558 | - | |
| 559 | - hidden(h_id, name, init) then hidden(name, init), | |
| 560 | - | |
| 561 | - explain(t) then | |
| 562 | - div([class("sub")], literal(t)), | |
| 563 | - | |
| 564 | - selector(options, _label, id, wan, size, items, selected, mand) then | |
| 565 | - if selected is | |
| 566 | - { | |
| 567 | - failure then selector([class("in") . options], star(_label, mand), id, wan, size, items), | |
| 568 | - success(default) then selector([class("in") . options], star(_label, mand), id, wan, size, items, init(get_String(lwa, wan.name, default.value))), | |
| 569 | - }, | |
| 570 | - | |
| 571 | - selector_c(options, _label, id, wan, size, items, selected, mand) then | |
| 572 | - if selected is | |
| 573 | - { | |
| 574 | - failure then selector_c([class("in") . options], star(_label, mand), id, wan, size, items), | |
| 575 | - success(default) then selector_c([class("in") . options], star(_label, mand), id, wan, size, items, init(get_String(lwa, wan.name, default.value))), | |
| 576 | - }, | |
| 577 | - | |
| 578 | - selector_hide_show(options, _label, id, wan, size, items_with_partial, selected, mand) then | |
| 579 | - with div_id = generate_random_string(15), | |
| 580 | - since construct_selector_hide_show(div_id, items_with_partial) is (items, partial_content_list), | |
| 581 | - sequence([ | |
| 582 | - selector_c([class("in"), class("cxm_selector_hide_show"), event(onchange, "select_hide_show('" + div_id + "', this);")], star(_label, mand), id, wan, size, reverse(items), if selected is { failure then init(""), success(default) then init(get_String(lwa, wan.name, default.value)) } ), | |
| 583 | - partial(partial_content(partial_content_list)) | |
| 584 | - ]), | |
| 585 | - | |
| 586 | - checkbox(options, _label, id, wan, checked, mand) then | |
| 587 | - check_box([class("in") . options], star(_label, mand), id, wan, get_Bool(lwa, wan.name, checked)), | |
| 588 | - | |
| 589 | - checkboxr(options, _label, id, wan, checked, mand) then | |
| 590 | - check_box_r([class("in") . options], star(_label, mand), id, wan, get_Bool(lwa, wan.name, checked)), | |
| 591 | - | |
| 592 | - checkbox_hide_show(options, _label, wan, checked, fields) then | |
| 593 | - with div_id = generate_random_string(15), | |
| 594 | - sequence([ | |
| 595 | - check_box([data("show_id", div_id), class("in cxm_checkbox_hide_show"), event(onclick, "checked_hide_show_element('"+div_id+"', this);")], _label, html_Id("checkbox_"+div_id), wan, get_Bool(lwa, wan.name, checked)), | |
| 596 | - div([id(div_id), style("display:"+if checked then "block" else "none")], format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)) | |
| 597 | - ]), | |
| 598 | - | |
| 599 | - radio_button(options, _label, id, wan, val, checked, mand) then | |
| 600 | - radio_button([class("in"), event(onclick, "radio_hide_show_group('"+wan.name+"', this);") . options], star(_label, mand), id, wan, val, get_Bool(lwa, wan.name, checked)), | |
| 601 | - | |
| 602 | - radio_button_hide_show(options, _label, wan, val, checked, fields) then | |
| 603 | - with div_id = generate_random_string(15), | |
| 604 | - sequence([ | |
| 605 | - radio_button([data("show_id", div_id), class("in"), class("cxm_radio_hide_show"), event(onclick, "radio_hide_show_group('"+wan.name+"', this);")], _label, html_Id("radio_button_hide_show_"+div_id), wan, val, get_Bool(lwa, wan.name, checked)), | |
| 606 | - div([id(div_id), style("display:"+if checked then "block" else "none")], format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)) | |
| 607 | - ]), | |
| 608 | - | |
| 609 | - radio_buttonr(options, _label, id, wan, val, checked, mand) then | |
| 610 | - radio_button_r([class("in") . options], star(_label, mand), id, wan, val, get_Bool(lwa, wan.name, checked)), | |
| 611 | - | |
| 612 | - radio_button_list (options, _label, id, wan, items, selected, mand, wide) then | |
| 613 | - with new_selected = | |
| 614 | - if get_String(lwa, wan.name) is | |
| 615 | - { | |
| 616 | - failure then selected, | |
| 617 | - success(value) then success(init(value)) | |
| 618 | - }, | |
| 619 | - | |
| 620 | - sequence([ | |
| 621 | - //literal("<label for=\"" + wan.name + "\">" + label + star(_label, mand) + "</label>"), | |
| 622 | - div( [class("radiolist")], sequence( | |
| 623 | - with i = var((Int)-1), | |
| 624 | - itemclass = if wide then "radiolistitem_wide" else "radiolistitem", | |
| 625 | - map( ((WebArgValue, String) item) |-> | |
| 626 | - i <- *i + 1; | |
| 627 | - if item is (wav, item_label) then | |
| 628 | - with _id = if id is html_Id(the_id) then html_Id(the_id + "_radio_" + *i), | |
| 629 | - div([class(itemclass)], radio_button_r(options, label(item_label), _id, wan, wav, | |
| 630 | - if new_selected is success(v) then wav.value = v.value else false)), | |
| 631 | - items)) | |
| 632 | - ), | |
| 633 | - ]), | |
| 634 | - one_line_fields(fields) then | |
| 635 | - table([nude, class("form_one_line")],[row([], | |
| 636 | - map((CXM_Form_Field ff2) |-> cell([],format_CXM_Form_Field(ff2, lwa, _class, b_with_label)),fields))]) | |
| 637 | - , | |
| 638 | - | |
| 639 | - upload(options, _label, id, name, w, mand) then | |
| 640 | - file_upload([class("in") . options], star(_label, mand), id, name, pixels(w)), | |
| 641 | - | |
| 642 | - raw_in_form(html) then html, | |
| 643 | -// div([class("in")], html), | |
| 644 | - label_for(label, id, input) then | |
| 645 | - sequence([ | |
| 646 | - if id is html_Id(_id) then | |
| 647 | - literal("<label for=\"" + _id + "\">" + label + "</label>"), | |
| 648 | - input | |
| 649 | - ]), | |
| 650 | - | |
| 651 | - div(options, e) then div(options, e), | |
| 652 | - div(options, fields)then div(options, format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)), | |
| 653 | - partial(p_content) then partial(p_content), | |
| 654 | - br then br, | |
| 655 | - hr(opts) then hr(opts), | |
| 656 | -// input_with_help(input, help_title, help_text, width) then | |
| 657 | -// sequence([ | |
| 658 | -// format_CXM_Form_Field(input, lwa, html_tooltip(force_String(help_title), help_text, width)), | |
| 659 | -// ]), | |
| 660 | - | |
| 661 | - fieldset(options, legend, fields) then | |
| 662 | - sequence([ | |
| 663 | - literal("<fieldset" + format_attrs(options) + ">"), | |
| 664 | - literal(if length(legend) > 0 then "<legend>" + legend + "</legend>" else ""), | |
| 665 | - format_div_CXM_Form_Field(fields, lwa, _class, b_with_label), | |
| 666 | - literal("</fieldset>") | |
| 667 | - ]), | |
| 668 | - | |
| 669 | - blank_space then | |
| 670 | - div([class("blank_space")], literal(" ")), | |
| 671 | - | |
| 672 | - blank_space(htmlClass) then | |
| 673 | - div([class(htmlClass.class)], literal(" ")), | |
| 674 | - | |
| 675 | - submit(attrs, htmlClass, action_name, Maybe(String) mb_label, button_text, extra_operands) then | |
| 676 | - actioner( same, // TODO change this to allow external URL | |
| 677 | - if mb_label is | |
| 678 | - { | |
| 679 | - failure then same, | |
| 680 | - success(n) then same(n) | |
| 681 | - }, | |
| 682 | - submit(attrs + [class(htmlClass.class + " cxm_submit")], button_text), | |
| 683 | - action_name, | |
| 684 | - extra_operands | |
| 685 | - ), | |
| 686 | - empty then literal("") | |
| 687 | - }. | |
| 688 | - | |
| 689 | - | |
| 690 | -public define HTML_Off_Form | |
| 691 | - format_div_CXM_Form_Field | |
| 692 | - ( | |
| 693 | - List(CXM_Form_Field) fields, | |
| 694 | - List(Web_arg) lwa, | |
| 695 | - String _class, | |
| 696 | - Bool b_with_label | |
| 697 | - )= | |
| 698 | - //println("format_div_CXM_Form_Field"); | |
| 699 | - sequence( map((CXM_Form_Field field) | |
| 700 | - |-> | |
| 701 | - //with css_line = if line = 0 then " odd_line" else " even_line", | |
| 702 | - //println("class "+css_line+" line "+line); | |
| 703 | - if field is empty then | |
| 704 | - empty | |
| 705 | - else if field is no_field then | |
| 706 | - empty | |
| 707 | - else if field is hidden(_id, name, init) then | |
| 708 | - format_CXM_Form_Field(field, lwa, _class, b_with_label) | |
| 709 | - else if field is br then | |
| 710 | - format_CXM_Form_Field(field, lwa, _class, b_with_label) | |
| 711 | - else if field is text_area(options, _label, id, wan, default, w, height, mand) then | |
| 712 | - div([class(_class)], format_CXM_Form_Field(field, lwa, _class, b_with_label)) | |
| 713 | - else | |
| 714 | - div([class(_class)], format_CXM_Form_Field(field, lwa, _class, b_with_label)) | |
| 715 | - , fields)) | |
| 716 | -. | |
| 717 | - | |
| 718 | -public define HTML_Off_Form | |
| 719 | - to_HTML_Off_Form | |
| 720 | - ( | |
| 721 | - List(CXM_Form_Field) fields, | |
| 722 | - List(Web_arg) lwa, | |
| 723 | - String _class, | |
| 724 | - Bool b_with_label | |
| 725 | - )= | |
| 726 | - format_div_CXM_Form_Field(fields, lwa, _class, b_with_label) | |
| 727 | -. | |
| 728 | - | |
| 729 | -public define HTML_Off_Form | |
| 730 | - to_HTML_Off_Form | |
| 731 | - ( | |
| 732 | - List(CXM_Form_Field) fields, | |
| 733 | - String _class, | |
| 734 | - Bool b_with_label | |
| 735 | - )= | |
| 736 | - to_HTML_Off_Form(fields, [], _class, b_with_label). | |
| 737 | - | |
| 738 | -public define HTML_Off_Form | |
| 739 | - to_HTML_Off_Form | |
| 740 | - ( | |
| 741 | - List(CXM_Form_Field) fields, | |
| 742 | - List(Web_arg) lwa | |
| 743 | - )= | |
| 744 | - to_HTML_Off_Form(fields, lwa, "form_field aligned", true) | |
| 745 | -. | |
| 746 | - | |
| 747 | -public define HTML_Off_Form | |
| 748 | - to_HTML_Off_Form | |
| 749 | - ( | |
| 750 | - CXM_Form_Field field, | |
| 751 | - List(Web_arg) lwa | |
| 752 | - )= | |
| 753 | - to_HTML_Off_Form([field], lwa, "form_field aligned", true) | |
| 754 | -. | |
| 755 | - | |
| 756 | -public define HTML_Off_Form | |
| 757 | - to_HTML_Off_Form | |
| 758 | - ( | |
| 759 | - List(CXM_Form_Field) fields | |
| 760 | - )= | |
| 761 | - to_HTML_Off_Form(fields, [], "form_field aligned", true) | |
| 762 | -. | |
| 763 | - | |
| 764 | -public define HTML_Off_Form | |
| 765 | - cxm_form | |
| 766 | - ( | |
| 767 | - HTML_Id form_Id, | |
| 768 | - List(CoreAttrs) options, | |
| 769 | - WEB_Action_Name action, | |
| 770 | - List((String,String)) extra_ops, | |
| 771 | - List(Web_arg) lwa, | |
| 772 | - List(CXM_Form_Field) fields, | |
| 773 | - String _class, | |
| 774 | - Bool b_with_label | |
| 775 | - ) = | |
| 776 | - form( | |
| 777 | - //form_Id, | |
| 778 | - [class("cxm_form"), id(form_Id.id) . options], | |
| 779 | - action, | |
| 780 | - extra_ops, | |
| 781 | - format_div_CXM_Form_Field(fields, lwa, _class, b_with_label) | |
| 782 | - ). | |
| 783 | - | |
| 784 | -public define HTML_Off_Form | |
| 785 | -/* older manner to call CXM_form with action as String. | |
| 786 | - * this function only exists for compatibility with older projects. Please consider | |
| 787 | - * to use the above function with WEB_Action_Name instead of String | |
| 788 | -*/ | |
| 789 | - cxm_form | |
| 790 | - ( | |
| 791 | - HTML_Id form_Id, | |
| 792 | - List(CoreAttrs) options, | |
| 793 | - String action, //older manner to call action with String | |
| 794 | - List((String,String)) extra_ops, | |
| 795 | - List(Web_arg) lwa, | |
| 796 | - List(CXM_Form_Field) fields, | |
| 797 | - String _class, | |
| 798 | - Bool b_with_label | |
| 799 | - ) = | |
| 800 | - | |
| 801 | - form( | |
| 802 | - //form_Id, | |
| 803 | - [class("cxm_form"), id(form_Id.id) . options], | |
| 804 | - action_name(action), | |
| 805 | - extra_ops, | |
| 806 | - format_div_CXM_Form_Field(fields, lwa, _class, b_with_label) | |
| 807 | - ). | |
| 808 | - | |
| 809 | -public define HTML_Off_Form | |
| 810 | - cxm_form | |
| 811 | - ( | |
| 812 | - String form_name, | |
| 813 | - List(CoreAttrs) options, | |
| 814 | - WEB_Action_Name action, | |
| 815 | - List((String,String)) extra_ops, | |
| 816 | - List(Web_arg) lwa, | |
| 817 | - List(CXM_Form_Field) form_fields, | |
| 818 | - String _class, | |
| 819 | - Bool b_with_label | |
| 820 | - )= | |
| 821 | - cxm_form(html_Id(form_name), options, action, extra_ops, lwa, form_fields, _class, b_with_label). | |
| 822 | - | |
| 823 | -public define HTML_Off_Form | |
| 824 | - cxm_form | |
| 825 | - ( | |
| 826 | - String form_name, | |
| 827 | - List(CoreAttrs) options, | |
| 828 | - WEB_Action_Name action, | |
| 829 | - List((String,String)) extra_ops, | |
| 830 | - List(Web_arg) lwa, | |
| 831 | - List(CXM_Form_Field) form_fields | |
| 832 | - )= | |
| 833 | - cxm_form(form_name, options, action, extra_ops, lwa, form_fields, "form_field aligned", true) | |
| 834 | -. | |
| 835 | - | |
| 836 | -public define HTML_Off_Form | |
| 837 | - cxm_form | |
| 838 | - ( | |
| 839 | - String form_name, | |
| 840 | - List(CoreAttrs) options, | |
| 841 | - String action, | |
| 842 | - List((String,String)) extra_ops, | |
| 843 | - List(Web_arg) lwa, | |
| 844 | - List(CXM_Form_Field) form_fields, | |
| 845 | - | |
| 846 | - Bool b_with_label | |
| 847 | - )= | |
| 848 | - cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields, "form_field aligned", b_with_label) | |
| 849 | -. | |
| 850 | - | |
| 851 | -public define HTML_Off_Form | |
| 852 | - cxm_form | |
| 853 | - ( | |
| 854 | - String form_name, | |
| 855 | - List(CoreAttrs) options, | |
| 856 | - String action, | |
| 857 | - List((String,String)) extra_ops, | |
| 858 | - List(Web_arg) lwa, | |
| 859 | - List(CXM_Form_Field) form_fields | |
| 860 | - )= | |
| 861 | - cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields, "form_field aligned", true) | |
| 862 | -. | |
| 863 | - | |
| 864 | -public define HTML_Off_Form | |
| 865 | - cxm_form | |
| 866 | - ( | |
| 867 | - String form_id, | |
| 868 | - List(CoreAttrs) options, | |
| 869 | - List(HTML_Off_Form) fields, | |
| 870 | - String _class | |
| 871 | - ) = | |
| 872 | - cxm_form(html_Id(form_id), options, action_name(""), [], [], map((HTML_Off_Form field) |-> raw_in_form(field), fields), _class, true ) | |
| 873 | -. | |
| 874 | - | |
| 875 | -public define HTML_Off_Form | |
| 876 | - cxm_form | |
| 877 | - ( | |
| 878 | - String form_id, | |
| 879 | - List(CoreAttrs) options, | |
| 880 | - List(HTML_Off_Form) fields | |
| 881 | - ) = | |
| 882 | - cxm_form(options, action_name(""), [], [], map((HTML_Off_Form field) |-> raw_in_form(field), fields), "form_field aligned", true ) | |
| 883 | -. | |
| 884 | - | |
| 885 | -public define HTML_Off_Form | |
| 886 | - cxm_form | |
| 887 | - ( | |
| 888 | - String form_id, | |
| 889 | - List(CoreAttrs) options, | |
| 890 | - List(Web_arg) lwa, | |
| 891 | - List(CXM_Form_Field) fields, | |
| 892 | - String _class, | |
| 893 | - Bool b_with_label | |
| 894 | - ) = | |
| 895 | - cxm_form(html_Id(form_id), options, action_name(""), [], lwa, fields, _class, b_with_label). | |
| 896 | - | |
| 897 | -public define HTML_Off_Form | |
| 898 | - cxm_form | |
| 899 | - ( | |
| 900 | - String form_id, | |
| 901 | - List(HTML_Off_Form) fields, | |
| 902 | - String _class | |
| 903 | - ) = | |
| 904 | - cxm_form(html_Id(form_id), [], action_name(""), [], [], map((HTML_Off_Form field) |-> raw_in_form(field), fields), _class, true ). | |
| 905 | - | |
| 906 | -public define HTML_Off_Form | |
| 907 | - cxm_form | |
| 908 | - ( | |
| 909 | - String form_id, | |
| 910 | - List(Web_arg) lwa, | |
| 911 | - List(CXM_Form_Field) fields, | |
| 912 | - String _class | |
| 913 | - ) = | |
| 914 | - cxm_form(form_id, [], lwa, fields, _class, true). | |
| 915 | - | |
| 916 | -public define HTML_Off_Form | |
| 917 | - cxm_form | |
| 918 | - ( | |
| 919 | - String form_id, | |
| 920 | - List(Web_arg) lwa, | |
| 921 | - List(CXM_Form_Field) fields, | |
| 922 | - ) = | |
| 923 | - cxm_form(form_id, [], lwa, fields, "form_field aligned", true). | |
| 924 | - | |
| 925 | -public define HTML_Off_Form | |
| 926 | - cxm_form | |
| 927 | - ( | |
| 928 | - String form_id, | |
| 929 | - List(CoreAttrs) options, | |
| 930 | - List(CXM_Form_Field) fields, | |
| 931 | - ) = | |
| 932 | - cxm_form(form_id, options, [], fields, "form_field aligned", true). | |
| 933 | - | |
| 934 | -public define HTML_Off_Form | |
| 935 | - cxm_form | |
| 936 | - ( | |
| 937 | - String form_id, | |
| 938 | - List(CXM_Form_Field) fields, | |
| 939 | - String _class | |
| 940 | - ) = | |
| 941 | - cxm_form(html_Id(form_id), [], action_name(""), [], [], fields, _class, true). | |
| 942 | - | |
| 943 | -public define HTML_Off_Form | |
| 944 | - cxm_form | |
| 945 | - ( | |
| 946 | - String form_id, | |
| 947 | - List(CXM_Form_Field) fields | |
| 948 | - ) = | |
| 949 | - cxm_form(html_Id(form_id), [], action_name(""), [], [], fields, "form_field aligned", true). |
web/form.anubis.rej deleted
| 1 | -diff a/web/form.anubis b/web/form.anubis (rejected hunks) | |
| 2 | -@@ -521,7 +521,6 @@ | |
| 3 | - | |
| 4 | - message(t) then literal(t), | |
| 5 | - | |
| 6 | -- input(options, _label, id, wan, default, w, mand) then | |
| 7 | - input(options, _label, _id, _name, default, w, mand) then | |
| 8 | - sequence([ | |
| 9 | - input([class("in"), options], name(_name.name), value(get_String(lwa, wan.name, default.value)), size(pixels(w)) . options], star(_label, mand)), |
web/making_a_web_site.anubis.bak deleted
Changes suppressed. Click to show
| 1 | - | |
| 2 | - | |
| 3 | - *Project* Anubis | |
| 4 | - | |
| 5 | - *Title* Making interactive Web sites. | |
| 6 | - | |
| 7 | - *Copyright* Copyright (c) Alain Prouté 2004-2005. | |
| 8 | - Copyright (c) Calexium 2007-2017. | |
| 9 | - Copyright (c) David René 2007-2021. | |
| 10 | - | |
| 11 | - | |
| 12 | - *Authors* Alain Prouté | |
| 13 | - David René | |
| 14 | - Jérémy Larrieu | |
| 15 | - Julien Verneuil | |
| 16 | - | |
| 17 | - | |
| 18 | - *Revised* May 2015 | |
| 19 | - | |
| 20 | - | |
| 21 | - *Overview* | |
| 22 | - | |
| 23 | - In this file we propose simple tools for making well structured interactive and secured | |
| 24 | - web sites. | |
| 25 | - | |
| 26 | - | |
| 27 | - ----------------------------------- Table of Contents --------------------------------- | |
| 28 | - | |
| 29 | - * (1) Structure of a web site. | |
| 30 | - ** (1.1) Three sorts of data. | |
| 31 | - ** (1.2) How requests are handled. | |
| 32 | - ** (1.3) What web pages are made of. | |
| 33 | - ** (1.4) Actions. | |
| 34 | - ** (1.5) States. | |
| 35 | - | |
| 36 | - * (2) Carrying on. | |
| 37 | - ** (2.1) Describing your web sites. | |
| 38 | - ** (2.2) Directories on the server's disk. | |
| 39 | - ** (2.3) Starting your web sites. | |
| 40 | - | |
| 41 | - * (3) The HTML interface. | |
| 42 | - ** (3.1) Types used by the HTML interface. | |
| 43 | - ** (3.2) ``in form'' versus ``off form''. | |
| 44 | - ** (3.3) Defining your own style. | |
| 45 | - ** (3.4) Actioners and forms. | |
| 46 | - ** (3.5) Local popup. | |
| 47 | - | |
| 48 | - --------------------------------------------------------------------------------------- | |
| 49 | - | |
| 50 | - | |
| 51 | -transmit tools/basis.anubis | |
| 52 | -read tools/printable_tree.anubis | |
| 53 | -read tools/base64.anubis | |
| 54 | -read tools/random.anubis | |
| 55 | -read tools/avlt_dictionaries.anubis | |
| 56 | -read system/lists.anubis | |
| 57 | -read system/string.anubis | |
| 58 | -read system/logger.anubis | |
| 59 | -transmit xlib/web/common.anubis | |
| 60 | -transmit xlib/web/multihost_http_server.anubis | |
| 61 | -read web/mime.anubis | |
| 62 | - | |
| 63 | -read xlib/web/cookies.anubis | |
| 64 | -read xlib/web/json.anubis | |
| 65 | -transmit xlib/web/web_dump.anubis | |
| 66 | -transmit xlib/web/web_arg_utils.anubis | |
| 67 | -transmit xlib/web/web_session.anubis | |
| 68 | -transmit xlib/web/web_action.anubis | |
| 69 | - | |
| 70 | -transmit xlib/web/types/web_action_name.anubis | |
| 71 | -transmit xlib/web/types/making_a_web_site.anubis | |
| 72 | - | |
| 73 | -//TODO move anywhere | |
| 74 | - | |
| 75 | - | |
| 76 | -define List(Word8) | |
| 77 | -/** Test for HTML entity which must be encoded | |
| 78 | - * and return the encoded entity if needed | |
| 79 | - */ | |
| 80 | - get_entity | |
| 81 | - ( | |
| 82 | - Word8 _char, | |
| 83 | - List(Word8) tail | |
| 84 | - )= | |
| 85 | - //test for the ampersand | |
| 86 | - if _char = '&' then | |
| 87 | - //test if it's already an encoded string like & < etc. In that case we do nothing | |
| 88 | - if insensitive_equal(['&','a','m','p',';'], tail, 0) then [_char] | |
| 89 | - else if insensitive_equal(['&','l','t',';'], tail, 0) then [_char] | |
| 90 | - else if insensitive_equal(['&','g','t',';'], tail, 0) then [_char] | |
| 91 | - else if insensitive_equal(['&','q','u','o','t',';'], tail, 0) then [_char] | |
| 92 | - else | |
| 93 | - [';','p','m','a','&'] | |
| 94 | - //test for '<' etc. | |
| 95 | - else if _char = '<' then [';','t','l','&'] | |
| 96 | - else if _char = '>' then [';','t','g','&'] | |
| 97 | - else if _char = '\"' then [';','t','o','u','q','&'] | |
| 98 | - else [_char] | |
| 99 | -. | |
| 100 | - | |
| 101 | -define String | |
| 102 | - _HTML_encode_entities | |
| 103 | - ( | |
| 104 | - List(Word8) source, | |
| 105 | - List(Word8) current | |
| 106 | - )= | |
| 107 | - if source is | |
| 108 | - { | |
| 109 | - [] then implode(reverse(current)), | |
| 110 | - [c . t] then | |
| 111 | - _HTML_encode_entities(t, get_entity(c, t) + current) | |
| 112 | - } | |
| 113 | -. | |
| 114 | - | |
| 115 | -public define String | |
| 116 | - encode_HTML_entities | |
| 117 | - ( | |
| 118 | - String source | |
| 119 | - )= | |
| 120 | - _HTML_encode_entities(explode(source), []) | |
| 121 | -. | |
| 122 | - | |
| 123 | -define List(Word8) | |
| 124 | -/** Test for HTML entity which must be encoded | |
| 125 | - * and return the encoded entity if needed | |
| 126 | - */ | |
| 127 | - get_entity_quote | |
| 128 | - ( | |
| 129 | - Word8 _char, | |
| 130 | - List(Word8) tail | |
| 131 | - )= | |
| 132 | - //test for the ampersand | |
| 133 | - if _char = '&' then | |
| 134 | - //test if it's already an encoded string like & < etc. In that case we do nothing | |
| 135 | - if insensitive_equal(['&','a','m','p',';'], tail, 0) then [_char] | |
| 136 | - else if insensitive_equal(['&','l','t',';'], tail, 0) then [_char] | |
| 137 | - else if insensitive_equal(['&','g','t',';'], tail, 0) then [_char] | |
| 138 | - else if insensitive_equal(['&','q','u','o','t',';'], tail, 0) then [_char] | |
| 139 | - else | |
| 140 | - [';','p','m','a','&'] | |
| 141 | - //test for '"' only. | |
| 142 | - else if _char = '\"' then [';','t','o','u','q','&'] | |
| 143 | - else [_char] | |
| 144 | -. | |
| 145 | - | |
| 146 | -define String | |
| 147 | - _HTML_encode_quote | |
| 148 | - ( | |
| 149 | - List(Word8) source, | |
| 150 | - List(Word8) current | |
| 151 | - )= | |
| 152 | - if source is | |
| 153 | - { | |
| 154 | - [] then implode(reverse(current)), | |
| 155 | - [c . t] then | |
| 156 | - _HTML_encode_quote(t, get_entity_quote(c, t) + current) | |
| 157 | - } | |
| 158 | -. | |
| 159 | - | |
| 160 | -public define String | |
| 161 | - encode_HTML_quote | |
| 162 | - ( | |
| 163 | - String source | |
| 164 | - )= | |
| 165 | - _HTML_encode_quote(explode(source), []) | |
| 166 | -. | |
| 167 | - | |
| 168 | - * (1) Structure of a web site. | |
| 169 | - | |
| 170 | - First of all we need to explain what a web site should be made of. Ideally, the | |
| 171 | - visitor (also called the 'client') should see the web site working as any other | |
| 172 | - interactive computer software. So, it should be clear that a 'session' (i.e. a visit | |
| 173 | - to the web site, including the consultation of several pages) is some kind of | |
| 174 | - conversation between the visitor and the web site, and that the web site should | |
| 175 | - maintain a 'current state' of this conversation. At each new request (click) from the | |
| 176 | - visitor, this state must be updated. This whole conversation is called a 'session' and | |
| 177 | - should not be confused with a single request. | |
| 178 | - | |
| 179 | - | |
| 180 | - | |
| 181 | - ** (1.1) Three sorts of data. | |
| 182 | - | |
| 183 | - All the data needed for putting a web site at work may be dispatched into three | |
| 184 | - categories: | |
| 185 | - | |
| 186 | - 1. Constant data (data that never change). These data may be hard coded into the | |
| 187 | - Anubis source files of the web site. | |
| 188 | - | |
| 189 | - 2. Permanent data (data which always exist independantly of the users connected to | |
| 190 | - the web site). These data are normally recorded into data bases. | |
| 191 | - | |
| 192 | - 3. Session data (data which depend on a particular visitor and which exist only | |
| 193 | - during the time he visits the web site). These data are stored into so-called | |
| 194 | - 'states'. | |
| 195 | - | |
| 196 | - | |
| 197 | - It is important to determine which data belongs to which category. This is part of your | |
| 198 | - design decisions. | |
| 199 | - | |
| 200 | - | |
| 201 | - | |
| 202 | - ** (1.2) How requests are handled. | |
| 203 | - | |
| 204 | - We want to separate the following two functionalities (which are used at each request | |
| 205 | - (click) during a single session): | |
| 206 | - | |
| 207 | - - computing the new state from the previous state and from the client request, and | |
| 208 | - updating the data base, | |
| 209 | - | |
| 210 | - - computing the page to be sent to the client from the new current state and from | |
| 211 | - the informations in the data base. | |
| 212 | - | |
| 213 | - | |
| 214 | - The next picture shows the structure we have in mind: | |
| 215 | - | |
| 216 | - | |
| 217 | - request +---------+ HTML page (with state name in cookie) | |
| 218 | - .-------------------| client |<--------------. | |
| 219 | - | .-----------------| | | | |
| 220 | - | | session +---------+ | | |
| 221 | - | | in cookie | | |
| 222 | - | | | client side | |
| 223 | - ............................................................................ | |
| 224 | - | | | server side | |
| 225 | - | | | | |
| 226 | - | | .-------------------. | | |
| 227 | - | | | previous session | | | |
| 228 | - V V V | | | |
| 229 | - +---------------+ +---------------+ +--------------+ | |
| 230 | - | compute state | | server's disk | | compute page | | |
| 231 | - +---------------+ +---------------+ +--------------+ | |
| 232 | - ^ | | ^ ^ ^ ^ ^ | |
| 233 | - | | | | | | | | | |
| 234 | - | | `--------------------+--------------------' | | | |
| 235 | - | | new state | | | | |
| 236 | - read | `------------------------+--------------------' | | |
| 237 | - write | new state name | | |
| 238 | - update V | | |
| 239 | - +-----------+ | | |
| 240 | - | data base |--------------------------------------------' | |
| 241 | - +-----------+ read only | |
| 242 | - | |
| 243 | - | |
| 244 | - When the client begins a session, there is no previous state. In this case, a default | |
| 245 | - 'initial state' is used instead. | |
| 246 | - | |
| 247 | - The data base may be updated by 'compute state' box, but should not be update by the | |
| 248 | - 'compute page' box. The 'compute page' box should be allowed only to read the data | |
| 249 | - base. | |
| 250 | - | |
| 251 | - In this file, all the above stuff is defined, except the 'compute state' and 'compute | |
| 252 | - page' boxes. You just have to provide the function for computing a new state (compute | |
| 253 | - state) and the function for computing the page (compute page) from the new state. You | |
| 254 | - don't have to worry about state names, saving and retrieving states and the like. | |
| 255 | - | |
| 256 | - | |
| 257 | - | |
| 258 | - | |
| 259 | - | |
| 260 | - ** (1.3) What web pages are made of. | |
| 261 | - | |
| 262 | - What the client can see in his browser's window may be called a 'page'. Within a page, | |
| 263 | - we have several sorts of components: | |
| 264 | - | |
| 265 | - - 'local' components, i.e. all components which do not open a connection, like | |
| 266 | - texts, images, etc... possibly using JavaScript programmation, | |
| 267 | - | |
| 268 | - - 'actioners', which, when clicked upon, open a connection with our web site; they | |
| 269 | - may appear as links or buttons, etc... | |
| 270 | - | |
| 271 | - - 'foreign links', which when clicked upon, open a connection with another web site | |
| 272 | - (or ours eventually). | |
| 273 | - | |
| 274 | - Of course, what an actioner does is just ask our web site to perform an action. To that | |
| 275 | - end, the actioner essentially sends the name of the action to be performed. However, it | |
| 276 | - may be necessary to provide additional informations which may be seen as 'operands' of | |
| 277 | - the action. In order to attach operands to an action, HTML provides the notion of | |
| 278 | - 'form'. Indeed, a form contains essentially a set of input fields into which the client | |
| 279 | - may put values for the required operands of the action, and a submit button, which is | |
| 280 | - the actioner itself. Notice that a single form may contain several submit buttons, | |
| 281 | - which simply means that there are several distincts actions taking the same set of | |
| 282 | - operands. | |
| 283 | - | |
| 284 | - Restrictions must be put on the use of all theses gadgets. Indeed, for example, | |
| 285 | - putting a form within another form is officially meaningless in HTML, and the client's | |
| 286 | - browser may be seriously disturbed by this. In this file, we propose an interface to | |
| 287 | - the HTML language, which forbids such meaningless things, simply by imposing a strict | |
| 288 | - typing of HTML concepts. | |
| 289 | - | |
| 290 | - Each web site may be accessible through two communication channels: | |
| 291 | - | |
| 292 | - - a non secured channel (HTTP), | |
| 293 | - - a secured channel (HTTPS). | |
| 294 | - | |
| 295 | - Nevertheless, the whole thing should be considered as a single web site. For example, | |
| 296 | - you may have a secured page, obtained through HTTPS, containing public images obtained | |
| 297 | - through HTTP. An actioner in a non secured page may open a secured connection, and | |
| 298 | - conversely. | |
| 299 | - | |
| 300 | - Summarizing, a web page is made of local elements, foreign links and actioners. | |
| 301 | - Actioners receive operands from forms, and they also choose to communicate through the | |
| 302 | - non secured or through the secured channel. | |
| 303 | - | |
| 304 | - | |
| 305 | - | |
| 306 | - +-------------------+ | |
| 307 | - | page | | |
| 308 | - | | +---------------+ | |
| 309 | - | +--------------+ | | next page | | |
| 310 | - | | form | | | (non secured) | | |
| 311 | - | | +----------+ | | HTTP | | | |
| 312 | - | | | actioner |---------------------------->| | | |
| 313 | - | | +----------+ | | +---------------+ | |
| 314 | - | | | | | |
| 315 | - | | +----------+ | | +---------------+ | |
| 316 | - | | | actioner |---------------------------->| next page | | |
| 317 | - | | +----------+ | | HTTPS | (secured) | | |
| 318 | - | | | | | | | |
| 319 | - | +--------------+ | | | | |
| 320 | - | | +---------------+ | |
| 321 | - | | | |
| 322 | - +-------------------+ | |
| 323 | - | |
| 324 | - | |
| 325 | - Notice that actioners need no be necessarily put into forms. In that case, they work as | |
| 326 | - ordinary links, but they still may receive operands as we shall see. | |
| 327 | - | |
| 328 | - | |
| 329 | - | |
| 330 | - | |
| 331 | - ** (1.4) Actions. | |
| 332 | - | |
| 333 | - The client opens a new connection with our web site whenever he clicks on an | |
| 334 | - actioner. The result is that a request is sent, essentially made of a list of 'web | |
| 335 | - arguments'. Each web argument is a pair (name,value). One of these web arguments, the | |
| 336 | - 'action' web argument (whose name is "a"), determines the action to be performed. The | |
| 337 | - other web arguments (not including "s", used to identify the state) are the operands | |
| 338 | - for this action. | |
| 339 | - | |
| 340 | - Hence, the 'compute state' box in the picture above, splits naturally into as many | |
| 341 | - sub-boxes as there are actions. For this reason, we define the following type for | |
| 342 | - representing actions (where '$State' is the type representing session informations): | |
| 343 | - | |
| 344 | - | |
| 345 | - | |
| 346 | - 'http_action's are executed only under HTTP, and 'https_action's are executed only | |
| 347 | - under HTTPS. 'http_https_action's may be executed under both types of connections. | |
| 348 | - | |
| 349 | - Each action has a name, which is used to identify the action. Each action also has a | |
| 350 | - function 'allow' whose job is to verify that the action is allowed in the current | |
| 351 | - state, and a function 'do_it' for performing the action. The function 'do_it' receives | |
| 352 | - a lot of informations: | |
| 353 | - | |
| 354 | - - 'HTTP informations': | |
| 355 | - - the IP address of the client, | |
| 356 | - - the URI requested by the client (after redirection), | |
| 357 | - - the list of HTTP headers generated by the client's browser, | |
| 358 | - - the list of web arguments sent by the client (except "s" and "a"), | |
| 359 | - - the previous state (or the 'initial' or 'ticket expired' state if no previous | |
| 360 | - state can be found). | |
| 361 | - | |
| 362 | - In most cases, HTTP informations are not used. This is the reason why they are gathered | |
| 363 | - for simplicity into a unique datum of type 'HTTP_Info'. | |
| 364 | - | |
| 365 | - | |
| 366 | - | |
| 367 | - | |
| 368 | - When you define your web site, you must provide the list of all the actions of the | |
| 369 | - site. When a new state has been computed, a graphical representation of this state | |
| 370 | - must be sent to the client. To that end, you must provide a function (named below | |
| 371 | - 'compute_page') of type: | |
| 372 | - | |
| 373 | - $State -> HTTP_Answer | |
| 374 | - | |
| 375 | - where the type 'HTTP_Answer' (defined below in this file) abstractly represents HTML | |
| 376 | - pages. | |
| 377 | - | |
| 378 | -//public type HTTP_Answer:... | |
| 379 | - | |
| 380 | - It should be clear that states and pages are deeply linked together. Indeed, we really | |
| 381 | - understand the page shown to the client as a representation of the current state of the | |
| 382 | - conversation between the client and the web site, but also containing informations | |
| 383 | - taken from the data bases. | |
| 384 | - | |
| 385 | - | |
| 386 | -//public type HTML_Partial_Content:... | |
| 387 | - | |
| 388 | - | |
| 389 | - | |
| 390 | - | |
| 391 | - | |
| 392 | - | |
| 393 | - | |
| 394 | - | |
| 395 | - | |
| 396 | -public define List(HTTP_header) | |
| 397 | - make_session_cookie_headers | |
| 398 | - ( | |
| 399 | - String website_name, | |
| 400 | - String session_name | |
| 401 | - ) | |
| 402 | - = | |
| 403 | - //println("Set-Cookie state_"+website_name+"="+state_name); | |
| 404 | - [ | |
| 405 | - http_header("Set-Cookie", "session_"+website_name+"="+session_name+"; SameSite=Strict") | |
| 406 | - ] | |
| 407 | - . | |
| 408 | - | |
| 409 | - | |
| 410 | - | |
| 411 | - When a request arrives, we need to retrieve the previous state from the server's | |
| 412 | - disk. We receive the name of that state. If the state is out of date, the state file is | |
| 413 | - kept 3 days, and then deleted. | |
| 414 | - | |
| 415 | - | |
| 416 | - | |
| 417 | - | |
| 418 | -define One | |
| 419 | - delete_out_of_date_sessions // for all web sites | |
| 420 | - ( | |
| 421 | - List((String, List(String) -> One)) directories_and_functions | |
| 422 | - )= | |
| 423 | - if directories_and_functions is | |
| 424 | - { | |
| 425 | - [ ] then unique, | |
| 426 | - [h . t] then | |
| 427 | - since h is (state_directory, function), | |
| 428 | - function(directory_list(state_directory,"*")); | |
| 429 | - delete_out_of_date_sessions(t) | |
| 430 | - } | |
| 431 | -. | |
| 432 | - | |
| 433 | - ** (1.5) States. | |
| 434 | - | |
| 435 | - Now, we explain how you can define the type (say 'State') to be used as an instance of | |
| 436 | - the type parameter '$State'. The following is just a suggestion. | |
| 437 | - | |
| 438 | - Each state determines a page (since 'compute_page' computes a page from a | |
| 439 | - state). However, some components of the state may be independant of the page. It may be | |
| 440 | - the case for example for the indication of the natural language used by the | |
| 441 | - client. Hence, a state should be made of (at least) two parts: | |
| 442 | - | |
| 443 | - - informations which are the same for all pages, | |
| 444 | - - informations which are particular to each page. | |
| 445 | - | |
| 446 | - For example, you could define: | |
| 447 | - | |
| 448 | - type Page: // one alternative per page, with particular informations | |
| 449 | - login(...), // in the components | |
| 450 | - main_page(...), | |
| 451 | - ...etc... | |
| 452 | - | |
| 453 | - Now, the type 'State' could be defined as follows: | |
| 454 | - | |
| 455 | - type State: | |
| 456 | - state(Language, // informations valid for all pages | |
| 457 | - ..., | |
| 458 | - Page). // informations particular to a page | |
| 459 | - | |
| 460 | - However, if you are making a secured web site within which clients should be identified | |
| 461 | - (by id and password), it may be a good idea to have two sorts of states, one for non | |
| 462 | - identified clients and one for identified clients. In this case, define the type | |
| 463 | - 'State' as follows (this is just a suggestion): | |
| 464 | - | |
| 465 | - type State: | |
| 466 | - non_identified(Language), | |
| 467 | - identified(String id, | |
| 468 | - Language, | |
| 469 | - Page). | |
| 470 | - | |
| 471 | - When a request arrives, check if the previous state is 'identified(...)' or | |
| 472 | - 'non_identified(...)', and don't provide access to certain pages to non identified | |
| 473 | - clients. This is required for security. | |
| 474 | - | |
| 475 | - Some more words on security. If your site needs to identify clients, define the | |
| 476 | - initial state as 'non_identified(...)'. Construct a 'login' page, and check the id and | |
| 477 | - password of the client. If the id and password are correct, then change the state of | |
| 478 | - the client to 'identified(...)'. No other action should be able to do that. Now, be | |
| 479 | - confident that clients cannot forge states. The only information they have is the name | |
| 480 | - of a state, not the state itself which is never sent over the network, but only stored | |
| 481 | - on the server's disk. The name of the state is constructed using strong cryptographical | |
| 482 | - methods (sha1). If everything (since the 'login' page) is performed under HTTPS, even | |
| 483 | - state names cannot be seen by a third party. So, if the system retrieves a previous | |
| 484 | - state of the form 'identified(...)', you can be confident that your client is well | |
| 485 | - identified, and you can send him confidential informations. | |
| 486 | - | |
| 487 | - States have a limited life time. It may happen that a client clicks on a button at a | |
| 488 | - time its state is out of date. In this case, this system considers that the new state | |
| 489 | - is a special state named 'ticket expired'. You must provide a function producing this | |
| 490 | - state when you describe your web site. The page corresponding to this state must just | |
| 491 | - inform the client that he/she waited a too long time before clicking on a button, and | |
| 492 | - has to restart (a new conversation) from the begining. | |
| 493 | - | |
| 494 | - | |
| 495 | - | |
| 496 | - * (2) Carrying on. | |
| 497 | - | |
| 498 | - ** (2.1) Describing your web sites. | |
| 499 | - | |
| 500 | - Before you may start your web site, you must describe it, i.e. produce a datum of the | |
| 501 | - opaque type 'Web_Site'. | |
| 502 | - | |
| 503 | -public type Web_Site:... | |
| 504 | - | |
| 505 | - Producing such a datum may be performed by: | |
| 506 | - | |
| 507 | - public define Web_Site | |
| 508 | - make_web_site_description | |
| 509 | - ( | |
| 510 | - List(String) common_names, // for example: ["www.our-business.com", | |
| 511 | - // "192.168.0.1"] | |
| 512 | - // the second one is just for testing | |
| 513 | - String site_directory, // where 'public' and other directories are | |
| 514 | - // located (should NOT end with '/') | |
| 515 | - String state_directory, | |
| 516 | - One -> One init, | |
| 517 | - (HTTP_Info, | |
| 518 | - List(Web_arg), | |
| 519 | - Bool is_https) -> $State initial_state, | |
| 520 | - ($State expired, | |
| 521 | - Maybe(String), | |
| 522 | - HTTP_Info, | |
| 523 | - List(Web_arg), | |
| 524 | - Bool is_https) -> $State ticket_expired_state, | |
| 525 | - (Maybe(String), | |
| 526 | - HTTP_Info, | |
| 527 | - List(Web_arg), | |
| 528 | - Bool is_https) -> $State ticket_lost_state, | |
| 529 | - List(Web_Action($State)) actions, | |
| 530 | - $State -> HTTP_Answer compute_page, | |
| 531 | - $State -> List(HTTP_header) additional_headers, | |
| 532 | - List(HTTP_header) constant_additional_headers, | |
| 533 | - Int timeout, // seconds (todo: minutes) | |
| 534 | - Redirections redirections, | |
| 535 | - String charset, | |
| 536 | - List(String) journal_extensions, | |
| 537 | - List(String) journal_headers, | |
| 538 | - String authorization_secret, | |
| 539 | - List(MIME) known_mime_types, | |
| 540 | - (String action_name, | |
| 541 | - List(Web_arg) args)-> One before_send_file | |
| 542 | - ). | |
| 543 | - | |
| 544 | - | |
| 545 | - Explanations: | |
| 546 | - | |
| 547 | - 'common_names' is the list of names of the site (the name the browser must send as the | |
| 548 | - value of the 'Host' HTTP header in order to access the site must be in that list). Such | |
| 549 | - a name generally looks like this: | |
| 550 | - | |
| 551 | - www.somewhere.com | |
| 552 | - | |
| 553 | - If you are using HTTPS, you also have an 'X.509 SSL server certificate'. The name of | |
| 554 | - the site must be exactly the same as the name on the certificate (which is precisely | |
| 555 | - called the 'common name' in the X.509 jargon). If the two names do not match, the site | |
| 556 | - will still work, but the transaction will not be transparent to the client. His browser | |
| 557 | - will complain that the name of the certificate does not match the name of the site, and | |
| 558 | - he will have to accept the certificate manually. | |
| 559 | - | |
| 560 | - 'site_directory' is the absolute path to the directory where the files needed by the | |
| 561 | - site are located. Usually this directory looks like: | |
| 562 | - | |
| 563 | - my_anubis/web_sites/www.somewhere.com | |
| 564 | - | |
| 565 | - However, this information is not computed from 'common_name', so that you can change | |
| 566 | - the common name (for example temporarily, for networking reasons) without loosing | |
| 567 | - access to the files. | |
| 568 | - | |
| 569 | - 'ticket_expired_state(expired_state,http_info,lwa,is_https)' must produce the state | |
| 570 | - whose graphical representation is a page explaining to the user that its 'ticket' (or | |
| 571 | - 'session information') has expired, and that he/she must close all popup windows and | |
| 572 | - start a new session. The arguments of the function contain the previous (expired) | |
| 573 | - state and all current informations concerning the user. This arguments may be useful | |
| 574 | - for example for producing the expiration message in the language chosen by the user. | |
| 575 | - You can also (and this may be much smarter) send a 'ticket prolongation page' | |
| 576 | - (including a new login for example), and resume the same conversation, since you have | |
| 577 | - all the pertinent informations at hand. In the case the ticket is definitely lost, the | |
| 578 | - second fonction 'ticket_lost_state' is used. | |
| 579 | - | |
| 580 | - Notice that despite the fact that the parameter $State is involved in the arguments of | |
| 581 | - the above function, the type 'Web_Site' does not depend on this parameter. This allows | |
| 582 | - to produce lists of web site descriptions, where each description may be constructed | |
| 583 | - with a different instance of $State. This is required because distinct sites must have | |
| 584 | - distinct types of session informations. This is made possible by the fact that the | |
| 585 | - type is obscure, and the constructor replaced by a function which assembles | |
| 586 | - 'ticket_expired_state', ticket_lost_state', 'actions' and 'compute_page' into a single | |
| 587 | - entity not depending on $State. You should have a look to the private part of this file | |
| 588 | - if you want more precisions about this programming technique. | |
| 589 | - | |
| 590 | - 'charset' is a string which will determine the character encoding to be used by the | |
| 591 | - browser. Typically, this string is one of: "UTF-8", "ISO-8859-1", "Windows-1252", | |
| 592 | - etc... | |
| 593 | - | |
| 594 | - 'before_send_file' is a function which is executed just before the HTTP server sends a | |
| 595 | - file. It gets an action name and the web arguments received with the request for that | |
| 596 | - file. Notice that this action name and these web arguments may be put into a | |
| 597 | - 'private_download' element, and will come back to the server at the time of the | |
| 598 | - download. | |
| 599 | - | |
| 600 | - | |
| 601 | - | |
| 602 | - ** (2.2) Directories on the server's disk. | |
| 603 | - | |
| 604 | - The description of your site contains the name of the directory within which the | |
| 605 | - required files are located. This may be for example: | |
| 606 | - | |
| 607 | - my_anubis/web_sites/www.our-business.com/ | |
| 608 | - | |
| 609 | - This is called the 'site directory' (for the given site). Within the site directory, | |
| 610 | - the following directories are created by this program: | |
| 611 | - | |
| 612 | - states | |
| 613 | - public | |
| 614 | - journal | |
| 615 | - private_download | |
| 616 | - upload_temporary | |
| 617 | - | |
| 618 | - The directory 'states' is used for storing states (session informations). Out of date | |
| 619 | - states are automatically removed after some time. | |
| 620 | - | |
| 621 | - The tree rooted at 'public' contains files that the server is allowed to send to the | |
| 622 | - clients. For security reasons, the server never sends a file which is not within the | |
| 623 | - tree whose root is this 'public' directory (except for the 'private download' mecanism; | |
| 624 | - see 'web/multihost_http_server.anubis'). Also, the MIME type (see 'web/mime.anubis') | |
| 625 | - must have been recognized before the file may be sent. | |
| 626 | - | |
| 627 | - The directory 'journal' contains the jounal files. The roles of the remaining | |
| 628 | - directories 'private_download' and 'upload_temporary' is explained in | |
| 629 | - 'multihost_http_server.anubis', where you will also find further informations on | |
| 630 | - 'public' and 'journal'. | |
| 631 | - | |
| 632 | - | |
| 633 | - ** (2.3) Web servers parameters. | |
| 634 | - | |
| 635 | - The web servers have several parameters useful for administration. They are described | |
| 636 | - as follows: | |
| 637 | - | |
| 638 | - public type WebServersParameters: | |
| 639 | - wsparms(Var(Bool) shutdown_required, | |
| 640 | - | |
| 641 | - ** (2.4) Starting your web sites. | |
| 642 | - | |
| 643 | - When you have described all your web sites (you may want to have several web sites, and | |
| 644 | - they are distinguished by their 'common name'), you may start them all together using | |
| 645 | - 'start_web_sites' below. This function returns a result of the following type: | |
| 646 | - | |
| 647 | -public type Start_Web_Sites_Result: | |
| 648 | - cannot_bind_to_port(Word32), | |
| 649 | - cannot_bind_to_port(Word32,Word32), | |
| 650 | - ok(Server http_server, | |
| 651 | - Server https_server). | |
| 652 | - | |
| 653 | - Indeed, it may happen that the system cannot bind (begin to listen) to one of the two | |
| 654 | - ports (or to both). The main reason is that another server is already listening on that | |
| 655 | - port. Another reason may be that 'anbexec' has not been correctly installed, i.e. that | |
| 656 | - the 's' bit has not been set for 'user' and 'group' (there is not such problem under | |
| 657 | - Windows). Also notice that the Linux kernel may need a rather long time (up to several | |
| 658 | - minutes) before liberating a listening port. Now, if the system can bind to the two | |
| 659 | - ports, the pair of the two servers is returned. Two tools are useful for manipulating | |
| 660 | - servers: | |
| 661 | - | |
| 662 | - shutdown of type Server -> One | |
| 663 | - is_down of type Server -> Bool | |
| 664 | - | |
| 665 | - They are defined in 'predefined.anubis' (together with the type 'Server'). | |
| 666 | - | |
| 667 | - | |
| 668 | -public define Start_Web_Sites_Result | |
| 669 | - start_web_sites | |
| 670 | - ( | |
| 671 | - Word32 ip_address, // the IP address shared by the web sites | |
| 672 | - Word32 http_port, // usually: 80 | |
| 673 | - Word32 https_port, // usually: 443 | |
| 674 | - String ssl_certificate_common_name, | |
| 675 | - List(Web_Site) web_sites, // web sites to be started | |
| 676 | - (One) -> Bool shutdown_required | |
| 677 | - ). | |
| 678 | - | |
| 679 | - 'ip_address' is the IP address on which the two servers listen. If you put 0, the | |
| 680 | - servers listen on all the IP addresses of the machine. This may be useful if the | |
| 681 | - machine has several network interfaces. | |
| 682 | - | |
| 683 | - 'ssl_certificate_common_name' is the common name of the SSL certificate that 'anbexec' | |
| 684 | - loads when it starts. One instance of 'anbexec' cannot handle more than one SSL server | |
| 685 | - certificate. This is due to a problem of conception of SSL itself. See the book 'SSL | |
| 686 | - and TLS' by Eric Rescorla (at Addison Wesley) for more explanations. | |
| 687 | - | |
| 688 | - Notice that the number of servers is always 2, regardless of the number of web sites | |
| 689 | - you are starting. | |
| 690 | - | |
| 691 | - The dynamic variable 'shutdown_required' may be used to control the shutdown of the two | |
| 692 | - servers from within the web site (typically the administration part). The servers will | |
| 693 | - shutdown as soon as this variable contains 'true'. So you must provide a variable | |
| 694 | - containing 'false' otherwise your servers will not run. You may also use the primitive | |
| 695 | - 'must_restart' (see 'predefined.anubis') to control the restarting of your servers. | |
| 696 | - | |
| 697 | - * (3) The HTML interface. | |
| 698 | - | |
| 699 | - We propose an interface to dynamic HTML. Dynamic HTML includes HTML, and a combination | |
| 700 | - of CSS (Cascading Style Sheet) and JavaScript techniques for making HTML elements more | |
| 701 | - reactive and attractive on the client side. | |
| 702 | - | |
| 703 | - | |
| 704 | - ** (3.1) Types used by the HTML interface. | |
| 705 | - | |
| 706 | - For easy reference, we gather below the definitions of all the types used by the HTML | |
| 707 | - interface, and we comment them immediately. | |
| 708 | - | |
| 709 | - //public type HTML_Off_Form:... | |
| 710 | - | |
| 711 | - | |
| 712 | -public define Printable_tree [HTML_Id x . Printable_tree y] = str_pt(x.id, y). | |
| 713 | -public define Printable_tree [HtmlClass x . Printable_tree y] = str_pt(x.class, y). | |
| 714 | -public define Printable_tree [WebArgName x . Printable_tree y] = str_pt(x.name, y). | |
| 715 | -public define Printable_tree [WebArgValue x . Printable_tree y] = str_pt(x.value, y). | |
| 716 | -public define Printable_tree [InitialValue x . Printable_tree y] = str_pt(x.value, y). | |
| 717 | - | |
| 718 | -public define CoreAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false"). | |
| 719 | -public define CoreAttrs attr(String name, Int value) = attr(name, to_String(value)). | |
| 720 | - | |
| 721 | - | |
| 722 | -public define InputAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false"). | |
| 723 | - | |
| 724 | - | |
| 725 | - | |
| 726 | -public define Text_Option | |
| 727 | - tooltip(String s) = title(s). | |
| 728 | - | |
| 729 | - A list of 'Text_Option' must be given with each text you want to put in your page. | |
| 730 | - | |
| 731 | -public define CoreAttrs | |
| 732 | - tooltip(String s) = title(s). | |
| 733 | -public define InputAttrs | |
| 734 | - tooltip(String s) = title(s). | |
| 735 | - | |
| 736 | - | |
| 737 | -public type I18n: | |
| 738 | - lang (String), | |
| 739 | - dir (Reading_Way). | |
| 740 | - | |
| 741 | - | |
| 742 | - A list of 'DIV_Option' must be given with each DIV you want to put in your page. | |
| 743 | - | |
| 744 | -public define String | |
| 745 | - event_name | |
| 746 | - ( | |
| 747 | - HtmlEvents e | |
| 748 | - ) = | |
| 749 | - if e is | |
| 750 | - { | |
| 751 | - onafterprint then "onafterprint", //HTML5 Script to be run after the document is printed | |
| 752 | - onbeforeprint then "onbeforeprint", //HTML5 Script to be run before the document is printed | |
| 753 | - onbeforeunload then "onbeforeunload", //HTML5 Script to be run when the document is about to be unloaded | |
| 754 | - onerror then "onerror", //HTML5 Script to be run when an error occurs | |
| 755 | - onhashchange then "onhashchange", //HTML5 Script to be run when there has been changes to the anchor part of the a URL | |
| 756 | - onload then "onload", // Fires after the page is finished loading | |
| 757 | - onmessage then "onmessage", //HTML5 Script to be run when the message is triggered | |
| 758 | - onoffline then "onoffline", //HTML5 Script to be run when the browser starts to work offline | |
| 759 | - ononline then "ononline", //HTML5 Script to be run when the browser starts to work online | |
| 760 | - onpagehide then "onpagehide", //HTML5 Script to be run when a user navigates away from a page | |
| 761 | - onpageshow then "onpageshow", //HTML5 Script to be run when a user navigates to a page | |
| 762 | - onpopstate then "onpopstate", //HTML5 Script to be run when the window's history changes | |
| 763 | - onresize then "onresize", //HTML5 Fires when the browser window is resized | |
| 764 | - onstorage then "onstorage", //HTML5 Script to be run when a Web Storage area is updated | |
| 765 | - onunload then "onunload", // Fires once a page has unloaded (or the browser window has been closed) | |
| 766 | - // Form element events | |
| 767 | - onblur then "onblur", // Fires the moment that the element loses focus | |
| 768 | - onchange then "onchange", // Fires the moment when the value of the element is changed | |
| 769 | - oncontextmenu then "oncontextmenu", //HTML5 Script to be run when a context menu is triggered | |
| 770 | - onfocus then "onfocus", // Fires the moment when the element gets focus | |
| 771 | - oninput then "oninput", //HTML5 Script to be run when an element gets user input | |
| 772 | - oninvalid then "oninvalid", //HTML5 Script to be run when an element is invalid | |
| 773 | - onreset then "onreset", // Fires when the Reset button in a form is clicked | |
| 774 | - onsearch then "onsearch", // Fires when the user writes something in a search field (for <input="search">) | |
| 775 | - onselect then "onselect", // Fires after some text has been selected in an element | |
| 776 | - onsubmit then "onsubmit", // Fires when a form is submitted | |
| 777 | - // Keyboard events (Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.) | |
| 778 | - onkeydown then "onkeydown", // Fires when a user is pressing a key | |
| 779 | - onkeypress then "onkeypress", // Fires when a user presses a key | |
| 780 | - onkeyup then "onkeyup", // Fires when a user releases a key | |
| 781 | - // Mouse events (Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.) | |
| 782 | - onclick then "onclick", // Fires on a mouse click on the element | |
| 783 | - ondblclick then "ondblclick", // Fires on a mouse double-click on the element | |
| 784 | - onmousedown then "onmousedown", // Fires when a mouse button is pressed down on an element | |
| 785 | - onmousemove then "onmousemove", // Fires when the mouse pointer is moving while it is over an element | |
| 786 | - onmouseout then "onmouseout", // Fires when the mouse pointer moves out of an element | |
| 787 | - onmouseover then "onmouseover", // Fires when the mouse pointer moves over an element | |
| 788 | - onmouseup then "onmouseup", // Fires when a mouse button is released over an element | |
| 789 | - onwheel then "onwheel", //HTML5 Fires when the mouse wheel rolls up or down over an element | |
| 790 | - //Drag Events | |
| 791 | - ondrag then "ondrag", //HMTL5 Script to be run when an element is dragged | |
| 792 | - ondragend then "ondragend", //HTML5 Script to be run at the end of a drag operation | |
| 793 | - ondragenter then "ondragenter", //HTML5 Script to be run when an element has been dragged to a valid drop target | |
| 794 | - ondragleave then "ondragleave", //HTML5 Script to be run when an element leaves a valid drop target | |
| 795 | - ondragover then "ondragover", //HTML5 Script to be run when an element is being dragged over a valid drop target | |
| 796 | - ondragstart then "ondragstart", //HTML5 Script to be run at the start of a drag operation | |
| 797 | - ondrop then "ondrop", //HTML5 Script to be run when dragged element is being dropped | |
| 798 | - onscroll then "onscroll", //HTML5 Script to be run when an element's scrollbar is being scrolled | |
| 799 | - //Clipboard Events | |
| 800 | - oncopy then "oncopy", //HTML5 Fires when the user copies the content of an element | |
| 801 | - oncut then "oncut", //HTML5 Fires when the user cuts the content of an element | |
| 802 | - onpaste then "onpaste", //HTML5 Fires when the user pastes some content in an element | |
| 803 | - //Media Events | |
| 804 | - onabort then "onabort", //HTML5 Script to be run on abort | |
| 805 | - oncanplay then "oncanplay", //HTML5 Script to be run when a file is ready to start playing (when it has buffered enough to begin) | |
| 806 | - oncanplaythrough then "oncanplaythrough", //HTML5 Script to be run when a file can be played all the way to the end without pausing for buffering | |
| 807 | - oncuechange then "oncuechange", //HTML5 Script to be run when the cue changes in a <track> element | |
| 808 | - ondurationchange then "ondurationchange", //HTML5 Script to be run when the length of the media changes | |
| 809 | - onemptied then "onemptied", //HTML5 Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects) | |
| 810 | - onended then "onended", //HTML5 Script to be run when the media has reach the end (a useful event for messages like "thanks for listening") | |
| 811 | - onerror then "onerror", //HTML5 Script to be run when an error occurs when the file is being loaded | |
| 812 | - onloadeddata then "onloadeddata", //HTML5 Script to be run when media data is loaded | |
| 813 | - onloadedmetadata then "onloadedmetadata", //HTML5 Script to be run when meta data (like dimensions and duration) are loaded | |
| 814 | - onloadstart then "onloadstart", //HTML5 Script to be run just as the file begins to load before anything is actually loaded | |
| 815 | - onpause then "onpause", //HTML5 Script to be run when the media is paused either by the user or programmatically | |
| 816 | - onplay then "onplay", //HTML5 Script to be run when the media is ready to start playing | |
| 817 | - onplaying then "onplaying", //HTML5 Script to be run when the media actually has started playing | |
| 818 | - onprogress then "onprogress", //HTML5 Script to be run when the browser is in the process of getting the media data | |
| 819 | - onratechange then "onratechange", //HTML5 Script to be run each time the playback rate changes (like when a user switches to a slow motion or fast forward mode) | |
| 820 | - onseeked then "onseeked", //HTML5 Script to be run when the seeking attribute is set to false indicating that seeking has ended | |
| 821 | - onseeking then "onseeking", //HTML5 Script to be run when the seeking attribute is set to true indicating that seeking is active | |
| 822 | - onstalled then "onstalled", //HTML5 Script to be run when the browser is unable to fetch the media data for whatever reason | |
| 823 | - onsuspend then "onsuspend", //HTML5 Script to be run when fetching the media data is stopped before it is completely loaded for whatever reason | |
| 824 | - ontimeupdate then "ontimeupdate", //HTML5 Script to be run when the playing position has changed (like when the user fast forwards to a different point in the media) | |
| 825 | - onvolumechange then "onvolumechange", //HTML5 Script to be run each time the volume is changed which (includes setting the volume to "mute") | |
| 826 | - onwaiting then "onwaiting", //HTML5 Script to be run when the media has paused but is expected to resume (like when the media pauses to buffer more data) | |
| 827 | - //Misc Events | |
| 828 | - onshow then "onshow", //HTML5 Fires when a <menu> element is shown as a context menu | |
| 829 | - ontoggle then "ontoggle" | |
| 830 | - }. | |
| 831 | - | |
| 832 | - | |
| 833 | -public define Table_Option nude = border(0,0,0,rgb(0,0,0)). | |
| 834 | - | |
| 835 | - | |
| 836 | - A list of 'Table_Option' must be given with each table. | |
| 837 | - | |
| 838 | - | |
| 839 | - | |
| 840 | - | |
| 841 | - | |
| 842 | - | |
| 843 | - A list of 'Cell_Option' must be given with each cell and each row in a table. Options | |
| 844 | - given with a row apply to all the cells in the row, but are superseded by options given | |
| 845 | - with cells, which apply only to the cell they are given with. | |
| 846 | - | |
| 847 | - | |
| 848 | - | |
| 849 | - | |
| 850 | - | |
| 851 | - The parameter $T is later instantiated either to 'HTML_In_Form' or to 'HTML_Off_Form', | |
| 852 | - depending on where you put your table (within a form or not within a form). For your | |
| 853 | - convenience, we define the following particular case: | |
| 854 | - | |
| 855 | -public define HTML_Cell($T) | |
| 856 | - cell | |
| 857 | - ( | |
| 858 | - $T content | |
| 859 | - )= | |
| 860 | - cell([],content) | |
| 861 | -. | |
| 862 | - | |
| 863 | -public define HTML_Cell($T) | |
| 864 | - cell | |
| 865 | - ( | |
| 866 | - Cell_Option option, | |
| 867 | - $T content | |
| 868 | - ) = | |
| 869 | - cell([option],content) | |
| 870 | -. | |
| 871 | - | |
| 872 | -public define HTML_Header_Cell($T) | |
| 873 | - header_cell | |
| 874 | - ( | |
| 875 | - $T content | |
| 876 | - ) = | |
| 877 | - header_cell([],content). | |
| 878 | - | |
| 879 | - | |
| 880 | - | |
| 881 | - | |
| 882 | - Same remark as for 'HTML_Cell($T)'. We define several convenience functions: | |
| 883 | - | |
| 884 | -public define HTML_Row($T) | |
| 885 | - row | |
| 886 | - ( | |
| 887 | - List(HTML_Cell($T)) cells | |
| 888 | - )= | |
| 889 | - row([],cells). | |
| 890 | - | |
| 891 | -public define HTML_Row($T) | |
| 892 | - row | |
| 893 | - ( | |
| 894 | - HTML_Cell($T) cell | |
| 895 | - )= | |
| 896 | - row([],[cell]). | |
| 897 | - | |
| 898 | -public define HTML_Row($T) | |
| 899 | - row | |
| 900 | - ( | |
| 901 | - List(Cell_Option) options, | |
| 902 | - HTML_Cell($T) cell | |
| 903 | - )= | |
| 904 | - row(options,[cell]). | |
| 905 | - | |
| 906 | -public define HTML_Row($T) | |
| 907 | - row | |
| 908 | - ( | |
| 909 | - Cell_Option option, | |
| 910 | - HTML_Cell($T) cell | |
| 911 | - )= | |
| 912 | - row([option],[cell]). | |
| 913 | - | |
| 914 | -public define HTML_Header_Row($T) | |
| 915 | - header_row | |
| 916 | - ( | |
| 917 | - List(HTML_Header_Cell($T)) cells | |
| 918 | - ) = | |
| 919 | - header_row([],cells). | |
| 920 | - | |
| 921 | -public define HTML_Header_Row($T) | |
| 922 | - header_row | |
| 923 | - ( | |
| 924 | - HTML_Header_Cell($T) cell | |
| 925 | - ) = | |
| 926 | - header_row([],[cell]). | |
| 927 | - | |
| 928 | - | |
| 929 | - | |
| 930 | -public define Actioner_Aspect | |
| 931 | - immediate_selector | |
| 932 | - ( | |
| 933 | - List(CoreAttrs) core_attrs, | |
| 934 | - WebArgName name, | |
| 935 | - Int size, | |
| 936 | - List((List(CoreAttrs),WebArgValue,String)) choices | |
| 937 | - )= | |
| 938 | - immediate_selector(core_attrs, name, size, choices, failure, "") | |
| 939 | - . | |
| 940 | - | |
| 941 | -public define Actioner_Aspect | |
| 942 | - immediate_selector | |
| 943 | - ( | |
| 944 | - List(CoreAttrs) core_attrs, | |
| 945 | - WebArgName name, | |
| 946 | - Int size, | |
| 947 | - List((List(CoreAttrs),WebArgValue,String)) choices, | |
| 948 | - Maybe(InitialValue) selected | |
| 949 | - )= | |
| 950 | - immediate_selector(core_attrs, name, size, choices, selected, "") | |
| 951 | - . | |
| 952 | - | |
| 953 | - | |
| 954 | -public define Actioner_Aspect | |
| 955 | - link | |
| 956 | - ( | |
| 957 | - List(Text_Option) options, | |
| 958 | - String text | |
| 959 | - )= | |
| 960 | - link(options, text, failure). | |
| 961 | - | |
| 962 | -public define Actioner_Aspect | |
| 963 | - link | |
| 964 | - ( | |
| 965 | - String text | |
| 966 | - ) = | |
| 967 | - link([], text, failure). | |
| 968 | - | |
| 969 | - | |
| 970 | -public define Actioner_Aspect | |
| 971 | - link | |
| 972 | - ( | |
| 973 | - List(Text_Option) options, | |
| 974 | - Int i | |
| 975 | - ) = | |
| 976 | - link(options, to_decimal(i), failure). | |
| 977 | - | |
| 978 | -public define Actioner_Aspect | |
| 979 | - link | |
| 980 | - ( | |
| 981 | - Int i | |
| 982 | - ) = | |
| 983 | - link([], i). | |
| 984 | - | |
| 985 | -public define Actioner_Aspect | |
| 986 | - button | |
| 987 | - ( | |
| 988 | - String url_img | |
| 989 | - ) = | |
| 990 | - button(url_img,url_img). | |
| 991 | - | |
| 992 | - Actioners are explained in details below. | |
| 993 | - | |
| 994 | - | |
| 995 | - | |
| 996 | - | |
| 997 | - | |
| 998 | -public define String | |
| 999 | - to_String | |
| 1000 | - ( | |
| 1001 | - CSS_File_Media css_file_media | |
| 1002 | - )= | |
| 1003 | - if css_file_media is | |
| 1004 | - { | |
| 1005 | - screen then "screen", | |
| 1006 | - tty then "tty", | |
| 1007 | - tv then "tv", | |
| 1008 | - projection then "projection", | |
| 1009 | - handheld then "handheld", | |
| 1010 | - print then "print", | |
| 1011 | - braille then "braille", | |
| 1012 | - aural then "aural", | |
| 1013 | - all then "all" | |
| 1014 | - }. | |
| 1015 | - | |
| 1016 | - | |
| 1017 | -//public type HTML_Meta:... | |
| 1018 | - | |
| 1019 | - | |
| 1020 | - | |
| 1021 | -public define HTML_Head_Tag | |
| 1022 | - js_script | |
| 1023 | - ( | |
| 1024 | - String script_content | |
| 1025 | - )= | |
| 1026 | - js_inline(script("text/javascript", script_content)) | |
| 1027 | -. | |
| 1028 | - /* Label with help */ | |
| 1029 | - | |
| 1030 | - | |
| 1031 | -public define HTML_tooltip | |
| 1032 | - html_tooltip | |
| 1033 | - ( | |
| 1034 | - String keyword, | |
| 1035 | - Int width | |
| 1036 | - )= | |
| 1037 | - html_tooltip("", keyword, width). | |
| 1038 | - | |
| 1039 | -public define HTML_tooltip | |
| 1040 | - html_tooltip | |
| 1041 | - ( | |
| 1042 | - String title, | |
| 1043 | - String keyword | |
| 1044 | - )= | |
| 1045 | - html_tooltip(title, keyword, 0). | |
| 1046 | - | |
| 1047 | - | |
| 1048 | - | |
| 1049 | -public define HTML_Help | |
| 1050 | - tooltip | |
| 1051 | - ( | |
| 1052 | - HTML_tooltip h_tooltip | |
| 1053 | - )= | |
| 1054 | - tooltip(h_tooltip, left) | |
| 1055 | -. | |
| 1056 | - | |
| 1057 | - | |
| 1058 | - | |
| 1059 | - /* It contains | |
| 1060 | - * - a List of HTML_Head_Tag representing necessaries head tags for the content. ex: jquery js files, js script, css specific styles, ... | |
| 1061 | - * - a HTML_Off_Form representing the HTML code for the part of the page we want to display | |
| 1062 | - */ | |
| 1063 | -//public type HTML_In_Form:... | |
| 1064 | - | |
| 1065 | - | |
| 1066 | - | |
| 1067 | -public define List(HTML_Head_Tag) | |
| 1068 | - to_HTML_Head_Tag | |
| 1069 | - ( | |
| 1070 | - List(CSS_File) css_file_list | |
| 1071 | - )= | |
| 1072 | - map((CSS_File css_f) |-> css(css_f), css_file_list). | |
| 1073 | - | |
| 1074 | -public define List(HTML_Head_Tag) | |
| 1075 | - to_HTML_Head_Tag | |
| 1076 | - ( | |
| 1077 | - List(JS_File) js_file_list | |
| 1078 | - )= | |
| 1079 | - map((JS_File js_f) |-> js(js_f), js_file_list). | |
| 1080 | - | |
| 1081 | - | |
| 1082 | - | |
| 1083 | - 'HTML_In_Form' defines all the elements you may put within a form. We define a | |
| 1084 | - convenience function: | |
| 1085 | - | |
| 1086 | - | |
| 1087 | -public define HTML_Off_Form text_input(HTML_Label label, HTML_Id id, WebArgName name, InitialValue init, Int width) = text_input([], label, id, name, init, width). | |
| 1088 | - | |
| 1089 | -public define HTML_Off_Form literal(Printable_tree t) = literal_pt(t). | |
| 1090 | - | |
| 1091 | -public define HTML_Off_Form image(String url) = image([], url, url). | |
| 1092 | - | |
| 1093 | -public define HTML_Off_Form image(String url, Int width, Int height) = image([], url, url, width, height). | |
| 1094 | - | |
| 1095 | -public define HTML_In_Form | |
| 1096 | - foreign_link | |
| 1097 | - ( | |
| 1098 | - Int tsize, | |
| 1099 | - String url, | |
| 1100 | - String name | |
| 1101 | - ) = | |
| 1102 | - foreign_link([size(tsize)],url,name). | |
| 1103 | - | |
| 1104 | -public define HTML_In_Form | |
| 1105 | -/* Older call with String as action instead of WEB_Action_Name. | |
| 1106 | - * This function exists only for compatibility with older project. | |
| 1107 | - * Please condiser to use above function instead | |
| 1108 | - */ | |
| 1109 | - actioner | |
| 1110 | - ( | |
| 1111 | - Actioner_Connection conn, | |
| 1112 | - Actioner_Target targ, | |
| 1113 | - Actioner_Aspect asp, | |
| 1114 | - String action, | |
| 1115 | - List((String,String)) extra_ops, | |
| 1116 | - List(Actioner_Local_Action) local_actions | |
| 1117 | - )= | |
| 1118 | - actioner(conn,targ,asp,action_name(action),extra_ops,local_actions) | |
| 1119 | -. | |
| 1120 | - | |
| 1121 | -public define HTML_In_Form | |
| 1122 | - actioner | |
| 1123 | - ( | |
| 1124 | - Actioner_Connection conn, | |
| 1125 | - Actioner_Target targ, | |
| 1126 | - Actioner_Aspect asp, | |
| 1127 | - WEB_Action_Name action, | |
| 1128 | - List((String,String)) extra_ops | |
| 1129 | - )= | |
| 1130 | - actioner(conn,targ,asp,action,extra_ops,[]) | |
| 1131 | -. | |
| 1132 | - | |
| 1133 | -public define HTML_In_Form | |
| 1134 | -/* Older call with String as action instead of WEB_Action_Name. | |
| 1135 | - * This function exists only for compatibility with older project. | |
| 1136 | - * Please condiser to use above function instead | |
| 1137 | - */ | |
| 1138 | - actioner | |
| 1139 | - ( | |
| 1140 | - Actioner_Connection conn, | |
| 1141 | - Actioner_Target targ, | |
| 1142 | - Actioner_Aspect asp, | |
| 1143 | - String action, | |
| 1144 | - List((String,String)) extra_ops | |
| 1145 | - )= | |
| 1146 | - actioner(conn,targ,asp,action_name(action),extra_ops,[]) | |
| 1147 | -. | |
| 1148 | - | |
| 1149 | -public define HTML_In_Form | |
| 1150 | - actioner | |
| 1151 | - ( | |
| 1152 | - Actioner_Connection conn, | |
| 1153 | - Actioner_Target targ, | |
| 1154 | - Actioner_Aspect asp, | |
| 1155 | - )= | |
| 1156 | - actioner(conn, targ, asp, action_name(""), [], []). | |
| 1157 | - | |
| 1158 | - | |
| 1159 | -public define HTML_In_Form | |
| 1160 | - text_area | |
| 1161 | - ( | |
| 1162 | - WebArgName name, | |
| 1163 | - InitialValue init, | |
| 1164 | - Int width, | |
| 1165 | - Int height | |
| 1166 | - ) = | |
| 1167 | - text_area([], no_label, html_Id(""), name,init,width,height). | |
| 1168 | - | |
| 1169 | -public define HTML_In_Form | |
| 1170 | - text_area | |
| 1171 | - ( | |
| 1172 | - List(TextAreaOption) options, | |
| 1173 | - WebArgName name, | |
| 1174 | - InitialValue init, | |
| 1175 | - Int width, | |
| 1176 | - Int height | |
| 1177 | - ) = | |
| 1178 | - text_area(options, no_label, html_Id(""), name,init,width,height). | |
| 1179 | - | |
| 1180 | -public define HTML_In_Form | |
| 1181 | - table | |
| 1182 | - ( | |
| 1183 | - List(HTML_Row(HTML_In_Form)) rows | |
| 1184 | - ) = | |
| 1185 | - table([],empty,rows,empty). | |
| 1186 | - | |
| 1187 | -public define HTML_In_Form | |
| 1188 | - table | |
| 1189 | - ( | |
| 1190 | - List(Table_Option) options, | |
| 1191 | - List(HTML_Row(HTML_In_Form)) rows | |
| 1192 | - ) = | |
| 1193 | - table(options,empty,rows,empty). | |
| 1194 | - | |
| 1195 | -public define HTML_In_Form | |
| 1196 | - table | |
| 1197 | - ( | |
| 1198 | - HTML_Header_Row(HTML_In_Form) h_row, | |
| 1199 | - List(HTML_Row(HTML_In_Form)) rows | |
| 1200 | - ) = | |
| 1201 | - table([],h_row,rows,empty). | |
| 1202 | - | |
| 1203 | -public define HTML_In_Form | |
| 1204 | - table | |
| 1205 | - ( | |
| 1206 | - List(Table_Option) options, | |
| 1207 | - HTML_Header_Row(HTML_In_Form) h_row, | |
| 1208 | - List(HTML_Row(HTML_In_Form)) rows | |
| 1209 | - ) = | |
| 1210 | - table(options,h_row,rows,empty). | |
| 1211 | - | |
| 1212 | -public define HTML_In_Form | |
| 1213 | - private_download | |
| 1214 | - ( | |
| 1215 | - String abs_path, | |
| 1216 | - String name, | |
| 1217 | - String extra_ext | |
| 1218 | - ) = | |
| 1219 | - private_download(abs_path,name,extra_ext,failure). | |
| 1220 | - | |
| 1221 | -public define HTML_In_Form | |
| 1222 | - private_download | |
| 1223 | - ( | |
| 1224 | - String abs_path, | |
| 1225 | - String name, | |
| 1226 | - String extra_ext, | |
| 1227 | - String action_name, | |
| 1228 | - List((String,String)) args | |
| 1229 | - ) = | |
| 1230 | - private_download(abs_path,name,extra_ext,success((action_name,args))). | |
| 1231 | - | |
| 1232 | - | |
| 1233 | - | |
| 1234 | -public define HTML_In_Form | |
| 1235 | - text | |
| 1236 | - ( | |
| 1237 | - List(CoreAttrs) l, | |
| 1238 | - Int i | |
| 1239 | - ) = | |
| 1240 | - text(l, to_decimal(i)). | |
| 1241 | - | |
| 1242 | -public define HTML_In_Form | |
| 1243 | - text | |
| 1244 | - ( | |
| 1245 | - String s | |
| 1246 | - )= | |
| 1247 | - text([],s) | |
| 1248 | -. | |
| 1249 | - | |
| 1250 | -public define HTML_In_Form | |
| 1251 | - text | |
| 1252 | - ( | |
| 1253 | - Int i | |
| 1254 | - ) = | |
| 1255 | - text([], i) | |
| 1256 | -. | |
| 1257 | - | |
| 1258 | -public define HTML_In_Form | |
| 1259 | - div | |
| 1260 | - ( | |
| 1261 | - HTML_In_Form element | |
| 1262 | - )= | |
| 1263 | - div([], [element]) | |
| 1264 | -. | |
| 1265 | - | |
| 1266 | -public define HTML_In_Form | |
| 1267 | - div | |
| 1268 | - ( | |
| 1269 | - List(CoreAttrs) attrs, | |
| 1270 | - HTML_In_Form element | |
| 1271 | - )= | |
| 1272 | - div(attrs, [element]) | |
| 1273 | -. | |
| 1274 | - | |
| 1275 | -public define HTML_In_Form | |
| 1276 | - span | |
| 1277 | - ( | |
| 1278 | - String s | |
| 1279 | - )= | |
| 1280 | - span([],s) | |
| 1281 | -. | |
| 1282 | - | |
| 1283 | -public define HTML_In_Form | |
| 1284 | - span | |
| 1285 | - ( | |
| 1286 | - Int i | |
| 1287 | - ) = | |
| 1288 | - span([], to_decimal(i)) | |
| 1289 | -. | |
| 1290 | - | |
| 1291 | -public define HTML_In_Form | |
| 1292 | - radio_button (List(CoreAttrs) options, HTML_Label label, WebArgName n, WebArgValue value, Bool checked) | |
| 1293 | - = radio_button (options, label, html_Id(n.name), n, value, checked). | |
| 1294 | - | |
| 1295 | -public define HTML_In_Form | |
| 1296 | - radio_button_r (List(CoreAttrs) options, HTML_Label label, WebArgName n, WebArgValue value, Bool checked) | |
| 1297 | - = radio_button_r (options, label, html_Id(n.name), n, value, checked). | |
| 1298 | - | |
| 1299 | -public define HTML_In_Form | |
| 1300 | - check_box (List(CoreAttrs) options, HTML_Label label, WebArgName n, Bool checked) | |
| 1301 | - = check_box (options, label, html_Id(n.name), n, checked). | |
| 1302 | - | |
| 1303 | -public define HTML_In_Form | |
| 1304 | - check_box_r (List(CoreAttrs) options, HTML_Label label, WebArgName n, Bool checked) | |
| 1305 | - = check_box_r (options, label, html_Id(n.name), n, checked). | |
| 1306 | - | |
| 1307 | -public define HTML_In_Form | |
| 1308 | - file_upload (WebArgName n, Int width) | |
| 1309 | - = file_upload([], no_label, html_Id(n.name), n, width). | |
| 1310 | - | |
| 1311 | -public define HTML_In_Form | |
| 1312 | - hidden (WebArgName name, WebArgValue value) | |
| 1313 | - = | |
| 1314 | - hidden(html_Id(""), name, value). | |
| 1315 | - | |
| 1316 | -public type Input_Type: | |
| 1317 | -button, | |
| 1318 | -checkbox, | |
| 1319 | -color, | |
| 1320 | -date, | |
| 1321 | -datetime_local, | |
| 1322 | -email, | |
| 1323 | -file, | |
| 1324 | -hidden, | |
| 1325 | -image, | |
| 1326 | -month, | |
| 1327 | -number, | |
| 1328 | -password, | |
| 1329 | -radio, | |
| 1330 | -range, | |
| 1331 | -reset, | |
| 1332 | -search, | |
| 1333 | -submit, | |
| 1334 | -tel, | |
| 1335 | -text, | |
| 1336 | -time, | |
| 1337 | -url, | |
| 1338 | -week | |
| 1339 | -. | |
| 1340 | - | |
| 1341 | -public define String | |
| 1342 | - to_String | |
| 1343 | - ( | |
| 1344 | - Input_Type type | |
| 1345 | - )= | |
| 1346 | - if type is | |
| 1347 | - { | |
| 1348 | - button then "button", | |
| 1349 | - checkbox then "checkbox", | |
| 1350 | - color then "color", | |
| 1351 | - date then "date", | |
| 1352 | - datetime_local then "datetime_local", | |
| 1353 | - email then "email", | |
| 1354 | - file then "file", | |
| 1355 | - hidden then "hidden", | |
| 1356 | - image then "image", | |
| 1357 | - month then "month", | |
| 1358 | - number then "number", | |
| 1359 | - password then "password", | |
| 1360 | - radio then "radio", | |
| 1361 | - range then "range", | |
| 1362 | - reset then "reset", | |
| 1363 | - search then "search", | |
| 1364 | - submit then "submit", | |
| 1365 | - tel then "tel", | |
| 1366 | - text then "text", | |
| 1367 | - time then "time", | |
| 1368 | - url then "url", | |
| 1369 | - week then "week" | |
| 1370 | - } | |
| 1371 | -. | |
| 1372 | - | |
| 1373 | -define Printable_tree | |
| 1374 | - add_js_files_attributes | |
| 1375 | - ( | |
| 1376 | - List(JS_Attribute) l | |
| 1377 | - ) = | |
| 1378 | - if l is | |
| 1379 | - { | |
| 1380 | - [ ] then [ ], | |
| 1381 | - [h . t] then | |
| 1382 | - [ " " + to_String(h) | |
| 1383 | - . add_js_files_attributes(t)] | |
| 1384 | - } | |
| 1385 | -. | |
| 1386 | - | |
| 1387 | - | |
| 1388 | -define Printable_tree | |
| 1389 | - add_js_files | |
| 1390 | - ( | |
| 1391 | - List(JS_File) l | |
| 1392 | - ) = | |
| 1393 | - if l is | |
| 1394 | - { | |
| 1395 | - [ ] then [ ], | |
| 1396 | - [h . t] then | |
| 1397 | - [ ["<script src=\""+ file_name(h) +"\" type=\"text/javascript\"" | |
| 1398 | - . add_js_files_attributes(attributes(h)) ] | |
| 1399 | - . ["></script>\n" | |
| 1400 | - . add_js_files(t)] ] | |
| 1401 | - } | |
| 1402 | -. | |
| 1403 | - | |
| 1404 | -define Printable_tree | |
| 1405 | - add_script | |
| 1406 | - ( | |
| 1407 | - List(Script) l | |
| 1408 | - ) = | |
| 1409 | - if l is | |
| 1410 | - { | |
| 1411 | - [ ] then [ ], | |
| 1412 | - [h . t] then [ "<script type=\""+ script_type(h) +"\">\n"+ content(h) + "\n</script>\n" . add_script(t) ] | |
| 1413 | - }. | |
| 1414 | - | |
| 1415 | -public type FormMethod: | |
| 1416 | - get, | |
| 1417 | - post | |
| 1418 | -. | |
| 1419 | - | |
| 1420 | -//public type HTML_Body:... | |
| 1421 | - | |
| 1422 | -public define CoreAttrs formaction(WEB_Action_Name action, List((String,String)) extra_ops) = attr("formaction", format_web_action_name(action, extra_ops)). | |
| 1423 | -public define CoreAttrs formaction(WEB_Action_Name action, (String,String) extra_op) = attr("formaction", format_web_action_name(action, extra_op)). | |
| 1424 | -public define CoreAttrs formaction(WEB_Action_Name action) = attr("formaction", format_web_action_name(action)). | |
| 1425 | -public define CoreAttrs formmethod(FormMethod method) = attr("formmethod", if method is { get then "get", post then "post"}). | |
| 1426 | - | |
| 1427 | - | |
| 1428 | - 'HTML_Off_Form' defines all the elements you may put outside any form. | |
| 1429 | - | |
| 1430 | - | |
| 1431 | -public define CoreAttrs method(String value) = attr("method", value). | |
| 1432 | -public define CoreAttrs action(WEB_Action_Name action)= attr("action", "/"+format_web_action_name(action)). | |
| 1433 | -public define CoreAttrs action(WEB_Action_Name action, List((String,String)) extra_ops)= attr("action", "/"+format_web_action_name(action, extra_ops)). | |
| 1434 | -public define CoreAttrs formmethod(String value) = attr("formmethod", value). | |
| 1435 | -public define CoreAttrs form(String value) = attr("form", value). | |
| 1436 | -public define CoreAttrs for(String value) = attr("for", value). | |
| 1437 | - | |
| 1438 | - | |
| 1439 | -public define HTML_Off_Form text(List(CoreAttrs) attrs, Int i) = text(attrs, to_decimal(i)). | |
| 1440 | -public define HTML_Off_Form text(CoreAttrs attr, Int i) = text([attr], i). | |
| 1441 | -public define HTML_Off_Form text(Int i) = text([], i). | |
| 1442 | -public define HTML_Off_Form text(String s) = text([], s). | |
| 1443 | -public define HTML_Off_Form text(CoreAttrs attr, String s) = text([attr], s). | |
| 1444 | - | |
| 1445 | -public define HTML_Off_Form a(A_href _href) = a([], _href, _self, []). | |
| 1446 | -public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href) = a(attrs, _href, _self, []). | |
| 1447 | -public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href, HTML_Off_Form content) = a(attrs, _href, _self, [content]). | |
| 1448 | -public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href, List(HTML_Off_Form) content) = a(attrs, _href, _self, content). | |
| 1449 | -public define HTML_Off_Form a(A_href _href, HTML_Off_Form content) = a([], _href, _self, [content]). | |
| 1450 | -public define HTML_Off_Form a(A_href _href, String _text) = a([], _href, _self, [text(_text)]). | |
| 1451 | -public define HTML_Off_Form a(A_href _href, List(HTML_Off_Form) content) = a([], _href, _self, content). | |
| 1452 | -public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href, A_target _target, HTML_Off_Form content) = a(attrs, _href, _target, [content]). | |
| 1453 | -public define HTML_Off_Form a(CoreAttrs attr, A_href _href, A_target _target, HTML_Off_Form content) = a([attr], _href, _target, [content]). | |
| 1454 | -public define HTML_Off_Form a(A_href _href, A_target _target, HTML_Off_Form content) = a([], _href, _target, [content]). | |
| 1455 | -public define HTML_Off_Form a(A_href _href, A_target _target, List(HTML_Off_Form) content) = a([], _href, _target, content). | |
| 1456 | -public define HTML_Off_Form a(CoreAttrs attr, A_href _href, A_target _target, List(HTML_Off_Form) content) = a([attr], _href, _target, content). | |
| 1457 | -public define HTML_Off_Form a(CoreAttrs attr, A_href _href, List(HTML_Off_Form) content) = a([attr], _href, _self, content). | |
| 1458 | -public define HTML_Off_Form a(CoreAttrs attr, A_href _href, HTML_Off_Form content) = a([attr], _href, _self, [content]). | |
| 1459 | - | |
| 1460 | - // <article> | |
| 1461 | -public define HTML_Off_Form article(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("article", attrs, content). | |
| 1462 | -public define HTML_Off_Form article(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("article", attrs, [content]). | |
| 1463 | -public define HTML_Off_Form article(List(HTML_Off_Form) content) = html_tag("article", [], content). | |
| 1464 | -public define HTML_Off_Form article(HTML_Off_Form content) = html_tag("article", [], [content]). | |
| 1465 | - | |
| 1466 | - // <aside> | |
| 1467 | -public define HTML_Off_Form aside(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("aside", attrs, content). | |
| 1468 | -public define HTML_Off_Form aside(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("aside", attrs, [content]). | |
| 1469 | -public define HTML_Off_Form aside(List(HTML_Off_Form) content) = html_tag("aside", [], content). | |
| 1470 | -public define HTML_Off_Form aside(HTML_Off_Form content) = html_tag("aside", [], [content]). | |
| 1471 | - | |
| 1472 | - // <b> text in bold face | |
| 1473 | -public define HTML_Off_Form b(String string) = html_tag("b", [], [text(string)]). | |
| 1474 | -public define HTML_Off_Form b(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("b", attrs, [content]). | |
| 1475 | -public define HTML_Off_Form b(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("b", [attr], content). | |
| 1476 | -public define HTML_Off_Form b(CoreAttrs attr, HTML_Off_Form content) = html_tag("b", [attr], [content]). | |
| 1477 | -public define HTML_Off_Form b(List(CoreAttrs) attrs, String string) = html_tag("b", attrs, [text(string)]). | |
| 1478 | -public define HTML_Off_Form b(CoreAttrs attr, String string) = html_tag("b", [attr], [text(string)]). | |
| 1479 | - | |
| 1480 | - // <br> | |
| 1481 | -public define HTML_Off_Form br = html_void_tag("br", []). | |
| 1482 | -public define HTML_Off_Form br(List(CoreAttrs) attrs) = html_void_tag("br", attrs). | |
| 1483 | - | |
| 1484 | - // <button> | |
| 1485 | -public define HTML_Off_Form button(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("button", attrs, content). | |
| 1486 | -public define HTML_Off_Form button(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("button", attrs, [content]). | |
| 1487 | -public define HTML_Off_Form button(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("button", [attr], content). | |
| 1488 | -public define HTML_Off_Form button(CoreAttrs attr, HTML_Off_Form content) = html_tag("button", [attr], [content]). | |
| 1489 | -public define HTML_Off_Form button(List(CoreAttrs) attrs) = html_tag("button", attrs, []). | |
| 1490 | -public define HTML_Off_Form button(List(CoreAttrs) attrs, String string) = html_tag("button", attrs, [text(string)]). | |
| 1491 | -public define HTML_Off_Form button(List(HTML_Off_Form) content) = html_tag("button", [], content). | |
| 1492 | -public define HTML_Off_Form button(HTML_Off_Form content) = html_tag("button", [], [content]). | |
| 1493 | - | |
| 1494 | - // <canvas> | |
| 1495 | -public define HTML_Off_Form canvas(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("canvas", attrs, content). | |
| 1496 | -public define HTML_Off_Form canvas(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("canvas", attrs, [content]). | |
| 1497 | -public define HTML_Off_Form canvas(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("canvas", [attr], content). | |
| 1498 | -public define HTML_Off_Form canvas(CoreAttrs attr, HTML_Off_Form content) = html_tag("canvas", [attr], [content]). | |
| 1499 | -public define HTML_Off_Form canvas(List(CoreAttrs) attrs) = html_tag("canvas", attrs, []). | |
| 1500 | -public define HTML_Off_Form canvas(List(HTML_Off_Form) content) = html_tag("canvas", [], content). | |
| 1501 | -public define HTML_Off_Form canvas(HTML_Off_Form content) = html_tag("canvas", [], [content]). | |
| 1502 | -public define HTML_Off_Form canvas(CoreAttrs cattr, Int width, Int height) = html_tag("canvas", [cattr, | |
| 1503 | - attr("width", to_String(width)), | |
| 1504 | - attr("height", to_String(height)) | |
| 1505 | - ], []). | |
| 1506 | -public define HTML_Off_Form canvas(List(CoreAttrs) attrs, Int width, Int height) = html_tag("canvas", [ | |
| 1507 | - attr("width", to_String(width)), | |
| 1508 | - attr("height", to_String(height)). | |
| 1509 | - attrs | |
| 1510 | - ], []). | |
| 1511 | - // <datalist> | |
| 1512 | -public define HTML_Off_Form datalist(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("datalist", attrs, content). | |
| 1513 | -public define HTML_Off_Form datalist(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("datalist", attrs, [content]). | |
| 1514 | -public define HTML_Off_Form datalist(List(HTML_Off_Form) content) = html_tag("datalist", [], content). | |
| 1515 | -public define HTML_Off_Form datalist(HTML_Off_Form content) = html_tag("datalist", [], [content]). | |
| 1516 | - | |
| 1517 | - // <div> | |
| 1518 | -public define HTML_Off_Form div(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("div", attrs, content). | |
| 1519 | -public define HTML_Off_Form div(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("div", attrs, [content]). | |
| 1520 | -public define HTML_Off_Form div(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("div", [attr], content). | |
| 1521 | -public define HTML_Off_Form div(CoreAttrs attr, HTML_Off_Form content) = html_tag("div", [attr], [content]). | |
| 1522 | -public define HTML_Off_Form div(List(HTML_Off_Form) content) = html_tag("div", [], content). | |
| 1523 | -public define HTML_Off_Form div(HTML_Off_Form content) = html_tag("div", [], [content]). | |
| 1524 | -public define HTML_Off_Form div(List(CoreAttrs) attrs) = html_tag("div", attrs, []). | |
| 1525 | -public define HTML_Off_Form div(CoreAttrs attr) = html_tag("div", [attr], []). | |
| 1526 | - | |
| 1527 | -public define HTML_Off_Form div(String string) = html_tag("div", [], [text(string)]). | |
| 1528 | -public define HTML_Off_Form div(CoreAttrs attr, String string) = html_tag("div", [attr], [text(string)]). | |
| 1529 | -public define HTML_Off_Form div(List(CoreAttrs) attrs, String string) = html_tag("div", attrs, [text(string)]). | |
| 1530 | - | |
| 1531 | -public define HTML_Off_Form div(List(CoreAttrs) attrs, HTML_Partial_Content content) = div(attrs, [content]). | |
| 1532 | -public define HTML_Off_Form div(List(HTML_Partial_Content) content) = div([], content). | |
| 1533 | -public define HTML_Off_Form div(CoreAttrs attr, HTML_Partial_Content content) = div([attr], [content]). | |
| 1534 | -public define HTML_Off_Form div(HTML_Partial_Content content) = div([], [content]). | |
| 1535 | - | |
| 1536 | -//public define HTML_Partial_Content div(List(CoreAttrs) attrs, HTML_Partial_Content content) = partial_content([], div(attrs, [content])). | |
| 1537 | -//public define HTML_Partial_Content div(CoreAttrs attr, HTML_Partial_Content content) = partial_content([], div([attr], [content])). | |
| 1538 | -//public define HTML_Partial_Content div(List(HTML_Partial_Content) content) = partial_content([], div([], content)). | |
| 1539 | -//public define HTML_Partial_Content div(HTML_Partial_Content content) = partial_content([], div([], [content])). | |
| 1540 | - | |
| 1541 | - // <dd> | |
| 1542 | -public define HTML_Off_Form dd(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("dd", attrs, content). | |
| 1543 | -public define HTML_Off_Form dd(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("dd", attrs, [content]). | |
| 1544 | -public define HTML_Off_Form dd(List(HTML_Off_Form) content) = html_tag("dd", [], content). | |
| 1545 | -public define HTML_Off_Form dd(HTML_Off_Form content) = html_tag("dd", [], [content]). | |
| 1546 | - | |
| 1547 | - // <dl> | |
| 1548 | -public define HTML_Off_Form dl(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("dl", attrs, content). | |
| 1549 | -public define HTML_Off_Form dl(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("dl", attrs, [content]). | |
| 1550 | -public define HTML_Off_Form dl(List(HTML_Off_Form) content) = html_tag("dl", [], content). | |
| 1551 | -public define HTML_Off_Form dl(HTML_Off_Form content) = html_tag("dl", [], [content]). | |
| 1552 | - | |
| 1553 | - // <dt> | |
| 1554 | -public define HTML_Off_Form dt(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("dt", attrs, content). | |
| 1555 | -public define HTML_Off_Form dt(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("dt", attrs, [content]). | |
| 1556 | -public define HTML_Off_Form dt(List(HTML_Off_Form) content) = html_tag("dt", [], content). | |
| 1557 | -public define HTML_Off_Form dt(HTML_Off_Form content) = html_tag("dt", [], [content]). | |
| 1558 | - | |
| 1559 | - // <em> | |
| 1560 | -public define HTML_Off_Form em(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("em", attrs, content). | |
| 1561 | -public define HTML_Off_Form em(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("em", attrs, [content]). | |
| 1562 | -public define HTML_Off_Form em(List(HTML_Off_Form) content) = html_tag("em", [], content). | |
| 1563 | -public define HTML_Off_Form em(HTML_Off_Form content) = html_tag("em", [], [content]). | |
| 1564 | - | |
| 1565 | - // <fieldset> | |
| 1566 | -public define HTML_Off_Form fieldset(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("fieldset", attrs, content). | |
| 1567 | -public define HTML_Off_Form fieldset(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("fieldset", attrs, [content]). | |
| 1568 | -public define HTML_Off_Form fieldset(List(HTML_Off_Form) content) = html_tag("fieldset", [], content). | |
| 1569 | -public define HTML_Off_Form fieldset(HTML_Off_Form content) = html_tag("fieldset", [], [content]). | |
| 1570 | - | |
| 1571 | - // <footer> | |
| 1572 | -public define HTML_Off_Form footer(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("footer", attrs, content). | |
| 1573 | -public define HTML_Off_Form footer(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("footer", attrs, [content]). | |
| 1574 | -public define HTML_Off_Form footer(List(HTML_Off_Form) content) = html_tag("footer", [], content). | |
| 1575 | -public define HTML_Off_Form footer(HTML_Off_Form content) = html_tag("footer", [], [content]). | |
| 1576 | - | |
| 1577 | - // <form> | |
| 1578 | -public define HTML_Off_Form form(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("form", attrs, content). | |
| 1579 | -public define HTML_Off_Form form(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("form", attrs, [content]). | |
| 1580 | -public define HTML_Off_Form form(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("form", [attr], content). | |
| 1581 | -public define HTML_Off_Form form(CoreAttrs attr, HTML_Off_Form content) = html_tag("form", [attr], [content]). | |
| 1582 | -public define HTML_Off_Form form(List(CoreAttrs) attrs) = html_tag("form", attrs, []). | |
| 1583 | -public define HTML_Off_Form form(CoreAttrs attr) = html_tag("form", [attr], []). | |
| 1584 | - | |
| 1585 | -public define HTML_Off_Form form(List(HTML_Off_Form) content) = html_tag("form", [], content). | |
| 1586 | -public define HTML_Off_Form form(HTML_Off_Form content) = html_tag("form", [], [content]). | |
| 1587 | - | |
| 1588 | - | |
| 1589 | - // <header> | |
| 1590 | -public define HTML_Off_Form header(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("header", attrs, content). | |
| 1591 | -public define HTML_Off_Form header(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("header", attrs, [content]). | |
| 1592 | -public define HTML_Off_Form header(List(HTML_Off_Form) content) = html_tag("header", [], content). | |
| 1593 | -public define HTML_Off_Form header(HTML_Off_Form content) = html_tag("header", [], [content]). | |
| 1594 | - | |
| 1595 | - // <h1> | |
| 1596 | -public define HTML_Off_Form h1(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h1", attrs, content). | |
| 1597 | -public define HTML_Off_Form h1(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("h1", [attr], content). | |
| 1598 | -public define HTML_Off_Form h1(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h1", attrs, [content]). | |
| 1599 | -public define HTML_Off_Form h1(CoreAttrs attr, HTML_Off_Form content) = html_tag("h1", [attr], [content]). | |
| 1600 | -public define HTML_Off_Form h1(List(HTML_Off_Form) content) = html_tag("h1", [], content). | |
| 1601 | -public define HTML_Off_Form h1(HTML_Off_Form content) = html_tag("h1", [], [content]). | |
| 1602 | - // <h2> | |
| 1603 | -public define HTML_Off_Form h2(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h2", attrs, content). | |
| 1604 | -public define HTML_Off_Form h2(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h2", attrs, [content]). | |
| 1605 | -public define HTML_Off_Form h2(List(HTML_Off_Form) content) = html_tag("h2", [], content). | |
| 1606 | -public define HTML_Off_Form h2(HTML_Off_Form content) = html_tag("h2", [], [content]). | |
| 1607 | - // <h3> | |
| 1608 | -public define HTML_Off_Form h3(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h3", attrs, content). | |
| 1609 | -public define HTML_Off_Form h3(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h3", attrs, [content]). | |
| 1610 | -public define HTML_Off_Form h3(List(HTML_Off_Form) content) = html_tag("h3", [], content). | |
| 1611 | -public define HTML_Off_Form h3(HTML_Off_Form content) = html_tag("h3", [], [content]). | |
| 1612 | -public define HTML_Off_Form h3(String content) = html_tag("h3", [], [text(content)]). | |
| 1613 | - | |
| 1614 | - // <h4> | |
| 1615 | -public define HTML_Off_Form h4(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h4", attrs, content). | |
| 1616 | -public define HTML_Off_Form h4(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h4", attrs, [content]). | |
| 1617 | -public define HTML_Off_Form h4(List(HTML_Off_Form) content) = html_tag("h4", [], content). | |
| 1618 | -public define HTML_Off_Form h4(HTML_Off_Form content) = html_tag("h4", [], [content]). | |
| 1619 | - // <h5> | |
| 1620 | -public define HTML_Off_Form h5(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h5", attrs, content). | |
| 1621 | -public define HTML_Off_Form h5(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h5", attrs, [content]). | |
| 1622 | -public define HTML_Off_Form h5(List(HTML_Off_Form) content) = html_tag("h5", [], content). | |
| 1623 | -public define HTML_Off_Form h5(HTML_Off_Form content) = html_tag("h5", [], [content]). | |
| 1624 | - | |
| 1625 | - // <h6> | |
| 1626 | -public define HTML_Off_Form h6(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h6", attrs, content). | |
| 1627 | -public define HTML_Off_Form h6(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h6", attrs, [content]). | |
| 1628 | -public define HTML_Off_Form h6(List(HTML_Off_Form) content) = html_tag("h6", [], content). | |
| 1629 | -public define HTML_Off_Form h6(HTML_Off_Form content) = html_tag("h6", [], [content]). | |
| 1630 | - | |
| 1631 | - // <hr> | |
| 1632 | -public define HTML_Off_Form hr = html_void_tag("hr", []). | |
| 1633 | -public define HTML_Off_Form hr(List(CoreAttrs) attrs) = html_void_tag("hr", attrs). | |
| 1634 | -public define HTML_Off_Form hr(CoreAttrs attr) = html_void_tag("hr", [attr]). | |
| 1635 | - | |
| 1636 | - // <i> | |
| 1637 | -public define HTML_Off_Form i(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("i", attrs, content). | |
| 1638 | -public define HTML_Off_Form i(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("i", attrs, [content]). | |
| 1639 | -public define HTML_Off_Form i(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("i", [attr], content). | |
| 1640 | -public define HTML_Off_Form i(CoreAttrs attr, HTML_Off_Form content) = html_tag("i", [attr], [content]). | |
| 1641 | -public define HTML_Off_Form i(List(HTML_Off_Form) content) = html_tag("i", [], content). | |
| 1642 | -public define HTML_Off_Form i(HTML_Off_Form content) = html_tag("i", [], [content]). | |
| 1643 | -public define HTML_Off_Form i(String string) = html_tag("i", [], [text(string)]). | |
| 1644 | -public define HTML_Off_Form i(CoreAttrs attr, String string) = html_tag("i", [attr], [text(string)]). | |
| 1645 | -public define HTML_Off_Form i(List(CoreAttrs) attrs, String string) = html_tag("i", attrs, [text(string)]). | |
| 1646 | - | |
| 1647 | - // <iframe> | |
| 1648 | -public define HTML_Off_Form iframe(CoreAttrs _attr, String src, Int width, Int height) = | |
| 1649 | - html_tag("iframe", [_attr, attr("src",src), width_px(width), height_px(height)], []). | |
| 1650 | -public define HTML_Off_Form iframe(String src, Int width, Int height) = | |
| 1651 | - html_tag("iframe", [attr("src",src), width_px(width), height_px(height)], []). | |
| 1652 | -public define HTML_Off_Form iframe(String src) = html_tag("iframe", [attr("src",src)], []). | |
| 1653 | - | |
| 1654 | - // <input> | |
| 1655 | -public define HTML_Off_Form input(List(CoreAttrs) attrs) = html_void_tag("input", attrs). | |
| 1656 | -public define HTML_Off_Form input(CoreAttrs attr) = html_void_tag("input", [attr]). | |
| 1657 | - | |
| 1658 | -public define CoreAttrs type(Input_Type value)= attr("type", to_String(value)). | |
| 1659 | -public define CoreAttrs type(String value)= attr("type", value). | |
| 1660 | -public define CoreAttrs name(String value)= attr("name", value). | |
| 1661 | -public define CoreAttrs value(String value)= attr("value", value). | |
| 1662 | -public define CoreAttrs placeholder(String value) = attr("placeholder", value). | |
| 1663 | -public define CoreAttrs init(String value)= attr("value", encode_HTML_entities(value)). | |
| 1664 | - //-- BEGIN of <input> preset type | |
| 1665 | - | |
| 1666 | -public define HTML_Off_Form text_input(List(CoreAttrs) options, HTML_Label label_text, WebArgName _name, InitialValue _init, Int w) = | |
| 1667 | - sequence([ | |
| 1668 | - format_label(label_text), | |
| 1669 | - input([class("in"), id(_id), name(_name), value(_int), size(w), options]) | |
| 1670 | - ]). | |
| 1671 | - | |
| 1672 | - /// Checkbox | |
| 1673 | -public define HTML_Off_Form checkbox(List(CoreAttrs) attrs, String _name, String _form, Bool checked) = input([type(checkbox), name(_name), form(_form), bool_attr(checked, "checked") . attrs]). | |
| 1674 | -public define HTML_Off_Form checkbox(List(CoreAttrs) attrs, String _name, Bool checked) = input([type(checkbox), name(_name), bool_attr(checked, "checked") . attrs]). | |
| 1675 | -public define HTML_Off_Form checkbox(String name, String form, Bool checked) = checkbox([], name, form, checked). | |
| 1676 | -public define HTML_Off_Form checkbox(String name, Bool checked) = checkbox([], name, checked). | |
| 1677 | - | |
| 1678 | - /// Radio button | |
| 1679 | -public define HTML_Off_Form radio(List(CoreAttrs) attrs, String _name, String _value, String _form, Bool checked) = input([type(radio), name(_name), value(_value), form(_form), bool_attr(checked, "checked") . attrs]). | |
| 1680 | -public define HTML_Off_Form radio(List(CoreAttrs) attrs, String name, String value, String form) = radio(attrs, name, value, form, false). | |
| 1681 | -public define HTML_Off_Form radio(String name, String value, String form, Bool checked) = radio([], name, value, form, checked). | |
| 1682 | -public define HTML_Off_Form radio(String name, String value, String form) = radio([], name, value, form, false). | |
| 1683 | - | |
| 1684 | - /// hidden value | |
| 1685 | -public define HTML_Off_Form hidden(List(CoreAttrs) attrs, String name, String value, String form) = input([type("hidden"), attr("name",name), attr("value",value), attr("form", form) . attrs]). | |
| 1686 | -public define HTML_Off_Form hidden(CoreAttrs attr, String name, String value, String form) = hidden([attr], name, value, form). | |
| 1687 | -public define HTML_Off_Form hidden(String name, String value, String form) = hidden([], name, value, form). | |
| 1688 | -public define HTML_Off_Form hidden(String _name, String _value) = input([type("hidden"), name(_name), value(_value)]). | |
| 1689 | - | |
| 1690 | - //-- END of <input> preset type | |
| 1691 | - | |
| 1692 | - // <img> | |
| 1693 | -public define HTML_Off_Form img(List(CoreAttrs) attrs, String src, String alt) = html_void_tag("img", attrs + [attr("src",src), attr("alt",alt)] ). | |
| 1694 | -public define HTML_Off_Form img(CoreAttrs _attr, String src, String alt) = html_void_tag("img", [_attr, attr("src",src), attr("alt",alt)] ). | |
| 1695 | -public define HTML_Off_Form img(String src) = img([], src, ""). | |
| 1696 | -public define HTML_Off_Form img(String src, String alt) = img([], src, alt). | |
| 1697 | -public define HTML_Off_Form img(List(CoreAttrs) attrs, String src) = img(attrs, src, ""). | |
| 1698 | -public define HTML_Off_Form img(CoreAttrs attr, String src) = img([attr], src, ""). | |
| 1699 | -public define HTML_Off_Form img(String src, Int width, Int height) = img([attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")], src, src). | |
| 1700 | -public define HTML_Off_Form img(String src, String alt, Int width, Int height) = | |
| 1701 | - html_void_tag("img", [attr("src",src), attr("alt",alt), attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")]). | |
| 1702 | - | |
| 1703 | -public define HTML_Off_Form img(List(CoreAttrs) attrs, String src, String alt, Int width, Int height) = | |
| 1704 | - html_void_tag("img", attrs + [attr("src",src), attr("alt",alt), attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")]). | |
| 1705 | - | |
| 1706 | -public define HTML_Off_Form img(CoreAttrs _attr, String src, String alt, Int width, Int height) = | |
| 1707 | - html_void_tag("img", [_attr, attr("src",src), attr("alt",alt), width_px(width), height_px(height)]). | |
| 1708 | - | |
| 1709 | - // <label> | |
| 1710 | -public define HTML_Off_Form label(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("label", attrs, content). | |
| 1711 | -public define HTML_Off_Form label(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("label", [attr], content). | |
| 1712 | -public define HTML_Off_Form label(List(HTML_Off_Form) content) = html_tag("label", [], content). | |
| 1713 | -public define HTML_Off_Form label(HTML_Off_Form content) = html_tag("label", [], [content]). | |
| 1714 | -public define HTML_Off_Form label(String string) = html_tag("label", [], [text(string)]). | |
| 1715 | -public define HTML_Off_Form label(CoreAttrs attr, String string) = html_tag("label", [attr], [text(string)]). | |
| 1716 | -public define HTML_Off_Form label(List(CoreAttrs) attrs, String string) = html_tag("label", attrs, [text(string)]). | |
| 1717 | - | |
| 1718 | - // <legend> | |
| 1719 | -public define HTML_Off_Form legend(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("legend", attrs, content). | |
| 1720 | -public define HTML_Off_Form legend(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("legend", attrs, [content]). | |
| 1721 | -public define HTML_Off_Form legend(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("legend", [attr], content). | |
| 1722 | -public define HTML_Off_Form legend(CoreAttrs attr, HTML_Off_Form content) = html_tag("legend", [attr], [content]). | |
| 1723 | -public define HTML_Off_Form legend(List(HTML_Off_Form) content) = html_tag("legend", [], content). | |
| 1724 | -public define HTML_Off_Form legend(HTML_Off_Form content) = html_tag("legend", [], [content]). | |
| 1725 | - | |
| 1726 | - // <li> | |
| 1727 | -public define HTML_Off_Form li(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("li", attrs, content). | |
| 1728 | -public define HTML_Off_Form li(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("li", attrs, [content]). | |
| 1729 | -public define HTML_Off_Form li(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("li", [attr], content). | |
| 1730 | -public define HTML_Off_Form li(CoreAttrs attr, HTML_Off_Form content) = html_tag("li", [attr], [content]). | |
| 1731 | -public define HTML_Off_Form li(List(HTML_Off_Form) content) = html_tag("li", [], content). | |
| 1732 | -public define HTML_Off_Form li(HTML_Off_Form content) = html_tag("li", [], [content]). | |
| 1733 | -public define HTML_Off_Form li(String string) = html_tag("li", [], [text(string)]). | |
| 1734 | -public define HTML_Off_Form li(CoreAttrs attr, String string) = html_tag("li", [attr], [text(string)]). | |
| 1735 | -public define HTML_Off_Form li(List(CoreAttrs) attrs, String string) = html_tag("li", attrs, [text(string)]). | |
| 1736 | - | |
| 1737 | - // <main> | |
| 1738 | -public define HTML_Off_Form main(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("main", attrs, content). | |
| 1739 | -public define HTML_Off_Form main(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("main", attrs, [content]). | |
| 1740 | -public define HTML_Off_Form main(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("main", [attr], content). | |
| 1741 | -public define HTML_Off_Form main(CoreAttrs attr, HTML_Off_Form content) = html_tag("main", [attr], [content]). | |
| 1742 | -public define HTML_Off_Form main(List(HTML_Off_Form) content) = html_tag("main", [], content). | |
| 1743 | -public define HTML_Off_Form main(HTML_Off_Form content) = html_tag("main", [], [content]). | |
| 1744 | - | |
| 1745 | - // <nav> | |
| 1746 | -public define HTML_Off_Form nav(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("nav", attrs, content). | |
| 1747 | -public define HTML_Off_Form nav(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("nav", attrs, [content]). | |
| 1748 | -public define HTML_Off_Form nav(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("nav", [attr], content). | |
| 1749 | -public define HTML_Off_Form nav(CoreAttrs attr, HTML_Off_Form content) = html_tag("nav", [attr], [content]). | |
| 1750 | -public define HTML_Off_Form nav(List(HTML_Off_Form) content) = html_tag("nav", [], content). | |
| 1751 | -public define HTML_Off_Form nav(HTML_Off_Form content) = html_tag("nav", [], [content]). | |
| 1752 | - | |
| 1753 | - // <ol> | |
| 1754 | -public define HTML_Off_Form ol(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("ol", attrs, content). | |
| 1755 | -public define HTML_Off_Form ol(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("ol", attrs, [content]). | |
| 1756 | -public define HTML_Off_Form ol(List(HTML_Off_Form) content) = html_tag("ol", [], content). | |
| 1757 | -public define HTML_Off_Form ol(HTML_Off_Form content) = html_tag("ol", [], [content]). | |
| 1758 | - | |
| 1759 | - // <option> | |
| 1760 | -public define HTML_Off_Form option(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("option", attrs, content). | |
| 1761 | -public define HTML_Off_Form option(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("option", attrs, [content]). | |
| 1762 | -public define HTML_Off_Form option(List(HTML_Off_Form) content) = html_tag("option", [], content). | |
| 1763 | -public define HTML_Off_Form option(CoreAttrs attr, HTML_Off_Form content) = html_tag("option", [attr], [content]). | |
| 1764 | -public define HTML_Off_Form option(HTML_Off_Form content) = html_tag("option", [], [content]). | |
| 1765 | -public define HTML_Off_Form option(String _value, String _text) = html_tag("option", [value(_value)], [text(_text)]). | |
| 1766 | - // <p> | |
| 1767 | -public define HTML_Off_Form p(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("p", attrs, content). | |
| 1768 | -public define HTML_Off_Form p(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("p", attrs, [content]). | |
| 1769 | -public define HTML_Off_Form p(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("p", [attr], content). | |
| 1770 | -public define HTML_Off_Form p(CoreAttrs attr, HTML_Off_Form content) = html_tag("p", [attr], [content]). | |
| 1771 | -public define HTML_Off_Form p(CoreAttrs attr, String _text) = html_tag("p", [attr], [text(_text)]). | |
| 1772 | -public define HTML_Off_Form p(List(HTML_Off_Form) content) = html_tag("p", [], content). | |
| 1773 | -public define HTML_Off_Form p(HTML_Off_Form content) = html_tag("p", [], [content]). | |
| 1774 | - | |
| 1775 | - // <pre> preformatted | |
| 1776 | -public define HTML_Off_Form pre(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("pre", attrs, content). | |
| 1777 | -public define HTML_Off_Form pre(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("pre", attrs, [content]). | |
| 1778 | -public define HTML_Off_Form pre(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("pre", [attr], content). | |
| 1779 | -public define HTML_Off_Form pre(CoreAttrs attr, HTML_Off_Form content) = html_tag("pre", [attr], [content]). | |
| 1780 | -public define HTML_Off_Form pre(List(HTML_Off_Form) content) = html_tag("pre", [], content). | |
| 1781 | -public define HTML_Off_Form pre(HTML_Off_Form content) = html_tag("pre", [], [content]). | |
| 1782 | -public define HTML_Off_Form pre(String string) = html_tag("pre", [], [text(string)]). | |
| 1783 | -public define HTML_Off_Form pre(CoreAttrs attr, String string) = html_tag("pre", [attr], [text(string)]). | |
| 1784 | -public define HTML_Off_Form pre(List(CoreAttrs) attrs, String string) = html_tag("pre", attrs, [text(string)]). | |
| 1785 | - | |
| 1786 | - // <progress> | |
| 1787 | -public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, List(HTML_Off_Form) content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], content). | |
| 1788 | -public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], [content]). | |
| 1789 | -public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max) , _attr], [content]). | |
| 1790 | -public define HTML_Off_Form progress(Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max)], [content]). | |
| 1791 | -public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], [text(content)]). | |
| 1792 | -public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max), _attr], [text(content)]). | |
| 1793 | -public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], []). | |
| 1794 | -public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max), _attr], []). | |
| 1795 | -public define HTML_Off_Form progress(Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max)], [text(content)]). | |
| 1796 | -public define HTML_Off_Form progress(Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max)], []). | |
| 1797 | - | |
| 1798 | - // <script> | |
| 1799 | -public define HTML_Off_Form script(String file_name, List(JS_Attribute) attrs) = literal_pt(add_js_files([js_file(file_name, attrs)])). | |
| 1800 | -public define HTML_Off_Form script(String content) = literal_pt(add_script([script("text/javascript", content)])). | |
| 1801 | - | |
| 1802 | - // <section> | |
| 1803 | -public define HTML_Off_Form section(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("section", attrs, content). | |
| 1804 | -public define HTML_Off_Form section(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("section", attrs, [content]). | |
| 1805 | -public define HTML_Off_Form section(List(HTML_Off_Form) content) = html_tag("section", [], content). | |
| 1806 | -public define HTML_Off_Form section(HTML_Off_Form content) = html_tag("section", [], [content]). | |
| 1807 | - | |
| 1808 | - // <select> | |
| 1809 | -public define HTML_Off_Form select(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("select", attrs, content). | |
| 1810 | -public define HTML_Off_Form select(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("select", attrs, [content]). | |
| 1811 | -public define HTML_Off_Form select(List(CoreAttrs) attrs) = html_tag("select", attrs, []). | |
| 1812 | -public define HTML_Off_Form select(List(HTML_Off_Form) content) = html_tag("select", [], content). | |
| 1813 | -public define HTML_Off_Form select(HTML_Off_Form content) = html_tag("select", [], [content]). | |
| 1814 | - | |
| 1815 | - | |
| 1816 | - // <span> | |
| 1817 | -public define HTML_Off_Form span(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("span", attrs, content). | |
| 1818 | -public define HTML_Off_Form span(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("span", attrs, [content]). | |
| 1819 | -public define HTML_Off_Form span(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("span", [attr], content). | |
| 1820 | -public define HTML_Off_Form span(CoreAttrs attr, HTML_Off_Form content) = html_tag("span", [attr], [content]). | |
| 1821 | -public define HTML_Off_Form span(List(HTML_Off_Form) content) = html_tag("span", [], content). | |
| 1822 | -public define HTML_Off_Form span(HTML_Off_Form content) = html_tag("span", [], [content]). | |
| 1823 | -public define HTML_Off_Form span(Int i) = html_tag("span", [], [text(to_decimal(i))]). | |
| 1824 | -public define HTML_Off_Form span(List(CoreAttrs) attrs, String s) = html_tag("span", attrs, [text(s)]). | |
| 1825 | -public define HTML_Off_Form span(CoreAttrs attr, String s) = html_tag("span", [attr],[text(s)]). | |
| 1826 | -public define HTML_Off_Form span(String s) = html_tag("span", [], [text(s)]). | |
| 1827 | -public define HTML_Off_Form span(List(CoreAttrs) attrs) = html_tag("span", attrs, []). | |
| 1828 | -public define HTML_Off_Form span(CoreAttrs attr) = html_tag("span", [attr],[]). | |
| 1829 | - | |
| 1830 | - // <strong> | |
| 1831 | -public define HTML_Off_Form strong(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("strong", attrs, content). | |
| 1832 | -public define HTML_Off_Form strong(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("strong", attrs, [content]). | |
| 1833 | -public define HTML_Off_Form strong(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("strong", [attr], content). | |
| 1834 | -public define HTML_Off_Form strong(CoreAttrs attr, HTML_Off_Form content) = html_tag("strong", [attr], [content]). | |
| 1835 | -public define HTML_Off_Form strong(List(HTML_Off_Form) content) = html_tag("strong", [], content). | |
| 1836 | -public define HTML_Off_Form strong(HTML_Off_Form content) = html_tag("strong", [], [content]). | |
| 1837 | - | |
| 1838 | - // <svg> | |
| 1839 | -public define HTML_Off_Form svg(List(CoreAttrs) attrs) = html_tag("svg", attrs, []). | |
| 1840 | - | |
| 1841 | - | |
| 1842 | - // <table> | |
| 1843 | -public define HTML_Off_Form table(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("table", attrs, content). | |
| 1844 | -public define HTML_Off_Form table(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("table", attrs, [content]). | |
| 1845 | -public define HTML_Off_Form table(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("table", [attr], content). | |
| 1846 | -public define HTML_Off_Form table(CoreAttrs attr, HTML_Off_Form content) = html_tag("table", [attr], [content]). | |
| 1847 | -public define HTML_Off_Form table(List(HTML_Off_Form) content) = html_tag("table", [], content). | |
| 1848 | -public define HTML_Off_Form table(HTML_Off_Form content) = html_tag("table", [], [content]). | |
| 1849 | - | |
| 1850 | - // <textarea> | |
| 1851 | - // CoreAttrs for textarea | |
| 1852 | -public define CoreAttrs wrap_lines = attr("wrap", "hard"). | |
| 1853 | -public define CoreAttrs read_only = bool_attr(true, "readonly"). | |
| 1854 | -public define CoreAttrs cols(Int value) = attr("cols",to_String(value)). | |
| 1855 | -public define CoreAttrs rows(Int value) = attr("rows",to_String(value)). | |
| 1856 | - | |
| 1857 | -public define HTML_Off_Form textarea(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("textarea", attrs, content). | |
| 1858 | -public define HTML_Off_Form textarea(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("textarea", attrs, [content]). | |
| 1859 | - | |
| 1860 | -public define HTML_Off_Form textarea(List(CoreAttrs) attrs, Int _cols, Int _rows, List(HTML_Off_Form) content) | |
| 1861 | - = html_tag("textarea", [cols(_cols), rows(_rows) . attrs], content). | |
| 1862 | - | |
| 1863 | -public define HTML_Off_Form textarea(List(CoreAttrs) attrs, Int _cols, Int _rows, HTML_Off_Form content) | |
| 1864 | - = html_tag("textarea", [cols(_cols), rows(_rows) . attrs], [content]). | |
| 1865 | - | |
| 1866 | -public define HTML_Off_Form textarea(Int _cols, Int _rows, HTML_Off_Form content) = html_tag("textarea", [cols(_cols), rows(_rows)], [content]). | |
| 1867 | -public define HTML_Off_Form textarea(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("textarea", [attr], content). | |
| 1868 | -public define HTML_Off_Form textarea(CoreAttrs attr, HTML_Off_Form content) = html_tag("textarea", [attr], [content]). | |
| 1869 | - | |
| 1870 | - // <thead> | |
| 1871 | -public define HTML_Off_Form thead(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("thead", attrs, content). | |
| 1872 | -public define HTML_Off_Form thead(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("thead", attrs, [content]). | |
| 1873 | -public define HTML_Off_Form thead(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("thead", [attr], content). | |
| 1874 | -public define HTML_Off_Form thead(CoreAttrs attr, HTML_Off_Form content) = html_tag("thead", [attr], [content]). | |
| 1875 | -public define HTML_Off_Form thead(List(HTML_Off_Form) content) = html_tag("thead", [], content). | |
| 1876 | -public define HTML_Off_Form thead(HTML_Off_Form content) = html_tag("thead", [], [content]). | |
| 1877 | - | |
| 1878 | - // <tbody> | |
| 1879 | -public define HTML_Off_Form tbody(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("tbody", attrs, content). | |
| 1880 | -public define HTML_Off_Form tbody(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("tbody", attrs, [content]). | |
| 1881 | -public define HTML_Off_Form tbody(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("tbody", [attr], content). | |
| 1882 | -public define HTML_Off_Form tbody(CoreAttrs attr, HTML_Off_Form content) = html_tag("tbody", [attr], [content]). | |
| 1883 | -public define HTML_Off_Form tbody(List(HTML_Off_Form) content) = html_tag("tbody", [], content). | |
| 1884 | -public define HTML_Off_Form tbody(HTML_Off_Form content) = html_tag("tbody", [], [content]). | |
| 1885 | - | |
| 1886 | - // <tfoot> | |
| 1887 | -public define HTML_Off_Form tfoot(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("tfoot", attrs, content). | |
| 1888 | -public define HTML_Off_Form tfoot(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("tfoot", attrs, [content]). | |
| 1889 | -public define HTML_Off_Form tfoot(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("tfoot", [attr], content). | |
| 1890 | -public define HTML_Off_Form tfoot(CoreAttrs attr, HTML_Off_Form content) = html_tag("tfoot", [attr], [content]). | |
| 1891 | -public define HTML_Off_Form tfoot(List(HTML_Off_Form) content) = html_tag("tfoot", [], content). | |
| 1892 | -public define HTML_Off_Form tfoot(HTML_Off_Form content) = html_tag("tfoot", [], [content]). | |
| 1893 | - | |
| 1894 | - // <th> | |
| 1895 | -public define HTML_Off_Form th(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("th", attrs, content). | |
| 1896 | -public define HTML_Off_Form th(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("th", attrs, [content]). | |
| 1897 | -public define HTML_Off_Form th(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("th", [attr], content). | |
| 1898 | -public define HTML_Off_Form th(CoreAttrs attr, HTML_Off_Form content) = html_tag("th", [attr], [content]). | |
| 1899 | -public define HTML_Off_Form th(CoreAttrs attr) = html_tag("th", [attr], []). | |
| 1900 | -public define HTML_Off_Form th(List(HTML_Off_Form) content) = html_tag("th", [], content). | |
| 1901 | -public define HTML_Off_Form th(HTML_Off_Form content) = html_tag("th", [], [content]). | |
| 1902 | -public define HTML_Off_Form th(String string) = html_tag("th", [], [text(string)]). | |
| 1903 | -public define HTML_Off_Form th(CoreAttrs attr, String string) = html_tag("th", [attr], [text(string)]). | |
| 1904 | -public define HTML_Off_Form th(List(CoreAttrs) attrs, String string) = html_tag("th", attrs, [text(string)]). | |
| 1905 | -public define HTML_Off_Form th = html_tag("th", [], []). | |
| 1906 | - | |
| 1907 | - // <td> | |
| 1908 | - // CoreAttrs for <td> | |
| 1909 | -//public define CoreAttrs colspan(Int value) = attr("colspan", to_String(value)). | |
| 1910 | -//public define CoreAttrs rowspan(Int value) = attr("rowspan", to_String(value)). | |
| 1911 | -//public define CoreAttrs headers(String header_id) = attr("headers", header_id). | |
| 1912 | - | |
| 1913 | -public define HTML_Off_Form td(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("td", attrs, content). | |
| 1914 | -public define HTML_Off_Form td(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("td", attrs, [content]). | |
| 1915 | -public define HTML_Off_Form td(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("td", [attr], content). | |
| 1916 | -public define HTML_Off_Form td(CoreAttrs attr, HTML_Off_Form content) = html_tag("td", [attr], [content]). | |
| 1917 | -public define HTML_Off_Form td(List(HTML_Off_Form) content) = html_tag("td", [], content). | |
| 1918 | -public define HTML_Off_Form td(HTML_Off_Form content) = html_tag("td", [], [content]). | |
| 1919 | -public define HTML_Off_Form td(List(CoreAttrs) attrs, String string) = html_tag("td", attrs, [text(string)]). | |
| 1920 | -public define HTML_Off_Form td(CoreAttrs attr, String string) = html_tag("td", [attr], [text(string)]). | |
| 1921 | -public define HTML_Off_Form td(String string) = html_tag("td", [], [text(string)]). | |
| 1922 | -public define HTML_Off_Form td(List(CoreAttrs) attrs, Int i) = html_tag("td", attrs, [text(to_decimal(i))]). | |
| 1923 | -public define HTML_Off_Form td(CoreAttrs attr, Int i) = html_tag("td", [attr], [text(to_decimal(i))]). | |
| 1924 | -public define HTML_Off_Form td(Int i) = html_tag("td", [], [text(to_decimal(i))]). | |
| 1925 | - | |
| 1926 | - // <tr> | |
| 1927 | -public define HTML_Off_Form tr(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("tr", attrs, content). | |
| 1928 | -public define HTML_Off_Form tr(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("tr", attrs, [content]). | |
| 1929 | -public define HTML_Off_Form tr(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("tr", [attr], content). | |
| 1930 | -public define HTML_Off_Form tr(CoreAttrs attr, HTML_Off_Form content) = html_tag("tr", [attr], [content]). | |
| 1931 | -public define HTML_Off_Form tr(List(HTML_Off_Form) content) = html_tag("tr", [], content). | |
| 1932 | -public define HTML_Off_Form tr(HTML_Off_Form content) = html_tag("tr", [], [content]). | |
| 1933 | - | |
| 1934 | - // <ul> | |
| 1935 | -public define HTML_Off_Form ul(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("ul", attrs, content). | |
| 1936 | -public define HTML_Off_Form ul(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("ul", attrs, [content]). | |
| 1937 | -public define HTML_Off_Form ul(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("ul", [attr], content). | |
| 1938 | -public define HTML_Off_Form ul(CoreAttrs attr, HTML_Off_Form content) = html_tag("ul", [attr], [content]). | |
| 1939 | -public define HTML_Off_Form ul(List(HTML_Off_Form) content) = html_tag("ul", [], content). | |
| 1940 | -public define HTML_Off_Form ul(HTML_Off_Form content) = html_tag("ul", [], [content]). | |
| 1941 | - | |
| 1942 | -//public define HTML_Off_Form empty = html_tag( | |
| 1943 | - | |
| 1944 | -//public define HTML_Off_Form | |
| 1945 | -// form | |
| 1946 | -// ( | |
| 1947 | -// String form_name, | |
| 1948 | -// List(CoreAttrs) options, | |
| 1949 | -// HTML_Off_Form content | |
| 1950 | -// ) = | |
| 1951 | -// form([id(form_name). options], [content]). | |
| 1952 | - | |
| 1953 | -//public define HTML_Off_Form | |
| 1954 | -// form | |
| 1955 | -// ( | |
| 1956 | -// String form_name, | |
| 1957 | -// List(CoreAttrs) options, | |
| 1958 | -// List(HTML_Off_Form) contents | |
| 1959 | -// ) = | |
| 1960 | -// form([id(form_name) . options], contents). | |
| 1961 | - | |
| 1962 | -public define HTML_Off_Form | |
| 1963 | - form | |
| 1964 | - ( | |
| 1965 | - List(CoreAttrs) options, | |
| 1966 | - WEB_Action_Name _action, | |
| 1967 | - List((String,String)) extra_ops, | |
| 1968 | - HTML_Off_Form content | |
| 1969 | - ) = | |
| 1970 | - form([action(_action, extra_ops). options], [content]). | |
| 1971 | - | |
| 1972 | -//public define HTML_Off_Form | |
| 1973 | -// form | |
| 1974 | -// ( | |
| 1975 | -// List(CoreAttrs) options, | |
| 1976 | -// WEB_Action_Name action, | |
| 1977 | -// List((String,String)) extra_ops, | |
| 1978 | -// HTML_Off_Form content | |
| 1979 | -// ) = | |
| 1980 | -// form(options, action, extra_ops, [content]). | |
| 1981 | - | |
| 1982 | -public define HTML_Off_Form | |
| 1983 | - form | |
| 1984 | - ( | |
| 1985 | - List(CoreAttrs) options, | |
| 1986 | - WEB_Action_Name action, | |
| 1987 | - List((String,String)) extra_ops, | |
| 1988 | - List(HTML_Off_Form) contents | |
| 1989 | - ) = | |
| 1990 | - form(options, action, extra_ops, contents). | |
| 1991 | - | |
| 1992 | -public define HTML_Off_Form | |
| 1993 | - form | |
| 1994 | - ( | |
| 1995 | - List(CoreAttrs) options, | |
| 1996 | - String action, | |
| 1997 | - List((String,String)) extra_ops, | |
| 1998 | - HTML_Off_Form content | |
| 1999 | - ) = | |
| 2000 | - form(options, action_name(action), extra_ops, [content]). | |
| 2001 | - | |
| 2002 | -public define HTML_Off_Form | |
| 2003 | - form | |
| 2004 | - ( | |
| 2005 | - String form_name, | |
| 2006 | - List(CoreAttrs) options, | |
| 2007 | - String action, | |
| 2008 | - List((String,String)) extra_ops, | |
| 2009 | - List(HTML_Off_Form) contents | |
| 2010 | - ) = | |
| 2011 | - form(options, action_name(action), extra_ops, contents). | |
| 2012 | - | |
| 2013 | -public define HTML_Off_Form literal(Printable_tree t) = literal_pt(t). | |
| 2014 | -//public define HTML_Off_Form fixed_size(HTML_Size width, HTML_Size height, String name_of_HTML_file) | |
| 2015 | -// = fixed_size_2(width,height,name_of_HTML_file). | |
| 2016 | - | |
| 2017 | - | |
| 2018 | -public define HTML_Off_Form | |
| 2019 | - foreign_link | |
| 2020 | - ( | |
| 2021 | - Int tsize, | |
| 2022 | - String url, | |
| 2023 | - String name | |
| 2024 | - ) = | |
| 2025 | - foreign_link([size(tsize)],url,name). | |
| 2026 | - | |
| 2027 | - | |
| 2028 | -public define HTML_Off_Form | |
| 2029 | - actioner | |
| 2030 | - ( | |
| 2031 | - Actioner_Connection conn, | |
| 2032 | - Actioner_Target targ, | |
| 2033 | - Actioner_Aspect asp, | |
| 2034 | - WEB_Action_Name action, | |
| 2035 | - List((String,String)) extra_ops | |
| 2036 | - ) = | |
| 2037 | - actioner(conn,targ,asp,action,extra_ops,[]). | |
| 2038 | - | |
| 2039 | -public define HTML_Off_Form | |
| 2040 | - actioner | |
| 2041 | - ( | |
| 2042 | - Actioner_Connection conn, | |
| 2043 | - Actioner_Target targ, | |
| 2044 | - Actioner_Aspect asp, | |
| 2045 | - WEB_Action_Name action, | |
| 2046 | - List((String,String)) extra_ops, | |
| 2047 | - String form_name | |
| 2048 | - ) = | |
| 2049 | - actioner(conn,targ,asp,action,extra_ops,[], form_name). | |
| 2050 | - | |
| 2051 | -public define HTML_Off_Form | |
| 2052 | - actioner | |
| 2053 | - ( | |
| 2054 | - Actioner_Aspect asp, | |
| 2055 | - WEB_Action_Name action, | |
| 2056 | - List((String,String)) extra_ops | |
| 2057 | - ) = | |
| 2058 | - actioner(same, same, asp, action, extra_ops, []). | |
| 2059 | - | |
| 2060 | -public define HTML_Off_Form | |
| 2061 | - actioner | |
| 2062 | - ( | |
| 2063 | - Actioner_Aspect asp, | |
| 2064 | - WEB_Action_Name action, | |
| 2065 | - List((String,String)) extra_ops, | |
| 2066 | - String form_name | |
| 2067 | - ) = | |
| 2068 | - actioner(same, same, asp, action, extra_ops, [], form_name). | |
| 2069 | - | |
| 2070 | -public define HTML_Off_Form | |
| 2071 | -/* Older call with String as action instead of WEB_Action_Name. | |
| 2072 | - * This function exists only for compatibility with older project. | |
| 2073 | - * Please condiser to use above function instead | |
| 2074 | - */ | |
| 2075 | - actioner | |
| 2076 | - ( | |
| 2077 | - Actioner_Connection conn, | |
| 2078 | - Actioner_Target targ, | |
| 2079 | - Actioner_Aspect asp, | |
| 2080 | - String action, | |
| 2081 | - List((String,String)) extra_ops, | |
| 2082 | - List(Actioner_Local_Action) local_actions | |
| 2083 | - )= | |
| 2084 | - actioner(conn,targ,asp,action_name(action),extra_ops,local_actions) | |
| 2085 | -. | |
| 2086 | - | |
| 2087 | -public define HTML_Off_Form | |
| 2088 | -/* Older call with String as action instead of WEB_Action_Name. | |
| 2089 | - * This function exists only for compatibility with older project. | |
| 2090 | - * Please condiser to use above function instead | |
| 2091 | - */ | |
| 2092 | - actioner | |
| 2093 | - ( | |
| 2094 | - Actioner_Connection conn, | |
| 2095 | - Actioner_Target targ, | |
| 2096 | - Actioner_Aspect asp, | |
| 2097 | - String action, | |
| 2098 | - List((String,String)) extra_ops, | |
| 2099 | - List(Actioner_Local_Action) local_actions, | |
| 2100 | - String form_name | |
| 2101 | - )= | |
| 2102 | - actioner(conn, targ, asp, action_name(action), extra_ops, local_actions, form_name) | |
| 2103 | -. | |
| 2104 | - | |
| 2105 | -public define HTML_Off_Form | |
| 2106 | -/* Older call with String as action instead of WEB_Action_Name. | |
| 2107 | - * This function exists only for compatibility with older project. | |
| 2108 | - * Please condiser to use above function instead | |
| 2109 | - */ | |
| 2110 | - actioner | |
| 2111 | - ( | |
| 2112 | - Actioner_Connection conn, | |
| 2113 | - Actioner_Target targ, | |
| 2114 | - Actioner_Aspect asp, | |
| 2115 | - String action, | |
| 2116 | - List((String,String)) extra_ops | |
| 2117 | - )= | |
| 2118 | - actioner(conn,targ,asp,action_name(action),extra_ops,[]) | |
| 2119 | -. | |
| 2120 | - | |
| 2121 | -public define HTML_Off_Form | |
| 2122 | -/* Older call with String as action instead of WEB_Action_Name. | |
| 2123 | - * This function exists only for compatibility with older project. | |
| 2124 | - * Please condiser to use above function instead | |
| 2125 | - */ | |
| 2126 | - actioner | |
| 2127 | - ( | |
| 2128 | - Actioner_Connection conn, | |
| 2129 | - Actioner_Target targ, | |
| 2130 | - Actioner_Aspect asp, | |
| 2131 | - String action, | |
| 2132 | - List((String,String)) extra_ops, | |
| 2133 | - String form_name | |
| 2134 | - )= | |
| 2135 | - actioner(conn, targ, asp, action_name(action), extra_ops, [], form_name) | |
| 2136 | -. | |
| 2137 | - | |
| 2138 | -//public define HTML_Off_Form | |
| 2139 | -// table | |
| 2140 | -// ( | |
| 2141 | -// List(HTML_Row(HTML_Off_Form)) rows | |
| 2142 | -// )= | |
| 2143 | -// table([], empty, rows,empty) | |
| 2144 | -//. | |
| 2145 | - | |
| 2146 | -//public define HTML_Off_Form | |
| 2147 | -// table | |
| 2148 | -// ( | |
| 2149 | -// List(Table_Option) options, | |
| 2150 | -// List(HTML_Row(HTML_Off_Form)) rows | |
| 2151 | -// ) = | |
| 2152 | -// table(options,empty,rows,empty) | |
| 2153 | -//. | |
| 2154 | - | |
| 2155 | -//public define HTML_Off_Form | |
| 2156 | -// table | |
| 2157 | -// ( | |
| 2158 | -// Table_Option option, | |
| 2159 | -// HTML_Row(HTML_Off_Form) row | |
| 2160 | -// ) = | |
| 2161 | -// table([option], empty, [row], empty) | |
| 2162 | -//. | |
| 2163 | -// | |
| 2164 | -//public define HTML_Off_Form | |
| 2165 | -// table | |
| 2166 | -// ( | |
| 2167 | -// HTML_Header_Row(HTML_Off_Form) h_row, | |
| 2168 | -// List(HTML_Row(HTML_Off_Form)) rows | |
| 2169 | -// ) = | |
| 2170 | -// table([],h_row,rows,empty) | |
| 2171 | -//. | |
| 2172 | - | |
| 2173 | -//public define HTML_Off_Form | |
| 2174 | -// table | |
| 2175 | -// ( | |
| 2176 | -// List(Table_Option) options, | |
| 2177 | -// HTML_Header_Row(HTML_Off_Form) h_row, | |
| 2178 | -// List(HTML_Row(HTML_Off_Form)) rows | |
| 2179 | -// ) = | |
| 2180 | -// table(options,h_row,rows,empty) | |
| 2181 | -//. | |
| 2182 | - | |
| 2183 | -//public define HTML_Off_Form | |
| 2184 | -// table | |
| 2185 | -// ( | |
| 2186 | -// Table_Option option, | |
| 2187 | -// HTML_Header_Row(HTML_Off_Form) h_row, | |
| 2188 | -// List(HTML_Row(HTML_Off_Form)) rows | |
| 2189 | -// ) = | |
| 2190 | -// table([option], h_row, rows,empty) | |
| 2191 | -//. | |
| 2192 | - | |
| 2193 | - We add two convenience functions for 'row'. The reason why we add two functions, one | |
| 2194 | - for 'HTML_In_Form' and one for 'HTML_Off_Form', is that adding a schema with an | |
| 2195 | - arbitrary '$T' creates too many ambiguities. This is due to the fact that, if we do so, | |
| 2196 | - the arguments of the function do not refer to any of the types defined here. | |
| 2197 | - | |
| 2198 | -public define HTML_Row(HTML_In_Form) | |
| 2199 | - row | |
| 2200 | - ( | |
| 2201 | - HTML_In_Form content | |
| 2202 | - ) = | |
| 2203 | - row([],[cell([],content)]). | |
| 2204 | - | |
| 2205 | -public define HTML_Row(HTML_Off_Form) | |
| 2206 | - row | |
| 2207 | - ( | |
| 2208 | - HTML_Off_Form content | |
| 2209 | - ) = | |
| 2210 | - row([],[cell([],content)]). | |
| 2211 | - | |
| 2212 | -//public define HTML_Cell(HTML_Off_Form) | |
| 2213 | -// cells_to_column_in_cell | |
| 2214 | -// ( | |
| 2215 | -// List(HTML_Cell(HTML_Off_Form)) cells | |
| 2216 | -// )= | |
| 2217 | -// cell( | |
| 2218 | -// table( | |
| 2219 | -// map( (HTML_Cell(HTML_Off_Form) current_cell) |-> row(current_cell), cells) | |
| 2220 | -// )). | |
| 2221 | - | |
| 2222 | -//public define HTML_Off_Form | |
| 2223 | -// cells_to_line | |
| 2224 | -// ( | |
| 2225 | -// List(HTML_Off_Form) cells | |
| 2226 | -// )= | |
| 2227 | -// table([row( | |
| 2228 | -// map (((HTML_Off_Form) current_cell) |-> cell(current_cell), cells))]) | |
| 2229 | -// . | |
| 2230 | - | |
| 2231 | -public define HTML_Off_Form | |
| 2232 | - private_download | |
| 2233 | - ( | |
| 2234 | - String abs_path, | |
| 2235 | - String name, | |
| 2236 | - String extra_ext | |
| 2237 | - ) = | |
| 2238 | - private_download(abs_path,name,extra_ext,failure). | |
| 2239 | - | |
| 2240 | - | |
| 2241 | -public define HTML_Off_Form | |
| 2242 | - private_download | |
| 2243 | - ( | |
| 2244 | - String abs_path, | |
| 2245 | - String name, | |
| 2246 | - String extra_ext, | |
| 2247 | - String action_name, | |
| 2248 | - List((String,String)) args | |
| 2249 | - ) = | |
| 2250 | - private_download(abs_path,name,extra_ext,success((action_name,args))). | |
| 2251 | - | |
| 2252 | -. | |
| 2253 | - | |
| 2254 | - | |
| 2255 | - | |
| 2256 | -public define HTML_In_Form | |
| 2257 | - hr | |
| 2258 | - = | |
| 2259 | - hr([]) | |
| 2260 | -. | |
| 2261 | - | |
| 2262 | -public define HTML_In_Form | |
| 2263 | - button | |
| 2264 | - ( | |
| 2265 | - List(HTML_In_Form) elements | |
| 2266 | - )= | |
| 2267 | - button([], elements) | |
| 2268 | -. | |
| 2269 | - | |
| 2270 | -public define HTML_In_Form | |
| 2271 | - button | |
| 2272 | - ( | |
| 2273 | - List(CoreAttrs) attrs, | |
| 2274 | - HTML_In_Form element | |
| 2275 | - )= | |
| 2276 | - button(attrs, [element]) | |
| 2277 | -. | |
| 2278 | - | |
| 2279 | -public define HTML_In_Form | |
| 2280 | - button | |
| 2281 | - ( | |
| 2282 | - HTML_In_Form element | |
| 2283 | - )= | |
| 2284 | - button([], [element]) | |
| 2285 | -. | |
| 2286 | - - Cell a gap between two other cells : | |
| 2287 | - | |
| 2288 | -public define HTML_Cell(HTML_Off_Form) | |
| 2289 | - width_gap | |
| 2290 | - ( | |
| 2291 | - Int w | |
| 2292 | - )= | |
| 2293 | - cell([width(w)], empty). | |
| 2294 | - | |
| 2295 | -public define HTML_Cell(HTML_In_Form) | |
| 2296 | - width_gap | |
| 2297 | - ( | |
| 2298 | - Int w | |
| 2299 | - )= | |
| 2300 | - cell([width(w)],empty) | |
| 2301 | -. | |
| 2302 | - - Row a gap between two other rows : | |
| 2303 | - | |
| 2304 | -public define HTML_Row(HTML_Off_Form) | |
| 2305 | - height_gap | |
| 2306 | - ( | |
| 2307 | - Int h | |
| 2308 | - )= | |
| 2309 | - row([],[cell([height(h)],empty)]). | |
| 2310 | - | |
| 2311 | -public define HTML_Row(HTML_In_Form) | |
| 2312 | - height_gap | |
| 2313 | - ( | |
| 2314 | - Int h | |
| 2315 | - )= | |
| 2316 | - row([],[cell([height(h)],empty)]) | |
| 2317 | -. | |
| 2318 | - | |
| 2319 | - | |
| 2320 | - Notice that the two types have alternatives in common (same name, same arguments types, | |
| 2321 | - up to the value of the parameter $T), which correspond to elements which may be put | |
| 2322 | - anywhere in the page. | |
| 2323 | - | |
| 2324 | -public define HTML_Partial_Content | |
| 2325 | - partial_content | |
| 2326 | - ( | |
| 2327 | - List(HTML_Head_Tag) tags, | |
| 2328 | - List(HTML_Off_Form) content | |
| 2329 | - )= | |
| 2330 | - partial_content(tags, sequence(content)). | |
| 2331 | - | |
| 2332 | -public define HTML_Partial_Content | |
| 2333 | - partial_content | |
| 2334 | - ( | |
| 2335 | - HTML_Off_Form content | |
| 2336 | - )= | |
| 2337 | - partial_content([], content). | |
| 2338 | - | |
| 2339 | -public define HTML_Partial_Content | |
| 2340 | - partial_content | |
| 2341 | - ( | |
| 2342 | - List(HTML_Off_Form) content | |
| 2343 | - )= | |
| 2344 | - partial_content([], sequence(content)). | |
| 2345 | - | |
| 2346 | -public define HTML_Partial_Content | |
| 2347 | - partial_content | |
| 2348 | - ( | |
| 2349 | - List(HTML_Head_Tag) tags, | |
| 2350 | - HTML_Partial_Content p_content | |
| 2351 | - )= | |
| 2352 | - if p_content is partial_content(ptags, html) then | |
| 2353 | - partial_content(tags + ptags, html). | |
| 2354 | - | |
| 2355 | -define HTML_Partial_Content | |
| 2356 | - list_to_pcontent | |
| 2357 | - ( | |
| 2358 | - List(HTML_Partial_Content) l_p_content, | |
| 2359 | - List(HTML_Head_Tag) so_far_tags, | |
| 2360 | - List(HTML_Off_Form) so_far_html | |
| 2361 | - )= | |
| 2362 | - if l_p_content is | |
| 2363 | - { | |
| 2364 | - [] then partial_content(so_far_tags, sequence(reverse(so_far_html))), | |
| 2365 | - [h . t] then | |
| 2366 | - //extract resurgent type and symbols of h | |
| 2367 | - if h is partial_content(tags, html) then | |
| 2368 | - list_to_pcontent(t, so_far_tags + tags, [html . so_far_html]) | |
| 2369 | - }. | |
| 2370 | - | |
| 2371 | -public define HTML_Partial_Content | |
| 2372 | - partial_content | |
| 2373 | - ( | |
| 2374 | - List(HTML_Partial_Content) l_p_content | |
| 2375 | - )= | |
| 2376 | - list_to_pcontent(l_p_content, [], []). | |
| 2377 | - | |
| 2378 | -public define HTML_Partial_Content | |
| 2379 | - partial_empty | |
| 2380 | - = | |
| 2381 | - partial_content(empty) | |
| 2382 | -. | |
| 2383 | - | |
| 2384 | -define String | |
| 2385 | - format | |
| 2386 | - ( | |
| 2387 | - List(Text_Option) l | |
| 2388 | - ). | |
| 2389 | - | |
| 2390 | - | |
| 2391 | - | |
| 2392 | - | |
| 2393 | -define Printable_tree | |
| 2394 | - format_css_styles | |
| 2395 | - ( | |
| 2396 | - List(CSS_Style) l | |
| 2397 | - ) = | |
| 2398 | - if l is | |
| 2399 | - { | |
| 2400 | - [ ] then [ ], | |
| 2401 | - [h . t] then | |
| 2402 | - [ if h is | |
| 2403 | - { | |
| 2404 | - text_options(tos) then | |
| 2405 | - [" body, span, p { ", format(tos), " }\n" ] | |
| 2406 | - } | |
| 2407 | - . format_css_styles(t)] | |
| 2408 | - }. | |
| 2409 | - | |
| 2410 | - | |
| 2411 | - | |
| 2412 | - | |
| 2413 | - | |
| 2414 | - Meta tags are put in the 'head' of the HTML page. | |
| 2415 | - | |
| 2416 | -public define HTML_Meta | |
| 2417 | - refresh | |
| 2418 | - ( | |
| 2419 | - Actioner_Connection connection, | |
| 2420 | - Actioner_Target target, | |
| 2421 | - String action, | |
| 2422 | - Int delay | |
| 2423 | - )= | |
| 2424 | - refresh(connection, target, action_name(action), delay) | |
| 2425 | -. | |
| 2426 | - | |
| 2427 | - | |
| 2428 | - | |
| 2429 | - | |
| 2430 | - | |
| 2431 | - | |
| 2432 | - | |
| 2433 | - | |
| 2434 | -public define HTTP_Answer | |
| 2435 | - html_page | |
| 2436 | - ( | |
| 2437 | - String title, | |
| 2438 | - List(HTML_Head_Tag) head_tags, | |
| 2439 | - HTML_Body body | |
| 2440 | - )= | |
| 2441 | - html_page(http_ok, title, head_tags,[],[],[],[],body). | |
| 2442 | - | |
| 2443 | -public define HTTP_Answer | |
| 2444 | - html_page | |
| 2445 | - ( | |
| 2446 | - String title, | |
| 2447 | - List(HTML_Head_Tag) head_tags, | |
| 2448 | - List(CSS_Style) styles, | |
| 2449 | - HTML_Body body | |
| 2450 | - )= | |
| 2451 | - html_page(http_ok, title, head_tags, styles, [], [], [], body). | |
| 2452 | - | |
| 2453 | -public define HTTP_Answer | |
| 2454 | - web_controller_error_page | |
| 2455 | - ( | |
| 2456 | - String name | |
| 2457 | - ) | |
| 2458 | - = | |
| 2459 | - html_page | |
| 2460 | - ( | |
| 2461 | - name+" Controller error", // title of web site | |
| 2462 | - [], // list of 'META' tags (empty for this site) | |
| 2463 | - body // body of page | |
| 2464 | - ( | |
| 2465 | - // list of body options | |
| 2466 | - [ | |
| 2467 | - //background_color(rgb(255,200,200)) | |
| 2468 | - // add more body options here | |
| 2469 | - ], | |
| 2470 | - | |
| 2471 | - // content of page | |
| 2472 | - text(name+" Controller error") | |
| 2473 | - ) | |
| 2474 | - ) | |
| 2475 | -. | |
| 2476 | - | |
| 2477 | - | |
| 2478 | - 'HTTP_Answer' represents the final product of the construction of a web page. | |
| 2479 | - | |
| 2480 | - | |
| 2481 | - | |
| 2482 | - | |
| 2483 | - *** (3.2) ``in form'' versus ``off form''. | |
| 2484 | - | |
| 2485 | - There is a variety of HTML elements: texts, buttons, links, forms, inputs, etc... Some | |
| 2486 | - of them may have a content, which is yet another HTML element (or several). Hence, it | |
| 2487 | - is meaningful to say that an element is 'within' another one. Now, putting any element | |
| 2488 | - within any other one may be meaningless. For example, an input element must be put | |
| 2489 | - within a form (otherwise, it is useless), and a from within another form has no precise | |
| 2490 | - meaning (and is forbidden by the HTML specification). | |
| 2491 | - | |
| 2492 | - Actually, the main criterium is ``within a form or not within a form''. So, HTML | |
| 2493 | - elements in a given page are separated into two categories: those who are within a | |
| 2494 | - form, and the others. Nevertheless, there are elements which may belong to both | |
| 2495 | - categories, like images and texts. We want to make use of the strong typing mecanism of | |
| 2496 | - Anubis in order to forbid non meaningful placement of elements. | |
| 2497 | - | |
| 2498 | - The type 'HTML_In_Form' defines elements to be put within forms. Similarly, | |
| 2499 | - 'HTML_Off_Form' defines elements not to be put within forms. Both types are recursive, | |
| 2500 | - and 'HTML_Off_Form' refers to 'HTML_In_Form' (via the 'form' alternative, of course), | |
| 2501 | - but the two types are not cross recursive. This is the reason why it is impossible to | |
| 2502 | - put a form within a form. In order to construct a web page, you essentially have to | |
| 2503 | - produce a datum of type 'HTML_Off_Form' (maybe containing data of type 'HTML_In_Form'). | |
| 2504 | - | |
| 2505 | - In practice, you don't have to worry so much about these two types, because elements | |
| 2506 | - which may be put anywhere are constructed for both types by functions with the same | |
| 2507 | - name and the same arguments. Hence, for both types, you just write the same thing. You | |
| 2508 | - are warned by the compiler only when you try to put an element at a place it is not | |
| 2509 | - allowed. | |
| 2510 | - | |
| 2511 | - | |
| 2512 | - | |
| 2513 | - *** (3.3) Defining your own style. | |
| 2514 | - | |
| 2515 | - We provide generic tools for constructing HTML elements. However, your web site needs | |
| 2516 | - to have a ``style''. | |
| 2517 | - | |
| 2518 | - To that end, you need to write down a set of ``styling functions'', using the tools | |
| 2519 | - defined here. These styling functions allow the introduction of your colors and other | |
| 2520 | - visual characteristics into the constructed elements once and for all. For example, you | |
| 2521 | - may want all your texts to be rendered in the ``Helvetica'' font, in size 14 and using | |
| 2522 | - some 'text_color'. You may write something like this: | |
| 2523 | - | |
| 2524 | - define RGB text_color = rgb(10,40,40). | |
| 2525 | - | |
| 2526 | - define HTML_Off_Form | |
| 2527 | - text | |
| 2528 | - ( | |
| 2529 | - String the_text | |
| 2530 | - ) = | |
| 2531 | - text([font("helvetica"),size(14),color(text_color)], | |
| 2532 | - the_text). | |
| 2533 | - | |
| 2534 | - (and the same one for type 'HTML_In_Form') so that in order to put a piece of text in a | |
| 2535 | - page, you just write: | |
| 2536 | - | |
| 2537 | - text("... some text ...") | |
| 2538 | - | |
| 2539 | - and you don't have to provide the font, size and color for each text. If you want to | |
| 2540 | - have several styles of text presentation, you just write several sets of such | |
| 2541 | - convenience functions. This also suggests a trick. You may want for example different | |
| 2542 | - colors for 'in form' texts and 'off form' texts. This may be achieved automatically by | |
| 2543 | - defining two functions as above, with the same name and same argument type, but | |
| 2544 | - returning either a 'HTML_In_Form' or a 'HTML_Off_Form'. | |
| 2545 | - | |
| 2546 | - If this preliminary work is well done, you will not waste your time later when you | |
| 2547 | - concentrate on the actual informational content of your pages. | |
| 2548 | - | |
| 2549 | - This general principle should be applied to all sorts of elements. This is the best | |
| 2550 | - thing to do in order to separate the functions defining the visual style from the | |
| 2551 | - functions defining the informational content itself, so that changing the style without | |
| 2552 | - changing the content becomes easy. This is also the best way for having a clean and | |
| 2553 | - easily readable source for your web site. | |
| 2554 | - | |
| 2555 | - | |
| 2556 | - | |
| 2557 | - | |
| 2558 | - | |
| 2559 | - *** (3.4) Actioners and forms. | |
| 2560 | - | |
| 2561 | - We have gathered several notions from HTML into that of an 'actioner'. An actioner is | |
| 2562 | - an HTML element which opens a connection to our server when clicked upon. Actioners may | |
| 2563 | - have different visual aspects. They may look like hypertext links or like buttons | |
| 2564 | - (rollovers), or even like selectors (with immediate action). In any case, their | |
| 2565 | - behavior is the same: they open a connection to our server, and send a set of 'web | |
| 2566 | - arguments', i.e. pairs 'name=value'. Among these web arguments, one of them denotes | |
| 2567 | - the action to be performed, and the others should be considered as operands for this | |
| 2568 | - action. Actually, the precise behavior of the actioner has several variants. | |
| 2569 | - | |
| 2570 | - The connection with the server may be secured (HTTPS) or non secured (HTTP). See the | |
| 2571 | - type 'Actioner_Connection' above. | |
| 2572 | - | |
| 2573 | - You must also choose where the answer must be rendered. This may be in the same window | |
| 2574 | - or in another window (or frame). If it is in another window, the name of that window | |
| 2575 | - must be given. If the window does not exist, the browser will create it. Optionally, | |
| 2576 | - you may give the dimensions of the new window and other characteristics. See the type | |
| 2577 | - 'Actioner_Target' above. | |
| 2578 | - | |
| 2579 | - The actioner also has a visual aspect. See the type 'Actioner_Aspect' above. In the | |
| 2580 | - case of a rollover button, you provide the URLs of two images (of the same size) | |
| 2581 | - representing the button: | |
| 2582 | - | |
| 2583 | - url_off: to be used when the mouse is not over the button, | |
| 2584 | - url_on: to be used when the mouse is over the button. | |
| 2585 | - | |
| 2586 | - You can also create rollover buttons without creating images. Just use the second | |
| 2587 | - alternative named 'button'. The server creates the images automatically. | |
| 2588 | - | |
| 2589 | - The purpose of forms is just to give operands to actioners. If the actioner is placed | |
| 2590 | - within a form, all the input elements which are within this form provide operands to | |
| 2591 | - the actioner (except sometimes when they are not set by the client). If it is not put | |
| 2592 | - within a form, the actioner gets no operand, except if the name of a form is explicitly | |
| 2593 | - given, in which case the actioner gets all the inputs from that form as | |
| 2594 | - operands. Furthermore, you may want to give extra operands to the actioner. This may be | |
| 2595 | - useful for separating families of actioners with the same action name. Extra operands | |
| 2596 | - 'name=value' must be given in the form of pairs '(name,value)'. | |
| 2597 | - | |
| 2598 | - Notice that the name of a form may be used by an actioner which is off the form, so as | |
| 2599 | - to get the operands provided by this form. Also notice that several actioners may refer | |
| 2600 | - to the same form, being either in the form, or referring to the form from the | |
| 2601 | - outside. These actioners simply get the same set of operands, even if they correspond | |
| 2602 | - to distinct actions. | |
| 2603 | - | |
| 2604 | - Input elements may be put only within a form. | |
| 2605 | - | |
| 2606 | - | |
| 2607 | - | |
| 2608 | - *** (3.5) Local popup. | |
| 2609 | - | |
| 2610 | - This element looks like a link or a rollover button. When this button is clicked upon, | |
| 2611 | - a 'popup window' appears. Actually, this popup window is just a layer in the same HTML | |
| 2612 | - page, which becomes suddenly visible. It is realized with a '<div>' HTML tag. In | |
| 2613 | - particular, clicking on the button does not open any connection. This is why it is | |
| 2614 | - called 'local'. The arguments have the following roles: | |
| 2615 | - | |
| 2616 | - Actioner_Aspect aspect of the button (same semantics as for actioners) | |
| 2617 | - content content of the popup window | |
| 2618 | - x, y, position of the popup window on the HTML page (not relative | |
| 2619 | - to the button but to the page itself) | |
| 2620 | - title title of the popup window | |
| 2621 | - color color of the title bar and close button in the popup window. | |
| 2622 | - A lightened version of this color is used for the background | |
| 2623 | - of the popup window. | |
| 2624 | - width width of the title bar | |
| 2625 | - | |
| 2626 | - | |
| 2627 | - | |
| 2628 | - | |
| 2629 | - | |
| 2630 | - --- That's all for the public part ! -------------------------------------------------- | |
| 2631 | - | |
| 2632 | - | |
| 2633 | - | |
| 2634 | - | |
| 2635 | - | |
| 2636 | - ----------------------------------- Table of Contents --------------------------------- | |
| 2637 | - | |
| 2638 | - *** [1] States. | |
| 2639 | - *** [1.1] Saving and retrieving states. | |
| 2640 | - *** [1.2] Deleting out of date states. | |
| 2641 | - | |
| 2642 | - *** [2] Sessions. | |
| 2643 | - *** [2.1] Saving and retrieving sessions. | |
| 2644 | - *** [2.2] Deleting out of date sessions. | |
| 2645 | - | |
| 2646 | - *** [3] Tools. | |
| 2647 | - *** [3.1] Directories. | |
| 2648 | - *** [3.2] Secondary documents. | |
| 2649 | - | |
| 2650 | - *** [4] Managing web arguments. | |
| 2651 | - *** [3.1] Prefixing web arguments names. | |
| 2652 | - *** [3.2] Separating web arguments. | |
| 2653 | - *** [3.3] Applying an action. | |
| 2654 | - | |
| 2655 | - *** [5] Web site descriptions and the 'awp handlers'. | |
| 2656 | - *** [4.1] The type 'Web_Site'. | |
| 2657 | - *** [4.2] Making a web site description. | |
| 2658 | - *** [4.3] Starting the servers. | |
| 2659 | - | |
| 2660 | - *** [6] HTML Formating. | |
| 2661 | - *** [5.1] The type 'HTML_Any($T)'. | |
| 2662 | - *** [5.2] Formating a color. | |
| 2663 | - *** [5.3] Creating buttons. | |
| 2664 | - *** [5.4] Formating an actioner. | |
| 2665 | - *** [5.5] Formating a private download link. | |
| 2666 | - *** [5.6] Formating rows and cells in a table. | |
| 2667 | - *** [5.7] Formating elements which may be put anywhere. | |
| 2668 | - *** [5.8] Formating 'in form' elements. | |
| 2669 | - *** [5.9] Formating 'off form' elements. | |
| 2670 | - *** [5.10] Formating meta-tags. | |
| 2671 | - | |
| 2672 | - --------------------------------------------------------------------------------------- | |
| 2673 | -public type CommonInfo:... | |
| 2674 | - | |
| 2675 | -define Printable_tree | |
| 2676 | - format | |
| 2677 | - ( | |
| 2678 | - CommonInfo cinfo, | |
| 2679 | - Var(Int) ic_v, // 'idnum' counter variable | |
| 2680 | - HTML_Off_Form element, | |
| 2681 | - Bool is_https, | |
| 2682 | - Var(Int) action_count, | |
| 2683 | - Var(List(HTML_Head_Tag)) head_tags | |
| 2684 | - ). | |
| 2685 | - | |
| 2686 | -public define String | |
| 2687 | - doctype_w3c_header | |
| 2688 | - = | |
| 2689 | - "<!DOCTYPE html>\n". //html 5 | |
| 2690 | - | |
| 2691 | - | |
| 2692 | - *** [1] States. | |
| 2693 | - | |
| 2694 | - We have to define functions for saving a state, retrieving a state, deleting out of | |
| 2695 | - date states. We need one such function per web site. The types of the first two | |
| 2696 | - functions depend on the parameter $State. This is not the case of the third one. The | |
| 2697 | - fact that the instance of $State is variable from one web sites to the other implies | |
| 2698 | - rather subtle manipulations using full functionality. | |
| 2699 | - | |
| 2700 | - | |
| 2701 | - *** [1.1] Saving and retrieving states. | |
| 2702 | - | |
| 2703 | - Each state is saved into a file on the server's disk (in the directory represented by | |
| 2704 | - the symbol 'state_directory', which is 'my_anubis/web_sites/common_name/states'). The | |
| 2705 | - state is saved together with a time stamp whose value is obtained by adding the current | |
| 2706 | - time to the given timeout for states. The state receives a name obtained by hashing | |
| 2707 | - (using sha1) the content of the file itself, and then encoding the hash with | |
| 2708 | - 'web_arg_encode'. The name of the file into which the state is saved is the | |
| 2709 | - concatenation of "s" and the name of the state. | |
| 2710 | - | |
| 2711 | -read web_arg_encode.anubis | |
| 2712 | - | |
| 2713 | - The tool below constructs the function which is able to save a state on the server's | |
| 2714 | - disk. | |
| 2715 | - | |
| 2716 | - | |
| 2717 | -define ($State s) -> String // the function constructed returns the name of the state | |
| 2718 | - make_save_state_function | |
| 2719 | - ( | |
| 2720 | - Int timeout, | |
| 2721 | - String state_directory, | |
| 2722 | - (LogLevel, String) -> One logger | |
| 2723 | - )= | |
| 2724 | - ($State s) |-> | |
| 2725 | - with time_stamp = now+timeout, | |
| 2726 | - to_be_saved = (time_stamp,s), | |
| 2727 | - state_name = to_ascii(sha1(s)), | |
| 2728 | - //println("make_save_state_function " + state_directory+"/s"+state_name); | |
| 2729 | - if save(to_be_saved,state_directory+"/s"+state_name) is ok then | |
| 2730 | - state_name | |
| 2731 | - else | |
| 2732 | - logger(logError, "Cannot create state file in '"+state_directory+"'.\n"); | |
| 2733 | - "" | |
| 2734 | -. | |
| 2735 | - | |
| 2736 | - | |
| 2737 | - When a request arrives, we need to retrieve the previous state from the server's | |
| 2738 | - disk. We receive the name of that state. If the state is out of date, the state file is | |
| 2739 | - kept 3 days, and then deleted. | |
| 2740 | - | |
| 2741 | -type PreviousState($State): | |
| 2742 | - not_found, // cannot retrieve the previous state | |
| 2743 | - out_of_date($State), // the previous state is out of date | |
| 2744 | - still_valid($State). // the previous state is still valid | |
| 2745 | - | |
| 2746 | -define (String state_name) -> PreviousState($State) | |
| 2747 | - make_retrieve_state_function | |
| 2748 | - ( | |
| 2749 | - String state_directory | |
| 2750 | - ) = | |
| 2751 | - (String state_name) |-> | |
| 2752 | - with file_path = state_directory+"/s"+state_name, | |
| 2753 | - if (RetrieveResult((Int,$State)))retrieve(file_path) is ok(d) | |
| 2754 | - then ( | |
| 2755 | - if d is (time_stamp,s) then | |
| 2756 | - if time_stamp < now | |
| 2757 | - then ( | |
| 2758 | - forget(remove(file_path)); | |
| 2759 | - out_of_date(s) | |
| 2760 | - ) | |
| 2761 | - else still_valid(s) // state has been successfully retrieved | |
| 2762 | - ) | |
| 2763 | - else | |
| 2764 | - forget(remove(file_path)); | |
| 2765 | - not_found. | |
| 2766 | - | |
| 2767 | - | |
| 2768 | - | |
| 2769 | - *** [1.2] Deleting out of date states. | |
| 2770 | - | |
| 2771 | - We also need to delete states which are out of date and which will never be deleted by | |
| 2772 | - the above method. This may be performed by a machine doing this periodically (say once | |
| 2773 | - per states life time period). | |
| 2774 | - | |
| 2775 | -define (List(String) file_names) -> One | |
| 2776 | - make_delete_out_of_date_states_function | |
| 2777 | - ( | |
| 2778 | - Maybe($State) dummy, | |
| 2779 | - String state_directory | |
| 2780 | - )= | |
| 2781 | - (List(String) file_names) |-df-> | |
| 2782 | - if file_names is | |
| 2783 | - { | |
| 2784 | - [ ] then unique, | |
| 2785 | - [h . t] then | |
| 2786 | - //we can't delete the "." and ".." file. So go to next file in the list | |
| 2787 | - if h = "." | h = ".." then | |
| 2788 | - df(t) | |
| 2789 | - else | |
| 2790 | - with file_path = state_directory+"/"+h, | |
| 2791 | - if (RetrieveResult((Int,$State)))retrieve(file_path) is ok(d) | |
| 2792 | - then ( | |
| 2793 | - if d is (time_stamp,data) then | |
| 2794 | - if time_stamp < now | |
| 2795 | - then (forget(remove(file_path)); df(t)) | |
| 2796 | - else df(t) | |
| 2797 | - ) | |
| 2798 | - else (forget(remove(file_path)); df(t)) | |
| 2799 | - } | |
| 2800 | -. | |
| 2801 | - | |
| 2802 | - | |
| 2803 | - The 'labelled arrow' |-df-> is documented in 'documentation/en/anubis_doc.txt'. | |
| 2804 | - | |
| 2805 | - Note: The argument 'dummy' (of type Maybe($State)) is not used in the body of the | |
| 2806 | - function (hence its name). Nevertheless, it is required. Indeed, the Anubis compiler | |
| 2807 | - does not accept a parameter in the body of a function (here the parameter is required | |
| 2808 | - by the use of 'retrieve') if this parameter does not appear in the type of the | |
| 2809 | - function. This is because this would create ambiguities that no explicit typing may | |
| 2810 | - ever resolve. If you put a double slash in front of the declaration of 'dummy' above, | |
| 2811 | - and if you compile this file, you will get a message like this one: | |
| 2812 | - | |
| 2813 | - Error in 'making_a_web_site.anubis', line 1300, column 7: | |
| 2814 | - A definition may not contain parameters which are not present | |
| 2815 | - in the declaration part (hidden parameters): | |
| 2816 | - $State | |
| 2817 | - | |
| 2818 | - The type of the function constructed by 'make_delete_out_of_date_states_function' is | |
| 2819 | - independant of the parameter $State. This is important because this allows to create | |
| 2820 | - the list of such functions for all web sites. From this list, it is possible to call | |
| 2821 | - the functions one after the other, so deleting out of date states for all web | |
| 2822 | - sites. Actually, the next function receives a list of pairs (state_directory,function), | |
| 2823 | - one for each web site. | |
| 2824 | - | |
| 2825 | -define One | |
| 2826 | - delete_out_of_date_states // for all web sites | |
| 2827 | - ( | |
| 2828 | - List((String, List(String) -> One)) directories_and_functions | |
| 2829 | - ) = | |
| 2830 | - if directories_and_functions is | |
| 2831 | - { | |
| 2832 | - [ ] then unique, | |
| 2833 | - [h . t] then if h is (state_directory,function) then | |
| 2834 | - function(directory_list(state_directory,"*")); | |
| 2835 | - delete_out_of_date_states(t) | |
| 2836 | - }. | |
| 2837 | - | |
| 2838 | - | |
| 2839 | - The above function must be called periodically in a separate virtual machine. The | |
| 2840 | - period we have choosen is (rather logically) the life time of states itself. This may | |
| 2841 | - be achieved by an 'infinite' loop, using a 'sleep(timeout)'. However, the loop must not | |
| 2842 | - be really infinite, because the servers may be shutdown. Hence, our loop must test | |
| 2843 | - (rather frequently; say every second) if the servers are down. If they are, the loop | |
| 2844 | - must be exited. | |
| 2845 | - | |
| 2846 | -define One | |
| 2847 | - delete_states_loop | |
| 2848 | - ( | |
| 2849 | - List((String,List(String) -> One)) directories_and_functions, | |
| 2850 | - Int timeout, | |
| 2851 | - Int next_time, | |
| 2852 | - Server http_server, | |
| 2853 | - Server https_server, | |
| 2854 | - (One) -> Bool shutdown_required | |
| 2855 | - ) = | |
| 2856 | - if shutdown_required(unique) | |
| 2857 | - then (shutdown(http_server); shutdown(https_server)) | |
| 2858 | - else unique; | |
| 2859 | - if (is_down(http_server) & is_down(https_server)) | |
| 2860 | - then unique | |
| 2861 | - else if now > next_time | |
| 2862 | - then | |
| 2863 | - ( | |
| 2864 | - delete_out_of_date_states(directories_and_functions); | |
| 2865 | - delete_states_loop(directories_and_functions, | |
| 2866 | - timeout, | |
| 2867 | - now+timeout, | |
| 2868 | - http_server, | |
| 2869 | - https_server, | |
| 2870 | - shutdown_required) | |
| 2871 | - ) | |
| 2872 | - else | |
| 2873 | - ( | |
| 2874 | - sleep(1000); // sleep just one second and try again | |
| 2875 | - delete_states_loop(directories_and_functions, | |
| 2876 | - timeout, | |
| 2877 | - next_time, | |
| 2878 | - http_server, | |
| 2879 | - https_server, | |
| 2880 | - shutdown_required) | |
| 2881 | - ). | |
| 2882 | - | |
| 2883 | - The above loop must be run in a separate virtual machine. This will be done just after | |
| 2884 | - the two servers are started. | |
| 2885 | - | |
| 2886 | - | |
| 2887 | - | |
| 2888 | - | |
| 2889 | - | |
| 2890 | - *** [2] Tools. | |
| 2891 | - | |
| 2892 | - *** [2.1] Directories. | |
| 2893 | - *** [2.2] Secondary documents. | |
| 2894 | - | |
| 2895 | - Some HTML elements (like '<object>', '<frame>') cannot receive their content directly | |
| 2896 | - from the current document, but only through an URL. For this reason, we implement a | |
| 2897 | - mecanism for creating secondary documents on the fly. To that end we use the 'private | |
| 2898 | - download' mecanism. | |
| 2899 | - | |
| 2900 | - A secondary document is formated by the same functions as the main document itself. The | |
| 2901 | - next function takes an 'off form' element, creates the file containing the secondary | |
| 2902 | - document in HTML format, and returns the URL at which the document will be available. | |
| 2903 | - | |
| 2904 | -define String | |
| 2905 | - create_secondary_document | |
| 2906 | - ( | |
| 2907 | - String sd, // site directory | |
| 2908 | - String as, // authorization_secret | |
| 2909 | - $T -> Printable_tree format_element, | |
| 2910 | - $T content, | |
| 2911 | - HTML_Size width | |
| 2912 | - ) = | |
| 2913 | - with private_download_directory = sd+"/private_download", | |
| 2914 | - hash = web_arg_encode(sha1(content)), | |
| 2915 | - file_content = (Printable_tree) | |
| 2916 | - [doctype_w3c_header, | |
| 2917 | - "<html><body><table ", | |
| 2918 | - if width is | |
| 2919 | - { | |
| 2920 | - absolute(w) then ["width=\"",w-25], | |
| 2921 | - percentage(w) then ["width=\"95%\""] | |
| 2922 | - },"\"><tbody><tr><td align=right>", | |
| 2923 | - format_element(content), | |
| 2924 | - "</td></tr></tbody></table></body></html>" | |
| 2925 | - ], | |
| 2926 | - file_name = "sd"+hash+".html", | |
| 2927 | - file_path = private_download_directory+"/"+file_name, | |
| 2928 | - if write_to_file(file_path,file_content) is | |
| 2929 | - { | |
| 2930 | - cannot_open_file then print("Cannot open file '"+file_path+"'.\n"); "", | |
| 2931 | - write_error(n) then print("Error writing file '"+file_path+"'.\n"); "", | |
| 2932 | - ok then file_name+"?zauth="+ | |
| 2933 | - make_authorization(sd,as,private_download_directory+"/"+file_name) | |
| 2934 | - }. | |
| 2935 | - | |
| 2936 | - | |
| 2937 | - | |
| 2938 | - | |
| 2939 | - *** [2.3] Generating unique ids. | |
| 2940 | - | |
| 2941 | - In order to uniquely name object for JavaScript we generate unique ids from a counter. | |
| 2942 | - | |
| 2943 | -define Int | |
| 2944 | - new_idnum | |
| 2945 | - ( | |
| 2946 | - Var(Int) ic_v // 'idnum' counter variable | |
| 2947 | - ) = | |
| 2948 | - protect | |
| 2949 | - with result = *ic_v+1, | |
| 2950 | - ic_v <- result; | |
| 2951 | - result. | |
| 2952 | - | |
| 2953 | - | |
| 2954 | - | |
| 2955 | - | |
| 2956 | - | |
| 2957 | - | |
| 2958 | - *** [3] Managing web arguments. | |
| 2959 | - | |
| 2960 | - Web arguments are those pairs 'name=value' which are transmitted through the HTTP | |
| 2961 | - protocol. We need precise naming conventions for these web arguments. | |
| 2962 | - | |
| 2963 | - | |
| 2964 | - | |
| 2965 | - *** [3.2] Separating web arguments. | |
| 2966 | - | |
| 2967 | - When a new request arrives, we need to separate the web arguments, that is to say: | |
| 2968 | - | |
| 2969 | - - find the value of "s", and recover the corresponding state, | |
| 2970 | - - find the value of "a", which is the name of the action to be performed, | |
| 2971 | - - get the list of all the remaining web arguments (operands of the action). | |
| 2972 | - | |
| 2973 | - We must also determine if the previous state may be recovered. If it is not the case | |
| 2974 | - (either because the previous state name is invalid, or the previous state is out of | |
| 2975 | - date), we must check if there is an action name. Indeed, the presence of an action name | |
| 2976 | - indicates that the user has clicked on one of our buttons or links. If on the contrary | |
| 2977 | - there is no action name the user has just entered our address in his browser. In this | |
| 2978 | - last case, we must send the first page of our site (maybe a 'login' page), but if there | |
| 2979 | - is an action, we must send a page just saying that the session ticket has expired. If | |
| 2980 | - the previous state is recovered and there is no action, the new state is the same as | |
| 2981 | - the previous state. | |
| 2982 | - | |
| 2983 | - The result of the separation of the web arguments is of type: | |
| 2984 | - | |
| 2985 | -type Separated_Web_Args($State): | |
| 2986 | - swa(PreviousState($State) previous_state, | |
| 2987 | - Maybe(String) action_name, | |
| 2988 | - List(Web_arg) operands). | |
| 2989 | - | |
| 2990 | - | |
| 2991 | - | |
| 2992 | - The next function constructs the function which separates the web arguments. | |
| 2993 | - | |
| 2994 | -define (List(Web_arg) lwa, HTTP_Info info) -> Separated_Web_Args($State) | |
| 2995 | - make_separate_web_args_function | |
| 2996 | - ( | |
| 2997 | - String state_directory, | |
| 2998 | - String -> PreviousState($State) retrieve_state, | |
| 2999 | - String website_name | |
| 3000 | - ) = | |
| 3001 | - (List(Web_arg) lwa, HTTP_Info info) |-swaf-> | |
| 3002 | - if lwa is | |
| 3003 | - { | |
| 3004 | - [ ] then | |
| 3005 | - // | |
| 3006 | - // no web arg found => no previous state and no action | |
| 3007 | - // | |
| 3008 | - //println("find_cookie(\"state_"+website_name+"\", ..."); | |
| 3009 | - if find_cookie("state_"+website_name, server_get_cookies(http_headers(info))) is | |
| 3010 | - { | |
| 3011 | - failure then | |
| 3012 | - //println("find_cookie(\"state_"+website_name+"\" failure"); | |
| 3013 | - swa(not_found,failure,[]), | |
| 3014 | - | |
| 3015 | - success(cookie) then | |
| 3016 | - //println("find_cookie(\"state_"+website_name+"\" success"); | |
| 3017 | - swa(retrieve_state(value(cookie)),failure,[]) | |
| 3018 | - }, | |
| 3019 | - | |
| 3020 | - //swa(failure,failure,[]), | |
| 3021 | - | |
| 3022 | - [wa_1 . wa_others] then | |
| 3023 | - // | |
| 3024 | - // at least one web arg => | |
| 3025 | - // separate other web args, and insert the first one as needed | |
| 3026 | - // | |
| 3027 | - if (Separated_Web_Args($State))swaf(wa_others, info) is | |
| 3028 | - { | |
| 3029 | - swa(ps1, // possible previous state | |
| 3030 | - an1, // maybe an action name | |
| 3031 | - op1) // operands so far | |
| 3032 | - then | |
| 3033 | - if wa_1 is | |
| 3034 | - { | |
| 3035 | - web_arg(n, value) then | |
| 3036 | - with name = if substr(n,0,4) = "amp;" then substr(n, 4, length(n) - 4) else n, | |
| 3037 | - if name = "a" then | |
| 3038 | - swa(ps1,success(value),op1) | |
| 3039 | - else if name = "aws_action" | name = "aws_a" then | |
| 3040 | - swa(ps1,success(value),op1) | |
| 3041 | - //else if name = "t" then | |
| 3042 | - // swa(ps1,an1,[web_arg("target",value) . op1]) | |
| 3043 | - else | |
| 3044 | - swa(ps1,an1,[web_arg(name,value) . op1]), | |
| 3045 | - | |
| 3046 | - upload(n,v,t) then | |
| 3047 | - swa(ps1,an1,[wa_1 . op1]) | |
| 3048 | - } | |
| 3049 | - } | |
| 3050 | - }. | |
| 3051 | - | |
| 3052 | - *** [3.3] Applying an action. | |
| 3053 | - | |
| 3054 | - When the web arguments are separated (and their names cleaned up from prefixes), we may | |
| 3055 | - apply the action to the operands and the current state. We search for the action to be | |
| 3056 | - applied in the list of actions. If no action is found, the new state is the same as | |
| 3057 | - the previous state. Also, we deny the application of an HTTP action if the request | |
| 3058 | - arrives through the HTTPS channel and conversely. | |
| 3059 | - | |
| 3060 | -define ($State previous, | |
| 3061 | - String action_name, | |
| 3062 | - HTTP_Info http_info, | |
| 3063 | - List(Web_arg) lwa, | |
| 3064 | - Bool is_https) -> $State | |
| 3065 | - make_apply_action_function | |
| 3066 | - ( | |
| 3067 | - List(Web_Action($State)) actions_list, | |
| 3068 | - (LogLevel, String) -> One logger //logger | |
| 3069 | - )= | |
| 3070 | - with f = | |
| 3071 | - ($State previous, | |
| 3072 | - String action_name, | |
| 3073 | - HTTP_Info http_info, | |
| 3074 | - List(Web_arg) lwa, | |
| 3075 | - Bool is_https, | |
| 3076 | - List(Web_Action($State)) actions) |-f-> | |
| 3077 | - //println("Looking for action ["+action_name+"]"); | |
| 3078 | - if actions is | |
| 3079 | - { | |
| 3080 | - [ ] then | |
| 3081 | - logger(logError, "action '"+action_name+"' not found.\n"); previous, | |
| 3082 | - [ac1 . others] then if ac1 is | |
| 3083 | - { | |
| 3084 | - //check for http action | |
| 3085 | - http_action(an, allow, do_it) then | |
| 3086 | - | |
| 3087 | - //Action name found | |
| 3088 | - if an = action_name then | |
| 3089 | - if is_https then | |
| 3090 | - (logger(logError, "HTTP action '"+an+"' called through HTTPS (denied).\n"); previous) | |
| 3091 | - else | |
| 3092 | - if allow(previous) then | |
| 3093 | - do_it(http_info,lwa,previous) | |
| 3094 | - else | |
| 3095 | - previous | |
| 3096 | - else | |
| 3097 | - f(previous,action_name,http_info,lwa,is_https,others), | |
| 3098 | - //check https action | |
| 3099 | - https_action(an,allow,do_it) then | |
| 3100 | - if an = action_name | |
| 3101 | - then if is_https | |
| 3102 | - then if allow(previous) | |
| 3103 | - then do_it(http_info,lwa,previous) | |
| 3104 | - else previous | |
| 3105 | - else (logger(logError, "HTTPS action '"+an+"' called through HTTP (denied).\n"); | |
| 3106 | - previous) | |
| 3107 | - else f(previous,action_name,http_info,lwa,is_https,others), | |
| 3108 | - | |
| 3109 | - http_https_action(an,allow,do_it) then | |
| 3110 | - if an = action_name then | |
| 3111 | - println("Action ["+action_name+"] found"); | |
| 3112 | - if allow(previous) | |
| 3113 | - then do_it(http_info,lwa,previous) | |
| 3114 | - else | |
| 3115 | - println("user not allowed to execute that Action ["+action_name+"]"); | |
| 3116 | - previous | |
| 3117 | - else f(previous,action_name,http_info,lwa,is_https,others), | |
| 3118 | - | |
| 3119 | - } | |
| 3120 | - }, | |
| 3121 | - ($State previous, | |
| 3122 | - String action_name, | |
| 3123 | - HTTP_Info http_info, | |
| 3124 | - List(Web_arg) lwa, | |
| 3125 | - Bool is_https) |-> | |
| 3126 | - f(previous, action_name, http_info, lwa, is_https, actions_list). | |
| 3127 | - | |
| 3128 | - *** [4] Web site descriptions and the 'awp handlers'. | |
| 3129 | - | |
| 3130 | - *** [4.1] The type 'Web_Site'. | |
| 3131 | - | |
| 3132 | - The type 'Web_Site_Description' is defined in 'web/multihost_http_server.anubis'. We | |
| 3133 | - need another one, because, we have some extra informations to record for each site. | |
| 3134 | - | |
| 3135 | -public type Web_Site: | |
| 3136 | - web_site((Word32,Word32) -> Web_Site_Description description, | |
| 3137 | - List(String) -> One delete_out_of_date). | |
| 3138 | - | |
| 3139 | - | |
| 3140 | - | |
| 3141 | - | |
| 3142 | - *** [4.2] Making a web site description. | |
| 3143 | - | |
| 3144 | - Below is the function which creates a web site description. It first creates (if | |
| 3145 | - needed) the directories for the site, then constructs the tool functions for the site, | |
| 3146 | - and the site handler. Finally, it constructs the web site description. | |
| 3147 | - | |
| 3148 | - We gather common (constant) informations in the following type: | |
| 3149 | - | |
| 3150 | -public type CommonInfo: | |
| 3151 | - info(String common_name, | |
| 3152 | - Word32 http_port, | |
| 3153 | - Word32 https_port, | |
| 3154 | - String site_directory, | |
| 3155 | - String authorization_secret | |
| 3156 | - ). | |
| 3157 | - | |
| 3158 | - We need a forward declaration. | |
| 3159 | - | |
| 3160 | -public define AWP_Handler_Answer | |
| 3161 | - format | |
| 3162 | - ( | |
| 3163 | - CommonInfo cinfo, | |
| 3164 | - List(HTTP_header) headers, | |
| 3165 | - HTTP_Answer page, | |
| 3166 | - Bool is_https, | |
| 3167 | - String charset | |
| 3168 | - ). | |
| 3169 | - | |
| 3170 | - | |
| 3171 | -define Printable_tree | |
| 3172 | - format | |
| 3173 | - ( | |
| 3174 | - HTML_Size s | |
| 3175 | - ) = | |
| 3176 | - if s is | |
| 3177 | - { | |
| 3178 | - absolute(x) then ["\"",x,"\""], | |
| 3179 | - percentage(x) then ["\"",x,"%\""] | |
| 3180 | - }. | |
| 3181 | - | |
| 3182 | -define List(HTTP_header) | |
| 3183 | - make_state_cookie_headers | |
| 3184 | - ( | |
| 3185 | - String website_name, | |
| 3186 | - String state_name | |
| 3187 | - ) | |
| 3188 | - = | |
| 3189 | - //println("Set-Cookie state_"+website_name+"="+state_name); | |
| 3190 | - [ | |
| 3191 | - http_header("Set-Cookie", "state_"+website_name+"="+state_name) | |
| 3192 | - ] | |
| 3193 | - . | |
| 3194 | - | |
| 3195 | - | |
| 3196 | -public define Web_Site | |
| 3197 | - make_web_site_description | |
| 3198 | - ( | |
| 3199 | - String website_name, // site_UID | |
| 3200 | - List(String) common_names, // for example: ["www.our-business.com"] | |
| 3201 | - String site_directory, | |
| 3202 | - String state_directory, | |
| 3203 | - One -> One init, | |
| 3204 | - (HTTP_Info, | |
| 3205 | - List(Web_arg), | |
| 3206 | - Bool is_https) -> $State initial_state, | |
| 3207 | - ($State expired, | |
| 3208 | - Maybe(String), | |
| 3209 | - HTTP_Info, | |
| 3210 | - List(Web_arg), | |
| 3211 | - Bool is_https) -> $State ticket_expired_state, | |
| 3212 | - (Maybe(String), | |
| 3213 | - HTTP_Info, | |
| 3214 | - List(Web_arg), | |
| 3215 | - Bool is_https) -> $State ticket_lost_state, | |
| 3216 | - List(Web_Action($State)) actions, | |
| 3217 | - $State -> HTTP_Answer compute_page, | |
| 3218 | - $State -> List(HTTP_header) additional_headers, | |
| 3219 | - List(HTTP_header) constant_additional_headers, | |
| 3220 | - Int timeout, | |
| 3221 | - Redirections redirections, | |
| 3222 | - String charset, | |
| 3223 | - List(String) journal_extensions, | |
| 3224 | - List(String) journal_headers, | |
| 3225 | - (LogLevel, String) -> One logger, //logger | |
| 3226 | - String secret, | |
| 3227 | - List(MIME) known_mime_types, | |
| 3228 | - (String action_name, | |
| 3229 | - List(Web_arg) args) -> One before_send_file | |
| 3230 | - )= | |
| 3231 | - init(unique); | |
| 3232 | - | |
| 3233 | - | |
| 3234 | - // | |
| 3235 | - // make required directories (if needed) | |
| 3236 | - // | |
| 3237 | - with //web_sites_directory = (String) make_directory(my_anubis_directory+"/web_sites"), | |
| 3238 | - base_directory = (String) make_directory(site_directory), | |
| 3239 | - // state_directory = make_directory(site_directory+"/states"), | |
| 3240 | - forget((String)make_directory(site_directory+"/public")); | |
| 3241 | - // | |
| 3242 | - // construct tool functions | |
| 3243 | - // TODO 'make_separate_web_args_function' must retrieve state_cookies before parsing web_args if using_state_cookies is true | |
| 3244 | - with save_state = make_save_state_function(timeout, state_directory, logger), | |
| 3245 | - retrieve_state = make_retrieve_state_function(state_directory), | |
| 3246 | - separate_web_args = make_separate_web_args_function(state_directory, retrieve_state, website_name), | |
| 3247 | - apply_action = make_apply_action_function(actions, logger), | |
| 3248 | - // | |
| 3249 | - // construct the site handler | |
| 3250 | - // | |
| 3251 | - site_handler = (Word32 http_port, Word32 https_port) |-> | |
| 3252 | - ((String host_name, | |
| 3253 | - HTTP_Info http_info, | |
| 3254 | - List(Web_arg) lwa, | |
| 3255 | - Bool is_https) |-> | |
| 3256 | - //println(dump_web_arg_values(lwa)); | |
| 3257 | - since separate_web_args(lwa, http_info) is swa(mb_previous_state, mb_action_name, operands), | |
| 3258 | - with new_state = if mb_previous_state is | |
| 3259 | - { | |
| 3260 | - not_found then | |
| 3261 | - //println("previous state not found"); | |
| 3262 | - if mb_action_name is | |
| 3263 | - { | |
| 3264 | - failure then initial_state(http_info, operands, is_https), | |
| 3265 | - success(_) then | |
| 3266 | - ticket_lost_state(mb_action_name, http_info,operands,is_https) | |
| 3267 | - }, | |
| 3268 | - | |
| 3269 | - out_of_date(state) then | |
| 3270 | - //println("previous out_of_date"); | |
| 3271 | - ticket_expired_state(state, mb_action_name, http_info,operands,is_https), | |
| 3272 | - | |
| 3273 | - still_valid(state) then | |
| 3274 | - //println("previous still_valid"); | |
| 3275 | - if mb_action_name is | |
| 3276 | - { | |
| 3277 | - failure then state, | |
| 3278 | - success(action_name) then | |
| 3279 | - apply_action(state,action_name,http_info,operands,is_https) | |
| 3280 | - } | |
| 3281 | - }, | |
| 3282 | - //if state_and_headers is (session_ticket, mb_new_state, headers) then | |
| 3283 | - with state_name = save_state(new_state), | |
| 3284 | - //println("Cookie new STATE NAME "+state_name); | |
| 3285 | - with cookie_headers = if mb_action_name is | |
| 3286 | - { | |
| 3287 | - failure then | |
| 3288 | - make_state_cookie_headers(website_name, state_name), | |
| 3289 | - success(action_name) then | |
| 3290 | - if action_name = "none" then | |
| 3291 | - [] | |
| 3292 | - else if substr(action_name, 0, 5)="ajax_" then | |
| 3293 | - [] | |
| 3294 | - else | |
| 3295 | - make_state_cookie_headers(website_name, state_name) | |
| 3296 | - }, | |
| 3297 | - | |
| 3298 | - format(info(host_name, http_port, https_port, site_directory, secret), | |
| 3299 | - additional_headers(new_state) + cookie_headers, | |
| 3300 | - compute_page(new_state), | |
| 3301 | - is_https, | |
| 3302 | - charset) | |
| 3303 | - ), | |
| 3304 | - // | |
| 3305 | - // make the delete_out_of_date function | |
| 3306 | - // | |
| 3307 | - delete_out_of_date = | |
| 3308 | - make_delete_out_of_date_states_function((Maybe($State))failure, | |
| 3309 | - site_directory+"/states"), | |
| 3310 | - // | |
| 3311 | - // construct the web site description | |
| 3312 | - // | |
| 3313 | - web_site((Word32 http_port, Word32 https_port) |-> | |
| 3314 | - web_site_description(common_names, | |
| 3315 | - site_directory, | |
| 3316 | - redirections, | |
| 3317 | - charset, | |
| 3318 | - journal_extensions, | |
| 3319 | - journal_headers, | |
| 3320 | - logger, | |
| 3321 | - secret, | |
| 3322 | - known_mime_types, | |
| 3323 | - site_handler(http_port, https_port), | |
| 3324 | - constant_additional_headers, | |
| 3325 | - (HTTP_Info http_info, List(Web_arg) lwa) |-> if separate_web_args(lwa, http_info ) is | |
| 3326 | - swa(mb_previous_state,mb_action_name,operands) then | |
| 3327 | - if mb_action_name is | |
| 3328 | - { | |
| 3329 | - failure then unique | |
| 3330 | - success(an) then before_send_file(an,operands) | |
| 3331 | - } | |
| 3332 | - //using_state_cookies | |
| 3333 | - ), | |
| 3334 | - delete_out_of_date). | |
| 3335 | - | |
| 3336 | - public type WEB_Controller: | |
| 3337 | - web_controller( | |
| 3338 | - String name, //controller name | |
| 3339 | - (HTTP_Info http_info, | |
| 3340 | - List(Web_arg) lwa, | |
| 3341 | - Bool is_https | |
| 3342 | - ) -> HTTP_Answer view //view renderer | |
| 3343 | - ) | |
| 3344 | - | |
| 3345 | - | |
| 3346 | - | |
| 3347 | - | |
| 3348 | -public define JsonValue to_html_ajax_content(Printable_tree content_HTML, String additional_script). | |
| 3349 | -public define JsonValue to_html_ajax_content(HTML_Partial_Content content_HTML, CommonInfo cinfo, String additional_script). | |
| 3350 | - | |
| 3351 | - | |
| 3352 | - | |
| 3353 | -define String | |
| 3354 | - get_site_uid | |
| 3355 | - ( | |
| 3356 | - String site_path, | |
| 3357 | - (LogLevel, String) -> One logger //logger | |
| 3358 | - )= | |
| 3359 | - with file_name = site_path+"/site_UID", | |
| 3360 | - if read_from_file(file_name) is | |
| 3361 | - { | |
| 3362 | - cannot_find_file then | |
| 3363 | - logger(logInfo,"site UID doesn't exists. Generating one now"); | |
| 3364 | - with uid = generate_random_string(9), | |
| 3365 | - if write_to_file(file_name, to_byte_array(uid)) is | |
| 3366 | - { | |
| 3367 | - cannot_open_file then logger(logError, "Can't create site UID here "+file_name);"", | |
| 3368 | - write_error(_) then logger(logError, "Can't write site UID here "+file_name);"", | |
| 3369 | - ok then uid | |
| 3370 | - } | |
| 3371 | - read_error(_) then | |
| 3372 | - logger(logError, "cannot read site UID from "+file_name);"" | |
| 3373 | - ok(ba) then to_string(ba) | |
| 3374 | - } | |
| 3375 | - . | |
| 3376 | - | |
| 3377 | -// Compatibility function for older websites | |
| 3378 | - public define Web_Site | |
| 3379 | - make_web_site_description | |
| 3380 | - ( | |
| 3381 | - List(String) common_names, // for example: ["www.our-business.com"] | |
| 3382 | - String site_directory, | |
| 3383 | - String state_directory, | |
| 3384 | - One -> One init, | |
| 3385 | - (HTTP_Info, | |
| 3386 | - List(Web_arg), | |
| 3387 | - Bool is_https) -> $State initial_state, | |
| 3388 | - ($State expired, | |
| 3389 | - Maybe(String), | |
| 3390 | - HTTP_Info, | |
| 3391 | - List(Web_arg), | |
| 3392 | - Bool is_https) -> $State ticket_expired_state, | |
| 3393 | - (Maybe(String), | |
| 3394 | - HTTP_Info, | |
| 3395 | - List(Web_arg), | |
| 3396 | - Bool is_https) -> $State ticket_lost_state, | |
| 3397 | - List(Web_Action($State)) actions, | |
| 3398 | - $State -> HTTP_Answer compute_page, | |
| 3399 | - $State -> List(HTTP_header) additional_headers, | |
| 3400 | - List(HTTP_header) constant_additional_headers, | |
| 3401 | - Int timeout, | |
| 3402 | - Redirections redirections, | |
| 3403 | - String charset, | |
| 3404 | - List(String) journal_extensions, | |
| 3405 | - List(String) journal_headers, | |
| 3406 | - (LogLevel, String) -> One logger, //logger | |
| 3407 | - String secret, | |
| 3408 | - List(MIME) known_mime_types, | |
| 3409 | - (String action_name, | |
| 3410 | - List(Web_arg) args) -> One before_send_file | |
| 3411 | - //Bool using_state_cookies | |
| 3412 | - ) | |
| 3413 | - = | |
| 3414 | - //generate an unique ID if doesn't exist in root of site_directory | |
| 3415 | - with site_UID = get_site_uid(site_directory, logger), | |
| 3416 | - make_web_site_description(site_UID, common_names, site_directory, state_directory, init, initial_state, ticket_expired_state, ticket_lost_state, actions, compute_page, additional_headers, constant_additional_headers, timeout, redirections, charset, journal_extensions, journal_headers, logger, secret, known_mime_types, before_send_file) | |
| 3417 | -. | |
| 3418 | - | |
| 3419 | - | |
| 3420 | - | |
| 3421 | - *** [4.3] Starting the servers. | |
| 3422 | - | |
| 3423 | -public define Start_Web_Sites_Result | |
| 3424 | - start_web_sites | |
| 3425 | - ( | |
| 3426 | - Word32 ip_address, // the IP address shared by the web sites | |
| 3427 | - Word32 http_port, // usually: 80 | |
| 3428 | - Word32 https_port, // usually: 443 | |
| 3429 | - String ssl_certificate_common_name, | |
| 3430 | - List(Web_Site) web_sites, // web sites to be started | |
| 3431 | - (One) -> Bool shutdown_required | |
| 3432 | - ) = | |
| 3433 | - with get_description = (Web_Site ws) |-> description(ws)(http_port,https_port), | |
| 3434 | - with http_server_r = | |
| 3435 | - start_http_server(ip_address,http_port, | |
| 3436 | - map(get_description,web_sites), | |
| 3437 | - //load_denial_of_service_info, | |
| 3438 | - shutdown_required), | |
| 3439 | - with https_server_r = | |
| 3440 | - start_https_server(ip_address,https_port, | |
| 3441 | - ssl_certificate_common_name, | |
| 3442 | - map(get_description,web_sites), | |
| 3443 | - shutdown_required), | |
| 3444 | - if http_server_r is ok(http_server) | |
| 3445 | - then | |
| 3446 | - ( | |
| 3447 | - if https_server_r is ok(https_server) | |
| 3448 | - then | |
| 3449 | - ( | |
| 3450 | - start_http_servers_tasks(map(get_description,web_sites), | |
| 3451 | - [http_server,https_server], | |
| 3452 | - 600); // period of 10 minutes | |
| 3453 | - delegate | |
| 3454 | - delete_states_loop( | |
| 3455 | - map((Web_Site ws) |-> | |
| 3456 | - (site_directory(description(ws)(http_port,https_port))+ | |
| 3457 | - "/states",delete_out_of_date(ws)), | |
| 3458 | - web_sites), | |
| 3459 | - 3600*24*3, // keep out of date states 3 days | |
| 3460 | - now, | |
| 3461 | - http_server, | |
| 3462 | - https_server, | |
| 3463 | - shutdown_required), | |
| 3464 | - ok(http_server,https_server) | |
| 3465 | - ) | |
| 3466 | - else cannot_bind_to_port(https_port) | |
| 3467 | - ) | |
| 3468 | - else | |
| 3469 | - ( | |
| 3470 | - if https_server_r is ok(https_server) | |
| 3471 | - then cannot_bind_to_port(http_port) | |
| 3472 | - else cannot_bind_to_port(http_port,https_port) | |
| 3473 | - ). | |
| 3474 | - | |
| 3475 | - | |
| 3476 | -public define One | |
| 3477 | - start_web_sites | |
| 3478 | - ( | |
| 3479 | - Word32 ip_address, // the IP address shared by the web sites | |
| 3480 | - Word32 http_port, // usually: 80 | |
| 3481 | - Word32 https_port, // usually: 443 | |
| 3482 | - String ssl_certificate_common_name, | |
| 3483 | - List(Web_Site) web_sites, // web sites to be started | |
| 3484 | - (One) -> Bool shutdown_required, | |
| 3485 | - (LogLevel, String) -> One logger //logger where to report the error | |
| 3486 | - )= | |
| 3487 | - if (Start_Web_Sites_Result)start_web_sites(ip_address, | |
| 3488 | - http_port, | |
| 3489 | - https_port, | |
| 3490 | - ssl_certificate_common_name, | |
| 3491 | - web_sites, | |
| 3492 | - shutdown_required) is | |
| 3493 | - { | |
| 3494 | - cannot_bind_to_port(n) then logger(logError, "Cannot bind to port: "+n), | |
| 3495 | - cannot_bind_to_port(n,m) then logger(logError, "Cannot bind to ports: "+n+", "+m), | |
| 3496 | - ok(s1,s2) then logger(logInfo, "Servers started on ports "+http_port+" (HTTP) and "+https_port+" (HTTPS).") | |
| 3497 | - }. | |
| 3498 | - | |
| 3499 | - | |
| 3500 | - | |
| 3501 | - | |
| 3502 | - | |
| 3503 | - *** [5] HTML Formating. | |
| 3504 | - | |
| 3505 | - We need to translate HTML elements as defined above into actual HTML text. | |
| 3506 | - | |
| 3507 | - Actioners require special informations, which must be transmitted when needed by the | |
| 3508 | - 'format' functions: | |
| 3509 | - | |
| 3510 | - - the 'common name', which is used for URLs, | |
| 3511 | - - the HTTP/HTTPS port number, | |
| 3512 | - - the 'state name', which must be transmitted when the actioner is clicked upon, | |
| 3513 | - - the 'form name' (if any) to which the actioner refers. | |
| 3514 | - | |
| 3515 | - If the actioner is off form, and if it refers to a form, the name of that form is | |
| 3516 | - already known by the actioner. On the contrary, if the actioner is 'in form', it refers | |
| 3517 | - implicitly to the form containing it. The name of that form is transmitted to the | |
| 3518 | - 'format' functions called from within the formating of that form. | |
| 3519 | - | |
| 3520 | - | |
| 3521 | - | |
| 3522 | - | |
| 3523 | - *** [5.1] The type 'HTML_Any($T)'. | |
| 3524 | - | |
| 3525 | - The type 'HTML_Any($T)' gathers elements which may be put anywhere in the page. The | |
| 3526 | - parameter $T becomes either 'HTML_Off_Form' or 'HTML_In_Form'. | |
| 3527 | - | |
| 3528 | -type HTML_Any($T): | |
| 3529 | - any_text (List(CoreAttrs), String the_text), | |
| 3530 | - any_preformated (List(Text_Option), String), | |
| 3531 | - any_paragraph (List(Text_Option), List($T) content), | |
| 3532 | - any_image (List(CoreAttrs), String url, String alternate), | |
| 3533 | - any_image (List(CoreAttrs), String url, String alternate, Int width, Int height), | |
| 3534 | - any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T)), HTML_Footer_Row($T)), | |
| 3535 | - any_center ($T), | |
| 3536 | - any_mail_to (String email, $T element), | |
| 3537 | - any_scroller (Int width, Int height, | |
| 3538 | - Int content_width, Int content_height, | |
| 3539 | - $T content), | |
| 3540 | - any_fixed_size (HTML_Size width, HTML_Size height, $T content), | |
| 3541 | - any_fixed_size_2 (HTML_Size width, HTML_Size height, String name_of_HTML_file), | |
| 3542 | - any_actioner (Actioner_Connection, | |
| 3543 | - Actioner_Target, | |
| 3544 | - Actioner_Aspect, | |
| 3545 | - WEB_Action_Name action, | |
| 3546 | - List((String,String)) extra_ops, | |
| 3547 | - List(Actioner_Local_Action), | |
| 3548 | - Maybe(String) form_name), | |
| 3549 | - any_foreign_link_new (Actioner_Target, Actioner_Aspect, String url), | |
| 3550 | - any_foreign_link (List(Text_Option), String url), | |
| 3551 | - any_foreign_link (List(Text_Option), String url, String name), | |
| 3552 | - any_private_download (String abs_path, String name, String extra_ext, | |
| 3553 | - Maybe((String,List((String,String))))), | |
| 3554 | - any_div (List(CoreAttrs), List($T) element), | |
| 3555 | - any_div_empty (List(CoreAttrs)), | |
| 3556 | - any_coreattrs (List(CoreAttrs)), | |
| 3557 | - any_ol (List(CoreAttrs), List($T) content), | |
| 3558 | - any_ul (List(CoreAttrs), List($T) content), | |
| 3559 | - any_li (List(CoreAttrs), List($T) content), | |
| 3560 | - any_button (List(CoreAttrs), List($T) element), | |
| 3561 | - any_i (List(CoreAttrs), String text), | |
| 3562 | - any_span (List(CoreAttrs), String text), | |
| 3563 | - any_hr (List(CoreAttrs)) | |
| 3564 | -. | |
| 3565 | - | |
| 3566 | - | |
| 3567 | - | |
| 3568 | - *** [5.2] Formating a color. | |
| 3569 | - | |
| 3570 | - RGB colors are formatted as '#rrggbb' where rr, gg and bb are two characters | |
| 3571 | - hexadecimal values. | |
| 3572 | - | |
| 3573 | -define String | |
| 3574 | - html_format | |
| 3575 | - ( | |
| 3576 | - RGB color | |
| 3577 | - ) = | |
| 3578 | - if color is rgb(r,g,b) then | |
| 3579 | - "#" + to_hexa(r) | |
| 3580 | - + to_hexa(g) | |
| 3581 | - + to_hexa(b). | |
| 3582 | - | |
| 3583 | - | |
| 3584 | - The following is a very arbitrary definition of the opposite color. The thing which is | |
| 3585 | - important is that it is far from the original, so that characters in 'opposite' color | |
| 3586 | - are clearly visible over the original. | |
| 3587 | - | |
| 3588 | -define RGB | |
| 3589 | - opposite | |
| 3590 | - ( | |
| 3591 | - RGB color | |
| 3592 | - ) = | |
| 3593 | - if color is rgb(r,g,b) then | |
| 3594 | - rgb(255-r, | |
| 3595 | - 255-g, | |
| 3596 | - 255-b). | |
| 3597 | - | |
| 3598 | - Converting RGB to RGBA. | |
| 3599 | - | |
| 3600 | -define RGBA | |
| 3601 | - to_rgba | |
| 3602 | - ( | |
| 3603 | - RGB color | |
| 3604 | - ) = | |
| 3605 | - if color is rgb(r,g,b) then rgba(r,g,b,255). | |
| 3606 | - | |
| 3607 | - | |
| 3608 | - *** [5.4] Formating an actioner. | |
| 3609 | - | |
| 3610 | - An actioner works as follows. Assume first that it refers to a form. When it is clicked | |
| 3611 | - upon, the actioner puts (via 'onMouseDown') the URL into the 'action' attribute of the | |
| 3612 | - form, and submits the form, using the JavaScript command 'form_name.submit()'. If the | |
| 3613 | - actioner does not refer to a form, it fires the URL directly via 'href', because in | |
| 3614 | - that case, the actioner is always an <a> tag. | |
| 3615 | - | |
| 3616 | - The URL itself is composed using the connection sort (same, http or https), the common | |
| 3617 | - name and port number (if needed), the state name, the action name, and the extra | |
| 3618 | - operands, which are put into a query string. It may look like this: | |
| 3619 | - | |
| 3620 | - http://common_name:port/?s=state_name&a=action_name&oname=value... | |
| 3621 | - | |
| 3622 | - Each extra operand is a pair of strings: (name,value). It is formated as: | |
| 3623 | - | |
| 3624 | - &oname=value | |
| 3625 | - | |
| 3626 | -public define String | |
| 3627 | - format_attrs | |
| 3628 | - ( | |
| 3629 | - List(CoreAttrs) attributs | |
| 3630 | - ). | |
| 3631 | - | |
| 3632 | -//public define String | |
| 3633 | -// format_extra_operands | |
| 3634 | -// ( | |
| 3635 | -// List((String,String)) l | |
| 3636 | -// ) = | |
| 3637 | -// if l is | |
| 3638 | -// { | |
| 3639 | -// [ ] then "", | |
| 3640 | -// [h . t] then if h is (n,v) then | |
| 3641 | -// "&"+n+"="+v+format_extra_operands(t) | |
| 3642 | -// } | |
| 3643 | -//. | |
| 3644 | - | |
| 3645 | - | |
| 3646 | - It seams that the standard requires "&" instead of "&" ! | |
| 3647 | - | |
| 3648 | - In case the target is another window, we need to format the options for this window. | |
| 3649 | - | |
| 3650 | -define String | |
| 3651 | - format | |
| 3652 | - ( | |
| 3653 | - List(Other_Window_Option) l | |
| 3654 | - ) = | |
| 3655 | - if l is | |
| 3656 | - { | |
| 3657 | - [ ] then "", | |
| 3658 | - [h . t] then if h is | |
| 3659 | - { | |
| 3660 | - resizable then "resizable", | |
| 3661 | - scrollbars then "scrollbars", | |
| 3662 | - width(w) then "width="+w, | |
| 3663 | - height(h2) then "height="+h2 | |
| 3664 | - } + if t is [ ] then "" else (","+format(t)) | |
| 3665 | - } | |
| 3666 | -. | |
| 3667 | - | |
| 3668 | - | |
| 3669 | - | |
| 3670 | - Formating choices for a <select> tag. | |
| 3671 | - | |
| 3672 | -public define Printable_tree | |
| 3673 | - format_choices | |
| 3674 | - ( | |
| 3675 | - List(String) l | |
| 3676 | - ) = | |
| 3677 | - if l is | |
| 3678 | - { | |
| 3679 | - [ ] then [ ], | |
| 3680 | - [h . t] then ["<option>", h, "</option>\n" . format_choices(t)] | |
| 3681 | - }. | |
| 3682 | - | |
| 3683 | - | |
| 3684 | -public define Printable_tree | |
| 3685 | - format_choices | |
| 3686 | - ( | |
| 3687 | - List(String) l, | |
| 3688 | - InitialValue selected | |
| 3689 | - ) = | |
| 3690 | - if l is | |
| 3691 | - { | |
| 3692 | - [ ] then [ ], | |
| 3693 | - [h . t] then if h = selected.value | |
| 3694 | - then ["<option selected=\"selected\">", h, "</option>\n" . format_choices(t)] | |
| 3695 | - else ["<option>", h, "</option>\n" . format_choices(t,selected)] | |
| 3696 | - }. | |
| 3697 | - | |
| 3698 | - | |
| 3699 | -public define Printable_tree | |
| 3700 | - format_choices | |
| 3701 | - ( | |
| 3702 | - List((List(CoreAttrs),WebArgValue,String)) l | |
| 3703 | - ) = | |
| 3704 | - if l is | |
| 3705 | - { | |
| 3706 | - [ ] then [ ], | |
| 3707 | - [h . t] then | |
| 3708 | - if h is (attrs,val,item) | |
| 3709 | - then ["<option value=\""+encode_HTML_entities(val.value)+"\" "+format_attrs(attrs)+">", item, "</option>\n" . format_choices(t)] | |
| 3710 | - }. | |
| 3711 | - | |
| 3712 | -public define Printable_tree | |
| 3713 | - format_choices | |
| 3714 | - ( | |
| 3715 | - List((List(CoreAttrs),WebArgValue,String)) l, | |
| 3716 | - InitialValue selected | |
| 3717 | - ) = | |
| 3718 | - if l is | |
| 3719 | - { | |
| 3720 | - [ ] then [ ], | |
| 3721 | - [h . t] then | |
| 3722 | - if h is (attrs,val,item) then | |
| 3723 | - if val.value = selected.value | |
| 3724 | - then ["<option value=\""+encode_HTML_entities(val.value)+"\" "+format_attrs(attrs)+" selected=\"selected\">", item, "</option>\n" . format_choices(t)] | |
| 3725 | - else ["<option value=\""+encode_HTML_entities(val.value)+"\" "+format_attrs(attrs)+" >", item, "</option>\n" . format_choices(t,selected)] | |
| 3726 | - }. | |
| 3727 | - | |
| 3728 | - | |
| 3729 | - | |
| 3730 | - Note: this counter is private to the virtual machine, hence there is one counter by | |
| 3731 | - client and by page : it seems that a new VM (simply a delegate) is started for each request. | |
| 3732 | - | |
| 3733 | -define Int | |
| 3734 | - new_count | |
| 3735 | - ( | |
| 3736 | - Var(Int) count | |
| 3737 | - ) | |
| 3738 | - = | |
| 3739 | - count <- *count+1; | |
| 3740 | - *count. | |
| 3741 | - | |
| 3742 | - | |
| 3743 | - The next function composes the URL. It is a JavaScript URL when the target is another | |
| 3744 | - window. | |
| 3745 | - | |
| 3746 | -//public define String | |
| 3747 | -// format_web_action_name | |
| 3748 | -// ( | |
| 3749 | -// WEB_Action_Name action | |
| 3750 | -// )= | |
| 3751 | -// if action is | |
| 3752 | -// { | |
| 3753 | -// no_action then "", | |
| 3754 | -// controller_action(controller, action_name) then "?aws_controller="+controller+"&aws_action="+action_name, | |
| 3755 | -// action_name(action_name) then "?aws_action="+action_name, | |
| 3756 | -// url(url) then url | |
| 3757 | -// } | |
| 3758 | -//. | |
| 3759 | -// | |
| 3760 | -//public define String | |
| 3761 | -// format_web_action_name | |
| 3762 | -// ( | |
| 3763 | -// WEB_Action_Name action, | |
| 3764 | -// List((String,String)) extra_ops, | |
| 3765 | -// )= | |
| 3766 | -// format_web_action_name(action) | |
| 3767 | -// + | |
| 3768 | -// format_extra_operands(extra_ops) | |
| 3769 | -//. | |
| 3770 | - | |
| 3771 | -define String | |
| 3772 | - make_actioner_url | |
| 3773 | - ( | |
| 3774 | - CommonInfo cinfo, | |
| 3775 | - Actioner_Connection connection, | |
| 3776 | - Actioner_Target target, | |
| 3777 | - WEB_Action_Name action, | |
| 3778 | - List((String,String)) extra_ops, | |
| 3779 | - Bool is_https | |
| 3780 | - ) = | |
| 3781 | - if cinfo is info(common_name,http_port,https_port,site_directory,secret) then | |
| 3782 | - with strict_url = | |
| 3783 | - if connection is | |
| 3784 | - { | |
| 3785 | - same then "/", | |
| 3786 | - http then | |
| 3787 | - if http_port = 80 then | |
| 3788 | - "http://"+common_name+"/" | |
| 3789 | - else | |
| 3790 | - "http://"+common_name+":"+http_port+"/", | |
| 3791 | - https then | |
| 3792 | - if https_port = 443 then | |
| 3793 | - "https://"+common_name+"/" | |
| 3794 | - else | |
| 3795 | - "https://"+common_name+":"+https_port+"/", | |
| 3796 | - } + | |
| 3797 | - //with action_string = | |
| 3798 | - format_web_action_name(action, extra_ops), | |
| 3799 | - if target is | |
| 3800 | - { | |
| 3801 | - same then strict_url, | |
| 3802 | - same(label) then strict_url+"#"+label, | |
| 3803 | - other(wn,ops) then | |
| 3804 | - | |
| 3805 | - "javascript:void window.open('"+strict_url+"&t="+wn+"','"+ | |
| 3806 | - "w"+to_ascii(sha1(wn))+"','"+format(ops)+"')" | |
| 3807 | - }. | |
| 3808 | - | |
| 3809 | -define String | |
| 3810 | - make_foreign_link_url | |
| 3811 | - ( | |
| 3812 | - Actioner_Target target, | |
| 3813 | - String url | |
| 3814 | - ) = | |
| 3815 | - if target is | |
| 3816 | - { | |
| 3817 | - same then "/", | |
| 3818 | - same(label) then "/#"+label, | |
| 3819 | - other(wn,ops) then | |
| 3820 | - | |
| 3821 | - "javascript:void window.open('"+url+"','"+ | |
| 3822 | - "w"+to_ascii(sha1(wn))+"','"+format(ops)+"')" | |
| 3823 | - }. | |
| 3824 | - | |
| 3825 | - | |
| 3826 | - Depending on the fact that the actioner refers to a form or not, the URL is used in two | |
| 3827 | - different ways. If the actioner does not refer to a form, it is realized by a '<a>' | |
| 3828 | - tag, with a 'href' attribute. If it refers to a form, it is still realized by a '<a>' | |
| 3829 | - tag, but with no href attribute. In this case, we use the 'onMouseDown' or 'onChange' | |
| 3830 | - event handler. The handler calls a JavaScript function which puts the URL as the value | |
| 3831 | - of the 'action' attribute of the form, and submits the form. | |
| 3832 | - | |
| 3833 | -type URL_or_JavaScript: | |
| 3834 | - url (String), | |
| 3835 | - javascript (Printable_tree script, Printable_tree handler). | |
| 3836 | - | |
| 3837 | - | |
| 3838 | - It was as shown below, in order to allow submission of a form from outside the form, | |
| 3839 | - but this makes problems: | |
| 3840 | - | |
| 3841 | -define URL_or_JavaScript | |
| 3842 | - format_action | |
| 3843 | - ( | |
| 3844 | - String the_url, | |
| 3845 | - Actioner_Aspect aspect, | |
| 3846 | - Maybe(String) mb_id, | |
| 3847 | - Maybe(String) mb_form_name, | |
| 3848 | - Var(Int) action_count | |
| 3849 | - ) = | |
| 3850 | - if mb_form_name is | |
| 3851 | - { | |
| 3852 | - failure then | |
| 3853 | - url(the_url), | |
| 3854 | - success(form_name) then | |
| 3855 | - with n = new_count(action_count), | |
| 3856 | - fn_name = "pfu_" + if mb_id is | |
| 3857 | - { | |
| 3858 | - failure then form_name + "_" + n, | |
| 3859 | - success(id) then id, | |
| 3860 | - }, | |
| 3861 | - javascript( | |
| 3862 | - [ | |
| 3863 | - "<script type=\"text/javascript\" language =\"JavaScript\">\n", | |
| 3864 | - "function ", fn_name, "() {\n", | |
| 3865 | - " var fa = document.forms.",form_name,";\n", | |
| 3866 | - " var u = \"",the_url,"\";\n", | |
| 3867 | - " fa.action = u;", | |
| 3868 | - if aspect is submit(_, _) then " }\n" | |
| 3869 | - else "\n fa.submit(); }\n", | |
| 3870 | - "</script>\n" | |
| 3871 | - ], | |
| 3872 | - [fn_name,"();"] | |
| 3873 | - ) | |
| 3874 | - }. | |
| 3875 | - | |
| 3876 | - Now, we format the actioner according to its aspect. | |
| 3877 | - | |
| 3878 | -define List(Text_Option) | |
| 3879 | - get_text_options | |
| 3880 | - ( | |
| 3881 | - List(Text_Option) l | |
| 3882 | - ) | |
| 3883 | - = | |
| 3884 | - if l is | |
| 3885 | - { | |
| 3886 | - [] then [], | |
| 3887 | - [h . t ] then | |
| 3888 | - if h is class(_) then | |
| 3889 | - get_text_options(t) | |
| 3890 | - else if h is id(_) then | |
| 3891 | - get_text_options(t) | |
| 3892 | - else if h is style(_) then | |
| 3893 | - get_text_options(t) | |
| 3894 | - else if h is title(_) then | |
| 3895 | - get_text_options(t) | |
| 3896 | - else if h is core_attrs(_) then | |
| 3897 | - get_text_options(t) | |
| 3898 | - else | |
| 3899 | - [ h . get_text_options(t) ] | |
| 3900 | - | |
| 3901 | - }. | |
| 3902 | - | |
| 3903 | - /** | |
| 3904 | - * Extract the CSS class list from the list of Text_Option | |
| 3905 | - */ | |
| 3906 | -define List(CoreAttrs) | |
| 3907 | - get_css_class | |
| 3908 | - ( | |
| 3909 | - List(Text_Option) l | |
| 3910 | - ) | |
| 3911 | - = | |
| 3912 | - if l is | |
| 3913 | - { | |
| 3914 | - [] then [], | |
| 3915 | - [h . t ] then | |
| 3916 | - | |
| 3917 | - | |
| 3918 | - if h is class(name) then | |
| 3919 | - [ class(name) . get_css_class(t) ] | |
| 3920 | - else if h is id(name) then | |
| 3921 | - [ id(name) . get_css_class(t) ] | |
| 3922 | - else if h is style(the_style) then | |
| 3923 | - [ style(the_style) . get_css_class(t) ] | |
| 3924 | - else if h is title(name) then | |
| 3925 | - [ tooltip(name) . get_css_class(t) ] | |
| 3926 | - else if h is attr(name, value) then | |
| 3927 | - [ attr(name, value) . get_css_class(t) ] | |
| 3928 | - else | |
| 3929 | - get_css_class(t) | |
| 3930 | - } | |
| 3931 | - . | |
| 3932 | - | |
| 3933 | - | |
| 3934 | -define List(CoreAttrs) | |
| 3935 | - get_core_attrs | |
| 3936 | - ( | |
| 3937 | - List(Text_Option) l | |
| 3938 | - ) | |
| 3939 | - = | |
| 3940 | - if l is | |
| 3941 | - { | |
| 3942 | - [] then [], | |
| 3943 | - [h . t ] then | |
| 3944 | - if h is core_attrs(attrs) then | |
| 3945 | - attrs + get_core_attrs(t) | |
| 3946 | - else | |
| 3947 | - get_core_attrs(t) | |
| 3948 | - } | |
| 3949 | - . | |
| 3950 | - | |
| 3951 | -define Printable_tree | |
| 3952 | - format | |
| 3953 | - ( | |
| 3954 | - List(Actioner_Local_Action) l | |
| 3955 | - ) = | |
| 3956 | - if l is | |
| 3957 | - { | |
| 3958 | - [ ] then [ ], | |
| 3959 | - [h . t] then [if h is | |
| 3960 | - { | |
| 3961 | - close_window then [" window.close(); "] | |
| 3962 | - } | |
| 3963 | - . format(t)] | |
| 3964 | - }. | |
| 3965 | - | |
| 3966 | - | |
| 3967 | -define String | |
| 3968 | - format_attrs | |
| 3969 | - ( | |
| 3970 | - List(InputAttrs) attributs, | |
| 3971 | - List(String) classes, | |
| 3972 | - List(String) styles | |
| 3973 | - )= | |
| 3974 | - if attributs is | |
| 3975 | - { | |
| 3976 | - [] then | |
| 3977 | - if length(classes) = 0 then "" else " class=\""+join(" ",classes)+"\""+ | |
| 3978 | - if length(styles) = 0 then "" else " style=\""+join(";",styles)+"\"", | |
| 3979 | - [h . t] then | |
| 3980 | - with new_classes = if h is class(class_name) then [class_name. classes] else classes, | |
| 3981 | - new_styles = if h is style(style_string) then [style_string . styles] else styles, | |
| 3982 | - current = if h is | |
| 3983 | - { | |
| 3984 | - id(id_name) then | |
| 3985 | - " id=\"" + id_name + "\"", | |
| 3986 | - class(class_name) then "", | |
| 3987 | - style(style_string) then "", | |
| 3988 | - title(title_string) then | |
| 3989 | - " title=\"" + title_string + "\"", | |
| 3990 | - | |
| 3991 | - lang(lang) then | |
| 3992 | - " xml:lang=" + lang, | |
| 3993 | - dir(reading_Way) then | |
| 3994 | - if reading_Way is | |
| 3995 | - { | |
| 3996 | - ltr then " dir=ltr", | |
| 3997 | - rtl then " dir=rtl" | |
| 3998 | - }, | |
| 3999 | - | |
| 4000 | - accesskey(key) then | |
| 4001 | - " accesskey=\"" + key + "\"", | |
| 4002 | - tabindex(index) then | |
| 4003 | - " tabindex=\"" + index + "\"", | |
| 4004 | - | |
| 4005 | - attr(name, value) then | |
| 4006 | - " " + name + "=\"" + value + "\"", | |
| 4007 | - | |
| 4008 | - event(e, value) then | |
| 4009 | - " " + event_name(e) + "=\"" + value + "\"", | |
| 4010 | - data(name, value) then | |
| 4011 | - " data-" + to_lower(name) + "=\"" + value + "\"", | |
| 4012 | - }, | |
| 4013 | - current + format_attrs(t, classes, styles) | |
| 4014 | - }. | |
| 4015 | - | |
| 4016 | -public define List(CoreAttrs) extract_attributes(HTML_tooltip htt). | |
| 4017 | - | |
| 4018 | -define String | |
| 4019 | - format_attrs | |
| 4020 | - ( | |
| 4021 | - List(CoreAttrs) attributs, | |
| 4022 | - List(String) classes, //class accumulator | |
| 4023 | - List(String) styles //styles accumulator | |
| 4024 | - )= | |
| 4025 | - if attributs is | |
| 4026 | - { | |
| 4027 | - [] then | |
| 4028 | - //concat all accumulated classes and styles | |
| 4029 | - (if length(classes) = 0 then "" else " class=\""+join(" ",classes)+"\"")+ | |
| 4030 | - if length(styles) = 0 then "" else " style=\""+join(";",styles)+"\"", | |
| 4031 | - [h . t] then | |
| 4032 | - with new_classes = if h is class(class_name) then [class_name. classes] else classes, | |
| 4033 | - new_styles = if h is style(style_string) then [style_string . styles] else styles, | |
| 4034 | - new_attrs = if h is tooltip(tt) then extract_attributes(tt) else [], | |
| 4035 | - | |
| 4036 | - current = if h is | |
| 4037 | - { | |
| 4038 | - empty then "", | |
| 4039 | - id(id_name) then | |
| 4040 | - " id=\"" + id_name + "\"", | |
| 4041 | - class(class_name) then "", //do nothing here, because we accumulate the class until we have some other attributes | |
| 4042 | - style(style_string) then "", //do nothing here, because we accumulate the style until we have some other attributes | |
| 4043 | - title(title_string) then | |
| 4044 | - " title=\"" + title_string + "\"", | |
| 4045 | - | |
| 4046 | - lang(lang) then | |
| 4047 | - " xml:lang=" + lang, | |
| 4048 | - dir(reading_Way) then | |
| 4049 | - if reading_Way is | |
| 4050 | - { | |
| 4051 | - ltr then " dir=ltr", | |
| 4052 | - rtl then " dir=rtl" | |
| 4053 | - }, | |
| 4054 | - | |
| 4055 | - accesskey(key) then | |
| 4056 | - " accesskey=\"" + key + "\"", | |
| 4057 | - tabindex(index) then | |
| 4058 | - " tabindex=\"" + index + "\"", | |
| 4059 | - attr(name, value) then | |
| 4060 | - " " + name + "=\"" + value + "\"", | |
| 4061 | - bool_attr(bool, value)then | |
| 4062 | - if bool then " "+value+" " else "", | |
| 4063 | - event(e, value) then | |
| 4064 | - " " + event_name(e) + "=\"" + value + "\"", | |
| 4065 | - tooltip(_) then "", //do nothing here, because we extract attributes at first in new_attrs | |
| 4066 | - data(name, value) then | |
| 4067 | - " data-" + to_lower(name) + "=\"" + value + "\"", | |
| 4068 | - | |
| 4069 | - contenteditable(value)then //boolean value | |
| 4070 | - " contenteditable=\""+ to_String(value)+ "\"" | |
| 4071 | - | |
| 4072 | - contextmenu(id_name) then //ID value | |
| 4073 | - " contextmenu=\"" + id_name + "\"", | |
| 4074 | - | |
| 4075 | - draggable(value) then //boolean value | |
| 4076 | - " draggable=\""+ to_String(value)+ "\"", | |
| 4077 | - | |
| 4078 | - enterkeyhint(value) then | |
| 4079 | - " enterkeyhint=\""+ value + "\"", | |
| 4080 | - | |
| 4081 | - hidden(value) then //boolean value | |
| 4082 | - " hidden=\""+ (if value then "hidden" else "") + "\"", | |
| 4083 | - | |
| 4084 | - inert then | |
| 4085 | - " inert", | |
| 4086 | - | |
| 4087 | - inputmode(value) then | |
| 4088 | - " inputmode =\"" + value + "\"", | |
| 4089 | - | |
| 4090 | - popover then | |
| 4091 | - " popover", | |
| 4092 | - | |
| 4093 | - spellcheck(value) then //boolean value | |
| 4094 | - " spellcheck=\""+ to_String(value)+ "\"" | |
| 4095 | - | |
| 4096 | - translate(value) then | |
| 4097 | - " translate=\"" + if value then "yes\"" else "no\"" | |
| 4098 | - }, | |
| 4099 | - current + format_attrs(t + new_attrs, new_classes, new_styles) | |
| 4100 | - }. | |
| 4101 | - | |
| 4102 | -define String | |
| 4103 | - format_attrs | |
| 4104 | - ( | |
| 4105 | - List(InputAttrs) attributs | |
| 4106 | - )= | |
| 4107 | - format_attrs(attributs, [], []). | |
| 4108 | - | |
| 4109 | -public define String | |
| 4110 | - format_attrs | |
| 4111 | - ( | |
| 4112 | - List(CoreAttrs) attributs | |
| 4113 | - )= | |
| 4114 | - format_attrs(attributs, [], []). | |
| 4115 | - | |
| 4116 | -define String | |
| 4117 | - format_text_options | |
| 4118 | - ( | |
| 4119 | - List(Text_Option) l | |
| 4120 | - ) | |
| 4121 | - = | |
| 4122 | - with text_options = get_text_options(l), | |
| 4123 | - core_attrs = get_css_class(l) + get_core_attrs(l), | |
| 4124 | - (if length(text_options)= 0 then "" else " style=\"" + format(text_options) + "\" ") | |
| 4125 | - + | |
| 4126 | - (if length(core_attrs) = 0 then "" else format_attrs(core_attrs)) | |
| 4127 | - . | |
| 4128 | - | |
| 4129 | -define Printable_tree | |
| 4130 | - format_div_option | |
| 4131 | - ( | |
| 4132 | - List(CoreAttrs) options | |
| 4133 | - )= | |
| 4134 | - ["<div" + format_attrs(options) + ">"] | |
| 4135 | -. | |
| 4136 | - | |
| 4137 | -define Maybe(String) | |
| 4138 | - extract_id | |
| 4139 | - ( | |
| 4140 | - List(CoreAttrs) attrbs | |
| 4141 | - ) = | |
| 4142 | - if attrbs is | |
| 4143 | - { | |
| 4144 | - [] then failure, | |
| 4145 | - [h . t] then | |
| 4146 | - if h is id(value) then success(value) | |
| 4147 | - else extract_id(t) | |
| 4148 | - } | |
| 4149 | -. | |
| 4150 | - | |
| 4151 | -define Maybe(String) | |
| 4152 | - extract_id | |
| 4153 | - ( | |
| 4154 | - Actioner_Aspect aspect | |
| 4155 | - ) = | |
| 4156 | - if aspect is | |
| 4157 | - { | |
| 4158 | - link(_,_,_) then failure, | |
| 4159 | - img_link(_,_,_) then failure, | |
| 4160 | - push_button(opts,_) then extract_id(opts), | |
| 4161 | - button(_,_) then failure, | |
| 4162 | - button(_,_,_,_) then failure, | |
| 4163 | - submit(opts,_) then extract_id(opts), | |
| 4164 | - //immediate_selector(_,_,_,_) then failure, | |
| 4165 | - immediate_selector(_,_,_,_,_,_) then failure, | |
| 4166 | - html(_, _) then failure, | |
| 4167 | - }. | |
| 4168 | - | |
| 4169 | -to do Complete format_foreign_link | |
| 4170 | -//TODO Complete format_foreign_link | |
| 4171 | - | |
| 4172 | - CommonInfo cinfo, | |
| 4173 | - String state_name, | |
| 4174 | - Var(Int) action_count, | |
| 4175 | - Var(Int) ic_v // 'idnum' counter variable | |
| 4176 | - | |
| 4177 | -define Printable_tree | |
| 4178 | - format_foreign_link | |
| 4179 | - ( | |
| 4180 | -// CommonInfo cinfo, | |
| 4181 | - Actioner_Target target, | |
| 4182 | - Actioner_Aspect aspect, | |
| 4183 | - String url, | |
| 4184 | - Bool is_https, | |
| 4185 | - CommonInfo cinfo, | |
| 4186 | -// String state_name, | |
| 4187 | - Var(Int) action_count, | |
| 4188 | - Var(Int) ic_v, // 'idnum' counter variable | |
| 4189 | - Var(List(HTML_Head_Tag)) head_tags | |
| 4190 | - ) = | |
| 4191 | - //if cinfo is info(common_name,http_port,https_port,site_dir,secret) then | |
| 4192 | - with full_url = make_foreign_link_url(target,url), | |
| 4193 | -// with action = format_action(full_url, aspect, extract_id(aspect), mb_form_name), | |
| 4194 | - if aspect is | |
| 4195 | - { | |
| 4196 | - | |
| 4197 | - link(opt, text, mb_name) then | |
| 4198 | - with name_tag = if mb_name is success(n) then " name=\"" + n + "\"" else "", | |
| 4199 | - [ | |
| 4200 | - "<a href=\"", full_url, "\"", format_text_options(opt), name_tag, ">", | |
| 4201 | - text, | |
| 4202 | - "</a>" | |
| 4203 | - ], | |
| 4204 | - img_link(opt, img, alt_text) then | |
| 4205 | - [ | |
| 4206 | - "<a href=\"", full_url ,"\"", format_attrs(opt),"><img src=\"", img, | |
| 4207 | - "\" alt=\"" + alt_text + "\" border=\"0\"></a>" | |
| 4208 | - ], | |
| 4209 | - push_button(options, text) then | |
| 4210 | - ["<a href=\"",full_url,"\"", format_attrs(options), ">", | |
| 4211 | - text, "</a>" | |
| 4212 | - ], | |
| 4213 | - button(url_off,url_on) then | |
| 4214 | - [ ], | |
| 4215 | - | |
| 4216 | - button(url_off,url_on,w,h) then | |
| 4217 | - [ ], | |
| 4218 | - | |
| 4219 | - submit(options, text) then | |
| 4220 | - [ ], | |
| 4221 | - | |
| 4222 | - //immediate_selector(opt,name,size,choices) then | |
| 4223 | - // [ ], | |
| 4224 | - immediate_selector(opt,name,size,choices,selected,function) then | |
| 4225 | - [ ], | |
| 4226 | - html(options, html_off_form) then | |
| 4227 | - [ | |
| 4228 | - "<a href=\"", full_url,"\"", format_attrs(options), ">", | |
| 4229 | - format(cinfo, ic_v, html_off_form, is_https, action_count, head_tags), | |
| 4230 | - "</a>" | |
| 4231 | - ] | |
| 4232 | - }. | |
| 4233 | - | |
| 4234 | -define Printable_tree | |
| 4235 | - format_actioner | |
| 4236 | - ( | |
| 4237 | - CommonInfo cinfo, | |
| 4238 | - Actioner_Connection connection, | |
| 4239 | - Actioner_Target target, | |
| 4240 | - Actioner_Aspect aspect, | |
| 4241 | - WEB_Action_Name action, | |
| 4242 | - List((String,String)) extra_ops, | |
| 4243 | - List(Actioner_Local_Action) local_actions, | |
| 4244 | - Maybe(String) mb_form_name, | |
| 4245 | - Bool is_https, | |
| 4246 | - Var(Int) action_count, | |
| 4247 | - Var(Int) ic_v, // 'idnum' counter variable | |
| 4248 | - Var(List(HTML_Head_Tag)) head_tags | |
| 4249 | - | |
| 4250 | - ) = | |
| 4251 | - | |
| 4252 | - if cinfo is info(common_name,http_port,https_port,site_dir,secret) then | |
| 4253 | - with url = make_actioner_url(cinfo,connection,target, | |
| 4254 | - action,extra_ops,is_https), | |
| 4255 | - with formatted_action = format_action(url, aspect, extract_id(aspect), mb_form_name, action_count), | |
| 4256 | - if aspect is | |
| 4257 | - { | |
| 4258 | - | |
| 4259 | - link(opt, text, mb_name) then | |
| 4260 | - with name_tag = if mb_name is success(n) then " name=\"" + n + "\"" else "", | |
| 4261 | - with action_name = if action is { | |
| 4262 | - no_action then "" | |
| 4263 | - controller_action(_, an) then an, | |
| 4264 | - action_name(an) then an, | |
| 4265 | - url(_) then "" | |
| 4266 | - }, | |
| 4267 | - if action_name = "" then | |
| 4268 | - ["<a ", format_text_options(opt), name_tag, ">", text, "</a>" ] | |
| 4269 | - else | |
| 4270 | - ["<a href=\"",url,"\"", | |
| 4271 | - format_text_options(opt), name_tag, ">", | |
| 4272 | - text, | |
| 4273 | - "</a>" | |
| 4274 | - ], | |
| 4275 | - img_link(options, img, alt_text) then | |
| 4276 | - //if action name is empty, format options on image because maybe there onclick action | |
| 4277 | - with action_name = if action is { | |
| 4278 | - no_action then "" | |
| 4279 | - controller_action(_, an) then an, | |
| 4280 | - action_name(an) then an, | |
| 4281 | - url(_) then "" | |
| 4282 | - }, | |
| 4283 | - if action_name ="" then | |
| 4284 | - [ | |
| 4285 | - "<img src=\"", img,"\"", | |
| 4286 | - format_attrs(options)," alt=\"" + alt_text + "\" border=\"0\">" | |
| 4287 | - ] | |
| 4288 | - else | |
| 4289 | - [ | |
| 4290 | - "<a href=\"", url,"\"", format_attrs(options),"><img src=\"", img, | |
| 4291 | - "\" alt=\"" + alt_text + "\" border=\"0\"></a>" | |
| 4292 | - ], | |
| 4293 | - push_button(options, text) then | |
| 4294 | - [ | |
| 4295 | - if formatted_action is | |
| 4296 | - { | |
| 4297 | - url(u) then ["<a href=\"",u,"\"", format_attrs(options), ">", | |
| 4298 | - text, "</a>" | |
| 4299 | - ], | |
| 4300 | - javascript(s,h) then | |
| 4301 | - with action_name = | |
| 4302 | - if action is | |
| 4303 | - { | |
| 4304 | - no_action then "", | |
| 4305 | - controller_action(_, an) then an, | |
| 4306 | - action_name(an) then an, | |
| 4307 | - url(_) then "" | |
| 4308 | - }, | |
| 4309 | - if action_name = "" then | |
| 4310 | - ["<input type=\"button\" value=\"",encode_HTML_entities(text),"\"", format_attrs(options), " />"] | |
| 4311 | - else | |
| 4312 | - [s,"<input type=\"button\" value=\"",encode_HTML_entities(text),"\"", format_attrs(options), " onclick=\"",h,"\" />"] | |
| 4313 | - } | |
| 4314 | - ], | |
| 4315 | - button(url_off,url_on) then | |
| 4316 | - [ if formatted_action is | |
| 4317 | - { | |
| 4318 | - url(u) then ["<a href=\"",u], | |
| 4319 | - javascript(s,h) then [s,"<a onMouseDown=\"",h] | |
| 4320 | - }, | |
| 4321 | - "\" style=\"text-decoration:none\">", | |
| 4322 | - "<img alt=\"",url_off,"\" src=\"",url_off,"\" border=0", | |
| 4323 | - " onMouseOver=\"this.src='",url_on,"'\" ", | |
| 4324 | - " onMouseOut=\"this.src='",url_off,"'\">", | |
| 4325 | - "</a>" | |
| 4326 | - ], | |
| 4327 | - | |
| 4328 | - button(url_off,url_on,w,h) then | |
| 4329 | - [ if formatted_action is | |
| 4330 | - { | |
| 4331 | - url(u) then ["<a href=\"",u], | |
| 4332 | - javascript(s,h2) then [s,"<a onMouseDown=\"",h2] | |
| 4333 | - }, | |
| 4334 | - "\" style=\"text-decoration:none\">", | |
| 4335 | - "<img width=",w," height=",h," alt=\"",url_off,"\" src=\"",url_off,"\" border=0", | |
| 4336 | - " onMouseOver=\"this.src='",url_on,"'\" ", | |
| 4337 | - " onMouseOut=\"this.src='",url_off,"'\">", | |
| 4338 | - "</a>" | |
| 4339 | - ], | |
| 4340 | - | |
| 4341 | - submit(options, text) then | |
| 4342 | - [ | |
| 4343 | - if formatted_action is | |
| 4344 | - { | |
| 4345 | - url(u) then ["<a href=\"",u,"\"", format_attrs(options), ">", | |
| 4346 | - text, "</a>" | |
| 4347 | - ], | |
| 4348 | - javascript(s,h) then | |
| 4349 | - with action_name = if action is { | |
| 4350 | - no_action then "", | |
| 4351 | - controller_action(_, an) then an, | |
| 4352 | - action_name(an) then an, | |
| 4353 | - url(_) then "" | |
| 4354 | - }, | |
| 4355 | - if action_name = "" then // special case where URL (so the action_name) is provided by the form itself | |
| 4356 | - // so javascript isn't needed. This is the standard HMTL way. | |
| 4357 | - ["<input type=\"submit\" value=\"",text,"\"", format_attrs(options), " />"] | |
| 4358 | - else | |
| 4359 | - [s,"<input type=\"submit\" value=\"",text,"\"", format_attrs(options), " onclick=\"",h,"\" />"] | |
| 4360 | - } | |
| 4361 | - ], | |
| 4362 | - | |
| 4363 | -// immediate_selector(options,name,size,choices) then | |
| 4364 | -// [ if action is | |
| 4365 | -// { | |
| 4366 | -// url(u) then ["<select href=\"",u] | |
| 4367 | -// javascript(s,h) then [s,"<select onchange=\"",h] | |
| 4368 | -// }, | |
| 4369 | -// "\" name=\"",name,"\" size=\"",size,"\"", format_attrs(options), ">", | |
| 4370 | -// format_choices(choices),"</select>" | |
| 4371 | -// ], | |
| 4372 | - immediate_selector(options, name, size, choices, mb_selected, custom_function_name) then | |
| 4373 | - [ | |
| 4374 | - //if custom function name is provided, that name is used instead of autogenerated js function | |
| 4375 | - if custom_function_name = "" then | |
| 4376 | - if formatted_action is | |
| 4377 | - { | |
| 4378 | - url(u) then ["<select href=\"",u] | |
| 4379 | - javascript(s,h) then [s,"<select onchange=\"",h] | |
| 4380 | - } | |
| 4381 | - else | |
| 4382 | - ["<select onchange=\"",custom_function_name], | |
| 4383 | - | |
| 4384 | - "\" name=\"",name,"\" size=\"",size,"\"", format_attrs(options), ">", | |
| 4385 | - if mb_selected is success(selected) then format_choices(choices, selected) else format_choices(choices),"</select>" | |
| 4386 | - ], | |
| 4387 | - html(options, html_off_form) then | |
| 4388 | - [ | |
| 4389 | - "<a href=\"", url,"\"", format_attrs(options), ">", | |
| 4390 | - format(cinfo, ic_v, html_off_form, is_https, action_count, head_tags), | |
| 4391 | - "</a>" | |
| 4392 | - ] | |
| 4393 | - }. | |
| 4394 | - | |
| 4395 | - | |
| 4396 | - | |
| 4397 | - | |
| 4398 | - | |
| 4399 | - | |
| 4400 | - *** [5.5] Formating a private download link. | |
| 4401 | - | |
| 4402 | - We get the absolute path of the file to be downloaded, and the name under which it | |
| 4403 | - should appear to the client. The function 'format_private_download' creates an | |
| 4404 | - hypertext link for downloading the file. The secured mecanism of private download is | |
| 4405 | - used. This function is called by the function which formats HTML_Any($T) elements. | |
| 4406 | - | |
| 4407 | - | |
| 4408 | -define Printable_tree | |
| 4409 | - format_private_download | |
| 4410 | - ( | |
| 4411 | - CommonInfo cinfo, | |
| 4412 | - String abs_path, // absolute file path on server | |
| 4413 | - String name, // name of file as it appears in the browser | |
| 4414 | - String extra, // extra extension | |
| 4415 | - Maybe((String,List((String,String)))) action | |
| 4416 | - ) = | |
| 4417 | - if cinfo is info(common_name,http_port,https_port,site_directory,secret) then | |
| 4418 | - with private_download_directory = site_directory+"/private_download", | |
| 4419 | - with auth = make_authorization(site_directory,secret,abs_path), | |
| 4420 | - [ | |
| 4421 | - "<a href=\"",name,extra,"?zauth=",auth, | |
| 4422 | - if action is | |
| 4423 | - { | |
| 4424 | - failure then [ ] | |
| 4425 | - success(a) then if a is (an,args) then | |
| 4426 | - ["&a=",an,format_extra_operands(args)] | |
| 4427 | - }, | |
| 4428 | - "\">", | |
| 4429 | - name, | |
| 4430 | - "</a>" | |
| 4431 | - ]. | |
| 4432 | - | |
| 4433 | - *** [5.6] Formating rows and cells in a table. | |
| 4434 | - | |
| 4435 | -define Int | |
| 4436 | - percent | |
| 4437 | - ( | |
| 4438 | - Int p | |
| 4439 | - ) = | |
| 4440 | - if p < 0 then 0 else if p > 100 then 100 else p. | |
| 4441 | - | |
| 4442 | - | |
| 4443 | - | |
| 4444 | - | |
| 4445 | - Formating cell options. | |
| 4446 | - | |
| 4447 | - | |
| 4448 | - | |
| 4449 | -define String | |
| 4450 | - format | |
| 4451 | - ( | |
| 4452 | - BackgroundOption o | |
| 4453 | - ) = | |
| 4454 | - if o is | |
| 4455 | - { | |
| 4456 | - repeat then "", | |
| 4457 | - repeat_horizontal then "; background-repeat: repeat-x", | |
| 4458 | - repeat_vertical then "; background-repeat: repeat-y", | |
| 4459 | - no_repeat then "; background-repeat: no-repeat", | |
| 4460 | - center then "; background-position: center top" | |
| 4461 | - }. | |
| 4462 | - | |
| 4463 | -define String | |
| 4464 | - format | |
| 4465 | - ( | |
| 4466 | - List(BackgroundOption) l | |
| 4467 | - ) = | |
| 4468 | - if l is | |
| 4469 | - { | |
| 4470 | - [ ] then "", | |
| 4471 | - [h . t] then format(h)+format(t) | |
| 4472 | - }. | |
| 4473 | - | |
| 4474 | - | |
| 4475 | -define String | |
| 4476 | - format | |
| 4477 | - ( | |
| 4478 | - List(Cell_Option) options | |
| 4479 | - ) = | |
| 4480 | - if options is | |
| 4481 | - { | |
| 4482 | - [ ] then "", | |
| 4483 | - [h . t] then | |
| 4484 | - if h is | |
| 4485 | - { | |
| 4486 | - core_attrs(core_attr_list) then format_attrs(core_attr_list), | |
| 4487 | - left then " align=\"left\"", | |
| 4488 | - h_center then " align=\"center\"", | |
| 4489 | - right then " align=\"right\"", | |
| 4490 | - top then " valign=\"top\"", | |
| 4491 | - v_center then " valign=\"middle\"", | |
| 4492 | - bottom then " valign=\"bottom\"", | |
| 4493 | - base_line then " valign=\"baseline\"", | |
| 4494 | - background_color(c) then " bgcolor=\""+html_format(c)+"\"", | |
| 4495 | - background_image(n,o) then " style=\"background: url("+n+")"+format(o)+"\"", | |
| 4496 | - width(w) then " width=\""+w+"\"", | |
| 4497 | - percentage_width(n) then " width=\""+percent(n)+"%\"", | |
| 4498 | - height(h2) then " height=\""+h2+"\"", | |
| 4499 | - columns(n) then " colspan=\""+n+"\"", | |
| 4500 | - rows(n) then " rowspan=\""+n+"\"", | |
| 4501 | - nowrap then " nowrap", | |
| 4502 | - style(style_string) then " style=\"" + style_string + "\"", | |
| 4503 | - class(class_name) then " class=\""+class_name+"\"" | |
| 4504 | - } | |
| 4505 | - + format(t) | |
| 4506 | - }. | |
| 4507 | - | |
| 4508 | - | |
| 4509 | - Normalizing a list of cell options (horizontal position must be specified; the default | |
| 4510 | - is 'left'). | |
| 4511 | - | |
| 4512 | - Formating cells in a row. | |
| 4513 | - | |
| 4514 | -define Printable_tree | |
| 4515 | - format | |
| 4516 | - ( | |
| 4517 | - List(HTML_Cell($T)) cells, | |
| 4518 | - $T -> Printable_tree format_element | |
| 4519 | - ) = | |
| 4520 | - if cells is | |
| 4521 | - { | |
| 4522 | - [ ] then [ ], | |
| 4523 | - [h . t] then if h is cell(options,element) then | |
| 4524 | - ["<td",format(reverse(options)),">", | |
| 4525 | - format_element(element), | |
| 4526 | - "</td>" | |
| 4527 | - . format(t,format_element)] | |
| 4528 | - }. | |
| 4529 | - | |
| 4530 | -define Printable_tree | |
| 4531 | - format | |
| 4532 | - ( | |
| 4533 | - List(HTML_Header_Cell($T)) cells, | |
| 4534 | - $T -> Printable_tree format_element | |
| 4535 | - ) = | |
| 4536 | - if cells is | |
| 4537 | - { | |
| 4538 | - [ ] then [ ], | |
| 4539 | - [h . t] then if h is header_cell(options,element) then | |
| 4540 | - ["<th ",format(reverse(options)),">", | |
| 4541 | - format_element(element), | |
| 4542 | - "</th>" | |
| 4543 | - . format(t,format_element)] | |
| 4544 | - }. | |
| 4545 | - | |
| 4546 | - Formating the rows in a table. | |
| 4547 | - | |
| 4548 | -define Printable_tree | |
| 4549 | - format | |
| 4550 | - ( | |
| 4551 | - List(HTML_Row($T)) rows, | |
| 4552 | - $T -> Printable_tree format_element, | |
| 4553 | - )= | |
| 4554 | - if rows is | |
| 4555 | - { | |
| 4556 | - [ ] then [ ], | |
| 4557 | - [h . t] then | |
| 4558 | - if h is | |
| 4559 | - { | |
| 4560 | - empty then format(t, format_element), | |
| 4561 | - row(options, cells) then | |
| 4562 | - ["<tr",format(reverse(options)),">", format(cells, format_element), "</tr>\n" | |
| 4563 | - . format(t, format_element)] | |
| 4564 | - } | |
| 4565 | - } | |
| 4566 | -. | |
| 4567 | - | |
| 4568 | -define Printable_tree | |
| 4569 | - format | |
| 4570 | - ( | |
| 4571 | - HTML_Header_Row($T) row, | |
| 4572 | - $T -> Printable_tree format_element | |
| 4573 | - ) = | |
| 4574 | - if row is | |
| 4575 | - { | |
| 4576 | - empty then [ ], | |
| 4577 | - header_row(options,cells) then | |
| 4578 | - ["<thead> <tr",format(reverse(options)),">", | |
| 4579 | - format(cells,format_element), | |
| 4580 | - "</tr> </thead>\n" | |
| 4581 | - ] | |
| 4582 | - }. | |
| 4583 | - | |
| 4584 | -define Printable_tree | |
| 4585 | - format | |
| 4586 | - ( | |
| 4587 | - HTML_Footer_Row($T) row, | |
| 4588 | - $T -> Printable_tree format_element | |
| 4589 | - ) = | |
| 4590 | - if row is | |
| 4591 | - { | |
| 4592 | - empty then [ ], | |
| 4593 | - footer_row(options,cells) then | |
| 4594 | - ["<tfoot> <tr",format(reverse(options)),">", | |
| 4595 | - format(cells,format_element), | |
| 4596 | - "</tr> </tfoot>\n" | |
| 4597 | - ] | |
| 4598 | - }. | |
| 4599 | - | |
| 4600 | -define Printable_tree | |
| 4601 | - format1 | |
| 4602 | - ( | |
| 4603 | - List(TextAreaOption) l | |
| 4604 | - ) = | |
| 4605 | - if l is | |
| 4606 | - { | |
| 4607 | - [] then [], | |
| 4608 | - [h . t] then if h is | |
| 4609 | - { | |
| 4610 | - input_attrs(input_attr_list) then [format_attrs(input_attr_list) . format1(t)], | |
| 4611 | - disabled then [" disabled=\"disabled\" " . format1(t)] | |
| 4612 | - read_only then [" readonly=\"readonly\" " . format1(t)] | |
| 4613 | - wrap_lines then [" wrap=\"wrap\" " . format1(t)] | |
| 4614 | - } | |
| 4615 | - }. | |
| 4616 | - | |
| 4617 | -define Printable_tree | |
| 4618 | - format | |
| 4619 | - ( | |
| 4620 | - List(TextAreaOption) l | |
| 4621 | - )= | |
| 4622 | - if member(l, wrap_lines) then | |
| 4623 | - format1(l) | |
| 4624 | - else | |
| 4625 | - [" wrap=\"off\" " . format1(l)] | |
| 4626 | -. | |
| 4627 | - | |
| 4628 | - | |
| 4629 | - *** [5.7] Formating elements which may be put anywhere. | |
| 4630 | - | |
| 4631 | - The function below involves the parameter $T which is later instantiated as | |
| 4632 | - 'HTML_In_Form' or as 'HTML_Off_Form'. Now, since there are dictinct 'format' functions | |
| 4633 | - for these two types, and because formating of tables requires recursive calls of such | |
| 4634 | - functions, it is necessary to provide the 'format' function to be called recursively as | |
| 4635 | - an argument. Putting naively a call to 'format' will not work, because the compiler | |
| 4636 | - will look for a function able to format data of type $T (which is at that time distinct | |
| 4637 | - from any other type, including our two types). Such a function does not exist. Hence | |
| 4638 | - the function to be called for formating elements must be passed as a functional | |
| 4639 | - argument (called 'format_element' below). Actually, what we pass is a function taking | |
| 4640 | - a unique argument of type $T. Other informations (like the name of the state) are | |
| 4641 | - already in the function by way of full functionality. | |
| 4642 | - | |
| 4643 | - | |
| 4644 | - Formating text options. They are formated in CSS syntax, to be used within a | |
| 4645 | - 'style=...'. | |
| 4646 | - | |
| 4647 | -define String | |
| 4648 | - format | |
| 4649 | - ( | |
| 4650 | - List(Text_Option) l | |
| 4651 | - ) = | |
| 4652 | - if l is | |
| 4653 | - { | |
| 4654 | - [ ] then "", | |
| 4655 | - [h . t] then if h is | |
| 4656 | - { | |
| 4657 | - core_attrs(core_attr_list) then format_attrs(core_attr_list), | |
| 4658 | - size(n) then "font-size:"+n+"pt", | |
| 4659 | - font(fn) then "font-family:"+fn, | |
| 4660 | - color(c) then if c is rgb(r,g,b) then | |
| 4661 | - "color:rgb("+to_decimal(r)+","+to_decimal(g)+","+to_decimal(b)+")", | |
| 4662 | - italic then "font-style:italic", | |
| 4663 | - oblique then "font-style:oblique", | |
| 4664 | - small_capitals then "font-variant:small-caps", | |
| 4665 | - bold then "font-weight:bold", | |
| 4666 | - underlined then "text-decoration:underline", | |
| 4667 | - left_justified then "text-align:left", | |
| 4668 | - right_justified then "text-align:right", | |
| 4669 | - justified then "text-align:justify", | |
| 4670 | - line_through then "text-decoration:line-through", | |
| 4671 | - nowrap then "white-space:nowrap", | |
| 4672 | - class(class_name)then " class=\"" + class_name +"\"", | |
| 4673 | - id(id_name) then " id=\"" + id_name +"\"", | |
| 4674 | - style(style_string) then " style=\"" + style_string + "\"", | |
| 4675 | - title(s) then " title=\"" + s +"\"" | |
| 4676 | - attr(n,v) then " " + n + "=\"" + v +"\"" | |
| 4677 | - } + if t is [ ] then "" else ("; "+format(t)) | |
| 4678 | - }. | |
| 4679 | - | |
| 4680 | - | |
| 4681 | - | |
| 4682 | - Formating table options. | |
| 4683 | - | |
| 4684 | -define String | |
| 4685 | - format | |
| 4686 | - ( | |
| 4687 | - List(Table_Option) l, | |
| 4688 | - Bool border_seen | |
| 4689 | - ) = | |
| 4690 | - if l is | |
| 4691 | - { | |
| 4692 | - [ ] then if border_seen then "" else " border=\"0\" cellspacing=\"0\" cellpadding=\"0\"", | |
| 4693 | - [h . t] then if h is | |
| 4694 | - { | |
| 4695 | - core_attrs(core_attr_list) then format_attrs(core_attr_list), | |
| 4696 | - background_color(c) then " bgcolor=\""+html_format(c)+"\""+format(t,border_seen), | |
| 4697 | - background_image(url) then " background="+url+format(t,border_seen), | |
| 4698 | - border(o,top,i,c) then " border=\""+o+"\" cellspacing=\""+top+"\" cellpadding=\""+i+"\""+ | |
| 4699 | - //" bordercolor="+format(c)+ | |
| 4700 | - format(t,true), | |
| 4701 | - width(w) then " width=\""+w+"\""+format(t,border_seen), | |
| 4702 | - percentage_width(p) then " width=\""+percent(p)+"%\""+format(t,border_seen), | |
| 4703 | - attr(name, value) then " " + name + "=\"" + value + "\"" +format(t,border_seen), | |
| 4704 | - class(name) then " class=\""+name+"\"" | |
| 4705 | - } | |
| 4706 | - }. | |
| 4707 | - | |
| 4708 | - | |
| 4709 | - | |
| 4710 | - | |
| 4711 | - | |
| 4712 | -define Printable_tree | |
| 4713 | - format_scroller | |
| 4714 | - ( | |
| 4715 | - Int width, | |
| 4716 | - Int height, | |
| 4717 | - Int content_width, | |
| 4718 | - Int content_height, | |
| 4719 | - Int idnum, // identifying the scroller | |
| 4720 | - $T content, | |
| 4721 | - $T -> Printable_tree format_element | |
| 4722 | - ) = | |
| 4723 | - [ | |
| 4724 | - "<script type = \"text/javascript\" language=\"JavaScript\">", | |
| 4725 | - "function doscroll_",idnum,"(dx,dy) {\n", | |
| 4726 | - " if (document.layers) { var c_",idnum," = eval(document.cs_",idnum,"); } else\n", | |
| 4727 | - " if (document.getElementById) {var c_",idnum," = eval(\"document.getElementById('cs_", | |
| 4728 | - idnum,"').style\"); } else\n", | |
| 4729 | - " if (document.all) { var c_",idnum," = eval(document.all.cs_",idnum,".style); };\n", | |
| 4730 | - " var x_",idnum," = parseInt(c_",idnum,".left);\n", | |
| 4731 | - " var y_",idnum," = parseInt(c_",idnum,".top);\n", | |
| 4732 | - " if ((x_",idnum,"+dx <= 0) && (x_",idnum,"+dx > ",width-content_width,"))\n", | |
| 4733 | - " { x_",idnum," += dx; }\n", | |
| 4734 | - " if ((y_",idnum,"+dy <= 0) && (y_",idnum,"+dy > ",height-content_height,"))\n", | |
| 4735 | - " { y_",idnum," += dy; }\n", | |
| 4736 | - " c_",idnum,".left = x_",idnum,";\n", | |
| 4737 | - " c_",idnum,".top = y_",idnum,";\n", | |
| 4738 | - " }\n", | |
| 4739 | - "</script>\n", | |
| 4740 | - "<table>", | |
| 4741 | - "<tbody>", | |
| 4742 | - "<tr>", | |
| 4743 | - "<td align=left valign=top", | |
| 4744 | - " width=",width, | |
| 4745 | - " height=",height, | |
| 4746 | - ">", | |
| 4747 | - "<div id=\"ws_",idnum,"\" style=\"position:absolute; width:",width,"px; height:",height,"px;", | |
| 4748 | - " clip:rect(0px ",width,"px ",height,"px 0px)\">", | |
| 4749 | - "<div id=\"cs_",idnum,"\" style=\"position:absolute; left:0px; top:0px\">", | |
| 4750 | - format_element(content), | |
| 4751 | - "</div>", | |
| 4752 | - "</div>", | |
| 4753 | - "</td>", | |
| 4754 | - "<td valign=bottom>", | |
| 4755 | - "<table>", | |
| 4756 | - "<tbody>", | |
| 4757 | - "<tr><td><img alt=\"sroll up\" src=\"scrollup.gif\" onmousedown=\"doscroll_", idnum,"(0,20);\"></td></tr>", | |
| 4758 | - "<tr><td><img alt=\"scroll down\" src=\"scrolldown.gif\" onmousedown=\"doscroll_", idnum,"(0,-20);\"></td></tr>", | |
| 4759 | - "</tbody>", | |
| 4760 | - "</table>", | |
| 4761 | - "</td>", | |
| 4762 | - "</tr>", | |
| 4763 | - (if content_width > width then | |
| 4764 | - [ | |
| 4765 | - "<tr>", | |
| 4766 | - "<td align=right>", | |
| 4767 | - "<table>", | |
| 4768 | - "<tbody>", | |
| 4769 | - "<tr>", | |
| 4770 | - "<td><img alt=\"scroll left\" src=\"scrollleft.gif\" onmousedown=\"doscroll_", idnum,"(20,0);\"></td>", | |
| 4771 | - "<td><img alt=\"scroll right\" src=\"scrollright.gif\" onmousedown=\"doscroll_", idnum,"(-20,0);\"></td>", | |
| 4772 | - "</tr>", | |
| 4773 | - "</tbody>", | |
| 4774 | - "</table>", | |
| 4775 | - "</td>", | |
| 4776 | - "</tr>", | |
| 4777 | - ] else [ ]), | |
| 4778 | - "</tbody>", | |
| 4779 | - "</table>" | |
| 4780 | - ]. | |
| 4781 | - | |
| 4782 | - | |
| 4783 | - | |
| 4784 | - | |
| 4785 | -define Printable_tree | |
| 4786 | - add_css_files | |
| 4787 | - ( | |
| 4788 | - List(CSS_File) l | |
| 4789 | - ) = | |
| 4790 | - if l is | |
| 4791 | - { | |
| 4792 | - [ ] then [ ], | |
| 4793 | - [h . t] then | |
| 4794 | - since h is css_file(file_name, media), | |
| 4795 | - [ ["<link rel=\"stylesheet\" type=\"text/css\" href=\"" + file_name + "\" media=\""+to_String(media)+"\"/>\n" ] | |
| 4796 | - . add_css_files(t)] | |
| 4797 | - }. | |
| 4798 | - | |
| 4799 | - | |
| 4800 | -define Printable_tree | |
| 4801 | - add_css_styles | |
| 4802 | - ( | |
| 4803 | - List(CSS_Style) css_styles | |
| 4804 | - ) = | |
| 4805 | - | |
| 4806 | - if css_styles is | |
| 4807 | - { | |
| 4808 | - [] then [], | |
| 4809 | - [_ . _] then [ "<style type=\"text/css\"><!--\n", | |
| 4810 | - format_css_styles(css_styles), | |
| 4811 | - " --></style>\n" | |
| 4812 | - ] | |
| 4813 | - }. | |
| 4814 | - | |
| 4815 | - | |
| 4816 | - // The function below formats a datum of type 'HTML_Any($T)'. | |
| 4817 | - | |
| 4818 | -define Printable_tree | |
| 4819 | - format | |
| 4820 | - ( | |
| 4821 | - CommonInfo cinfo, | |
| 4822 | - Var(Int) ic_v, | |
| 4823 | - HTML_Any($T) element, | |
| 4824 | - $T -> Printable_tree format_element, // able to format a datum of type $T | |
| 4825 | - Bool is_https, | |
| 4826 | - Var(Int) action_count, | |
| 4827 | - Var(List(HTML_Head_Tag)) head_tags | |
| 4828 | - ) = | |
| 4829 | - if cinfo is info(common_name,http_port,https_port,site_directory,secret) then | |
| 4830 | - if element is | |
| 4831 | - { | |
| 4832 | - any_text(opts , t) then | |
| 4833 | - if opts is | |
| 4834 | - { | |
| 4835 | - [] then [t], | |
| 4836 | - [_ . _] then ["<span", format_attrs(opts), ">",t,"</span>"] | |
| 4837 | - }, | |
| 4838 | - any_preformated(opts,s) then | |
| 4839 | - ["<span", format_text_options(opts), "><pre>",s,"</pre></span>"], | |
| 4840 | - //["<pre>",s,"</pre>"], | |
| 4841 | - any_paragraph(opts,l) then | |
| 4842 | - ["<p", format_text_options(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</p>\n"], | |
| 4843 | - any_image(opts, url, _alt) then | |
| 4844 | - with alt = if _alt = "" then "" else "alt=\""+_alt+"\"", | |
| 4845 | - ["<img ",alt," src=\"",url,"\" ", format_attrs(opts)," />"], | |
| 4846 | - any_image(opts, url, alt, w, h) then | |
| 4847 | - ["<img alt=\"",alt,"\" src=\"",url,"\" width=\"",w,"\" height=\"",h,"\" ", format_attrs(opts)," />"], | |
| 4848 | - any_table(opts,h_row, rows, f_row) then | |
| 4849 | - ["<table",format(reverse(opts),false),">", | |
| 4850 | - format(h_row, format_element), | |
| 4851 | - "<tbody>",format(rows,format_element),"</tbody>", | |
| 4852 | - format(f_row, format_element), | |
| 4853 | - "</table>\n"], | |
| 4854 | - any_center(e) then | |
| 4855 | - ["<center>",format_element(e),"</center>"], | |
| 4856 | - any_mail_to(email,elem) then | |
| 4857 | - ["<a href=\"mailto:",email,"\">",format_element(elem),"</a>"], | |
| 4858 | - any_scroller(w,h,cw,ch,c) then | |
| 4859 | - format_scroller(w,h,cw,ch,new_idnum(ic_v),c,format_element), | |
| 4860 | - any_fixed_size(w,h,c) then | |
| 4861 | - with url = create_secondary_document(site_directory,secret,format_element,c,w), | |
| 4862 | - ["<object data=\"",url,"\" type=\"text/html\" width=\"",format(w),"\" height=\"",format(h),"\" >", | |
| 4863 | - "secondary document", | |
| 4864 | - "</object>"], | |
| 4865 | - any_fixed_size_2(w,h,fn) then | |
| 4866 | - with url = fn+"?zauth="+make_authorization(site_directory,secret, | |
| 4867 | - fn), | |
| 4868 | - ["<object data=\"",url,"\" type=\"text/html\" width=\"",format(w),"\" height=\"",format(h),"\" >", | |
| 4869 | - "secondary document", | |
| 4870 | - "</object>"], | |
| 4871 | - any_actioner(c,t,a,an,eo,ja,fn) then | |
| 4872 | - format_actioner(cinfo,c,t,a,an,eo,ja,fn,is_https, action_count, ic_v, head_tags), | |
| 4873 | - | |
| 4874 | - any_foreign_link_new(target, aspect, url) then | |
| 4875 | - format_foreign_link(target, aspect, url, is_https, cinfo, action_count, ic_v, head_tags), | |
| 4876 | - | |
| 4877 | - any_foreign_link(options,url) then | |
| 4878 | - ["<a href=\"",url,"\" ", format_text_options(options), "></a>"], // IE7 doesn't support the form <a href="..." /> | |
| 4879 | - any_foreign_link(options,url,name) then | |
| 4880 | - ["<a href=\"",url,"\"><span ", format_text_options(options), ">",name,"</span></a>"], | |
| 4881 | - any_private_download(url,name,extra_ext,action) then | |
| 4882 | - format_private_download(cinfo,url,name,extra_ext,action), | |
| 4883 | - any_div(options, l) then | |
| 4884 | - [format_div_option(options), flat(map(($T e) |-> format_element(e), l)),"</div>\n"], | |
| 4885 | - any_div_empty(options) then | |
| 4886 | - [format_div_option(options), "</div>\n"], | |
| 4887 | - any_coreattrs(attributs) then | |
| 4888 | - [format_attrs(attributs)], | |
| 4889 | - any_ol(opts, l) then | |
| 4890 | - ["<ol", format_attrs(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</ol>\n"], | |
| 4891 | - any_ul(opts, l) then | |
| 4892 | - ["<ul", format_attrs(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</ul>\n"], | |
| 4893 | - any_li(opts, l) then | |
| 4894 | - ["<li", format_attrs(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</li>\n"], | |
| 4895 | - any_button(options, l) then | |
| 4896 | - [["<button" + format_attrs(options) + ">"], flat(map(($T e) |-> format_element(e), l)),"</button>\n"], | |
| 4897 | - any_i(opts,t) then | |
| 4898 | - if t = "" then | |
| 4899 | - ["<i", format_attrs(opts), "></i>\n"] | |
| 4900 | - else | |
| 4901 | - ["<i", format_attrs(opts), ">",t,"</i>\n"], | |
| 4902 | - any_span(opts , t) then | |
| 4903 | - ["<span", format_attrs(opts), ">",t,"</span>"] | |
| 4904 | - any_hr(opts) then | |
| 4905 | - ["<hr", format_attrs(opts),">"] | |
| 4906 | - } | |
| 4907 | -. | |
| 4908 | - | |
| 4909 | - | |
| 4910 | - | |
| 4911 | - // *** [5.8] Formating 'in form' elements. | |
| 4912 | - | |
| 4913 | - | |
| 4914 | -//public define Printable_tree | |
| 4915 | -// format | |
| 4916 | -// ( | |
| 4917 | -// HTML_tooltip tooltip | |
| 4918 | -// )= | |
| 4919 | -// if tooltip is | |
| 4920 | -// { | |
| 4921 | -// html_tooltip(title, keyword, width) then | |
| 4922 | -// ["<a id=\"help_",keyword,"\" class=\"jTipu jTip_help\" name=\"",title,"\" href=\"/?a=ajax_show_tooltip&tooltip_id=",keyword,(if width > 0 then ["&width=",width,"\""] else ["\""]), "></a>"], | |
| 4923 | -// | |
| 4924 | -// html_tooltip_ext(title, extend_type, class_suffix, ext_args) then | |
| 4925 | -// with extra_args = format_extra_operands(ext_args), | |
| 4926 | -// ["<a id=\"jTip\" class=\"jTipu jTip_",class_suffix,"\" name=\"",title,"\" href=\"/?a=ajax_show_tooltip&tooltip_ext=",extend_type+extra_args,"\"></a>"] | |
| 4927 | -// }. | |
| 4928 | - | |
| 4929 | -public define List(CoreAttrs) | |
| 4930 | - extract_attributes | |
| 4931 | - ( | |
| 4932 | - HTML_tooltip tooltip | |
| 4933 | - )= | |
| 4934 | - if tooltip is | |
| 4935 | - { | |
| 4936 | - html_tooltip(title, keyword, width) then //TODO | |
| 4937 | - [] | |
| 4938 | - //["<a id=\"help_",keyword,"\" class=\"jTipu \" name=\"",title,"\" href=\"/?a=ajax_show_tooltip&tooltip_id=",keyword,(if width > 0 then ["&width=",width,"\""] else ["\""]), "><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"], | |
| 4939 | - | |
| 4940 | - html_tooltip_ext(title, extend_type, class_suffix, ext_args) then //TODO | |
| 4941 | - //[] | |
| 4942 | - with extra_args = format_extra_operands(ext_args), | |
| 4943 | - [id("jTip"), class("jTipu jTip_"+class_suffix), data("name",title), data("href", "/?a=ajax_show_tooltip&tooltip_ext="+extend_type+extra_args)] | |
| 4944 | - | |
| 4945 | - html_tooltip_ext(title, extend_type, ext_args) then //TODO | |
| 4946 | - with extra_args = format_extra_operands(ext_args), | |
| 4947 | - [id("jTip"), class("jTipu"), data("name",title), data("href", "/?a=ajax_show_tooltip&tooltip_ext="+extend_type+extra_args)] | |
| 4948 | -// [] | |
| 4949 | - //with extra_args = format_extra_operands(ext_args), | |
| 4950 | - //["<a id=\"jTip\" class=\"jTipu \" name=\"",title,"\" href=\"/?a=ajax_show_tooltip&tooltip_ext=",extend_type+extra_args,"\"><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"], | |
| 4951 | - | |
| 4952 | - html_tooltip(title, web_action, extra_args) then | |
| 4953 | - [ id("jTip"), class("jTipu"), data("name", title), data("href", "/"+format_web_action_name(web_action, extra_args)) | |
| 4954 | - ] | |
| 4955 | - | |
| 4956 | - //["<a id=\"jTip\" class=\"jTipu \" name=\"",title,"\" href=\"/", format_web_action_name(web_action, extra_args) ,"\"><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"], | |
| 4957 | - | |
| 4958 | - } | |
| 4959 | -. | |
| 4960 | - | |
| 4961 | - literal_pt(["<span id=\"jTip\" class=\"jTipu\" data-name=\"",title,"\" data-href=\"/", format_web_action_name(web_action, extra_args) ,"\">"]), | |
| 4962 | - | |
| 4963 | - | |
| 4964 | -public define Printable_tree | |
| 4965 | - format | |
| 4966 | - ( | |
| 4967 | - HTML_tooltip tooltip | |
| 4968 | - )= | |
| 4969 | - if tooltip is | |
| 4970 | - { | |
| 4971 | - html_tooltip(title, keyword, width) then | |
| 4972 | - ["<a id=\"help_",keyword,"\" class=\"jTipu \" data-name=\"",title,"\" data-href=\"/?a=ajax_show_tooltip&tooltip_id=",keyword,(if width > 0 then ["&width=",width,"\""] else ["\""]), "><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"], | |
| 4973 | - | |
| 4974 | - html_tooltip_ext(title, extend_type, class_suffix, ext_args) then | |
| 4975 | - with extra_args = format_extra_operands(ext_args), | |
| 4976 | - ["<a id=\"jTip\" class=\"jTipu jTip_",class_suffix,"\" data-name=\"",title,"\" data-href=\"/?a=ajax_show_tooltip&tooltip_ext=",extend_type+extra_args,"\"></a>"] | |
| 4977 | - | |
| 4978 | - html_tooltip_ext(title, extend_type, ext_args) then | |
| 4979 | - with extra_args = format_extra_operands(ext_args), | |
| 4980 | - ["<a id=\"jTip\" class=\"jTipu \" data-name=\"",title,"\" data-href=\"/?a=ajax_show_tooltip&tooltip_ext=",extend_type+extra_args,"\"><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"], | |
| 4981 | - html_tooltip(title, web_action, extra_args) then | |
| 4982 | - ["<a id=\"jTip\" class=\"jTipu \" data-name=\"",title,"\" data-href=\"/", format_web_action_name(web_action, extra_args) ,"\"><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"], | |
| 4983 | - | |
| 4984 | - } | |
| 4985 | -. | |
| 4986 | - | |
| 4987 | -public define HTML_Off_Form | |
| 4988 | - html_tooltip | |
| 4989 | - ( | |
| 4990 | - String title, | |
| 4991 | - WEB_Action_Name web_action, | |
| 4992 | - List((String,String)) extra_args, | |
| 4993 | - HTML_Off_Form html_element, | |
| 4994 | - )= | |
| 4995 | - span([id("jTip"), class("jTipu"), data("name", title), data("href", "/"+format_web_action_name(web_action, extra_args))], html_element) | |
| 4996 | -. | |
| 4997 | - | |
| 4998 | -public define HTML_Off_Form | |
| 4999 | - html_tooltip | |
| 5000 | - ( | |
| 5001 | - String title, | |
| 5002 | - String keyword, | |
| 5003 | - ) = | |
| 5004 | - literal_pt(format(html_tooltip(title, keyword, 0))). | |
| 5005 | - | |
| 5006 | -public define HTML_In_Form | |
| 5007 | - html_tooltip | |
| 5008 | - ( | |
| 5009 | - String title, | |
| 5010 | - String keyword, | |
| 5011 | - ) = | |
| 5012 | - literal_pt(format(html_tooltip(title, keyword, 0))). | |
| 5013 | - | |
| 5014 | -public define HTML_Off_Form | |
| 5015 | - html_tooltip | |
| 5016 | - ( | |
| 5017 | - String keyword, | |
| 5018 | - Int size, | |
| 5019 | - ) = | |
| 5020 | - literal_pt(format(html_tooltip("", keyword, size))). | |
| 5021 | - | |
| 5022 | -public define HTML_In_Form | |
| 5023 | - html_tooltip | |
| 5024 | - ( | |
| 5025 | - String keyword, | |
| 5026 | - Int size, | |
| 5027 | - ) = | |
| 5028 | - literal_pt(format(html_tooltip("", keyword, size))). | |
| 5029 | - | |
| 5030 | -public define Printable_tree | |
| 5031 | - format_help | |
| 5032 | - ( | |
| 5033 | - Printable_tree label, | |
| 5034 | - HTML_Help _help | |
| 5035 | - ) = | |
| 5036 | - if _help is | |
| 5037 | - { | |
| 5038 | - no_help then label, | |
| 5039 | - tooltip(html_tooltip, position) then | |
| 5040 | - if position is | |
| 5041 | - { | |
| 5042 | - left then pt_pt(format(html_tooltip),label), | |
| 5043 | - right then pt_pt(label, format(html_tooltip)) | |
| 5044 | - } | |
| 5045 | - }. | |
| 5046 | - | |
| 5047 | - | |
| 5048 | - | |
| 5049 | -public define HTML_Label | |
| 5050 | - label | |
| 5051 | - ( | |
| 5052 | - String text | |
| 5053 | - )= | |
| 5054 | - label(text, no_help). | |
| 5055 | - | |
| 5056 | - | |
| 5057 | - | |
| 5058 | - | |
| 5059 | -define Printable_tree | |
| 5060 | - format | |
| 5061 | - ( | |
| 5062 | - CommonInfo cinfo, | |
| 5063 | - String fn, // form_name | |
| 5064 | - Var(Int) ic_v, // idnum counter variable | |
| 5065 | - HTML_In_Form element, | |
| 5066 | - Bool is_https, | |
| 5067 | - Var(Int) action_count, | |
| 5068 | - Var(List(HTML_Head_Tag)) head_tags | |
| 5069 | - ) = | |
| 5070 | - if cinfo is info(common_name,http_port,https_port,site_directory,secret) then | |
| 5071 | - with format_element = (HTML_In_Form e) |-> format(cinfo, fn, ic_v, e, is_https, action_count, head_tags), | |
| 5072 | - if element is | |
| 5073 | - { | |
| 5074 | - empty then [], | |
| 5075 | - literal_pt(t) then t, | |
| 5076 | - literal(t) then [t], | |
| 5077 | - sequence(l) then flat(map(format_element,l)) | |
| 5078 | - text(opts,t) then | |
| 5079 | - format(cinfo,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags), | |
| 5080 | - preformated(o,s) then | |
| 5081 | - format(cinfo,ic_v,any_preformated(o,s),format_element,is_https, action_count, head_tags), | |
| 5082 | - paragraph(opts,t) then | |
| 5083 | - format(cinfo,ic_v,any_paragraph(opts,t),format_element,is_https, action_count, head_tags), | |
| 5084 | - image(opts, url, alt) then | |
| 5085 | - format(cinfo,ic_v,any_image(opts, url, alt),format_element,is_https, action_count, head_tags), | |
| 5086 | - image(opts, url, alt, w, h) then | |
| 5087 | - format(cinfo,ic_v,any_image(opts, url, alt, w, h),format_element,is_https, action_count, head_tags), | |
| 5088 | - table(opts,header_row,rows,footer_row) then | |
| 5089 | - format(cinfo,ic_v,any_table(opts, header_row, rows, footer_row),format_element,is_https, action_count, head_tags), | |
| 5090 | - center(e) then | |
| 5091 | - format(cinfo,ic_v,any_center(e),format_element,is_https, action_count, head_tags), | |
| 5092 | - mail_to(a,e) then | |
| 5093 | - format(cinfo,ic_v,any_mail_to(a,e),format_element,is_https, action_count, head_tags), | |
| 5094 | - scroller(w,h,cw,ch,c) then | |
| 5095 | - format(cinfo,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count, head_tags), | |
| 5096 | - actioner(c,t,a,an,eo,ja) then | |
| 5097 | - format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags), | |
| 5098 | - | |
| 5099 | - foreign_link_new(target, aspect, url) then | |
| 5100 | - format(cinfo,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags), | |
| 5101 | - | |
| 5102 | - foreign_link(options,url) then | |
| 5103 | - format(cinfo,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags), | |
| 5104 | - foreign_link(options,url,name) then | |
| 5105 | - format(cinfo,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags), | |
| 5106 | - private_download(url,name,extra,action) then | |
| 5107 | - format(cinfo,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags), | |
| 5108 | - text_input(options, label_text, id, name, init, w) then | |
| 5109 | - [ format_label(label_text, id), | |
| 5110 | - "<input type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",encode_HTML_entities(init.value),"\"",format_attrs([class("in") . options])," />"], | |
| 5111 | - text_input_ro(options, label_text, id, name, init, w) then | |
| 5112 | - [ format_label(label_text, id), | |
| 5113 | - "<input readonly=\"readonly\" type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",encode_HTML_entities(init.value),"\"",format_attrs([class("in") . options])," />"], | |
| 5114 | - password_input(options, label_text, id, name, init, w) then | |
| 5115 | - [ format_label(label_text, id), | |
| 5116 | - "<input type=\"password\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",encode_HTML_entities(init.value),"\"",format_attrs([class("in") . options])," />"], | |
| 5117 | - text_area(options,label_text, id, n, init, w, h) then | |
| 5118 | - [ format_label(label_text, id), "<textarea ",format(options)," id=\"",id,"\" name=\"",n,"\" cols=\"",w,"\" rows=\"",h,"\">",encode_HTML_entities(init.value),"</textarea>"], | |
| 5119 | - file_upload(options, label, id, n, w) then | |
| 5120 | - [ format_label(label, id), | |
| 5121 | - "<input type=\"file\" id=\"",id,"\" size=\"",w,"\" name=\"",n,"\"",format_attrs([class("in") . options])," />"], | |
| 5122 | - selector(options, label, id, n,s,cs) then | |
| 5123 | - [ format_label(label, id), | |
| 5124 | - "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs),"</select>"], | |
| 5125 | - selector(options, label, id, n,s,cs,sd) then | |
| 5126 | - [ format_label(label, id), | |
| 5127 | - "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs,sd),"</select>"], | |
| 5128 | - selector_c(options, label, id, n,s,cs) then | |
| 5129 | - [ format_label(label, id), | |
| 5130 | - "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs),"</select>"], | |
| 5131 | - selector_c(options, label, id, n,s,cs,sd) then | |
| 5132 | - [ format_label(label, id), | |
| 5133 | - "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs,sd),"</select>"], | |
| 5134 | - | |
| 5135 | - radio_button(options, label, id, n, value, c) then | |
| 5136 | - [ format_label(label, id), | |
| 5137 | - "<input type=\"radio\" name=\"",n,"\" id=\"",id,"\" value=\"",value,"\"",(if c then " checked=\"checked\"" else ""),format_attrs([class("in") . options])," />"], | |
| 5138 | - radio_button_r(options, label, id, n, value, c) then | |
| 5139 | - [ "<input type=\"radio\" name=\"",n,"\" id=\"",id,"\" value=\"",value,"\"",(if c then " checked=\"checked\"" else ""),format_attrs([class("in") . options])," />", | |
| 5140 | - format_label(label, id)], | |
| 5141 | - check_box(options, label, id, n, c) then | |
| 5142 | - [ format_label(label, id), | |
| 5143 | - "<input type=\"hidden\" name=\"~",n,"\" value=\"~true\" /><input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"true\"",(if c then " checked=\"checked\" " else ""),format_attrs([class("in") . options])," />"] | |
| 5144 | - check_box_r(options, label, id, n, c) then | |
| 5145 | - [ "<input type=\"hidden\" name=\"~",n,"\" value=\"~true\" /><input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"true\"",(if c then " checked=\"checked\" " else ""),format_attrs([class("in") . options])," />", | |
| 5146 | - format_label(label, id)] | |
| 5147 | - div(options, e) then | |
| 5148 | - format(cinfo,ic_v,any_div(options, e),format_element,is_https, action_count, head_tags), | |
| 5149 | - div_empty(options) then | |
| 5150 | - format(cinfo,ic_v,any_div_empty(options),format_element,is_https, action_count, head_tags), | |
| 5151 | - hidden(_id, name, init) then | |
| 5152 | - since _id is html_Id(id), | |
| 5153 | - ["<input type=\"hidden\"",(if id = "" then "" else " id=\""+id+"\"")," name=\"",name,"\" value=\"",encode_HTML_entities(init.value),"\" />"], | |
| 5154 | - partial(p_content) then | |
| 5155 | - if p_content is partial_content(tags, html_elements) then | |
| 5156 | - head_tags <- *head_tags + tags; | |
| 5157 | - | |
| 5158 | - format(cinfo, ic_v, html_elements, is_https, action_count, head_tags), | |
| 5159 | - br then ["<br>"], | |
| 5160 | - progress(options, value, max) then ["<progress max=\"",value,"\" value=\"",max,"\"",format_attrs(options),"></progress>"], | |
| 5161 | - ol(opts, t) then | |
| 5162 | - format(cinfo,ic_v,any_ol(opts,t),format_element,is_https, action_count, head_tags), | |
| 5163 | - ul(opts, t) then | |
| 5164 | - format(cinfo,ic_v,any_ul(opts,t),format_element,is_https, action_count, head_tags), | |
| 5165 | - li(opts, t) then | |
| 5166 | - format(cinfo,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags), | |
| 5167 | - button(options, e) then | |
| 5168 | - format(cinfo,ic_v,any_button(options, e),format_element,is_https, action_count, head_tags), | |
| 5169 | - i(opts, t) then | |
| 5170 | - format(cinfo,ic_v,any_i(opts,t),format_element,is_https, action_count, head_tags), | |
| 5171 | - span(opts,t) then | |
| 5172 | - format(cinfo,ic_v,any_span(opts,t),format_element,is_https, action_count, head_tags) | |
| 5173 | - hr(opts) then | |
| 5174 | - format(cinfo,ic_v,any_hr(opts),format_element,is_https, action_count, head_tags) | |
| 5175 | - }. | |
| 5176 | - | |
| 5177 | - | |
| 5178 | - | |
| 5179 | - | |
| 5180 | - | |
| 5181 | - | |
| 5182 | - *** [5.9] Formating 'off form' elements. | |
| 5183 | - | |
| 5184 | - The encryption type 'multipart/form-data' is required for a form containing an upload. | |
| 5185 | - | |
| 5186 | - | |
| 5187 | -define Bool | |
| 5188 | - contains_an_upload | |
| 5189 | - ( | |
| 5190 | - HTML_In_Form form_content | |
| 5191 | - ). | |
| 5192 | - | |
| 5193 | -define Bool | |
| 5194 | - contains_an_upload | |
| 5195 | - ( | |
| 5196 | - HTML_Row(HTML_In_Form) row | |
| 5197 | - ) = | |
| 5198 | - if row is | |
| 5199 | - { | |
| 5200 | - empty then false, | |
| 5201 | - row(_, cells) then | |
| 5202 | - mapor(contains_an_upload, | |
| 5203 | - map(content, cells)) | |
| 5204 | - } | |
| 5205 | -. | |
| 5206 | - | |
| 5207 | -define Bool | |
| 5208 | - contains_an_upload | |
| 5209 | - ( | |
| 5210 | - HTML_Footer_Row(HTML_In_Form) row | |
| 5211 | - )= | |
| 5212 | - if row is | |
| 5213 | - { | |
| 5214 | - empty then false, | |
| 5215 | - footer_row(_, cells) then | |
| 5216 | - mapor(contains_an_upload, | |
| 5217 | - map(content,cells)) | |
| 5218 | - }. | |
| 5219 | - | |
| 5220 | -define Bool | |
| 5221 | - contains_an_upload | |
| 5222 | - ( | |
| 5223 | - HTML_In_Form form_content | |
| 5224 | - ) = | |
| 5225 | - if form_content is | |
| 5226 | - { | |
| 5227 | - empty then false, | |
| 5228 | - literal_pt(t) then false, | |
| 5229 | - literal(t) then false, | |
| 5230 | - sequence(l) then mapor(contains_an_upload,l), | |
| 5231 | - text(o,t) then false, | |
| 5232 | - preformated(o,s) then false, | |
| 5233 | - paragraph(o,l) then mapor(contains_an_upload,l), | |
| 5234 | - image(o,u,a) then false, | |
| 5235 | - image(o,u,a,w,h) then false, | |
| 5236 | - table(o,_,rows,f_row) then if mapor(contains_an_upload,rows) then true | |
| 5237 | - else contains_an_upload(f_row), | |
| 5238 | - center(e) then contains_an_upload(e), | |
| 5239 | - mail_to(m,e) then false, // 'e' may but should not contain an upload | |
| 5240 | - scroller(w,h,cw,ch,e) then contains_an_upload(e), | |
| 5241 | - actioner(c,t,a,an,eo,ja) then false, | |
| 5242 | - foreign_link_new(_,_,_) then false, | |
| 5243 | - foreign_link(o,u) then false, | |
| 5244 | - foreign_link(o,u,n) then false, | |
| 5245 | - private_download(p,n,e,a) then false, | |
| 5246 | - text_input(o,lt,l,n,i,w) then false, | |
| 5247 | - text_input_ro(o,lt,l,n,i,w) then false, | |
| 5248 | - password_input(o,lt,l,n,i,w) then false, | |
| 5249 | - text_area(o,lt,id,n,i,w,h) then false, | |
| 5250 | - file_upload(o,l,i,n,w) then true, | |
| 5251 | - selector(o,l,i,n,s,c) then false, | |
| 5252 | - selector(o,l,i,n,s,c,p) then false, | |
| 5253 | - selector_c(o,l,i,n,s,c) then false, | |
| 5254 | - selector_c(o,l,i,n,s,c,p) then false, | |
| 5255 | - radio_button(o,_,_,n,v,c) then false, | |
| 5256 | - radio_button_r(o,_,_,n,v,c) then false, | |
| 5257 | - check_box(o,_,_,n,c) then false, | |
| 5258 | - check_box_r(o,_,_,n,c) then false, | |
| 5259 | - div(o,l) then mapor(contains_an_upload,l), //contains_an_upload(c), | |
| 5260 | - div_empty(o) then false, | |
| 5261 | - hidden(_,_,_) then false, | |
| 5262 | - partial(_) then false, | |
| 5263 | - br then false, | |
| 5264 | - progress(_,_,_) then false, | |
| 5265 | - ol(_,l) then mapor(contains_an_upload,l), | |
| 5266 | - ul(_,l) then mapor(contains_an_upload,l), | |
| 5267 | - li(_,l) then mapor(contains_an_upload,l), | |
| 5268 | - button(_,_) then false, | |
| 5269 | - i(_,_) then false, | |
| 5270 | - span(_,_) then false, | |
| 5271 | - hr(_) then false | |
| 5272 | - } | |
| 5273 | -. | |
| 5274 | - | |
| 5275 | -define String | |
| 5276 | - enctype | |
| 5277 | - ( | |
| 5278 | - List(HTML_In_Form) form_contents | |
| 5279 | - )= | |
| 5280 | - if mapor(contains_an_upload, form_contents) then | |
| 5281 | - " enctype=\"multipart/form-data\"" | |
| 5282 | - else | |
| 5283 | - "" | |
| 5284 | -. | |
| 5285 | - | |
| 5286 | -define Printable_tree | |
| 5287 | - format_href | |
| 5288 | - ( | |
| 5289 | - A_href _href | |
| 5290 | - )= | |
| 5291 | - if _href is | |
| 5292 | - { | |
| 5293 | - href(str) then if str = "" then [] else [" href=\"", str, "\""], | |
| 5294 | - href(action, extra) then [" href=\"",format_web_action_name(action, extra), "\""] | |
| 5295 | - } | |
| 5296 | -. | |
| 5297 | - | |
| 5298 | -define Printable_tree | |
| 5299 | - format_target | |
| 5300 | - ( | |
| 5301 | - A_target _target | |
| 5302 | - )= | |
| 5303 | - [" target=\"", | |
| 5304 | - if _target is | |
| 5305 | - { | |
| 5306 | - _blank then "_blank", | |
| 5307 | - _self then "_self", | |
| 5308 | - _parent then "_parent", | |
| 5309 | - _top then "_top", | |
| 5310 | - framename(name) then name | |
| 5311 | - }, | |
| 5312 | - "\""] | |
| 5313 | -. | |
| 5314 | - | |
| 5315 | -define Printable_tree | |
| 5316 | - format | |
| 5317 | - ( | |
| 5318 | - CommonInfo cinfo, | |
| 5319 | - Var(Int) ic_v, // 'idnum' counter variable | |
| 5320 | - List(HTML_Off_Form) elements, | |
| 5321 | - Bool is_https, | |
| 5322 | - Var(Int) action_count, | |
| 5323 | - Var(List(HTML_Head_Tag)) head_tags | |
| 5324 | - ). | |
| 5325 | - | |
| 5326 | -define Printable_tree | |
| 5327 | - format | |
| 5328 | - ( | |
| 5329 | - CommonInfo cinfo, | |
| 5330 | - Var(Int) ic_v, // 'idnum' counter variable | |
| 5331 | - HTML_Off_Form element, | |
| 5332 | - Bool is_https, | |
| 5333 | - Var(Int) action_count, | |
| 5334 | - Var(List(HTML_Head_Tag)) head_tags | |
| 5335 | - ) = | |
| 5336 | - if cinfo is info(common_name,http_port,https_port,site_directory,secret) then | |
| 5337 | - with format_element = (HTML_Off_Form e) |-> format(cinfo, ic_v, e, is_https, action_count, head_tags), | |
| 5338 | - if element is | |
| 5339 | - { | |
| 5340 | - a(opts, _href, _target, l) then ["<a ", format_attrs(opts), format_href(_href), format_target(_target), ">",flat(map(format_element,l)),"</a>\n"], | |
| 5341 | - empty then [], | |
| 5342 | - literal_pt(t) then t, | |
| 5343 | - literal(t) then [t], | |
| 5344 | - sequence(l) then flat(map(format_element,l)), | |
| 5345 | - text(opts,t) then | |
| 5346 | - format(cinfo,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags), | |
| 5347 | -// table(opts,header_row, rows, footer_row) then | |
| 5348 | -// format(cinfo,ic_v,any_table(opts,header_row, rows, footer_row),format_element,is_https, action_count, head_tags), | |
| 5349 | - actioner(c,t,a,an,eo,ja) then | |
| 5350 | - format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,failure),format_element,is_https, action_count, head_tags), | |
| 5351 | - actioner(c,t,a,an,eo,ja,fn) then | |
| 5352 | - format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags), | |
| 5353 | - foreign_link_new(target, aspect, url) then | |
| 5354 | - format(cinfo,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags), | |
| 5355 | -// foreign_link(options,url) then | |
| 5356 | -// format(cinfo,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags), | |
| 5357 | - foreign_link(options,url,name) then | |
| 5358 | - format(cinfo,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags), | |
| 5359 | - private_download(url,name,extra,action) then | |
| 5360 | - format(cinfo,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags), | |
| 5361 | -// form(fn, attributs, l) then | |
| 5362 | -// [ | |
| 5363 | -// "<form id=\"",fn,"\"", | |
| 5364 | -// format(cinfo,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags), | |
| 5365 | -// " method=\"post\"", | |
| 5366 | -// enctype(l), | |
| 5367 | -// " action=\"http",( | |
| 5368 | -// if is_https then "s" else "", | |
| 5369 | -// "://",common_name,":",to_decimal(http_port),"/\">", | |
| 5370 | -// // action is set dynamically by | |
| 5371 | -// // the actioner using JavaScript | |
| 5372 | -// if fn is html_Id(id) then | |
| 5373 | -// flat(map((HTML_In_Form e) |-> format(cinfo,id,ic_v,e,is_https, action_count, head_tags), l)), | |
| 5374 | -// "</form>" | |
| 5375 | -// ] | |
| 5376 | -// form(fn,attributs, action, extra_ops, l) then | |
| 5377 | -// with url = make_actioner_url(cinfo, same, same, | |
| 5378 | -// action, extra_ops, is_https), | |
| 5379 | -// [ | |
| 5380 | -// "<form id=\"",fn,"\"", | |
| 5381 | -// format(cinfo,ic_v, any_coreattrs(attributs),format_element,is_https, action_count, head_tags), | |
| 5382 | -// " method=\"post\"", | |
| 5383 | -// enctype(l), | |
| 5384 | -// " action=\"" + url + "\">", | |
| 5385 | -//// " action=\"http", | |
| 5386 | -//// if is_https then "s" else "", | |
| 5387 | -//// "://",common_name,":",http_port,"/\">", | |
| 5388 | -// // action is set dynamically by | |
| 5389 | -// // the actioner using JavaScript | |
| 5390 | -// if fn is html_Id(id) then | |
| 5391 | -// flat(map((HTML_In_Form e) |-> format(cinfo,id,ic_v,e,is_https, action_count, head_tags),l)), | |
| 5392 | -// "</form>" | |
| 5393 | -// ], | |
| 5394 | -// in_form(fn, content) then | |
| 5395 | -// if fn is html_Id(id) then | |
| 5396 | -// format(cinfo,id,ic_v, content,is_https, action_count, head_tags), | |
| 5397 | - div(options, p_content) then | |
| 5398 | - with html_elements = map((HTML_Partial_Content pc) |-> since pc is partial_content(tags, html_elem), head_tags <- *head_tags +tags; html_elem, p_content), | |
| 5399 | - | |
| 5400 | - format(cinfo, ic_v, any_div(options, html_elements), format_element, is_https, action_count, head_tags), | |
| 5401 | - iframe(options, css_styles, css_files, js_files, body) then | |
| 5402 | - println("formating iframe"); | |
| 5403 | - if body is body(body_options,elem) then | |
| 5404 | - [ "<iframe", format_attrs(options), " srcdoc=\"\n", | |
| 5405 | - | |
| 5406 | - encode_HTML_quote(to_String([ | |
| 5407 | - "<html style=\"margin: 0pt; padding: 0pt;\">\n", | |
| 5408 | - "<head>\n", | |
| 5409 | - add_css_styles(css_styles), | |
| 5410 | - add_css_files(css_files), | |
| 5411 | - add_js_files(js_files), | |
| 5412 | - "</head>\n", | |
| 5413 | - "<body ", format_attrs(body_options), ">\n", // format body options | |
| 5414 | - format(cinfo,ic_v, elem ,is_https, action_count, head_tags), | |
| 5415 | - "</body>\n", | |
| 5416 | - "</html>\n",])), | |
| 5417 | - | |
| 5418 | - "\"></iframe>\n", | |
| 5419 | - ], | |
| 5420 | - partial(p_content) then | |
| 5421 | - if p_content is partial_content(tags, html_elements) then | |
| 5422 | - head_tags <- *head_tags + tags; | |
| 5423 | - format(cinfo, ic_v, html_elements, is_https, action_count, head_tags), | |
| 5424 | -// i(opts, t) then | |
| 5425 | -// format(cinfo,ic_v,any_i(opts,t),format_element,is_https, action_count, head_tags), | |
| 5426 | - html_tag(tag_name, opts, l) then ["<",tag_name, format_attrs(opts), ">", flat(map(format_element,l)), "</",tag_name,">\n"], | |
| 5427 | - html_void_tag(tag_name, opts) then ["<",tag_name, format_attrs(opts), ">"], | |
| 5428 | - }. | |
| 5429 | - | |
| 5430 | -define Printable_tree | |
| 5431 | - format | |
| 5432 | - ( | |
| 5433 | - CommonInfo cinfo, | |
| 5434 | - Var(Int) ic_v, // 'idnum' counter variable | |
| 5435 | - List(HTML_Off_Form) elements, | |
| 5436 | - Bool is_https, | |
| 5437 | - Var(Int) action_count, | |
| 5438 | - Var(List(HTML_Head_Tag)) head_tags | |
| 5439 | - ) = | |
| 5440 | - if cinfo is info(common_name,http_port,https_port,site_directory,secret) then | |
| 5441 | - flat(map((HTML_Off_Form element) |-> | |
| 5442 | - format(cinfo, ic_v, element, is_https, action_count, head_tags), | |
| 5443 | - elements)) | |
| 5444 | -. | |
| 5445 | - | |
| 5446 | - *** [5.10] Formating meta-tags. | |
| 5447 | - | |
| 5448 | -define Printable_tree | |
| 5449 | - format_keywords | |
| 5450 | - ( | |
| 5451 | - List(String) l | |
| 5452 | - ) = | |
| 5453 | - if l is | |
| 5454 | - { | |
| 5455 | - [] then [ ], | |
| 5456 | - [h . t] then if t is [] | |
| 5457 | - then [h] | |
| 5458 | - else [h , ", " . format_keywords(t)] | |
| 5459 | - }. | |
| 5460 | - | |
| 5461 | - | |
| 5462 | -define Printable_tree | |
| 5463 | - format | |
| 5464 | - ( | |
| 5465 | - CommonInfo cinfo, | |
| 5466 | - HTML_Meta m, | |
| 5467 | - Bool is_https | |
| 5468 | - ) = | |
| 5469 | - if m is | |
| 5470 | - { | |
| 5471 | - keywords(l) then ["<meta name=\"keywords\" content=\"",format_keywords(l),"\" />\n"], | |
| 5472 | - refresh(co,ta,an,delay) then | |
| 5473 | - ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=", | |
| 5474 | - make_actioner_url(cinfo,co,ta,an,[],is_https),"\" />\n"], | |
| 5475 | - refresh(url,delay) then | |
| 5476 | - ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",url,"\" />\n"], | |
| 5477 | - meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"], | |
| 5478 | - http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"], | |
| 5479 | - generic_meta(l) then ["<meta ", | |
| 5480 | - flat(map(((String,String) p) |-> if p is (n,v) then [n,"=\"",v,"\" "], | |
| 5481 | - l)), | |
| 5482 | - " />\n"], | |
| 5483 | - literal(s) then [s] | |
| 5484 | - } | |
| 5485 | -. | |
| 5486 | - | |
| 5487 | -define Printable_tree // c'est le nôtre et c'est meilleur | |
| 5488 | - format | |
| 5489 | - ( | |
| 5490 | - HTML_Meta m, | |
| 5491 | - ) = | |
| 5492 | - if m is | |
| 5493 | - { | |
| 5494 | - keywords(l) then ["<meta name=\"keywords\" content=\"",format_keywords(l),"\" />\n"], | |
| 5495 | - refresh(co,ta,an,delay) then | |
| 5496 | - ["<!-- TODO refresh(co,ta,an,delay) --> "], // TODO | |
| 5497 | - refresh(url,delay) then | |
| 5498 | - ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",url,"\" />\n"], | |
| 5499 | - meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"], | |
| 5500 | - http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"], | |
| 5501 | - generic_meta(l) then ["<meta ", | |
| 5502 | - flat(map(((String,String) p) |-> if p is (n,v) then [n,"=\"",v,"\" "], | |
| 5503 | - l)), | |
| 5504 | - " />\n"], | |
| 5505 | - literal(s) then [s] | |
| 5506 | - }. | |
| 5507 | - | |
| 5508 | - | |
| 5509 | -define Printable_tree | |
| 5510 | - format | |
| 5511 | - ( | |
| 5512 | - CommonInfo cinfo, | |
| 5513 | - List(HTML_Meta) metas, | |
| 5514 | - Bool is_https, | |
| 5515 | - String charset | |
| 5516 | - ) = | |
| 5517 | - if metas is | |
| 5518 | - { | |
| 5519 | - [] then [format(cinfo,http_equiv("content-type", | |
| 5520 | - "text/html; charset="+charset),is_https)], | |
| 5521 | - [h . t] then [format(cinfo,h,is_https) | |
| 5522 | - . format(cinfo,t,is_https,charset)] | |
| 5523 | - }. | |
| 5524 | - | |
| 5525 | - define List(HTML_Head_Tag) | |
| 5526 | - rebuild_html_head_tags | |
| 5527 | - ( | |
| 5528 | - List(HTML_Head_Tag) lwf, | |
| 5529 | - List(HTML_Head_Tag) so_far | |
| 5530 | - ) = | |
| 5531 | - if lwf is | |
| 5532 | - { | |
| 5533 | - [] then so_far, | |
| 5534 | - [h . t] then | |
| 5535 | - rebuild_html_head_tags(t, append_once(so_far, h)) | |
| 5536 | - }. | |
| 5537 | - | |
| 5538 | -define Printable_tree | |
| 5539 | - _format_html_head | |
| 5540 | - ( | |
| 5541 | - List(HTML_Head_Tag) lwf, | |
| 5542 | - Printable_tree so_far, | |
| 5543 | - Dictionary(String, Word32) js_dict | |
| 5544 | - ) | |
| 5545 | - = | |
| 5546 | - //with lwf_ = rebuild_html_head_tags(lwf, []), | |
| 5547 | - if lwf is | |
| 5548 | - { | |
| 5549 | - [] then reverse(so_far), | |
| 5550 | - [ h . t] then | |
| 5551 | - if h is | |
| 5552 | - { | |
| 5553 | - meta(meta) then | |
| 5554 | - [format(meta) . _format_html_head(t, so_far, js_dict)], | |
| 5555 | - title(title) then | |
| 5556 | - ["<title>"+title+"</title>\n" . _format_html_head(t, so_far, js_dict)], | |
| 5557 | - js(jsf) then | |
| 5558 | - since jsf is js_file(filename, _), | |
| 5559 | - if js_dict.get(filename) is | |
| 5560 | - { | |
| 5561 | - failure then | |
| 5562 | - forget(js_dict.insert(filename, 0)); | |
| 5563 | - [add_js_files([jsf]) . _format_html_head(t, so_far, js_dict)], | |
| 5564 | - | |
| 5565 | - success(_) then | |
| 5566 | - _format_html_head(t, so_far, js_dict), | |
| 5567 | - } | |
| 5568 | - js_inline(jsi) then | |
| 5569 | - if jsi is | |
| 5570 | - { | |
| 5571 | - script(type, _) then | |
| 5572 | - ["<script type=\"" + type + "\">"+content(jsi)+"</script>\n" . _format_html_head(t, so_far, js_dict)], | |
| 5573 | - } | |
| 5574 | - css(cssf) then | |
| 5575 | - since cssf is css_file(file_name, media), | |
| 5576 | - ["<link rel=\"stylesheet\" type=\"text/css\" href=\""+file_name+"\" media=\""+to_String(media)+"\" />\n" . _format_html_head(t, so_far, js_dict)], | |
| 5577 | - | |
| 5578 | - css_inline(cssi) then | |
| 5579 | - ["<style>"+cssi+"</style>\n" . _format_html_head(t, so_far, js_dict)] | |
| 5580 | - | |
| 5581 | - link(link_attrs) then | |
| 5582 | - ["<link " + to_String(link_attrs) + " />\n" . _format_html_head(t, so_far, js_dict)] | |
| 5583 | - } | |
| 5584 | - } | |
| 5585 | -. | |
| 5586 | - | |
| 5587 | -public define Printable_tree | |
| 5588 | - format_html_head | |
| 5589 | - ( | |
| 5590 | - List(HTML_Head_Tag) lwf, | |
| 5591 | - String charset | |
| 5592 | - ) | |
| 5593 | - = | |
| 5594 | - _format_html_head((List(HTML_Head_Tag))[ meta(http_equiv("content-type", "text/html; charset="+charset)) . lwf], [], make_dictionary((Word32)0, dictionaryComparerString)). | |
| 5595 | - | |
| 5596 | -public define Printable_tree | |
| 5597 | - format_html_head | |
| 5598 | - ( | |
| 5599 | - List(HTML_Head_Tag) lwf | |
| 5600 | - ) | |
| 5601 | - = | |
| 5602 | - _format_html_head(lwf, [], make_dictionary((Word32)0, dictionaryComparerString)). | |
| 5603 | - | |
| 5604 | - | |
| 5605 | -public type HTML_ajax_content: | |
| 5606 | - html_ajax_content( String html_body, String script, List(String) js_file, List(String) css_file). | |
| 5607 | - | |
| 5608 | -public define HTML_ajax_content | |
| 5609 | - sort_head_tag | |
| 5610 | - ( | |
| 5611 | - List(HTML_Head_Tag) lwf, | |
| 5612 | - String script, | |
| 5613 | - List(String) js_file, | |
| 5614 | - List(String) css_file | |
| 5615 | - )= | |
| 5616 | - if lwf is | |
| 5617 | - { | |
| 5618 | - [] then html_ajax_content("", script, reverse(js_file), reverse(css_file)), | |
| 5619 | - [ h . t ] then | |
| 5620 | - if h is | |
| 5621 | - { | |
| 5622 | - meta(meta) then sort_head_tag(t, script, js_file, css_file), | |
| 5623 | - title(title) then sort_head_tag(t, script, js_file, css_file), | |
| 5624 | - js(jsf) then /*println("sort_head_tag jsf["+jsf.file_name+"]");*/sort_head_tag(t, script, [file_name(jsf) . js_file], css_file), | |
| 5625 | - js_inline(jsi) then /*println("sort_head_tag jsi["+jsi.content+"]");*/sort_head_tag(t, script + content(jsi), js_file, css_file), | |
| 5626 | - css(cssf) then sort_head_tag(t, script, js_file, [file_name(cssf) . css_file]), | |
| 5627 | - css_inline(cssi) then sort_head_tag(t, script, js_file, css_file), | |
| 5628 | - link(_) then sort_head_tag(t, script, js_file, css_file), | |
| 5629 | - } | |
| 5630 | - }. | |
| 5631 | - | |
| 5632 | -public define HTML_ajax_content | |
| 5633 | - to_html_ajax_content | |
| 5634 | - ( | |
| 5635 | - HTML_Off_Form content_HTML, | |
| 5636 | - CommonInfo cinfo | |
| 5637 | - )= | |
| 5638 | - //println("to_html_ajax_content(content_HTML, cinfo)"); | |
| 5639 | - with p_content_head_tags = var((List(HTML_Head_Tag))[]), | |
| 5640 | - with content = format(cinfo, var((Int)0), content_HTML, false, var(0), p_content_head_tags), | |
| 5641 | - if sort_head_tag(*p_content_head_tags, "", [], []) is html_ajax_content(_, script, js_file, css_file) then | |
| 5642 | - html_ajax_content(to_String(content), script, js_file, css_file). | |
| 5643 | - | |
| 5644 | -public define String | |
| 5645 | - to_String | |
| 5646 | - ( | |
| 5647 | - HTML_Off_Form content_HTML, | |
| 5648 | - CommonInfo cinfo | |
| 5649 | - )= | |
| 5650 | - //println("to_html_ajax_content(content_HTML, cinfo)"); | |
| 5651 | - with p_content_head_tags = var((List(HTML_Head_Tag))[]), | |
| 5652 | - with content = format(cinfo, var((Int)0), content_HTML, false, var(0), p_content_head_tags), | |
| 5653 | - to_String(content) | |
| 5654 | -. | |
| 5655 | - | |
| 5656 | - | |
| 5657 | -public define JsonValue | |
| 5658 | - to_html_ajax_content | |
| 5659 | - ( | |
| 5660 | - HTML_Partial_Content content_HTML, | |
| 5661 | - CommonInfo cinfo, | |
| 5662 | - String additional_script | |
| 5663 | - )= | |
| 5664 | - //println("to_html_ajax_content(content_HTML, cinfo, additional_script)"); | |
| 5665 | - //println("additional_script"+additional_script); | |
| 5666 | - since to_html_ajax_content(partial(content_HTML), cinfo) is html_ajax_content(html, script, js_files, css_files), | |
| 5667 | - json_object([ | |
| 5668 | - json_member("html", json_string(html)), | |
| 5669 | - json_member("js_files", to_json_array(js_files)), | |
| 5670 | - json_member("css_files", to_json_array(css_files)), | |
| 5671 | - json_member("script", json_string(additional_script+script)), | |
| 5672 | - ]) | |
| 5673 | -. | |
| 5674 | - | |
| 5675 | -public define JsonValue | |
| 5676 | - to_html_ajax_content | |
| 5677 | - ( | |
| 5678 | - HTML_Partial_Content content_HTML, | |
| 5679 | - CommonInfo cinfo | |
| 5680 | - )= to_html_ajax_content(content_HTML, cinfo, ""). | |
| 5681 | - | |
| 5682 | -public define JsonValue | |
| 5683 | - to_html_ajax_content | |
| 5684 | - ( | |
| 5685 | - Printable_tree content_HTML, | |
| 5686 | - String additional_script | |
| 5687 | - )= | |
| 5688 | - //since to_html_ajax_content(partial(content_HTML), cinfo) is html_ajax_content(html, script, js_files, css_files), | |
| 5689 | - json_object([ | |
| 5690 | - json_member("html", json_string(to_String(content_HTML))), | |
| 5691 | - json_member("js_files", to_json_array([])), | |
| 5692 | - json_member("css_files", to_json_array([])), | |
| 5693 | - json_member("script", json_string(additional_script)), | |
| 5694 | - ]) | |
| 5695 | -. | |
| 5696 | - | |
| 5697 | -public define AWP_Handler_Answer //Printable_tree | |
| 5698 | - format | |
| 5699 | - ( | |
| 5700 | - CommonInfo cinfo, | |
| 5701 | - List(HTTP_header) additional_headers, | |
| 5702 | - HTTP_Answer page, | |
| 5703 | - Bool is_https, | |
| 5704 | - String charset | |
| 5705 | - )= | |
| 5706 | - if cinfo is info(common_name,http_port,https_port,site_directory,secret) then | |
| 5707 | - with ic_v = var((Int)0), | |
| 5708 | - p_content_head_tags = var((List(HTML_Head_Tag))[]), //list of heat_tags extracted from partial_content during format of body content | |
| 5709 | - if page is | |
| 5710 | - { | |
| 5711 | - html_page(status, head_tags, body) then | |
| 5712 | - if body is body(options,element) then | |
| 5713 | - if format(status) is (status_string, status_headers) then | |
| 5714 | - with | |
| 5715 | - answer_body_body = (Printable_tree) | |
| 5716 | - [ "<body ", format_attrs(options), ">", // format body options | |
| 5717 | - format(cinfo,ic_v,element,is_https, var(0), p_content_head_tags), | |
| 5718 | - "</body>\n", | |
| 5719 | - | |
| 5720 | - "</html>"], | |
| 5721 | - answer_body_header = | |
| 5722 | - [doctype_w3c_header, | |
| 5723 | - // html_header, | |
| 5724 | - | |
| 5725 | - "<head>\n", format_html_head(head_tags + *p_content_head_tags, charset),"</head>\n", | |
| 5726 | - ], | |
| 5727 | - printable_tree([ | |
| 5728 | - "HTTP/1.1 " + status_string, crlf, | |
| 5729 | - format_headers(standard_headers), | |
| 5730 | - format_headers(standard_headers_for("text/html", length(answer_body_header) + length(answer_body_body), success(charset))), | |
| 5731 | - format_headers(status_headers), | |
| 5732 | - format_headers(additional_headers), | |
| 5733 | - crlf, | |
| 5734 | - answer_body_header . | |
| 5735 | - answer_body_body | |
| 5736 | - ]), | |
| 5737 | - | |
| 5738 | - html_page(status, title, head_tags, css_styles, css_files, js_files, script, body) then | |
| 5739 | - if body is body(options,element) then | |
| 5740 | - if format(status) is (status_string, status_headers) then | |
| 5741 | - with | |
| 5742 | - answer_body_body = (Printable_tree) | |
| 5743 | - [ "<body ", format_attrs(options), ">", // format body options | |
| 5744 | - format(cinfo,ic_v,element,is_https, var(0), p_content_head_tags), | |
| 5745 | - "</body>\n", | |
| 5746 | - "</html>" | |
| 5747 | - ], | |
| 5748 | - answer_body_header = | |
| 5749 | - [ doctype_w3c_header, | |
| 5750 | - //html_header, | |
| 5751 | - "<head>\n", | |
| 5752 | - add_css_styles(css_styles), | |
| 5753 | - add_css_files(css_files), | |
| 5754 | - add_js_files(js_files), | |
| 5755 | - add_script(script), | |
| 5756 | - "<link rel=\"shortcut icon\" href=\"favicon.ico\" />\n", | |
| 5757 | - "<script type = \"text/javascript\" language=\"JavaScript\">", | |
| 5758 | - " function show_local_popup(divname,stvname) {", | |
| 5759 | - " if (document.layers) { var d = eval(document.divname); } else\n", | |
| 5760 | - " if (document.getElementById) { var d = eval(\"document.getElementById(divname)\"); } else\n", | |
| 5761 | - " if (document.all) { var d = eval(document.all.divname.style)};\n", | |
| 5762 | - // " alert(typeof(eval(stvname))); ", | |
| 5763 | - " var s = eval(stvname); ", | |
| 5764 | - " if (s[0]==0) ", | |
| 5765 | - " { s[0]=1; d.style.visibility = 'visible'; d.zIndex = 100; } else\n", | |
| 5766 | - " { s[0]=0; d.style.visibility = 'hidden'; }; }", | |
| 5767 | - "</script>\n", | |
| 5768 | - "<title>",title,"</title>\n", // put title | |
| 5769 | - //format(cinfo,metas,is_https,charset), // format the metas | |
| 5770 | - format_html_head(head_tags + *p_content_head_tags, charset), | |
| 5771 | - "</head>\n" | |
| 5772 | - ], | |
| 5773 | - printable_tree([ | |
| 5774 | - "HTTP/1.1 " + status_string, crlf, | |
| 5775 | - format_headers(standard_headers), | |
| 5776 | - format_headers(standard_headers_for("text/html", length(answer_body_header) + length(answer_body_body), success(charset))), | |
| 5777 | - format_headers(status_headers), | |
| 5778 | - format_headers(additional_headers), | |
| 5779 | - crlf, | |
| 5780 | - answer_body_header . | |
| 5781 | - answer_body_body | |
| 5782 | - ]), | |
| 5783 | - | |
| 5784 | - plain_text (HTTP_Status status, String text) then | |
| 5785 | - if format(status) is (status_string, status_headers) then | |
| 5786 | - printable_tree([ | |
| 5787 | - "HTTP/1.1 " + status_string, crlf, | |
| 5788 | - format_headers(standard_headers), | |
| 5789 | - format_headers(standard_headers_for("text/plain", length(text), success(charset))), | |
| 5790 | - format_headers(status_headers), | |
| 5791 | - format_headers(additional_headers), | |
| 5792 | - crlf, | |
| 5793 | - text . (Printable_tree)[] | |
| 5794 | - ]), | |
| 5795 | - | |
| 5796 | - custom_text(HTTP_Status status, mime_type, String content) then | |
| 5797 | - if format(status) is (status_string, status_headers) then | |
| 5798 | - printable_tree([ | |
| 5799 | - "HTTP/1.1 " + status_string, crlf, | |
| 5800 | - format_headers(standard_headers), | |
| 5801 | - format_headers(standard_headers_for(to_String(mime_type), length(content), success(charset))), | |
| 5802 | - format_headers(status_headers), | |
| 5803 | - format_headers(additional_headers), | |
| 5804 | - crlf, | |
| 5805 | - content . (Printable_tree)[] | |
| 5806 | - ]), | |
| 5807 | - | |
| 5808 | - custom_binary(HTTP_Status status, mime_type, ByteArray content, List(HTTP_header) other_headers) then | |
| 5809 | - if format(status) is (status_string, status_headers) then | |
| 5810 | - printable_tree([ | |
| 5811 | - "HTTP/1.1 " + status_string, crlf, | |
| 5812 | - format_headers(status_headers), | |
| 5813 | - format_headers(standard_headers_for(to_String(mime_type), length(content), failure)), | |
| 5814 | - format_headers(status_headers), | |
| 5815 | - format_headers(other_headers), | |
| 5816 | - format_headers(additional_headers), | |
| 5817 | - crlf, | |
| 5818 | - content . (Printable_tree)[] | |
| 5819 | - ]), | |
| 5820 | - | |
| 5821 | - custom_tree(HTTP_Status status, mime_type, Printable_tree content) then | |
| 5822 | - if format(status) is (status_string, status_headers) then | |
| 5823 | - printable_tree([ | |
| 5824 | - "HTTP/1.1 " + status_string, crlf, | |
| 5825 | - format_headers(standard_headers), | |
| 5826 | - format_headers(standard_headers_for(to_String(mime_type), length(content), success(charset))), | |
| 5827 | - format_headers(status_headers), | |
| 5828 | - format_headers(additional_headers), | |
| 5829 | - crlf . | |
| 5830 | - content | |
| 5831 | - ]), | |
| 5832 | - | |
| 5833 | - json(HTTP_Status status, JsonValue json_content) then | |
| 5834 | - //with start = unow, | |
| 5835 | - with content = (Printable_tree)format_json(json_content), | |
| 5836 | - //println(show_duration_string("HTTP json format json object ", start)); | |
| 5837 | - if format(status) is (status_string, status_headers) then | |
| 5838 | - printable_tree([ | |
| 5839 | - "HTTP/1.1 " + status_string, crlf, | |
| 5840 | - format_headers(standard_headers), | |
| 5841 | - format_headers(standard_headers_for(to_String(mime_application_json), length(content), success(charset))), | |
| 5842 | - format_headers(status_headers), | |
| 5843 | - format_headers(additional_headers), | |
| 5844 | - crlf . | |
| 5845 | - content | |
| 5846 | - ]) | |
| 5847 | - , | |
| 5848 | - send_file(file_path, c_disposition) then | |
| 5849 | - send_file(file_path, c_disposition), | |
| 5850 | - | |
| 5851 | - http_raw(Printable_tree content) then | |
| 5852 | - printable_tree(content), | |
| 5853 | - | |
| 5854 | - html_content(HTTP_Status status, HTML_Off_Form content_HTML) then | |
| 5855 | - if format(status) is (status_string, status_headers) then | |
| 5856 | - with content = format(cinfo, ic_v, content_HTML, is_https, var(0), p_content_head_tags), | |
| 5857 | - printable_tree([ | |
| 5858 | - "HTTP/1.1 " + status_string, crlf, | |
| 5859 | - format_headers(standard_headers), | |
| 5860 | - format_headers(standard_headers_for("text/html", length(content), success(charset))), | |
| 5861 | - format_headers(status_headers), | |
| 5862 | - format_headers(additional_headers), | |
| 5863 | - crlf . | |
| 5864 | - content | |
| 5865 | - ]), | |
| 5866 | - //HMTL content with some header | |
| 5867 | - html_partial_content(HTTP_Status status, HTML_Partial_Content p_content) then | |
| 5868 | - | |
| 5869 | - since p_content is partial_content(head_tags, html_content), | |
| 5870 | - since format(status) is (status_string, status_headers), | |
| 5871 | - with | |
| 5872 | - answer_body = (Printable_tree) | |
| 5873 | - [ | |
| 5874 | - format(cinfo, ic_v, html_content, is_https, var(0), p_content_head_tags), | |
| 5875 | - ], | |
| 5876 | - answer_header = (Printable_tree) | |
| 5877 | - [ | |
| 5878 | - // html_header, | |
| 5879 | - format_html_head(head_tags + *p_content_head_tags), | |
| 5880 | - ], | |
| 5881 | - printable_tree([ | |
| 5882 | - "HTTP/1.1 " + status_string, crlf, | |
| 5883 | - format_headers(standard_headers), | |
| 5884 | - format_headers(standard_headers_for("text/html", length(answer_header) + length(answer_body), success(charset))), | |
| 5885 | - format_headers(status_headers), | |
| 5886 | - format_headers(additional_headers), | |
| 5887 | - crlf, | |
| 5888 | - answer_header . | |
| 5889 | - answer_body | |
| 5890 | - ]), | |
| 5891 | - }. | |
| 5892 | - |
web/types/making_a_web_site.anubis.bak deleted
| 1 | -/* | |
| 2 | - * Created by PyramIDE. | |
| 3 | - * User: フランスのトトロ aka (David RENÉ) | |
| 4 | - * Date: 29/05/2019 | |
| 5 | - * Time: 18:41 | |
| 6 | - * © David RENÉ | |
| 7 | - */ | |
| 8 | -transmit xlib/web/types/web_action_name.anubis | |
| 9 | -transmit xlib/web/common.anubis | |
| 10 | - | |
| 11 | -transmit xlib/web/multihost_http_server.anubis | |
| 12 | -transmit xlib/web/json.anubis | |
| 13 | -transmit xlib/web/widgets/left_menu.anubis | |
| 14 | -read web/mime.anubis | |
| 15 | -read tools/printable_tree.anubis | |
| 16 | - | |
| 17 | -public type WEB_Action_Allowed_Protocol: | |
| 18 | - http, | |
| 19 | - https, | |
| 20 | - http_https | |
| 21 | -. | |
| 22 | - | |
| 23 | -public type Web_Action($State): | |
| 24 | - http_action (String name, // name of action | |
| 25 | - ($State) -> Bool allow, // true if action allowed | |
| 26 | - (HTTP_Info http_info, | |
| 27 | - List(Web_arg) web_args, // actually only 'operands' web arguments | |
| 28 | - $State state) -> $State do_it), | |
| 29 | - https_action (String name, // name of action | |
| 30 | - ($State) -> Bool allow, // true if action allowed | |
| 31 | - (HTTP_Info http_info, | |
| 32 | - List(Web_arg) web_args, // actually only 'operands' web arguments | |
| 33 | - $State state) -> $State do_it), | |
| 34 | - http_https_action (String name, | |
| 35 | - ($State) -> Bool allow, | |
| 36 | - (HTTP_Info http_info, | |
| 37 | - List(Web_arg) web_args, | |
| 38 | - $State state) -> $State do_it) | |
| 39 | -. | |
| 40 | - | |
| 41 | - This indicate the way of reading text. | |
| 42 | -public type Reading_Way: | |
| 43 | - ltr, //the text is readable from "Left To Right" like english | |
| 44 | - rtl //the text is readable from "Right To Left" like arabic | |
| 45 | -. | |
| 46 | - | |
| 47 | -public type CSS_File_Media: | |
| 48 | - screen, //Intended for non-paged computer screens. | |
| 49 | - tty, //Intended for media using a fixed-pitch character grid, such as teletypes, terminals, or portable devices with limited display capabilities. | |
| 50 | - tv, //Intended for television-type devices (low resolution, color, limited scrollability). | |
| 51 | - projection, //Intended for projectors. | |
| 52 | - handheld, //Intended for handheld devices (small screen, monochrome, bitmapped graphics, limited bandwidth). | |
| 53 | - print, //Intended for paged, opaque material and for documents viewed on screen in print preview mode. | |
| 54 | - braille, //Intended for braille tactile feedback devices. | |
| 55 | - aural, //Intended for speech synthesizers. | |
| 56 | - all. //Suitable for all devices. | |
| 57 | - | |
| 58 | -public type HtmlEvents: | |
| 59 | - // Window Event Attributes | |
| 60 | - onafterprint, //HTML5 Script to be run after the document is printed | |
| 61 | - onbeforeprint, //HTML5 Script to be run before the document is printed | |
| 62 | - onbeforeunload, //HTML5 Script to be run when the document is about to be unloaded | |
| 63 | - onerror, //HTML5 Script to be run when an error occurs | |
| 64 | - onhashchange, //HTML5 Script to be run when there has been changes to the anchor part of the a URL | |
| 65 | - onload, // Fires after the page is finished loading | |
| 66 | - onmessage, //HTML5 Script to be run when the message is triggered | |
| 67 | - onoffline, //HTML5 Script to be run when the browser starts to work offline | |
| 68 | - ononline, //HTML5 Script to be run when the browser starts to work online | |
| 69 | - onpagehide, //HTML5 Script to be run when a user navigates away from a page | |
| 70 | - onpageshow, //HTML5 Script to be run when a user navigates to a page | |
| 71 | - onpopstate, //HTML5 Script to be run when the window's history changes | |
| 72 | - onresize, //HTML5 Fires when the browser window is resized | |
| 73 | - onstorage, //HTML5 Script to be run when a Web Storage area is updated | |
| 74 | - onunload, // Fires once a page has unloaded (or the browser window has been closed) | |
| 75 | - // Form element events | |
| 76 | - onblur, // Fires the moment that the element loses focus | |
| 77 | - onchange, // Fires the moment when the value of the element is changed | |
| 78 | - oncontextmenu, //HTML5 Script to be run when a context menu is triggered | |
| 79 | - onfocus, // Fires the moment when the element gets focus | |
| 80 | - oninput, //HTML5 Script to be run when an element gets user input | |
| 81 | - oninvalid, //HTML5 Script to be run when an element is invalid | |
| 82 | - onreset, // Fires when the Reset button in a form is clicked | |
| 83 | - onsearch, // Fires when the user writes something in a search field (for <input="search">) | |
| 84 | - onselect, // Fires after some text has been selected in an element | |
| 85 | - onsubmit, // Fires when a form is submitted | |
| 86 | - // Keyboard events (Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.) | |
| 87 | - onkeydown, // Fires when a user is pressing a key | |
| 88 | - onkeypress, // Fires when a user presses a key | |
| 89 | - onkeyup, // Fires when a user releases a key | |
| 90 | - // Mouse events (Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.) | |
| 91 | - onclick, // Fires on a mouse click on the element | |
| 92 | - ondblclick, // Fires on a mouse double-click on the element | |
| 93 | - onmousedown, // Fires when a mouse button is pressed down on an element | |
| 94 | - onmousemove, // Fires when the mouse pointer is moving while it is over an element | |
| 95 | - onmouseout, // Fires when the mouse pointer moves out of an element | |
| 96 | - onmouseover, // Fires when the mouse pointer moves over an element | |
| 97 | - onmouseup, // Fires when a mouse button is released over an element | |
| 98 | - onwheel, //HTML5 Fires when the mouse wheel rolls up or down over an element | |
| 99 | - //Drag Events | |
| 100 | - ondrag, //HMTL5 Script to be run when an element is dragged | |
| 101 | - ondragend, //HTML5 Script to be run at the end of a drag operation | |
| 102 | - ondragenter, //HTML5 Script to be run when an element has been dragged to a valid drop target | |
| 103 | - ondragleave, //HTML5 Script to be run when an element leaves a valid drop target | |
| 104 | - ondragover, //HTML5 Script to be run when an element is being dragged over a valid drop target | |
| 105 | - ondragstart, //HTML5 Script to be run at the start of a drag operation | |
| 106 | - ondrop, //HTML5 Script to be run when dragged element is being dropped | |
| 107 | - onscroll, //HTML5 Script to be run when an element's scrollbar is being scrolled | |
| 108 | - //Clipboard Events | |
| 109 | - oncopy, //HTML5 Fires when the user copies the content of an element | |
| 110 | - oncut, //HTML5 Fires when the user cuts the content of an element | |
| 111 | - onpaste, //HTML5 Fires when the user pastes some content in an element | |
| 112 | - //Media Events | |
| 113 | - onabort, //HTML5 Script to be run on abort | |
| 114 | - oncanplay, //HTML5 Script to be run when a file is ready to start playing (when it has buffered enough to begin) | |
| 115 | - oncanplaythrough, //HTML5 Script to be run when a file can be played all the way to the end without pausing for buffering | |
| 116 | - oncuechange, //HTML5 Script to be run when the cue changes in a <track> element | |
| 117 | - ondurationchange, //HTML5 Script to be run when the length of the media changes | |
| 118 | - onemptied, //HTML5 Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects) | |
| 119 | - onended, //HTML5 Script to be run when the media has reach the end (a useful event for messages like "thanks for listening") | |
| 120 | - onerror, //HTML5 Script to be run when an error occurs when the file is being loaded | |
| 121 | - onloadeddata, //HTML5 Script to be run when media data is loaded | |
| 122 | - onloadedmetadata, //HTML5 Script to be run when meta data (like dimensions and duration) are loaded | |
| 123 | - onloadstart, //HTML5 Script to be run just as the file begins to load before anything is actually loaded | |
| 124 | - onpause, //HTML5 Script to be run when the media is paused either by the user or programmatically | |
| 125 | - onplay, //HTML5 Script to be run when the media is ready to start playing | |
| 126 | - onplaying, //HTML5 Script to be run when the media actually has started playing | |
| 127 | - onprogress, //HTML5 Script to be run when the browser is in the process of getting the media data | |
| 128 | - onratechange, //HTML5 Script to be run each time the playback rate changes (like when a user switches to a slow motion or fast forward mode) | |
| 129 | - onseeked, //HTML5 Script to be run when the seeking attribute is set to false indicating that seeking has ended | |
| 130 | - onseeking, //HTML5 Script to be run when the seeking attribute is set to true indicating that seeking is active | |
| 131 | - onstalled, //HTML5 Script to be run when the browser is unable to fetch the media data for whatever reason | |
| 132 | - onsuspend, //HTML5 Script to be run when fetching the media data is stopped before it is completely loaded for whatever reason | |
| 133 | - ontimeupdate, //HTML5 Script to be run when the playing position has changed (like when the user fast forwards to a different point in the media) | |
| 134 | - onvolumechange, //HTML5 Script to be run each time the volume is changed which (includes setting the volume to "mute") | |
| 135 | - onwaiting, //HTML5 Script to be run when the media has paused but is expected to resume (like when the media pauses to buffer more data) | |
| 136 | - //Misc Events | |
| 137 | - onshow, //HTML5 Fires when a <menu> element is shown as a context menu | |
| 138 | - ontoggle. //HTML5 Fires when the user opens or closes the <details> element | |
| 139 | - | |
| 140 | -public define String | |
| 141 | - to_String | |
| 142 | - ( | |
| 143 | - HtmlEvents e | |
| 144 | - ) = | |
| 145 | - if e is | |
| 146 | - { | |
| 147 | - onafterprint then "onafterprint", //HTML5 Script to be run after the document is printed | |
| 148 | - onbeforeprint then "onbeforeprint", //HTML5 Script to be run before the document is printed | |
| 149 | - onbeforeunload then "onbeforeunload", //HTML5 Script to be run when the document is about to be unloaded | |
| 150 | - onerror then "onerror", //HTML5 Script to be run when an error occurs | |
| 151 | - onhashchange then "onhashchange", //HTML5 Script to be run when there has been changes to the anchor part of the a URL | |
| 152 | - onload then "onload", // Fires after the page is finished loading | |
| 153 | - onmessage then "onmessage", //HTML5 Script to be run when the message is triggered | |
| 154 | - onoffline then "onoffline", //HTML5 Script to be run when the browser starts to work offline | |
| 155 | - ononline then "ononline", //HTML5 Script to be run when the browser starts to work online | |
| 156 | - onpagehide then "onpagehide", //HTML5 Script to be run when a user navigates away from a page | |
| 157 | - onpageshow then "onpageshow", //HTML5 Script to be run when a user navigates to a page | |
| 158 | - onpopstate then "onpopstate", //HTML5 Script to be run when the window's history changes | |
| 159 | - onresize then "onresize", //HTML5 Fires when the browser window is resized | |
| 160 | - onstorage then "onstorage", //HTML5 Script to be run when a Web Storage area is updated | |
| 161 | - onunload then "onunload", // Fires once a page has unloaded (or the browser window has been closed) | |
| 162 | - // Form element events | |
| 163 | - onblur then "onblur", // Fires the moment that the element loses focus | |
| 164 | - onchange then "onchange", // Fires the moment when the value of the element is changed | |
| 165 | - oncontextmenu then "oncontextmenu", //HTML5 Script to be run when a context menu is triggered | |
| 166 | - onfocus then "onfocus", // Fires the moment when the element gets focus | |
| 167 | - oninput then "oninput", //HTML5 Script to be run when an element gets user input | |
| 168 | - oninvalid then "oninvalid", //HTML5 Script to be run when an element is invalid | |
| 169 | - onreset then "onreset", // Fires when the Reset button in a form is clicked | |
| 170 | - onsearch then "onsearch", // Fires when the user writes something in a search field (for <input="search">) | |
| 171 | - onselect then "onselect", // Fires after some text has been selected in an element | |
| 172 | - onsubmit then "onsubmit", // Fires when a form is submitted | |
| 173 | - // Keyboard events (Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.) | |
| 174 | - onkeydown then "onkeydown", // Fires when a user is pressing a key | |
| 175 | - onkeypress then "onkeypress", // Fires when a user presses a key | |
| 176 | - onkeyup then "onkeyup", // Fires when a user releases a key | |
| 177 | - // Mouse events (Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.) | |
| 178 | - onclick then "onclick", // Fires on a mouse click on the element | |
| 179 | - ondblclick then "ondblclick", // Fires on a mouse double-click on the element | |
| 180 | - onmousedown then "onmousedown", // Fires when a mouse button is pressed down on an element | |
| 181 | - onmousemove then "onmousemove", // Fires when the mouse pointer is moving while it is over an element | |
| 182 | - onmouseout then "onmouseout", // Fires when the mouse pointer moves out of an element | |
| 183 | - onmouseover then "onmouseover", // Fires when the mouse pointer moves over an element | |
| 184 | - onmouseup then "onmouseup", // Fires when a mouse button is released over an element | |
| 185 | - onwheel then "onwheel", //HTML5 Fires when the mouse wheel rolls up or down over an element | |
| 186 | - //Drag Events | |
| 187 | - ondrag then "ondrag", //HMTL5 Script to be run when an element is dragged | |
| 188 | - ondragend then "ondragend", //HTML5 Script to be run at the end of a drag operation | |
| 189 | - ondragenter then "ondragenter", //HTML5 Script to be run when an element has been dragged to a valid drop target | |
| 190 | - ondragleave then "ondragleave", //HTML5 Script to be run when an element leaves a valid drop target | |
| 191 | - ondragover then "ondragover", //HTML5 Script to be run when an element is being dragged over a valid drop target | |
| 192 | - ondragstart then "ondragstart", //HTML5 Script to be run at the start of a drag operation | |
| 193 | - ondrop then "ondrop", //HTML5 Script to be run when dragged element is being dropped | |
| 194 | - onscroll then "onscroll", //HTML5 Script to be run when an element's scrollbar is being scrolled | |
| 195 | - //Clipboard Events | |
| 196 | - oncopy then "oncopy", //HTML5 Fires when the user copies the content of an element | |
| 197 | - oncut then "oncut", //HTML5 Fires when the user cuts the content of an element | |
| 198 | - onpaste then "onpaste", //HTML5 Fires when the user pastes some content in an element | |
| 199 | - //Media Events | |
| 200 | - onabort then "onabort", //HTML5 Script to be run on abort | |
| 201 | - oncanplay then "oncanplay", //HTML5 Script to be run when a file is ready to start playing (when it has buffered enough to begin) | |
| 202 | - oncanplaythrough then "oncanplaythrough", //HTML5 Script to be run when a file can be played all the way to the end without pausing for buffering | |
| 203 | - oncuechange then "oncuechange", //HTML5 Script to be run when the cue changes in a <track> element | |
| 204 | - ondurationchange then "ondurationchange", //HTML5 Script to be run when the length of the media changes | |
| 205 | - onemptied then "onemptied", //HTML5 Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects) | |
| 206 | - onended then "onended", //HTML5 Script to be run when the media has reach the end (a useful event for messages like "thanks for listening") | |
| 207 | - onerror then "onerror", //HTML5 Script to be run when an error occurs when the file is being loaded | |
| 208 | - onloadeddata then "onloadeddata", //HTML5 Script to be run when media data is loaded | |
| 209 | - onloadedmetadata then "onloadedmetadata", //HTML5 Script to be run when meta data (like dimensions and duration) are loaded | |
| 210 | - onloadstart then "onloadstart", //HTML5 Script to be run just as the file begins to load before anything is actually loaded | |
| 211 | - onpause then "onpause", //HTML5 Script to be run when the media is paused either by the user or programmatically | |
| 212 | - onplay then "onplay", //HTML5 Script to be run when the media is ready to start playing | |
| 213 | - onplaying then "onplaying", //HTML5 Script to be run when the media actually has started playing | |
| 214 | - onprogress then "onprogress", //HTML5 Script to be run when the browser is in the process of getting the media data | |
| 215 | - onratechange then "onratechange", //HTML5 Script to be run each time the playback rate changes (like when a user switches to a slow motion or fast forward mode) | |
| 216 | - onseeked then "onseeked", //HTML5 Script to be run when the seeking attribute is set to false indicating that seeking has ended | |
| 217 | - onseeking then "onseeking", //HTML5 Script to be run when the seeking attribute is set to true indicating that seeking is active | |
| 218 | - onstalled then "onstalled", //HTML5 Script to be run when the browser is unable to fetch the media data for whatever reason | |
| 219 | - onsuspend then "onsuspend", //HTML5 Script to be run when fetching the media data is stopped before it is completely loaded for whatever reason | |
| 220 | - ontimeupdate then "ontimeupdate", //HTML5 Script to be run when the playing position has changed (like when the user fast forwards to a different point in the media) | |
| 221 | - onvolumechange then "onvolumechange", //HTML5 Script to be run each time the volume is changed which (includes setting the volume to "mute") | |
| 222 | - onwaiting then "onwaiting", //HTML5 Script to be run when the media has paused but is expected to resume (like when the media pauses to buffer more data) | |
| 223 | - //Misc Events | |
| 224 | - onshow then "onshow", //HTML5 Fires when a <menu> element is shown as a context menu | |
| 225 | - ontoggle then "ontoggle" | |
| 226 | - }. | |
| 227 | - | |
| 228 | -public type Cross_origin: | |
| 229 | - anonymous, | |
| 230 | - use_credentials | |
| 231 | -. | |
| 232 | - | |
| 233 | -public define String | |
| 234 | - to_String | |
| 235 | - ( | |
| 236 | - Cross_origin c_origin | |
| 237 | - )= | |
| 238 | - if c_origin is | |
| 239 | - { | |
| 240 | - anonymous then "anonymous", | |
| 241 | - use_credentials then "use-credentials" | |
| 242 | - } | |
| 243 | -. | |
| 244 | - | |
| 245 | -public type Referrer_policy: | |
| 246 | - no_referrer, | |
| 247 | - no_referrer_when_downgrade, | |
| 248 | - origin, | |
| 249 | - origin_when_cross_origin, | |
| 250 | - unsafe_url | |
| 251 | -. | |
| 252 | - | |
| 253 | -public define String | |
| 254 | - to_String | |
| 255 | - ( | |
| 256 | - Referrer_policy r_policy | |
| 257 | - )= | |
| 258 | - if r_policy is | |
| 259 | - { | |
| 260 | - no_referrer then "no-referrer", | |
| 261 | - no_referrer_when_downgrade then "no-referrer-when-downgrade", | |
| 262 | - origin then "origin", | |
| 263 | - origin_when_cross_origin then "origin-when-cross-origin", | |
| 264 | - unsafe_url then "unsafe-url" | |
| 265 | - } | |
| 266 | -. | |
| 267 | - | |
| 268 | -public type CSS_File: | |
| 269 | - css_file(String file_name, CSS_File_Media). | |
| 270 | - | |
| 271 | -public type JS_Attribute: | |
| 272 | - async, | |
| 273 | - crossorigin(Cross_origin), //Specifies how the element handles cross-origin requests | |
| 274 | - defer, //Specifies the location of the linked document | |
| 275 | - integrity(String), | |
| 276 | - nomodule(Bool), | |
| 277 | - referrerpolicy(Referrer_policy), //Specifies which referrer to use when fetching the resource | |
| 278 | -// src(String), //Specifies on what device the linked document will be displayed | |
| 279 | - type(String), | |
| 280 | - attr(String, String). | |
| 281 | - | |
| 282 | -public define String | |
| 283 | - to_String | |
| 284 | - ( | |
| 285 | - JS_Attribute attr | |
| 286 | - )= | |
| 287 | - if attr is | |
| 288 | - { | |
| 289 | - async then "async", | |
| 290 | - crossorigin(c_org) then "crossorigin=\""+to_String(c_org)+"\"", //Specifies how the element handles cross-origin requests | |
| 291 | - defer then "defer", //Specifies the location of the linked document | |
| 292 | - integrity(filehash) then "integrity=\""+filehash+"\"", | |
| 293 | - nomodule(value) then "nomodule=\""+if value then "True\"" else "False\"", | |
| 294 | - referrerpolicy(r_pol) then "referrerpolicy=\""+ to_String(r_pol)+ "\"", //Specifies which referrer to use when fetching the resource | |
| 295 | - //src(url) then "src=\""+url+"\"", //Specifies on what device the linked document will be displayed | |
| 296 | - type(_type) then "type=\""+_type+"\"", | |
| 297 | - attr(key, value) then key+"=\""+value+"\"" | |
| 298 | - } | |
| 299 | -. | |
| 300 | - | |
| 301 | -public type JS_File: | |
| 302 | - js_file(String file_name, | |
| 303 | - List(JS_Attribute) attributes). | |
| 304 | - | |
| 305 | -public type Script: | |
| 306 | - script( String script_type, | |
| 307 | - String content). | |
| 308 | - | |
| 309 | -public define JS_File js_file(String file_name) = js_file(file_name, []). | |
| 310 | -public define CSS_File css_file(String file_name)= css_file(file_name, all). | |
| 311 | - | |
| 312 | -public type CoreAttrs:... | |
| 313 | -public type HTML_Partial_Content:... | |
| 314 | -public type HTML_Body:... | |
| 315 | -public type HTML_Off_Form:... | |
| 316 | -public type HTML_tooltip:... | |
| 317 | -public type HTTP_Answer:... | |
| 318 | - | |
| 319 | - | |
| 320 | -public type Text_Option: | |
| 321 | - core_attrs(List(CoreAttrs)), | |
| 322 | - size(Int), // size of character font to use | |
| 323 | - font(String), // name of character font to use (such as "helvetica",...) | |
| 324 | - color(RGB), // color to be used for characters | |
| 325 | - italic, | |
| 326 | - oblique, | |
| 327 | - small_capitals, | |
| 328 | - bold, | |
| 329 | - underlined, | |
| 330 | - left_justified, | |
| 331 | - right_justified, | |
| 332 | - justified, // justified on both sides | |
| 333 | - line_through, | |
| 334 | - nowrap, | |
| 335 | - class(String), //CSS class | |
| 336 | - id(String), | |
| 337 | - style(String), | |
| 338 | - title(String), | |
| 339 | - attr(String, String). | |
| 340 | - | |
| 341 | -public type CSS_Style: | |
| 342 | - text_options(List(Text_Option)). | |
| 343 | - | |
| 344 | -// Following types are define to prohib any arguments order error | |
| 345 | - | |
| 346 | -/** | |
| 347 | - * String value for 'id' attribut | |
| 348 | - */ | |
| 349 | -public type HTML_Id: | |
| 350 | - html_Id(String id). | |
| 351 | - | |
| 352 | -/** | |
| 353 | - * String value for 'class' attribut | |
| 354 | - */ | |
| 355 | -public type HtmlClass: | |
| 356 | - htmlClass(String class). | |
| 357 | - | |
| 358 | -/** | |
| 359 | - * Name used in arguments list when form is submitted. | |
| 360 | - */ | |
| 361 | -public type WebArgName: | |
| 362 | - wan(String name). | |
| 363 | - | |
| 364 | -/** | |
| 365 | - * Value passed to arguments list when form is submitted (for RadioButton and CheckBox). | |
| 366 | - */ | |
| 367 | -public type WebArgValue: | |
| 368 | - wav(String value). | |
| 369 | - | |
| 370 | -/** | |
| 371 | - * Initial value of an input field. | |
| 372 | - */ | |
| 373 | -public type InitialValue: | |
| 374 | - init(String value). | |
| 375 | - | |
| 376 | -public type HTML_Help_Position: | |
| 377 | - left, | |
| 378 | - right | |
| 379 | -. | |
| 380 | - | |
| 381 | -public type HTML_Help: | |
| 382 | - no_help, //no help text available | |
| 383 | - tooltip(HTML_tooltip, | |
| 384 | - HTML_Help_Position) | |
| 385 | -. | |
| 386 | - | |
| 387 | -public type HTML_Label: | |
| 388 | - no_label, | |
| 389 | - label( | |
| 390 | - String text, //label to show | |
| 391 | - HTML_Help help //HTML help (tooltip with ajax call or not) | |
| 392 | - ) | |
| 393 | -. | |
| 394 | - | |
| 395 | -public type InputAttrs: | |
| 396 | - id (String), | |
| 397 | - class (String), | |
| 398 | - style (String), | |
| 399 | - title (String), | |
| 400 | - lang (String), | |
| 401 | - dir (Reading_Way), | |
| 402 | - accesskey (Word8), | |
| 403 | - tabindex (Int), | |
| 404 | - attr (String, String), | |
| 405 | - event (HtmlEvents, String), | |
| 406 | - //HTML5 | |
| 407 | - data (String name, String value). | |
| 408 | - | |
| 409 | -public type TextAreaOption: | |
| 410 | - input_attrs(List(InputAttrs)), | |
| 411 | - disabled, | |
| 412 | - read_only, | |
| 413 | - wrap_lines | |
| 414 | -. | |
| 415 | - | |
| 416 | -public type Actioner_Local_Action: | |
| 417 | - close_window. | |
| 418 | - | |
| 419 | -public type Actioner_Connection: | |
| 420 | - same, // use same type of connection as current page | |
| 421 | - http, // use non secured connection | |
| 422 | - https. // use secured connection | |
| 423 | - | |
| 424 | -public type Other_Window_Option: | |
| 425 | - resizable, // the new window may be resized by the client | |
| 426 | - scrollbars, // the new window has scrollbars | |
| 427 | - width(Int), // the new window has the specified width | |
| 428 | - height(Int). // the new window has the specified height | |
| 429 | - | |
| 430 | -public type Actioner_Target: | |
| 431 | - same, | |
| 432 | - same (String label), | |
| 433 | - other(String window_name, List(Other_Window_Option)). | |
| 434 | - | |
| 435 | -public type Actioner_Aspect: | |
| 436 | - link (List(Text_Option), String text, Maybe(String) name),// hypertext link | |
| 437 | - img_link (List(CoreAttrs),String img_url, String alt_text), | |
| 438 | - push_button (List(CoreAttrs),String text), | |
| 439 | - button (String url_off, String url_on), // rollover button | |
| 440 | - button (String url_off, String url_on, Int w, Int h), // idem with size | |
| 441 | - submit (List(CoreAttrs),String text), | |
| 442 | - immediate_selector (List(CoreAttrs), String name, Int size, List((List(CoreAttrs),WebArgValue,String)) choices, Maybe(InitialValue) selected, String onchange_fn), | |
| 443 | - html (List(CoreAttrs), HTML_Off_Form). | |
| 444 | - | |
| 445 | -public define Actioner_Aspect html(HTML_Off_Form content) = html([], content). | |
| 446 | - | |
| 447 | -public type BackgroundOption: | |
| 448 | - repeat, // repeat the background in both directions | |
| 449 | - repeat_horizontal, // repeat the background only horizontally | |
| 450 | - repeat_vertical, // repeat the background only verticall | |
| 451 | - no_repeat, // don't repeat the background | |
| 452 | - center. | |
| 453 | - | |
| 454 | -public type Cell_Option: | |
| 455 | - core_attrs(List(CoreAttrs)), | |
| 456 | - left, // put the content of the cell on the left | |
| 457 | - h_center, // center the content of the cell horizontally | |
| 458 | - right, // put the content of the cell on the right | |
| 459 | - top, // put the content of the cell upwards | |
| 460 | - v_center, // center the content of tye cell vertically, | |
| 461 | - bottom, // put the content of the cell downwards | |
| 462 | - base_line, // align the content vertically according to base lines | |
| 463 | - background_color(RGB), | |
| 464 | - background_image(String url, BackgroundOption), | |
| 465 | - width(Int), // sets a minimal width for the cell | |
| 466 | - percentage_width(Int), | |
| 467 | - height(Int), // sets a minimal height for the cell | |
| 468 | - columns(Int), // lets the cell span over several columns | |
| 469 | - rows(Int), // lets the cell span over several rows | |
| 470 | - nowrap, // do not allow text wrapping within the cell | |
| 471 | - style(String), // in case nothing above is suitable | |
| 472 | - class(String class_name). | |
| 473 | - | |
| 474 | -public type HTML_Cell($T): | |
| 475 | - cell(List(Cell_Option) options, $T content). | |
| 476 | - | |
| 477 | -public type HTML_Footer_Row($T): | |
| 478 | - empty, | |
| 479 | - footer_row(List(Cell_Option) options, List(HTML_Cell($T)) cells). | |
| 480 | - | |
| 481 | -public type HTML_Row($T): | |
| 482 | - empty, | |
| 483 | - row(List(Cell_Option) options, List(HTML_Cell($T)) cells). | |
| 484 | - | |
| 485 | -public type HTML_Header_Cell($T): | |
| 486 | - header_cell(List(Cell_Option) options, $T content). | |
| 487 | - | |
| 488 | -public type HTML_Header_Row($T): | |
| 489 | - empty, | |
| 490 | - header_row(List(Cell_Option) options, List(HTML_Header_Cell($T)) cells). | |
| 491 | - | |
| 492 | - | |
| 493 | -public type Table_Option: | |
| 494 | - core_attrs(List(CoreAttrs)), | |
| 495 | - background_color(RGB), // applied to all cells in the table | |
| 496 | - background_image(String url), | |
| 497 | - border(Int width_of_outer_edge, // if not present, all values are 0 | |
| 498 | - Int width_of_top_of_relief, | |
| 499 | - Int width_of_inner_edge, | |
| 500 | - RGB border_color), | |
| 501 | - width(Int), // sets a minimal width for the table | |
| 502 | - percentage_width(Int), | |
| 503 | - attr(String name, String value), | |
| 504 | - class(String class_name). | |
| 505 | - | |
| 506 | - | |
| 507 | -public type HTML_In_Form: | |
| 508 | - empty, | |
| 509 | - literal_pt (Printable_tree), | |
| 510 | - literal (String), | |
| 511 | - sequence (List(HTML_In_Form) items), | |
| 512 | - text (List(CoreAttrs), String the_text), | |
| 513 | - preformated (List(Text_Option), String), | |
| 514 | - paragraph (List(Text_Option), List(HTML_In_Form) content), | |
| 515 | - image (List(CoreAttrs), String url, String alternate), | |
| 516 | - image (List(CoreAttrs), String url, String alternate, Int width, Int height), | |
| 517 | - table (List(Table_Option), HTML_Header_Row(HTML_In_Form), List(HTML_Row(HTML_In_Form)), HTML_Footer_Row(HTML_In_Form)), | |
| 518 | - center (HTML_In_Form), | |
| 519 | - mail_to (String email, HTML_In_Form element), | |
| 520 | - scroller (Int width, Int height, | |
| 521 | - Int content_width, Int content_height, | |
| 522 | - HTML_In_Form content), | |
| 523 | - actioner (Actioner_Connection, Actioner_Target, Actioner_Aspect, | |
| 524 | - WEB_Action_Name action_name, List((String,String)) extra_ops, | |
| 525 | - List(Actioner_Local_Action)), | |
| 526 | - foreign_link_new (Actioner_Target, Actioner_Aspect, String url), | |
| 527 | - foreign_link (List(Text_Option), String url), | |
| 528 | - foreign_link (List(Text_Option), String url, String name), | |
| 529 | - private_download (String abs_path, String name, String extra_ext, | |
| 530 | - Maybe((String,List((String,String)))) action), | |
| 531 | - text_input (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, InitialValue init, Int width), | |
| 532 | - text_input_ro (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, InitialValue init, Int width), | |
| 533 | - password_input (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, InitialValue init, Int width), | |
| 534 | - text_area (List(TextAreaOption), HTML_Label label, HTML_Id id, WebArgName name, InitialValue init, Int width, Int height), | |
| 535 | - file_upload (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, Int width), | |
| 536 | - selector (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, Int size, List(String) choices), | |
| 537 | - selector (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, Int size, List(String) choices, InitialValue selected), | |
| 538 | - // List((String,String)) = List((code,name)) where : | |
| 539 | - // code is the web-arg value | |
| 540 | - // name appears in selector | |
| 541 | - selector_c (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, Int size, List((List(CoreAttrs),WebArgValue,String)) choices), | |
| 542 | - selector_c (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, Int size, List((List(CoreAttrs),WebArgValue,String)) choices, InitialValue selected), | |
| 543 | - radio_button (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, WebArgValue value, Bool checked), | |
| 544 | - radio_button_r (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, WebArgValue value, Bool checked), | |
| 545 | - check_box (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, Bool checked), | |
| 546 | - check_box_r (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, Bool checked), | |
| 547 | - div (List(CoreAttrs), List(HTML_In_Form) content), | |
| 548 | - div_empty (List(CoreAttrs)), | |
| 549 | - hidden (HTML_Id id, WebArgName name, WebArgValue value), | |
| 550 | - partial (HTML_Partial_Content), | |
| 551 | - br, | |
| 552 | - progress (List(CoreAttrs), Int value, Int max), | |
| 553 | - ol (List(CoreAttrs), List(HTML_In_Form) content), | |
| 554 | - ul (List(CoreAttrs), List(HTML_In_Form) content), | |
| 555 | - li (List(CoreAttrs), List(HTML_In_Form) content), | |
| 556 | - button (List(CoreAttrs), List(HTML_In_Form) content), | |
| 557 | - i (List(CoreAttrs), String text), | |
| 558 | - span (List(CoreAttrs), String text), | |
| 559 | - hr (List(CoreAttrs)) | |
| 560 | -. | |
| 561 | - | |
| 562 | -public type HTML_Size: | |
| 563 | - absolute(Int), // in pixels | |
| 564 | - percentage(Int). | |
| 565 | - | |
| 566 | -public type A_href: | |
| 567 | - href(String href), | |
| 568 | - href(WEB_Action_Name action, List((String,String)) extra_ops) | |
| 569 | -. | |
| 570 | - | |
| 571 | -public define A_href | |
| 572 | - href | |
| 573 | - ( | |
| 574 | - WEB_Action_Name action, | |
| 575 | - (String,String) extra_ops | |
| 576 | - )= | |
| 577 | - href(action, [extra_ops]) | |
| 578 | -. | |
| 579 | - | |
| 580 | -public type A_target: | |
| 581 | - _blank, | |
| 582 | - _self, | |
| 583 | - _parent, | |
| 584 | - _top, | |
| 585 | - framename(String name) | |
| 586 | -. | |
| 587 | - | |
| 588 | - | |
| 589 | -public type HTML_Off_Form: | |
| 590 | - a (List(CoreAttrs), A_href, A_target, List(HTML_Off_Form) content), | |
| 591 | - empty, | |
| 592 | - literal_pt (Printable_tree), | |
| 593 | - literal (String), | |
| 594 | - sequence (List(HTML_Off_Form) items), | |
| 595 | - text (List(CoreAttrs), String the_text), | |
| 596 | - | |
| 597 | - //table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form)), HTML_Footer_Row(HTML_Off_Form)), | |
| 598 | - | |
| 599 | - actioner (Actioner_Connection, Actioner_Target, Actioner_Aspect, | |
| 600 | - WEB_Action_Name action_name, List((String,String)) extra_ops, | |
| 601 | - List(Actioner_Local_Action)), | |
| 602 | - actioner (Actioner_Connection, Actioner_Target, Actioner_Aspect, | |
| 603 | - WEB_Action_Name action_name, List((String,String)) extra_ops, | |
| 604 | - List(Actioner_Local_Action), String form_name), | |
| 605 | - foreign_link_new (Actioner_Target, Actioner_Aspect, String url), | |
| 606 | - //foreign_link (List(Text_Option), String url), | |
| 607 | - foreign_link (List(Text_Option), String url, String name), | |
| 608 | - private_download (String abs_path, String name, String extra_ext, | |
| 609 | - Maybe((String,List((String,String)))) action), | |
| 610 | - //label (String name), | |
| 611 | - //form (HTML_Id form_id, List(CoreAttrs), List(HTML_In_Form) content), | |
| 612 | -// form (HTML_Id form_id, List(CoreAttrs), | |
| 613 | -// WEB_Action_Name action, List((String,String)) extra_ops, | |
| 614 | -// List(HTML_In_Form) content), | |
| 615 | - //in_form (HTML_Id form_id, HTML_In_Form content), | |
| 616 | - div (List(CoreAttrs), List(HTML_Partial_Content) p_content), | |
| 617 | - iframe (List(CoreAttrs), | |
| 618 | - List(CSS_Style) /*styles*/, | |
| 619 | - List(CSS_File) /*css_files*/, | |
| 620 | - List(JS_File) /*js_files*/, | |
| 621 | - HTML_Body /*body*/), | |
| 622 | - partial (HTML_Partial_Content), | |
| 623 | - //progress (List(CoreAttrs), Int value, Int max), | |
| 624 | - //i (List(CoreAttrs), String text), | |
| 625 | - html_tag (String tag_name, List(CoreAttrs), List(HTML_Off_Form) content), | |
| 626 | - html_void_tag (String tag_name, List(CoreAttrs)) | |
| 627 | -. | |
| 628 | - | |
| 629 | - | |
| 630 | -public type Rel_attr: | |
| 631 | - alternate, | |
| 632 | - author, | |
| 633 | - dns_prefetch, | |
| 634 | - help, | |
| 635 | - icon, | |
| 636 | - license, | |
| 637 | - next, | |
| 638 | - pingback, | |
| 639 | - preconnect, | |
| 640 | - prefetch, | |
| 641 | - preload, | |
| 642 | - prerender, | |
| 643 | - prev, | |
| 644 | - search, | |
| 645 | - stylesheet | |
| 646 | -. | |
| 647 | - | |
| 648 | -public define String | |
| 649 | - to_String | |
| 650 | - ( | |
| 651 | - Rel_attr r_attr | |
| 652 | - )= | |
| 653 | - if r_attr is | |
| 654 | - { | |
| 655 | - alternate then "alternate", | |
| 656 | - author then "author", | |
| 657 | - dns_prefetch then "dns_prefetch", | |
| 658 | - help then "help", | |
| 659 | - icon then "icon", | |
| 660 | - license then "license", | |
| 661 | - next then "next", | |
| 662 | - pingback then "pingback", | |
| 663 | - preconnect then "preconnect", | |
| 664 | - prefetch then "prefetch", | |
| 665 | - preload then "preload", | |
| 666 | - prerender then "prerender", | |
| 667 | - prev then "prev", | |
| 668 | - search then "search", | |
| 669 | - stylesheet then "stylesheet" | |
| 670 | - } | |
| 671 | -. | |
| 672 | - | |
| 673 | -public type Link_attr: | |
| 674 | - crossorigin(Cross_origin), //Specifies how the element handles cross-origin requests | |
| 675 | - href(String), //Specifies the location of the linked document | |
| 676 | - media(String), //Specifies on what device the linked document will be displayed | |
| 677 | - referrerpolicy(Referrer_policy), //Specifies which referrer to use when fetching the resource | |
| 678 | - rel(Rel_attr), | |
| 679 | - sizes(String), | |
| 680 | - type(String), | |
| 681 | - as(String), | |
| 682 | - integrity(String), | |
| 683 | - event(HtmlEvents, String) | |
| 684 | -. | |
| 685 | - | |
| 686 | -public define String | |
| 687 | - to_String | |
| 688 | - ( | |
| 689 | - Link_attr attr | |
| 690 | - )= | |
| 691 | - if attr is | |
| 692 | - { | |
| 693 | - crossorigin(c_origin) then "crossorigin=\""+to_String(c_origin)+"\"", | |
| 694 | - href(url) then "href=\""+url+"\"", | |
| 695 | - media(media) then "media=\""+media+"\"", | |
| 696 | - referrerpolicy(r_policy) then "referrerpolicy=\""+to_String(r_policy)+"\"", | |
| 697 | - rel(rel_attr) then "rel=\""+to_String(rel_attr)+"\"", | |
| 698 | - sizes(_sizes) then "sizes=\""+_sizes+"\"", | |
| 699 | - type(_type) then "type=\""+_type+"\"", | |
| 700 | - as(_as) then "as=\""+_as+"\"", | |
| 701 | - integrity(_integrity) then "integrity=\""+_integrity+"\"", | |
| 702 | - event(_event, code) then to_String(_event)+"=\""+code+"\"", | |
| 703 | - } | |
| 704 | -. | |
| 705 | - | |
| 706 | -public define String | |
| 707 | - to_String | |
| 708 | - ( | |
| 709 | - List(Link_attr) attrs | |
| 710 | - )= | |
| 711 | - join(" ", map((Link_attr attr) |-> | |
| 712 | - to_String(attr), | |
| 713 | - attrs)) | |
| 714 | -. | |
| 715 | - | |
| 716 | - | |
| 717 | - | |
| 718 | -public type HTML_Meta: | |
| 719 | - keywords (List(String)), | |
| 720 | - refresh (Actioner_Connection connection, | |
| 721 | - Actioner_Target target, | |
| 722 | - WEB_Action_Name action, | |
| 723 | - Int delay), // in seconds | |
| 724 | - refresh (String url, Int delay), // in seconds | |
| 725 | - meta (String name, String content), | |
| 726 | - http_equiv (String name, String content), | |
| 727 | - generic_meta (List((String,String))), | |
| 728 | - literal (String). | |
| 729 | - | |
| 730 | -public type HTML_Head_Tag: | |
| 731 | - meta(HTML_Meta), | |
| 732 | - title(String), | |
| 733 | - js(JS_File), | |
| 734 | - js_inline(Script), | |
| 735 | - css(CSS_File), | |
| 736 | - css_inline(String css_styles), /* Note: <style> and </style> tags are not necessaries */ | |
| 737 | - link(List(Link_attr) link_attrs) | |
| 738 | -. | |
| 739 | - | |
| 740 | -public type HTML_Partial_Content: | |
| 741 | - partial_content | |
| 742 | - ( | |
| 743 | - List(HTML_Head_Tag), | |
| 744 | - HTML_Off_Form | |
| 745 | - ) | |
| 746 | -. | |
| 747 | - | |
| 748 | -public type HTML_Body: | |
| 749 | - body(List(CoreAttrs) attrs, List(HTML_Off_Form) content). | |
| 750 | - | |
| 751 | -public define HTML_Body | |
| 752 | - body | |
| 753 | - ( | |
| 754 | - List(CoreAttrs) attrs, | |
| 755 | - HTML_Off_Form content | |
| 756 | - )= | |
| 757 | - body(attrs, [content]) | |
| 758 | -. | |
| 759 | - | |
| 760 | -public define HTML_Body | |
| 761 | - body | |
| 762 | - ( | |
| 763 | - CoreAttrs attr, | |
| 764 | - HTML_Off_Form content | |
| 765 | - )= | |
| 766 | - body([attr], [content]) | |
| 767 | -. | |
| 768 | - | |
| 769 | -public define HTML_Body | |
| 770 | - body | |
| 771 | - ( | |
| 772 | - CoreAttrs attr, | |
| 773 | - List(HTML_Off_Form) content | |
| 774 | - )= | |
| 775 | - body([attr], content) | |
| 776 | -. | |
| 777 | - | |
| 778 | -public define HTML_Body | |
| 779 | - body | |
| 780 | - ( | |
| 781 | - HTML_Off_Form content | |
| 782 | - )= | |
| 783 | - body([], [content]) | |
| 784 | -. | |
| 785 | - | |
| 786 | - | |
| 787 | -public type HTML_tooltip: | |
| 788 | - html_tooltip | |
| 789 | - ( | |
| 790 | - String title, | |
| 791 | - String keyword, | |
| 792 | - Int width, | |
| 793 | - ), | |
| 794 | - html_tooltip_ext | |
| 795 | - ( | |
| 796 | - String title, | |
| 797 | - String extend_type, | |
| 798 | - String class_suffix, | |
| 799 | - List((String, String)) ext_args | |
| 800 | - ), | |
| 801 | - html_tooltip_ext //same without class suffix. This means we use awesome font | |
| 802 | - ( | |
| 803 | - String title, | |
| 804 | - String extend_type, | |
| 805 | - List((String, String)) ext_args | |
| 806 | - ), | |
| 807 | - html_tooltip | |
| 808 | - ( | |
| 809 | - String title, | |
| 810 | - WEB_Action_Name wan, | |
| 811 | - List((String, String)) ext_args | |
| 812 | - ). | |
| 813 | - | |
| 814 | - | |
| 815 | - | |
| 816 | -public type CoreAttrs: | |
| 817 | - empty, | |
| 818 | - id (String), //A unique identifier for the element. | |
| 819 | - //There must not be multiple elements in a document that have the same id value. | |
| 820 | - class (String), //A name of a classification, or list of names of classifications, to which the element belongs | |
| 821 | - style (String), //Specifies zero or more CSS declarations that apply to the element [CSS]. | |
| 822 | - title (String), //Advisory information associated with the element. | |
| 823 | - lang (String), //Specifies the primary language for the contents of the element and for any of the element’s attributes that contain text. | |
| 824 | - dir (Reading_Way), //Specifies the element’s text directionality. | |
| 825 | - accesskey (Word8), //A key label or list of key labels with which to associate the element; each key label represents | |
| 826 | - //a keyboard shortcut which UAs can use to activate the element or give focus to the element. | |
| 827 | - tabindex (Int), //Specifies whether the element represents an element that is is focusable (that is, an element which is part of the | |
| 828 | - //sequence of focusable elements in the document), and the relative order of the element in the sequence of focusable | |
| 829 | - //elements in the document. | |
| 830 | - //Anubis specific | |
| 831 | - attr (String, String), //intended to provide unknown attritute | |
| 832 | - bool_attr (Bool, String), //like checked in checkbox the attribute 'checked' is here if true else nothing | |
| 833 | - event (HtmlEvents, String), | |
| 834 | - tooltip (HTML_tooltip), | |
| 835 | - | |
| 836 | - //HTML5 | |
| 837 | - data (String name, String value), | |
| 838 | - contenteditable(Bool), //Specifies whether the contents of the element are editable | |
| 839 | - contextmenu(String), //Identifies a menu with which to associate the element as a context menu. | |
| 840 | - draggable(Bool), //Specifies whether the element is draggable. | |
| 841 | - enterkeyhint(String), //Specifies the text of the enter-key on a virtual keyboard | |
| 842 | - hidden(Bool), //Specifies that the element represents an element that is not yet, or is no longer, relevant. | |
| 843 | - inert, //Specifies that the browser should ignore this section | |
| 844 | - inputmode(String), //Specifies the mode of a virtual keyboard | |
| 845 | - popover, //Specifies a popover element | |
| 846 | - spellcheck(Bool), //Specifies whether the element represents an element whose contents are subject to spell checking and grammar checking. | |
| 847 | - translate(Bool) //Specifies whether the content of an element should be translated or not | |
| 848 | -. | |
| 849 | - | |
| 850 | -public define CoreAttrs colspan(Int value) = attr("colspan", to_String(value)). | |
| 851 | -public define CoreAttrs rowspan(Int value) = attr("rowspan", to_String(value)). | |
| 852 | -public define CoreAttrs headers(String header_id) = attr("headers", header_id). | |
| 853 | -public define CoreAttrs width(Int value) = attr("width", to_String(value)). | |
| 854 | -public define CoreAttrs height(Int value) = attr("height", to_String(value)). | |
| 855 | -public define CoreAttrs width_px(Int value) = attr("width", to_String(value)+"px"). | |
| 856 | -public define CoreAttrs height_px(Int value) = attr("height", to_String(value)+"px"). | |
| 857 | -public define CoreAttrs alt(String value) = attr("alt", value). | |
| 858 | -public define CoreAttrs size(Int value) = attr("size", to_String(value)). | |
| 859 | - | |
| 860 | -public define CoreAttrs boolean(String name) = attr(name, name). | |
| 861 | - | |
| 862 | -public type HTTP_Answer: | |
| 863 | - html_page (HTTP_Status /*http_status*/, | |
| 864 | - List(HTML_Head_Tag) /*html <head> tags*/, | |
| 865 | - HTML_Body /*body*/), | |
| 866 | - html_page (HTTP_Status /*http_status*/, | |
| 867 | - String /*title*/, | |
| 868 | - List(HTML_Head_Tag) /*meta_tags*/, | |
| 869 | - List(CSS_Style) /*styles*/, | |
| 870 | - List(CSS_File) /*css_files*/, | |
| 871 | - List(JS_File) /*js_files*/, | |
| 872 | - List(Script) /*script*/, | |
| 873 | - HTML_Body /*body*/), | |
| 874 | - plain_text (HTTP_Status /*http_status*/, | |
| 875 | - String /*text*/), | |
| 876 | - custom_text (HTTP_Status /*http_status*/, | |
| 877 | - MIME /*mime_type*/, | |
| 878 | - String /*content*/), | |
| 879 | - custom_binary(HTTP_Status /*http_status*/, | |
| 880 | - MIME /*mime_type*/, | |
| 881 | - ByteArray /*content*/, | |
| 882 | - List(HTTP_header)/*other headers*/), | |
| 883 | - custom_tree (HTTP_Status /*http_status*/, | |
| 884 | - MIME /*mime_type*/, | |
| 885 | - Printable_tree /*content*/), | |
| 886 | - json (HTTP_Status, /*http_status*/ | |
| 887 | - JsonValue), /*json value*/ | |
| 888 | - send_file ( String file_path, //file to send to client. //TODO add call back for before, during, after send | |
| 889 | - Content_Disposition c_disposition), | |
| 890 | - http_raw (Printable_tree), | |
| 891 | - html_content (HTTP_Status /*http_status*/, | |
| 892 | - HTML_Off_Form), | |
| 893 | - html_partial_content (HTTP_Status /*http_status*/, | |
| 894 | - HTML_Partial_Content) | |
| 895 | -. | |
| 896 | - | |
| 897 | -public define HTTP_Answer | |
| 898 | - no_content | |
| 899 | - = | |
| 900 | - plain_text(http_no_content, "") | |
| 901 | -. | |
| 902 | - | |
| 903 | - |