Commit 4b855b699e299a668c4e317fbfda5b9b76ba8162
1 parent
96101668
Paragraph tag can have an id and do no more contains only text, but also other tags.
Showing
2 changed files
with
478 additions
and
476 deletions
Show diff stats
calexium_lib/web/CXM_generic_form.anubis
| 1 | - | |
| 2 | - | |
| 3 | - | |
| 4 | - *Project* The Anubis Project | |
| 5 | - | |
| 6 | - *Title* | |
| 7 | - | |
| 8 | - *Copyright* Copyright (c) Alain Prouté 2005. | |
| 9 | - | |
| 10 | - | |
| 11 | - *Author* Alain Prouté | |
| 12 | - | |
| 13 | - | |
| 14 | - | |
| 15 | - In this file we rationalize the construction of forms. | |
| 16 | - | |
| 17 | - | |
| 18 | - | |
| 19 | -read CXM_making_a_web_site.anubis | |
| 20 | - | |
| 21 | - | |
| 22 | -public type Mandatory: // used to mark fields as mandatory. | |
| 23 | - mandatory, | |
| 24 | - non_mandatory. | |
| 25 | - | |
| 26 | -public type Width: | |
| 27 | - small, | |
| 28 | - narrow, | |
| 29 | - wide, | |
| 30 | - custom(Int32). | |
| 31 | - | |
| 32 | -public type FormFieldWidth: | |
| 33 | - auto, | |
| 34 | - custom(Int32). | |
| 35 | - | |
| 36 | - | |
| 37 | - | |
| 38 | - Sorts of fields that you can put in a form: | |
| 39 | - | |
| 40 | -public type FormField: | |
| 41 | - | |
| 42 | - //--- title field --------------------------------------------------------------------- | |
| 43 | - title (String text), | |
| 44 | - title (Int32 text_size, | |
| 45 | - String text), | |
| 46 | - title_f (List(Text_Option) -> HTML_In_Form), | |
| 47 | - | |
| 48 | - //--- message field ------------------------------------------------------------------- | |
| 49 | - message (Result(String,String) msg), | |
| 50 | - message_f (Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form)), | |
| 51 | - | |
| 52 | - //--- text input field ---------------------------------------------------------------- | |
| 53 | - input (String web_arg_name, | |
| 54 | - String tag, | |
| 55 | - Width width, | |
| 56 | - String init_value, | |
| 57 | - Mandatory mandatory), | |
| 58 | - input (String web_arg_name, | |
| 59 | - Width width, | |
| 60 | - String init_value), | |
| 61 | - input_f (String web_arg_name, | |
| 62 | - List(Text_Option) -> HTML_In_Form tag, | |
| 63 | - Width width, | |
| 64 | - String init_value, | |
| 65 | - Mandatory mandatory), | |
| 66 | - | |
| 67 | - //--- password input field ------------------------------------------------------------ | |
| 68 | - password_input (String web_arg_name, | |
| 69 | - String tag, | |
| 70 | - Mandatory mandatory), | |
| 71 | - password_input_f (String web_arg_name, | |
| 72 | - List(Text_Option) -> HTML_In_Form tag, | |
| 73 | - Mandatory mandatory), | |
| 74 | - | |
| 75 | - //--- explanation field --------------------------------------------------------------- | |
| 76 | - explain (String text), | |
| 77 | - explain (String text, | |
| 78 | - FormFieldWidth width), | |
| 79 | - explain_f (List(Text_Option) -> HTML_In_Form), | |
| 80 | - | |
| 81 | - //--- selector field ------------------------------------------------------------------ | |
| 82 | - selector (String web_arg_name, | |
| 83 | - String tag, | |
| 84 | - List(String) items, | |
| 85 | - Maybe(String) selected, | |
| 86 | - Mandatory mandatory), | |
| 87 | - selector_f (String web_arg_name, | |
| 88 | - List(Text_Option) -> HTML_In_Form, | |
| 89 | - List(String) items, | |
| 90 | - Maybe(String) selected, | |
| 91 | - Mandatory mandatory), | |
| 92 | - selector_c (String web_arg_name, | |
| 93 | - String tag, | |
| 94 | - List((String,String)) items, | |
| 95 | - Maybe(String) selected, | |
| 96 | - Mandatory mandatory), | |
| 97 | - | |
| 98 | - | |
| 99 | - | |
| 100 | - //--- checkbox field ------------------------------------------------------------------ | |
| 101 | - checkbox (String web_arg_name, | |
| 102 | - String tag, | |
| 103 | - Bool checked, | |
| 104 | - Mandatory mandatory), | |
| 105 | - // the same one, but with the tag on the right of the checkbox | |
| 106 | - checkboxr (String web_arg_name, | |
| 107 | - String tag, | |
| 108 | - Bool checked, | |
| 109 | - Mandatory mandatory), | |
| 110 | - checkbox_f (String web_arg_name, | |
| 111 | - List(Text_Option) -> HTML_In_Form, | |
| 112 | - Bool checked, | |
| 113 | - Mandatory mandatory), | |
| 114 | - | |
| 115 | - //--- radio-button field -------------------------------------------------------------- | |
| 116 | - radio_button (String web_arg_name, | |
| 117 | - String web_arg_value, | |
| 118 | - String tag, | |
| 119 | - Bool checked, | |
| 120 | - Mandatory mandatory), | |
| 121 | - // the same one, but with the tag on the right of the radio_button | |
| 122 | - radio_buttonr (String web_arg_name, | |
| 123 | - String web_arg_value, | |
| 124 | - String tag, | |
| 125 | - Bool checked, | |
| 126 | - Mandatory mandatory), | |
| 127 | - | |
| 128 | - //--- text area field ----------------------------------------------------------------- | |
| 129 | - text_area (String web_arg_name, | |
| 130 | - String initial_text), | |
| 131 | - text_area (String web_arg_name, | |
| 132 | - String tag, | |
| 133 | - String initial_text), | |
| 134 | - text_area (String web_arg_name, | |
| 135 | - String tag, | |
| 136 | - String initial_text, | |
| 137 | - Int32 width, | |
| 138 | - Int32 height), | |
| 139 | - | |
| 140 | - //--- fields table -------------------------------------------------------------------- | |
| 141 | - fields_table (String tag, | |
| 142 | - List(FormField) fields), | |
| 143 | - | |
| 144 | - //--- fields line --------------------------------------------------------------------- | |
| 145 | - fields_line (String tag, | |
| 146 | - List(FormField) fields), | |
| 147 | - fields_line (List(FormField) fields), | |
| 148 | - | |
| 149 | - //--- preview field ------------------------------------------------------------------- | |
| 150 | - preview (String html_text), | |
| 151 | - | |
| 152 | - //--- submit button ------------------------------------------------------------------- | |
| 153 | - submit (String action_name, | |
| 154 | - Maybe(String) label, | |
| 155 | - String button_text, | |
| 156 | - List((String,String)) extra_operands). | |
| 157 | - | |
| 158 | - | |
| 159 | - Convenience functions: | |
| 160 | - | |
| 161 | -public define FormField title(List(Text_Option) -> HTML_In_Form f) = title_f(f). | |
| 162 | -public define FormField | |
| 163 | - message(Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form) f) = message_f(f). | |
| 164 | -public define FormField input(String web_arg_name, | |
| 165 | - List(Text_Option) -> HTML_In_Form tag, | |
| 166 | - Width width, | |
| 167 | - String init_value, | |
| 168 | - Mandatory mandatory) | |
| 169 | - = input_f(web_arg_name,tag,width,init_value,mandatory). | |
| 170 | -public define FormField password_input(String web_arg_name, | |
| 171 | - List(Text_Option) -> HTML_In_Form tag, | |
| 172 | - Mandatory mandatory) | |
| 173 | - = password_input_f(web_arg_name,tag,mandatory). | |
| 174 | -public define FormField explain(List(Text_Option) -> HTML_In_Form f) = explain_f(f). | |
| 175 | -public define FormField selector(String web_arg_name, | |
| 176 | - List(Text_Option) -> HTML_In_Form f, | |
| 177 | - List(String) items, | |
| 178 | - Maybe(String) selected, | |
| 179 | - Mandatory mandatory) | |
| 180 | - = selector_f(web_arg_name,f,items,selected,mandatory). | |
| 181 | -public define FormField checkbox(String web_arg_name, | |
| 182 | - List(Text_Option) -> HTML_In_Form f, | |
| 183 | - Bool checked, | |
| 184 | - Mandatory mandatory) | |
| 185 | - = checkbox_f(web_arg_name,f,checked,mandatory). | |
| 186 | - | |
| 187 | - Make the form itself with: | |
| 188 | - | |
| 189 | -public define HTML_Off_Form | |
| 190 | - generic_form | |
| 191 | - ( | |
| 192 | - String form_name, | |
| 193 | - RGB background_color, | |
| 194 | - Int32 width, | |
| 195 | - List(FormField) fields | |
| 196 | - ). | |
| 197 | - | |
| 198 | - | |
| 199 | - | |
| 200 | - --- That's all for the public part ! -------------------------------------------------- | |
| 201 | - | |
| 202 | - | |
| 203 | -define HTML_Row(HTML_In_Form) | |
| 204 | - format_form_field | |
| 205 | - ( | |
| 206 | - FormField ff | |
| 207 | - ) = | |
| 208 | - with star = (Mandatory m) |-> (HTML_In_Form)text([color(rgb(255,0,0)),size(12)], | |
| 209 | - if m is | |
| 210 | - { | |
| 211 | - mandatory then "*", | |
| 212 | - non_mandatory then "" | |
| 213 | - }), | |
| 214 | - row( | |
| 215 | - if ff is | |
| 216 | - { | |
| 217 | - title(t) then (List(HTML_Cell(HTML_In_Form))) | |
| 218 | - [ | |
| 219 | - cell([columns(3),h_center],text([size(16),bold,color(rgb(0,0,0))],t)) | |
| 220 | - ], | |
| 221 | - | |
| 222 | - title(s,t) then (List(HTML_Cell(HTML_In_Form))) | |
| 223 | - [ | |
| 224 | - cell([columns(3),h_center],text([size(s),bold,color(rgb(0,0,0))],t)) | |
| 225 | - ], | |
| 226 | - | |
| 227 | - title_f(t) then (List(HTML_Cell(HTML_In_Form))) | |
| 228 | - [ | |
| 229 | - cell([columns(3),h_center],t([size(16),bold,color(rgb(0,0,0))])) | |
| 230 | - ], | |
| 231 | - | |
| 232 | - message(r) then (List(HTML_Cell(HTML_In_Form))) if r is | |
| 233 | - { | |
| 234 | - error(msg) then [cell([columns(3),h_center], | |
| 235 | - text([size(10),color(rgb(240,0,0))],msg))] | |
| 236 | - ok(msg) then [cell([columns(3),h_center], | |
| 237 | - text([size(10),color(rgb(0,150,0))],msg))] | |
| 238 | - }, | |
| 239 | - | |
| 240 | - message_f(r) then (List(HTML_Cell(HTML_In_Form))) if r is | |
| 241 | - { | |
| 242 | - error(msg) then [cell([columns(3),h_center], | |
| 243 | - msg([size(10),color(rgb(240,0,0))]))] | |
| 244 | - ok(msg) then [cell([columns(3),h_center], | |
| 245 | - msg([size(10),color(rgb(0,150,0))]))] | |
| 246 | - }, | |
| 247 | - | |
| 248 | - input(wan,tag,w,init,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 249 | - [ | |
| 250 | - cell([right ], text([size(10)],tag)), | |
| 251 | - cell([width(7) ], star(mand)), | |
| 252 | - cell([left ], text_input("","",wan,init,if w is | |
| 253 | - { | |
| 254 | - small then 10, | |
| 255 | - narrow then 30, | |
| 256 | - wide then 70, | |
| 257 | - custom(n) then n | |
| 258 | - })) | |
| 259 | - ], | |
| 260 | - | |
| 261 | - input(wan,w,init) then (List(HTML_Cell(HTML_In_Form))) | |
| 262 | - [ | |
| 263 | - cell([left,columns(3) ], text_input("","",wan,init,if w is | |
| 264 | - { | |
| 265 | - small then 10, | |
| 266 | - narrow then 30, | |
| 267 | - wide then 70, | |
| 268 | - custom(n) then n | |
| 269 | - })) | |
| 270 | - ], | |
| 271 | - | |
| 272 | - input_f(wan,tag,w,init,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 273 | - [ | |
| 274 | - cell([right ], tag([size(10)])), | |
| 275 | - cell([width(7) ], star(mand)), | |
| 276 | - cell([left ], text_input("","",wan,init,if w is | |
| 277 | - { | |
| 278 | - small then 15, | |
| 279 | - narrow then 30, | |
| 280 | - wide then 70, | |
| 281 | - custom(n) then n | |
| 282 | - })) | |
| 283 | - ], | |
| 284 | - | |
| 285 | - password_input(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 286 | - [ | |
| 287 | - cell([right ], text([size(10)],tag)), | |
| 288 | - cell([width(7) ], star(mand)), | |
| 289 | - cell([left ], password_input("","",wan,30)) | |
| 290 | - ], | |
| 291 | - | |
| 292 | - password_input_f(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 293 | - [ | |
| 294 | - cell([right ], tag([size(10)])), | |
| 295 | - cell([width(7) ], star(mand)), | |
| 296 | - cell([left ], password_input("","",wan,30)) | |
| 297 | - ], | |
| 298 | - | |
| 299 | - explain(t) then (List(HTML_Cell(HTML_In_Form))) | |
| 300 | - [ | |
| 301 | - cell([columns(3),h_center], | |
| 302 | - table([nude],[row(cell([width(500)], | |
| 303 | - paragraph([/*justified,*/size(10),color(rgb(0,100,0))],t)))])) | |
| 304 | - ], | |
| 305 | - | |
| 306 | - explain(t,w) then (List(HTML_Cell(HTML_In_Form))) | |
| 307 | - [ | |
| 308 | - cell([columns(3),h_center], | |
| 309 | - table([nude],[row(cell( | |
| 310 | - if w is | |
| 311 | - { | |
| 312 | - auto then [], | |
| 313 | - custom(i) then [width(i)] | |
| 314 | - }, | |
| 315 | - paragraph([/*justified,*/size(10),color(rgb(0,100,0))],t)))])) | |
| 316 | - ], | |
| 317 | - | |
| 318 | - explain_f(t) then (List(HTML_Cell(HTML_In_Form))) | |
| 319 | - [ | |
| 320 | - cell([columns(3),h_center], | |
| 321 | - table([nude],[row(cell([width(500)], | |
| 322 | - t([/*justified,*/size(10),color(rgb(0,100,0))])))])) | |
| 323 | - ], | |
| 324 | - | |
| 325 | - selector(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 326 | - [ | |
| 327 | - cell([right ], text([size(10)],tag)), | |
| 328 | - cell([width(7)], star(mand)), | |
| 329 | - cell([left ], if selected is | |
| 330 | - { | |
| 331 | - failure then selector(wan,1,items) | |
| 332 | - success(sel) then selector(wan,1,items,sel) | |
| 333 | - }) | |
| 334 | - ], | |
| 335 | - | |
| 336 | - selector_f(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 337 | - [ | |
| 338 | - cell([right ], tag([size(10)])), | |
| 339 | - cell([width(7)], star(mand)), | |
| 340 | - cell([left ], if selected is | |
| 341 | - { | |
| 342 | - failure then selector(wan,1,items) | |
| 343 | - success(sel) then selector(wan,1,items,sel) | |
| 344 | - }) | |
| 345 | - ], | |
| 346 | - | |
| 347 | - selector_c(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 348 | - [ | |
| 349 | - cell([right ], text([size(10)],tag)), | |
| 350 | - cell([width(7)], star(mand)), | |
| 351 | - cell([left ], if selected is | |
| 352 | - { | |
| 353 | - failure then selector_c(wan,1,items) | |
| 354 | - success(sel) then selector_c(wan,1,items,sel) | |
| 355 | - }) | |
| 356 | - ], | |
| 357 | - | |
| 358 | - checkbox(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 359 | - [ | |
| 360 | - cell([right ], text([size(10)],tag)), | |
| 361 | - cell([width(7)], star(mand)), | |
| 362 | - cell([left ], check_box("","",wan,checked)) | |
| 363 | - ], | |
| 364 | - | |
| 365 | - checkboxr(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 366 | - [ | |
| 367 | - cell([right ], check_box("","",wan,checked)), | |
| 368 | - cell([width(7)], star(mand)), | |
| 369 | - cell([left ], text([size(10)],tag)) | |
| 370 | - ], | |
| 371 | - | |
| 372 | - checkbox_f(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 373 | - [ | |
| 374 | - cell([right ], tag([size(10)])), | |
| 375 | - cell([width(7)], star(mand)), | |
| 376 | - cell([left ], check_box("","",wan,checked)) | |
| 377 | - ], | |
| 378 | - | |
| 379 | - radio_button(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 380 | - [ | |
| 381 | - cell([right ], text([size(10)],tag)), | |
| 382 | - cell([width(7)], star(mand)), | |
| 383 | - cell([left ], radio_button("","",wan,wav,checked)) | |
| 384 | - ], | |
| 385 | - | |
| 386 | - radio_buttonr(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 387 | - [ | |
| 388 | - cell([right ], radio_button("","",wan,wav,checked)), | |
| 389 | - cell([width(7)], star(mand)), | |
| 390 | - cell([left ], text([size(10)],tag)) | |
| 391 | - ], | |
| 392 | - | |
| 393 | - text_area(wan,tx) then (List(HTML_Cell(HTML_In_Form))) | |
| 394 | - [ | |
| 395 | - cell([h_center,columns(3)],text_area([wrap_lines],wan,tx,75,10)) | |
| 396 | - ], | |
| 397 | - | |
| 398 | - text_area(wan,tag,tx) then (List(HTML_Cell(HTML_In_Form))) | |
| 399 | - [ | |
| 400 | - cell([right,top], text([size(10)],tag)), | |
| 401 | - cell([width(7)], text([],"")), | |
| 402 | - cell([h_center],text_area([wrap_lines],wan,tx,75,10)) | |
| 403 | - ], | |
| 404 | - | |
| 405 | - text_area(wan,tag,tx,w,h) then (List(HTML_Cell(HTML_In_Form))) | |
| 406 | - [ | |
| 407 | - cell([right,top], text([size(10)],tag)), | |
| 408 | - cell([width(7)], text([],"")), | |
| 409 | - cell([h_center],text_area([wrap_lines],wan,tx,w,h)) | |
| 410 | - ], | |
| 411 | - | |
| 412 | - fields_table(tag,fields) then (List(HTML_Cell(HTML_In_Form))) | |
| 413 | - [ | |
| 414 | - cell([right,top], text([size(10)],tag)), | |
| 415 | - cell([width(7)], text([],"")), | |
| 416 | - cell([left,top], table([],map((FormField ff) |-> format_form_field(ff),fields))) | |
| 417 | - ], | |
| 418 | - | |
| 419 | - fields_line(tag,fields) then (List(HTML_Cell(HTML_In_Form))) | |
| 420 | - [ | |
| 421 | - cell([right,top], text([size(10)],tag)), | |
| 422 | - cell([width(7)], text([],"")), | |
| 423 | - cell([left,top], table([nude],[row([], //border(0,0,3,rgb(0,0,0)) | |
| 424 | - map((FormField ff) |-> cell([top],table([nude],[format_form_field(ff)])),fields))])) | |
| 425 | - ], | |
| 426 | - | |
| 427 | - fields_line(fields) then (List(HTML_Cell(HTML_In_Form))) | |
| 428 | - [ | |
| 429 | - cell([left,top,columns(3)], table([nude],[row([], | |
| 430 | - map((FormField ff) |-> cell([top],table([nude],[format_form_field(ff)])),fields))])) | |
| 431 | - ], | |
| 432 | - | |
| 433 | - preview(html_text) then (List(HTML_Cell(HTML_In_Form))) | |
| 434 | - [ | |
| 435 | - cell([top,left,columns(3),background_color(rgb(255,255,255))], | |
| 436 | - table([border(0,8,0,rgb(0,0,0))], | |
| 437 | - [row(cell([left,top,height(200)],literal(html_text)))])) | |
| 438 | - ], | |
| 439 | - | |
| 440 | - submit(action_name,mb_label,button_text,extra_operands) then (List(HTML_Cell(HTML_In_Form))) | |
| 441 | - [ | |
| 442 | - cell([columns(3),right],actioner(same, | |
| 443 | - if mb_label is | |
| 444 | - { | |
| 445 | - failure then same, | |
| 446 | - success(n) then same(n) | |
| 447 | - }, | |
| 448 | - link(button_text), | |
| 449 | - action_name, | |
| 450 | - extra_operands)) | |
| 451 | - ] | |
| 452 | - }). | |
| 453 | - | |
| 454 | - | |
| 455 | - | |
| 456 | -public define HTML_Off_Form | |
| 457 | - generic_form | |
| 458 | - ( | |
| 459 | - String form_name, | |
| 460 | - RGB bg_color, | |
| 461 | - Int32 w, | |
| 462 | - List(FormField) fields | |
| 463 | - ) = | |
| 464 | - table([border(0,0,5,bg_color),percentage_width(100), | |
| 465 | - background_color(bg_color)],[row(cell([h_center], | |
| 466 | - form(form_name,[],table([border(0,2,0,bg_color)], | |
| 467 | - map(format_form_field,fields)))))]). | |
| 468 | - | |
| 469 | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + *Project* The Anubis Project | |
| 5 | + | |
| 6 | + *Title* | |
| 7 | + | |
| 8 | + *Copyright* Copyright (c) Alain Prouté 2005. | |
| 9 | + | |
| 10 | + | |
| 11 | + *Author* Alain Prouté | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + In this file we rationalize the construction of forms. | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | +read CXM_making_a_web_site.anubis | |
| 20 | + | |
| 21 | + | |
| 22 | +public type Mandatory: // used to mark fields as mandatory. | |
| 23 | + mandatory, | |
| 24 | + non_mandatory. | |
| 25 | + | |
| 26 | +public type Width: | |
| 27 | + small, | |
| 28 | + narrow, | |
| 29 | + wide, | |
| 30 | + custom(Int32). | |
| 31 | + | |
| 32 | +public type FormFieldWidth: | |
| 33 | + auto, | |
| 34 | + custom(Int32). | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + Sorts of fields that you can put in a form: | |
| 39 | + | |
| 40 | +public type FormField: | |
| 41 | + | |
| 42 | + //--- title field --------------------------------------------------------------------- | |
| 43 | + title (String text), | |
| 44 | + title (Int32 text_size, | |
| 45 | + String text), | |
| 46 | + title_f (List(Text_Option) -> HTML_In_Form), | |
| 47 | + | |
| 48 | + //--- message field ------------------------------------------------------------------- | |
| 49 | + message (Result(String,String) msg), | |
| 50 | + message_f (Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form)), | |
| 51 | + | |
| 52 | + //--- text input field ---------------------------------------------------------------- | |
| 53 | + input (String web_arg_name, | |
| 54 | + String tag, | |
| 55 | + Width width, | |
| 56 | + String init_value, | |
| 57 | + Mandatory mandatory), | |
| 58 | + input (String web_arg_name, | |
| 59 | + Width width, | |
| 60 | + String init_value), | |
| 61 | + input_f (String web_arg_name, | |
| 62 | + List(Text_Option) -> HTML_In_Form tag, | |
| 63 | + Width width, | |
| 64 | + String init_value, | |
| 65 | + Mandatory mandatory), | |
| 66 | + | |
| 67 | + //--- password input field ------------------------------------------------------------ | |
| 68 | + password_input (String web_arg_name, | |
| 69 | + String tag, | |
| 70 | + Mandatory mandatory), | |
| 71 | + password_input_f (String web_arg_name, | |
| 72 | + List(Text_Option) -> HTML_In_Form tag, | |
| 73 | + Mandatory mandatory), | |
| 74 | + | |
| 75 | + //--- explanation field --------------------------------------------------------------- | |
| 76 | + explain (String text), | |
| 77 | + explain (String text, | |
| 78 | + FormFieldWidth width), | |
| 79 | + explain_f (List(Text_Option) -> HTML_In_Form), | |
| 80 | + | |
| 81 | + //--- selector field ------------------------------------------------------------------ | |
| 82 | + selector (String web_arg_name, | |
| 83 | + String tag, | |
| 84 | + List(String) items, | |
| 85 | + Maybe(String) selected, | |
| 86 | + Mandatory mandatory), | |
| 87 | + selector_f (String web_arg_name, | |
| 88 | + List(Text_Option) -> HTML_In_Form, | |
| 89 | + List(String) items, | |
| 90 | + Maybe(String) selected, | |
| 91 | + Mandatory mandatory), | |
| 92 | + selector_c (String web_arg_name, | |
| 93 | + String tag, | |
| 94 | + List((String,String)) items, | |
| 95 | + Maybe(String) selected, | |
| 96 | + Mandatory mandatory), | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + //--- checkbox field ------------------------------------------------------------------ | |
| 101 | + checkbox (String web_arg_name, | |
| 102 | + String tag, | |
| 103 | + Bool checked, | |
| 104 | + Mandatory mandatory), | |
| 105 | + // the same one, but with the tag on the right of the checkbox | |
| 106 | + checkboxr (String web_arg_name, | |
| 107 | + String tag, | |
| 108 | + Bool checked, | |
| 109 | + Mandatory mandatory), | |
| 110 | + checkbox_f (String web_arg_name, | |
| 111 | + List(Text_Option) -> HTML_In_Form, | |
| 112 | + Bool checked, | |
| 113 | + Mandatory mandatory), | |
| 114 | + | |
| 115 | + //--- radio-button field -------------------------------------------------------------- | |
| 116 | + radio_button (String web_arg_name, | |
| 117 | + String web_arg_value, | |
| 118 | + String tag, | |
| 119 | + Bool checked, | |
| 120 | + Mandatory mandatory), | |
| 121 | + // the same one, but with the tag on the right of the radio_button | |
| 122 | + radio_buttonr (String web_arg_name, | |
| 123 | + String web_arg_value, | |
| 124 | + String tag, | |
| 125 | + Bool checked, | |
| 126 | + Mandatory mandatory), | |
| 127 | + | |
| 128 | + //--- text area field ----------------------------------------------------------------- | |
| 129 | + text_area (String web_arg_name, | |
| 130 | + String initial_text), | |
| 131 | + text_area (String web_arg_name, | |
| 132 | + String tag, | |
| 133 | + String initial_text), | |
| 134 | + text_area (String web_arg_name, | |
| 135 | + String tag, | |
| 136 | + String initial_text, | |
| 137 | + Int32 width, | |
| 138 | + Int32 height), | |
| 139 | + | |
| 140 | + //--- fields table -------------------------------------------------------------------- | |
| 141 | + fields_table (String tag, | |
| 142 | + List(FormField) fields), | |
| 143 | + | |
| 144 | + //--- fields line --------------------------------------------------------------------- | |
| 145 | + fields_line (String tag, | |
| 146 | + List(FormField) fields), | |
| 147 | + fields_line (List(FormField) fields), | |
| 148 | + | |
| 149 | + //--- preview field ------------------------------------------------------------------- | |
| 150 | + preview (String html_text), | |
| 151 | + | |
| 152 | + //--- submit button ------------------------------------------------------------------- | |
| 153 | + submit (String action_name, | |
| 154 | + Maybe(String) label, | |
| 155 | + String button_text, | |
| 156 | + List((String,String)) extra_operands). | |
| 157 | + | |
| 158 | + | |
| 159 | + Convenience functions: | |
| 160 | + | |
| 161 | +public define FormField title(List(Text_Option) -> HTML_In_Form f) = title_f(f). | |
| 162 | +public define FormField | |
| 163 | + message(Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form) f) = message_f(f). | |
| 164 | +public define FormField input(String web_arg_name, | |
| 165 | + List(Text_Option) -> HTML_In_Form tag, | |
| 166 | + Width width, | |
| 167 | + String init_value, | |
| 168 | + Mandatory mandatory) | |
| 169 | + = input_f(web_arg_name,tag,width,init_value,mandatory). | |
| 170 | +public define FormField password_input(String web_arg_name, | |
| 171 | + List(Text_Option) -> HTML_In_Form tag, | |
| 172 | + Mandatory mandatory) | |
| 173 | + = password_input_f(web_arg_name,tag,mandatory). | |
| 174 | +public define FormField explain(List(Text_Option) -> HTML_In_Form f) = explain_f(f). | |
| 175 | +public define FormField selector(String web_arg_name, | |
| 176 | + List(Text_Option) -> HTML_In_Form f, | |
| 177 | + List(String) items, | |
| 178 | + Maybe(String) selected, | |
| 179 | + Mandatory mandatory) | |
| 180 | + = selector_f(web_arg_name,f,items,selected,mandatory). | |
| 181 | +public define FormField checkbox(String web_arg_name, | |
| 182 | + List(Text_Option) -> HTML_In_Form f, | |
| 183 | + Bool checked, | |
| 184 | + Mandatory mandatory) | |
| 185 | + = checkbox_f(web_arg_name,f,checked,mandatory). | |
| 186 | + | |
| 187 | + Make the form itself with: | |
| 188 | + | |
| 189 | +public define HTML_Off_Form | |
| 190 | + generic_form | |
| 191 | + ( | |
| 192 | + String form_name, | |
| 193 | + RGB background_color, | |
| 194 | + Int32 width, | |
| 195 | + List(FormField) fields | |
| 196 | + ). | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + --- That's all for the public part ! -------------------------------------------------- | |
| 201 | + | |
| 202 | + | |
| 203 | +define HTML_Row(HTML_In_Form) | |
| 204 | + format_form_field | |
| 205 | + ( | |
| 206 | + FormField ff | |
| 207 | + ) = | |
| 208 | + with star = (Mandatory m) |-> (HTML_In_Form)text([color(rgb(255,0,0)),size(12)], | |
| 209 | + if m is | |
| 210 | + { | |
| 211 | + mandatory then "*", | |
| 212 | + non_mandatory then "" | |
| 213 | + }), | |
| 214 | + row( | |
| 215 | + if ff is | |
| 216 | + { | |
| 217 | + title(t) then (List(HTML_Cell(HTML_In_Form))) | |
| 218 | + [ | |
| 219 | + cell([columns(3),h_center],text([size(16),bold,color(rgb(0,0,0))],t)) | |
| 220 | + ], | |
| 221 | + | |
| 222 | + title(s,t) then (List(HTML_Cell(HTML_In_Form))) | |
| 223 | + [ | |
| 224 | + cell([columns(3),h_center],text([size(s),bold,color(rgb(0,0,0))],t)) | |
| 225 | + ], | |
| 226 | + | |
| 227 | + title_f(t) then (List(HTML_Cell(HTML_In_Form))) | |
| 228 | + [ | |
| 229 | + cell([columns(3),h_center],t([size(16),bold,color(rgb(0,0,0))])) | |
| 230 | + ], | |
| 231 | + | |
| 232 | + message(r) then (List(HTML_Cell(HTML_In_Form))) if r is | |
| 233 | + { | |
| 234 | + error(msg) then [cell([columns(3),h_center], | |
| 235 | + text([size(10),color(rgb(240,0,0))],msg))] | |
| 236 | + ok(msg) then [cell([columns(3),h_center], | |
| 237 | + text([size(10),color(rgb(0,150,0))],msg))] | |
| 238 | + }, | |
| 239 | + | |
| 240 | + message_f(r) then (List(HTML_Cell(HTML_In_Form))) if r is | |
| 241 | + { | |
| 242 | + error(msg) then [cell([columns(3),h_center], | |
| 243 | + msg([size(10),color(rgb(240,0,0))]))] | |
| 244 | + ok(msg) then [cell([columns(3),h_center], | |
| 245 | + msg([size(10),color(rgb(0,150,0))]))] | |
| 246 | + }, | |
| 247 | + | |
| 248 | + input(wan,tag,w,init,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 249 | + [ | |
| 250 | + cell([right ], text([size(10)],tag)), | |
| 251 | + cell([width(7) ], star(mand)), | |
| 252 | + cell([left ], text_input("","",wan,init,if w is | |
| 253 | + { | |
| 254 | + small then 10, | |
| 255 | + narrow then 30, | |
| 256 | + wide then 70, | |
| 257 | + custom(n) then n | |
| 258 | + })) | |
| 259 | + ], | |
| 260 | + | |
| 261 | + input(wan,w,init) then (List(HTML_Cell(HTML_In_Form))) | |
| 262 | + [ | |
| 263 | + cell([left,columns(3) ], text_input("","",wan,init,if w is | |
| 264 | + { | |
| 265 | + small then 10, | |
| 266 | + narrow then 30, | |
| 267 | + wide then 70, | |
| 268 | + custom(n) then n | |
| 269 | + })) | |
| 270 | + ], | |
| 271 | + | |
| 272 | + input_f(wan,tag,w,init,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 273 | + [ | |
| 274 | + cell([right ], tag([size(10)])), | |
| 275 | + cell([width(7) ], star(mand)), | |
| 276 | + cell([left ], text_input("","",wan,init,if w is | |
| 277 | + { | |
| 278 | + small then 15, | |
| 279 | + narrow then 30, | |
| 280 | + wide then 70, | |
| 281 | + custom(n) then n | |
| 282 | + })) | |
| 283 | + ], | |
| 284 | + | |
| 285 | + password_input(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 286 | + [ | |
| 287 | + cell([right ], text([size(10)],tag)), | |
| 288 | + cell([width(7) ], star(mand)), | |
| 289 | + cell([left ], password_input("","",wan,30)) | |
| 290 | + ], | |
| 291 | + | |
| 292 | + password_input_f(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 293 | + [ | |
| 294 | + cell([right ], tag([size(10)])), | |
| 295 | + cell([width(7) ], star(mand)), | |
| 296 | + cell([left ], password_input("","",wan,30)) | |
| 297 | + ], | |
| 298 | + | |
| 299 | + explain(t) then (List(HTML_Cell(HTML_In_Form))) | |
| 300 | + [ | |
| 301 | + cell([columns(3),h_center], | |
| 302 | + table([nude],[row(cell([width(500)], | |
| 303 | + paragraph([/*justified,*/size(10),color(rgb(0,100,0))],literal(t))))])) | |
| 304 | + ], | |
| 305 | + | |
| 306 | + explain(t,w) then (List(HTML_Cell(HTML_In_Form))) | |
| 307 | + [ | |
| 308 | + cell([columns(3),h_center], | |
| 309 | + table([nude],[row(cell( | |
| 310 | + if w is | |
| 311 | + { | |
| 312 | + auto then [], | |
| 313 | + custom(i) then [width(i)] | |
| 314 | + }, | |
| 315 | + paragraph([/*justified,*/size(10),color(rgb(0,100,0))], literal(t))))])) | |
| 316 | + ], | |
| 317 | + | |
| 318 | + explain_f(t) then (List(HTML_Cell(HTML_In_Form))) | |
| 319 | + [ | |
| 320 | + cell([columns(3),h_center], | |
| 321 | + table([nude],[row(cell([width(500)], | |
| 322 | + t([/*justified,*/size(10),color(rgb(0,100,0))])))])) | |
| 323 | + ], | |
| 324 | + | |
| 325 | + selector(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 326 | + [ | |
| 327 | + cell([right ], text([size(10)],tag)), | |
| 328 | + cell([width(7)], star(mand)), | |
| 329 | + cell([left ], if selected is | |
| 330 | + { | |
| 331 | + failure then selector(wan,1,items) | |
| 332 | + success(sel) then selector(wan,1,items,sel) | |
| 333 | + }) | |
| 334 | + ], | |
| 335 | + | |
| 336 | + selector_f(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 337 | + [ | |
| 338 | + cell([right ], tag([size(10)])), | |
| 339 | + cell([width(7)], star(mand)), | |
| 340 | + cell([left ], if selected is | |
| 341 | + { | |
| 342 | + failure then selector(wan,1,items) | |
| 343 | + success(sel) then selector(wan,1,items,sel) | |
| 344 | + }) | |
| 345 | + ], | |
| 346 | + | |
| 347 | + selector_c(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 348 | + [ | |
| 349 | + cell([right ], text([size(10)],tag)), | |
| 350 | + cell([width(7)], star(mand)), | |
| 351 | + cell([left ], if selected is | |
| 352 | + { | |
| 353 | + failure then selector_c(wan,1,items) | |
| 354 | + success(sel) then selector_c(wan,1,items,sel) | |
| 355 | + }) | |
| 356 | + ], | |
| 357 | + | |
| 358 | + checkbox(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 359 | + [ | |
| 360 | + cell([right ], text([size(10)],tag)), | |
| 361 | + cell([width(7)], star(mand)), | |
| 362 | + cell([left ], check_box("","",wan,checked)) | |
| 363 | + ], | |
| 364 | + | |
| 365 | + checkboxr(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 366 | + [ | |
| 367 | + cell([right ], check_box("","",wan,checked)), | |
| 368 | + cell([width(7)], star(mand)), | |
| 369 | + cell([left ], text([size(10)],tag)) | |
| 370 | + ], | |
| 371 | + | |
| 372 | + checkbox_f(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 373 | + [ | |
| 374 | + cell([right ], tag([size(10)])), | |
| 375 | + cell([width(7)], star(mand)), | |
| 376 | + cell([left ], check_box("","",wan,checked)) | |
| 377 | + ], | |
| 378 | + | |
| 379 | + radio_button(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 380 | + [ | |
| 381 | + cell([right ], text([size(10)],tag)), | |
| 382 | + cell([width(7)], star(mand)), | |
| 383 | + cell([left ], radio_button("","",wan,wav,checked)) | |
| 384 | + ], | |
| 385 | + | |
| 386 | + radio_buttonr(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) | |
| 387 | + [ | |
| 388 | + cell([right ], radio_button("","",wan,wav,checked)), | |
| 389 | + cell([width(7)], star(mand)), | |
| 390 | + cell([left ], text([size(10)],tag)) | |
| 391 | + ], | |
| 392 | + | |
| 393 | + text_area(wan,tx) then (List(HTML_Cell(HTML_In_Form))) | |
| 394 | + [ | |
| 395 | + cell([h_center,columns(3)],text_area([wrap_lines],wan,tx,75,10)) | |
| 396 | + ], | |
| 397 | + | |
| 398 | + text_area(wan,tag,tx) then (List(HTML_Cell(HTML_In_Form))) | |
| 399 | + [ | |
| 400 | + cell([right,top], text([size(10)],tag)), | |
| 401 | + cell([width(7)], text([],"")), | |
| 402 | + cell([h_center],text_area([wrap_lines],wan,tx,75,10)) | |
| 403 | + ], | |
| 404 | + | |
| 405 | + text_area(wan,tag,tx,w,h) then (List(HTML_Cell(HTML_In_Form))) | |
| 406 | + [ | |
| 407 | + cell([right,top], text([size(10)],tag)), | |
| 408 | + cell([width(7)], text([],"")), | |
| 409 | + cell([h_center],text_area([wrap_lines],wan,tx,w,h)) | |
| 410 | + ], | |
| 411 | + | |
| 412 | + fields_table(tag,fields) then (List(HTML_Cell(HTML_In_Form))) | |
| 413 | + [ | |
| 414 | + cell([right,top], text([size(10)],tag)), | |
| 415 | + cell([width(7)], text([],"")), | |
| 416 | + cell([left,top], table([],map((FormField ff) |-> format_form_field(ff),fields))) | |
| 417 | + ], | |
| 418 | + | |
| 419 | + fields_line(tag,fields) then (List(HTML_Cell(HTML_In_Form))) | |
| 420 | + [ | |
| 421 | + cell([right,top], text([size(10)],tag)), | |
| 422 | + cell([width(7)], text([],"")), | |
| 423 | + cell([left,top], table([nude],[row([], //border(0,0,3,rgb(0,0,0)) | |
| 424 | + map((FormField ff) |-> cell([top],table([nude],[format_form_field(ff)])),fields))])) | |
| 425 | + ], | |
| 426 | + | |
| 427 | + fields_line(fields) then (List(HTML_Cell(HTML_In_Form))) | |
| 428 | + [ | |
| 429 | + cell([left,top,columns(3)], table([nude],[row([], | |
| 430 | + map((FormField ff) |-> cell([top],table([nude],[format_form_field(ff)])),fields))])) | |
| 431 | + ], | |
| 432 | + | |
| 433 | + preview(html_text) then (List(HTML_Cell(HTML_In_Form))) | |
| 434 | + [ | |
| 435 | + cell([top,left,columns(3),background_color(rgb(255,255,255))], | |
| 436 | + table([border(0,8,0,rgb(0,0,0))], | |
| 437 | + [row(cell([left,top,height(200)],literal(html_text)))])) | |
| 438 | + ], | |
| 439 | + | |
| 440 | + submit(action_name,mb_label,button_text,extra_operands) then (List(HTML_Cell(HTML_In_Form))) | |
| 441 | + [ | |
| 442 | + cell([columns(3),right],actioner(same, | |
| 443 | + if mb_label is | |
| 444 | + { | |
| 445 | + failure then same, | |
| 446 | + success(n) then same(n) | |
| 447 | + }, | |
| 448 | + link(button_text), | |
| 449 | + action_name, | |
| 450 | + extra_operands)) | |
| 451 | + ] | |
| 452 | + }). | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | +public define HTML_Off_Form | |
| 457 | + generic_form | |
| 458 | + ( | |
| 459 | + String form_name, | |
| 460 | + RGB bg_color, | |
| 461 | + Int32 w, | |
| 462 | + List(FormField) fields | |
| 463 | + ) = | |
| 464 | + table([border(0,0,5,bg_color),percentage_width(100), | |
| 465 | + background_color(bg_color)],[row(cell([h_center], | |
| 466 | + form(form_name,[],table([border(0,2,0,bg_color)], | |
| 467 | + map(format_form_field,fields)))))]). | |
| 468 | + | |
| 469 | + | ... | ... |
calexium_lib/web/CXM_making_a_web_site.anubis
| ... | ... | @@ -644,7 +644,8 @@ public type Text_Option: |
| 644 | 644 | justified, // justified on both sides |
| 645 | 645 | line_through, |
| 646 | 646 | nowrap, |
| 647 | - class(String). //CSS class | |
| 647 | + class(String), //CSS class | |
| 648 | + id(String). | |
| 648 | 649 | |
| 649 | 650 | A list of 'Text_Option' must be given with each text you want to put in your page. |
| 650 | 651 | |
| ... | ... | @@ -863,7 +864,7 @@ public type HTML_In_Form: |
| 863 | 864 | sequence (List(HTML_In_Form) items), |
| 864 | 865 | text (List(Text_Option), String the_text), |
| 865 | 866 | preformated (List(Text_Option), String), |
| 866 | - paragraph (List(Text_Option), String the_text), | |
| 867 | + paragraph (List(Text_Option), HTML_In_Form content), | |
| 867 | 868 | image (String url), |
| 868 | 869 | image (String url, Int32 width, Int32 height), |
| 869 | 870 | table (List(Table_Option), HTML_Header_Row(HTML_In_Form), List(HTML_Row(HTML_In_Form))), |
| ... | ... | @@ -996,7 +997,7 @@ public type HTML_Off_Form: |
| 996 | 997 | sequence (List(HTML_Off_Form) items), |
| 997 | 998 | text (List(Text_Option), String the_text), |
| 998 | 999 | preformated (List(Text_Option), String), |
| 999 | - paragraph (List(Text_Option), String the_text), | |
| 1000 | + paragraph (List(Text_Option), HTML_Off_Form content), | |
| 1000 | 1001 | image (String url), |
| 1001 | 1002 | image (String url, Int32 width, Int32 height), |
| 1002 | 1003 | table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form))), |
| ... | ... | @@ -2218,7 +2219,7 @@ public define One |
| 2218 | 2219 | type HTML_Any($T): |
| 2219 | 2220 | any_text (List(Text_Option), String the_text), |
| 2220 | 2221 | any_preformated (List(Text_Option), String), |
| 2221 | - any_paragraph (List(Text_Option), String the_text), | |
| 2222 | + any_paragraph (List(Text_Option), $T content), | |
| 2222 | 2223 | any_image (String url), |
| 2223 | 2224 | any_image (String url, Int32 width, Int32 height), |
| 2224 | 2225 | any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T))), |
| ... | ... | @@ -3225,7 +3226,8 @@ define String |
| 3225 | 3226 | justified then "text-align:justify", |
| 3226 | 3227 | line_through then "text-decoration:line-through", |
| 3227 | 3228 | nowrap then "white-space:nowrap", |
| 3228 | - class(class_name)then " class=\"" +class_name +"\"" | |
| 3229 | + class(class_name)then " class=\"" +class_name +"\"", | |
| 3230 | + id(id_name) then " id=\"" +id_name +"\"" | |
| 3229 | 3231 | } + if t is [ ] then "" else ("; "+format(t)) |
| 3230 | 3232 | }. |
| 3231 | 3233 | |
| ... | ... | @@ -3406,8 +3408,8 @@ define Printable_tree |
| 3406 | 3408 | any_preformated(opts,s) then |
| 3407 | 3409 | ["<span ", format_text_options(opts), "><pre>",s,"</pre></span>"], |
| 3408 | 3410 | //["<pre>",s,"</pre>"], |
| 3409 | - any_paragraph(opts,t) then | |
| 3410 | - ["<p ", format_text_options(opts), ">",t,"</p>\n"], | |
| 3411 | + any_paragraph(opts,e) then | |
| 3412 | + ["<p ", format_text_options(opts), ">",format_element(e),"</p>\n"], | |
| 3411 | 3413 | any_image(url) then |
| 3412 | 3414 | ["<img alt=\"",url,"\" src=\"",url,"\">"], |
| 3413 | 3415 | any_image(url,w,h) then | ... | ... |