Commit 837d26097599523c5da7aaaa68636d477a8392c2
1 parent
6c7d3b97
add ajax with WEB_session which means the cookie must update to reflect the change
Showing
7 changed files
with
592 additions
and
259 deletions
Show diff stats
web/CXM_form.anubis
| ... | ... | @@ -67,14 +67,14 @@ public type CXM_Form_Field: |
| 67 | 67 | |
| 68 | 68 | //--- text area field ----------------------------------------------------------------- |
| 69 | 69 | text_area( |
| 70 | - List(TextAreaOption) options, | |
| 71 | - HTML_Label label, | |
| 72 | - HTML_Id id, | |
| 73 | - WebArgName web_arg_name, | |
| 74 | - InitialValue init_value, | |
| 75 | - Width width, | |
| 76 | - Int height, | |
| 77 | - Mandatory mandatory | |
| 70 | + List(TextAreaOption) options, | |
| 71 | + HTML_Label label, | |
| 72 | + HTML_Id id, | |
| 73 | + WebArgName web_arg_name, | |
| 74 | + InitialValue init_value, | |
| 75 | + Width width, | |
| 76 | + Int height, | |
| 77 | + Mandatory mandatory | |
| 78 | 78 | ), |
| 79 | 79 | |
| 80 | 80 | //--- password input field ------------------------------------------------------------ |
| ... | ... | @@ -87,6 +87,28 @@ public type CXM_Form_Field: |
| 87 | 87 | Width width, |
| 88 | 88 | Mandatory mandatory), |
| 89 | 89 | |
| 90 | + //--- phone field ------------------------------------------------------------ | |
| 91 | + phone_input( | |
| 92 | + List(CoreAttrs) icon_options, | |
| 93 | + List(CoreAttrs) options, | |
| 94 | + HTML_Label label, | |
| 95 | + HTML_Id id, | |
| 96 | + WebArgName web_arg_name, | |
| 97 | + InitialValue init_value, | |
| 98 | + Width width, | |
| 99 | + Mandatory mandatory), | |
| 100 | + | |
| 101 | + //--- phone field ------------------------------------------------------------ | |
| 102 | + email_input( | |
| 103 | + List(CoreAttrs) icon_options, | |
| 104 | + List(CoreAttrs) options, | |
| 105 | + HTML_Label label, | |
| 106 | + HTML_Id id, | |
| 107 | + WebArgName web_arg_name, | |
| 108 | + InitialValue init_value, | |
| 109 | + Width width, | |
| 110 | + Mandatory mandatory), | |
| 111 | + | |
| 90 | 112 | //--- hidden field ------------------------------------------------------------ |
| 91 | 113 | hidden( |
| 92 | 114 | HTML_Id id, |
| ... | ... | @@ -489,7 +511,19 @@ public define HTML_In_Form |
| 489 | 511 | |
| 490 | 512 | password_input(options, _label, id, name, init, w, mand) then |
| 491 | 513 | password_input([class("in") . options], star(_label, mand), id, name, init, pixels(w)), |
| 492 | - | |
| 514 | + | |
| 515 | + phone_input(icon_options, options, _label, id, wan, default, w, mand) then | |
| 516 | + sequence([ | |
| 517 | + image(icon_options, "/icons/16x16/phone.png", ""), | |
| 518 | + text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)), | |
| 519 | + ]), | |
| 520 | + | |
| 521 | + email_input(icon_options, options, _label, id, wan, default, w, mand) then | |
| 522 | + sequence([ | |
| 523 | + image(icon_options, "/icons/16x16/email_edit.png", ""), | |
| 524 | + text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)), | |
| 525 | + ]) | |
| 526 | + | |
| 493 | 527 | hidden(id, name, init) then |
| 494 | 528 | hidden(id, name, init), |
| 495 | 529 | |
| ... | ... | @@ -707,7 +741,7 @@ public define HTML_In_Form |
| 707 | 741 | )= |
| 708 | 742 | to_HTML_In_Form(fields, [], _class, b_with_label). |
| 709 | 743 | |
| 710 | -public | |
| 744 | + | |
| 711 | 745 | |
| 712 | 746 | public define HTML_Off_Form |
| 713 | 747 | cxm_form | ... | ... |
web/CXM_making_a_web_site.anubis
| ... | ... | @@ -328,6 +328,10 @@ public type WEB_Controller_Result: |
| 328 | 328 | ), |
| 329 | 329 | ajax( |
| 330 | 330 | HTTP_Answer http_answer |
| 331 | + ), | |
| 332 | + ajax( | |
| 333 | + WEB_Session session, //modified session | |
| 334 | + HTTP_Answer http_answer //http answer | |
| 331 | 335 | ) |
| 332 | 336 | . |
| 333 | 337 | |
| ... | ... | @@ -759,30 +763,7 @@ public type HTML_Size: |
| 759 | 763 | percentage(Int). |
| 760 | 764 | |
| 761 | 765 | |
| 762 | -public type Text_Option: | |
| 763 | - size(Int), // size of character font to use | |
| 764 | - font(String), // name of character font to use (such as "helvetica",...) | |
| 765 | - color(RGB), // color to be used for characters | |
| 766 | - italic, | |
| 767 | - oblique, | |
| 768 | - small_capitals, | |
| 769 | - bold, | |
| 770 | - underlined, | |
| 771 | - left_justified, | |
| 772 | - right_justified, | |
| 773 | - justified, // justified on both sides | |
| 774 | - line_through, | |
| 775 | - nowrap, | |
| 776 | - class(String), //CSS class | |
| 777 | - id(String), | |
| 778 | - style(String), | |
| 779 | - title(String), | |
| 780 | - attr(String, String). | |
| 781 | - | |
| 782 | -public define Text_Option | |
| 783 | - tooltip(String s) = title(s). | |
| 784 | - | |
| 785 | - A list of 'Text_Option' must be given with each text you want to put in your page. | |
| 766 | + | |
| 786 | 767 | |
| 787 | 768 | This indicate the way of reading text. |
| 788 | 769 | public type Reading_Way: |
| ... | ... | @@ -882,11 +863,38 @@ public type InputAttrs: |
| 882 | 863 | |
| 883 | 864 | public define InputAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false"). |
| 884 | 865 | |
| 866 | +public type Text_Option: | |
| 867 | + core_attrs(List(CoreAttrs)), | |
| 868 | + size(Int), // size of character font to use | |
| 869 | + font(String), // name of character font to use (such as "helvetica",...) | |
| 870 | + color(RGB), // color to be used for characters | |
| 871 | + italic, | |
| 872 | + oblique, | |
| 873 | + small_capitals, | |
| 874 | + bold, | |
| 875 | + underlined, | |
| 876 | + left_justified, | |
| 877 | + right_justified, | |
| 878 | + justified, // justified on both sides | |
| 879 | + line_through, | |
| 880 | + nowrap, | |
| 881 | + class(String), //CSS class | |
| 882 | + id(String), | |
| 883 | + style(String), | |
| 884 | + title(String), | |
| 885 | + attr(String, String). | |
| 886 | + | |
| 887 | +public define Text_Option | |
| 888 | + tooltip(String s) = title(s). | |
| 889 | + | |
| 890 | + A list of 'Text_Option' must be given with each text you want to put in your page. | |
| 891 | + | |
| 885 | 892 | public define CoreAttrs |
| 886 | 893 | tooltip(String s) = title(s). |
| 887 | 894 | public define InputAttrs |
| 888 | 895 | tooltip(String s) = title(s). |
| 889 | 896 | |
| 897 | + | |
| 890 | 898 | public type I18n: |
| 891 | 899 | lang (String), |
| 892 | 900 | dir (Reading_Way). |
| ... | ... | @@ -1339,9 +1347,9 @@ public type HTML_In_Form: |
| 1339 | 1347 | literal_pt (Printable_tree), |
| 1340 | 1348 | literal (String), |
| 1341 | 1349 | sequence (List(HTML_In_Form) items), |
| 1342 | - text (List(Text_Option), String the_text), | |
| 1350 | + text (List(CoreAttrs), String the_text), | |
| 1343 | 1351 | preformated (List(Text_Option), String), |
| 1344 | - paragraph (List(Text_Option), HTML_In_Form content), | |
| 1352 | + paragraph (List(Text_Option), List(HTML_In_Form) content), | |
| 1345 | 1353 | image (List(CoreAttrs), String url, String alternate), |
| 1346 | 1354 | image (List(CoreAttrs), String url, String alternate, Int width, Int height), |
| 1347 | 1355 | table (List(Table_Option), HTML_Header_Row(HTML_In_Form), List(HTML_Row(HTML_In_Form)), HTML_Footer_Row(HTML_In_Form)), |
| ... | ... | @@ -1374,16 +1382,16 @@ public type HTML_In_Form: |
| 1374 | 1382 | radio_button_r (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, WebArgValue value, Bool checked), |
| 1375 | 1383 | check_box (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, WebArgValue value, Bool checked), |
| 1376 | 1384 | check_box_r (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, WebArgValue value, Bool checked), |
| 1377 | - div (List(CoreAttrs), HTML_In_Form content), | |
| 1385 | + div (List(CoreAttrs), List(HTML_In_Form) content), | |
| 1378 | 1386 | div_empty (List(CoreAttrs)), |
| 1379 | 1387 | hidden (HTML_Id id, WebArgName name, WebArgValue value), |
| 1380 | 1388 | partial (HTML_Partial_Content), |
| 1381 | 1389 | br, |
| 1382 | 1390 | progress (List(CoreAttrs), Int value, Int max), |
| 1383 | - ol (List(CoreAttrs), HTML_In_Form content), | |
| 1384 | - ul (List(CoreAttrs), HTML_In_Form content), | |
| 1385 | - li (List(CoreAttrs), HTML_In_Form content), | |
| 1386 | - button (List(CoreAttrs), HTML_In_Form content), | |
| 1391 | + ol (List(CoreAttrs), List(HTML_In_Form) content), | |
| 1392 | + ul (List(CoreAttrs), List(HTML_In_Form) content), | |
| 1393 | + li (List(CoreAttrs), List(HTML_In_Form) content), | |
| 1394 | + button (List(CoreAttrs), List(HTML_In_Form) content), | |
| 1387 | 1395 | i (List(CoreAttrs), String text), |
| 1388 | 1396 | span (List(CoreAttrs), String text), |
| 1389 | 1397 | hr (List(CoreAttrs)) |
| ... | ... | @@ -1457,13 +1465,13 @@ public define HTML_In_Form |
| 1457 | 1465 | . |
| 1458 | 1466 | |
| 1459 | 1467 | public define HTML_In_Form |
| 1460 | - actioner | |
| 1461 | - ( | |
| 1462 | - Actioner_Connection conn, | |
| 1463 | - Actioner_Target targ, | |
| 1464 | - Actioner_Aspect asp, | |
| 1465 | - ) = | |
| 1466 | - actioner(conn, targ, asp, action_name(""), [], []). | |
| 1468 | + actioner | |
| 1469 | + ( | |
| 1470 | + Actioner_Connection conn, | |
| 1471 | + Actioner_Target targ, | |
| 1472 | + Actioner_Aspect asp, | |
| 1473 | + )= | |
| 1474 | + actioner(conn, targ, asp, action_name(""), [], []). | |
| 1467 | 1475 | |
| 1468 | 1476 | |
| 1469 | 1477 | public define HTML_In_Form |
| ... | ... | @@ -1542,12 +1550,12 @@ public define HTML_In_Form |
| 1542 | 1550 | |
| 1543 | 1551 | |
| 1544 | 1552 | public define HTML_In_Form |
| 1545 | - text | |
| 1546 | - ( | |
| 1547 | - List(Text_Option) lto, | |
| 1548 | - Int i | |
| 1549 | - ) = | |
| 1550 | - text(lto, to_decimal(i)). | |
| 1553 | + text | |
| 1554 | + ( | |
| 1555 | + List(CoreAttrs) l, | |
| 1556 | + Int i | |
| 1557 | + ) = | |
| 1558 | + text(l, to_decimal(i)). | |
| 1551 | 1559 | |
| 1552 | 1560 | public define HTML_In_Form |
| 1553 | 1561 | text |
| ... | ... | @@ -1566,6 +1574,23 @@ public define HTML_In_Form |
| 1566 | 1574 | . |
| 1567 | 1575 | |
| 1568 | 1576 | public define HTML_In_Form |
| 1577 | + div | |
| 1578 | + ( | |
| 1579 | + HTML_In_Form element | |
| 1580 | + )= | |
| 1581 | + div([], [element]) | |
| 1582 | +. | |
| 1583 | + | |
| 1584 | +public define HTML_In_Form | |
| 1585 | + div | |
| 1586 | + ( | |
| 1587 | + List(CoreAttrs) attrs, | |
| 1588 | + HTML_In_Form element | |
| 1589 | + )= | |
| 1590 | + div(attrs, [element]) | |
| 1591 | +. | |
| 1592 | + | |
| 1593 | +public define HTML_In_Form | |
| 1569 | 1594 | span |
| 1570 | 1595 | ( |
| 1571 | 1596 | String s |
| ... | ... | @@ -1613,9 +1638,9 @@ public type HTML_Off_Form: |
| 1613 | 1638 | literal_pt (Printable_tree), |
| 1614 | 1639 | literal (String), |
| 1615 | 1640 | sequence (List(HTML_Off_Form) items), |
| 1616 | - text (List(Text_Option), String the_text), | |
| 1641 | + text (List(CoreAttrs), String the_text), | |
| 1617 | 1642 | preformated (List(Text_Option), String), |
| 1618 | - paragraph (List(Text_Option), HTML_Off_Form content), | |
| 1643 | + paragraph (List(Text_Option), List(HTML_Off_Form) content), | |
| 1619 | 1644 | image (List(CoreAttrs), String url, String alternate), |
| 1620 | 1645 | image (List(CoreAttrs), String url, String alternate, Int width, Int height), |
| 1621 | 1646 | table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form)), HTML_Footer_Row(HTML_Off_Form)), |
| ... | ... | @@ -1638,12 +1663,12 @@ public type HTML_Off_Form: |
| 1638 | 1663 | private_download (String abs_path, String name, String extra_ext, |
| 1639 | 1664 | Maybe((String,List((String,String)))) action), |
| 1640 | 1665 | label (String name), |
| 1641 | - form (HTML_Id form_id, List(CoreAttrs), HTML_In_Form content), | |
| 1666 | + form (HTML_Id form_id, List(CoreAttrs), List(HTML_In_Form) content), | |
| 1642 | 1667 | form (HTML_Id form_id, List(CoreAttrs), |
| 1643 | 1668 | WEB_Action_Name action, List((String,String)) extra_ops, |
| 1644 | - HTML_In_Form content), | |
| 1669 | + List(HTML_In_Form) content), | |
| 1645 | 1670 | in_form (HTML_Id form_id, HTML_In_Form content), |
| 1646 | - div (List(CoreAttrs), HTML_Off_Form content), | |
| 1671 | + div (List(CoreAttrs), List(HTML_Off_Form) content), | |
| 1647 | 1672 | div (List(CoreAttrs), HTML_Partial_Content p_content), |
| 1648 | 1673 | div_empty (List(CoreAttrs)), |
| 1649 | 1674 | iframe (List(CoreAttrs), |
| ... | ... | @@ -1654,10 +1679,10 @@ public type HTML_Off_Form: |
| 1654 | 1679 | partial (HTML_Partial_Content), |
| 1655 | 1680 | br, |
| 1656 | 1681 | progress (List(CoreAttrs), Int value, Int max), |
| 1657 | - ol (List(CoreAttrs), HTML_Off_Form content), | |
| 1658 | - ul (List(CoreAttrs), HTML_Off_Form content), | |
| 1659 | - li (List(CoreAttrs), HTML_Off_Form content), | |
| 1660 | - button (List(CoreAttrs), HTML_Off_Form content), | |
| 1682 | + ol (List(CoreAttrs), List(HTML_Off_Form) content), | |
| 1683 | + ul (List(CoreAttrs), List(HTML_Off_Form) content), | |
| 1684 | + li (List(CoreAttrs), List(HTML_Off_Form) content), | |
| 1685 | + button (List(CoreAttrs), List(HTML_Off_Form) content), | |
| 1661 | 1686 | i (List(CoreAttrs), String text), |
| 1662 | 1687 | span (List(CoreAttrs), String text), |
| 1663 | 1688 | hr (List(CoreAttrs)) |
| ... | ... | @@ -1667,7 +1692,7 @@ public type HTML_Off_Form: |
| 1667 | 1692 | |
| 1668 | 1693 | |
| 1669 | 1694 | public define HTML_Off_Form image(String url) = image([], url, url). |
| 1670 | - | |
| 1695 | +public define HTML_Off_Form image(List(CoreAttrs) attrs, String url) = image(attrs, url, url). | |
| 1671 | 1696 | public define HTML_Off_Form image(String url, Int width, Int height) = image([], url, url, width, height). |
| 1672 | 1697 | |
| 1673 | 1698 | public define HTML_Off_Form |
| ... | ... | @@ -1677,7 +1702,16 @@ public define HTML_Off_Form |
| 1677 | 1702 | List(CoreAttrs) options, |
| 1678 | 1703 | HTML_In_Form content |
| 1679 | 1704 | ) = |
| 1680 | - form(html_Id(form_name), options, content). | |
| 1705 | + form(html_Id(form_name), options, [content]). | |
| 1706 | + | |
| 1707 | +public define HTML_Off_Form | |
| 1708 | + form | |
| 1709 | + ( | |
| 1710 | + String form_name, | |
| 1711 | + List(CoreAttrs) options, | |
| 1712 | + List(HTML_In_Form) contents | |
| 1713 | + ) = | |
| 1714 | + form(html_Id(form_name), options, contents). | |
| 1681 | 1715 | |
| 1682 | 1716 | public define HTML_Off_Form |
| 1683 | 1717 | form |
| ... | ... | @@ -1688,19 +1722,52 @@ public define HTML_Off_Form |
| 1688 | 1722 | List((String,String)) extra_ops, |
| 1689 | 1723 | HTML_In_Form content |
| 1690 | 1724 | ) = |
| 1691 | - form(html_Id(form_name), options, action, extra_ops, content). | |
| 1725 | + form(html_Id(form_name), options, action, extra_ops, [content]). | |
| 1692 | 1726 | |
| 1693 | 1727 | public define HTML_Off_Form |
| 1694 | 1728 | form |
| 1695 | 1729 | ( |
| 1730 | + HTML_Id form_id, | |
| 1731 | + List(CoreAttrs) options, | |
| 1732 | + WEB_Action_Name action, | |
| 1733 | + List((String,String)) extra_ops, | |
| 1734 | + HTML_In_Form content | |
| 1735 | + ) = | |
| 1736 | + form(form_id, options, action, extra_ops, [content]). | |
| 1737 | + | |
| 1738 | +public define HTML_Off_Form | |
| 1739 | + form | |
| 1740 | + ( | |
| 1741 | + String form_name, | |
| 1742 | + List(CoreAttrs) options, | |
| 1743 | + WEB_Action_Name action, | |
| 1744 | + List((String,String)) extra_ops, | |
| 1745 | + List(HTML_In_Form) contents | |
| 1746 | + ) = | |
| 1747 | + form(html_Id(form_name), options, action, extra_ops, contents). | |
| 1748 | + | |
| 1749 | +public define HTML_Off_Form | |
| 1750 | + form | |
| 1751 | + ( | |
| 1696 | 1752 | String form_name, |
| 1697 | 1753 | List(CoreAttrs) options, |
| 1698 | 1754 | String action, |
| 1699 | 1755 | List((String,String)) extra_ops, |
| 1700 | 1756 | HTML_In_Form content |
| 1701 | 1757 | ) = |
| 1702 | - form(html_Id(form_name), options, action_name(action), extra_ops, content). | |
| 1703 | - | |
| 1758 | + form(html_Id(form_name), options, action_name(action), extra_ops, [content]). | |
| 1759 | + | |
| 1760 | +public define HTML_Off_Form | |
| 1761 | + form | |
| 1762 | + ( | |
| 1763 | + String form_name, | |
| 1764 | + List(CoreAttrs) options, | |
| 1765 | + String action, | |
| 1766 | + List((String,String)) extra_ops, | |
| 1767 | + List(HTML_In_Form) contents | |
| 1768 | + ) = | |
| 1769 | + form(html_Id(form_name), options, action_name(action), extra_ops, contents). | |
| 1770 | + | |
| 1704 | 1771 | public define HTML_Off_Form literal(Printable_tree t) = literal_pt(t). |
| 1705 | 1772 | public define HTML_Off_Form fixed_size(HTML_Size width, HTML_Size height, String name_of_HTML_file) |
| 1706 | 1773 | = fixed_size_2(width,height,name_of_HTML_file). |
| ... | ... | @@ -1728,6 +1795,15 @@ public define HTML_Off_Form |
| 1728 | 1795 | actioner(conn,targ,asp,action,extra_ops,[]). |
| 1729 | 1796 | |
| 1730 | 1797 | public define HTML_Off_Form |
| 1798 | + actioner | |
| 1799 | + ( | |
| 1800 | + Actioner_Aspect asp, | |
| 1801 | + WEB_Action_Name action, | |
| 1802 | + List((String,String)) extra_ops | |
| 1803 | + ) = | |
| 1804 | + actioner(same, same, asp, action, extra_ops, []). | |
| 1805 | + | |
| 1806 | +public define HTML_Off_Form | |
| 1731 | 1807 | /* Older call with String as action instead of WEB_Action_Name. |
| 1732 | 1808 | * This function exists only for compatibility with older project. |
| 1733 | 1809 | * Please condiser to use above function instead |
| ... | ... | @@ -1852,13 +1928,13 @@ public define HTML_Off_Form |
| 1852 | 1928 | private_download(abs_path,name,extra_ext,success((action_name,args))). |
| 1853 | 1929 | |
| 1854 | 1930 | public define HTML_Off_Form |
| 1855 | - text | |
| 1856 | - ( | |
| 1857 | - List(Text_Option) lto, | |
| 1858 | - Int i | |
| 1859 | - ) = | |
| 1860 | - text(lto,to_decimal(i)). | |
| 1861 | - | |
| 1931 | + text | |
| 1932 | + ( | |
| 1933 | + List(CoreAttrs) lto, | |
| 1934 | + Int i | |
| 1935 | + )= | |
| 1936 | + text(lto, to_decimal(i)) | |
| 1937 | +. | |
| 1862 | 1938 | |
| 1863 | 1939 | public define HTML_Off_Form |
| 1864 | 1940 | text |
| ... | ... | @@ -1875,9 +1951,133 @@ public define HTML_Off_Form |
| 1875 | 1951 | )= |
| 1876 | 1952 | text([], s) |
| 1877 | 1953 | . |
| 1878 | - | |
| 1879 | 1954 | |
| 1880 | - | |
| 1955 | +public define HTML_Off_Form | |
| 1956 | + div | |
| 1957 | + ( | |
| 1958 | + HTML_Off_Form element | |
| 1959 | + )= | |
| 1960 | + div([], [element]) | |
| 1961 | +. | |
| 1962 | + | |
| 1963 | +public define HTML_Off_Form | |
| 1964 | + div | |
| 1965 | + ( | |
| 1966 | + List(CoreAttrs) attrs, | |
| 1967 | + HTML_Off_Form element | |
| 1968 | + )= | |
| 1969 | + div(attrs, [element]) | |
| 1970 | +. | |
| 1971 | + | |
| 1972 | +public define HTML_Off_Form | |
| 1973 | + div | |
| 1974 | + ( | |
| 1975 | + List(HTML_Off_Form) elements | |
| 1976 | + )= | |
| 1977 | + div([], elements) | |
| 1978 | +. | |
| 1979 | + | |
| 1980 | + | |
| 1981 | +public define HTML_Off_Form | |
| 1982 | + li | |
| 1983 | + ( | |
| 1984 | + List(HTML_Off_Form) elements | |
| 1985 | + )= | |
| 1986 | + li([], elements) | |
| 1987 | +. | |
| 1988 | + | |
| 1989 | +public define HTML_Off_Form | |
| 1990 | + li | |
| 1991 | + ( | |
| 1992 | + List(CoreAttrs) attrs, | |
| 1993 | + HTML_Off_Form element | |
| 1994 | + )= | |
| 1995 | + li(attrs, [element]) | |
| 1996 | +. | |
| 1997 | + | |
| 1998 | +public define HTML_Off_Form | |
| 1999 | + li | |
| 2000 | + ( | |
| 2001 | + HTML_Off_Form element | |
| 2002 | + )= | |
| 2003 | + li([], [element]) | |
| 2004 | +. | |
| 2005 | + | |
| 2006 | +public define HTML_Off_Form | |
| 2007 | + ul | |
| 2008 | + ( | |
| 2009 | + List(HTML_Off_Form) elements | |
| 2010 | + )= | |
| 2011 | + ul([], elements) | |
| 2012 | +. | |
| 2013 | + | |
| 2014 | +public define HTML_Off_Form | |
| 2015 | + ul | |
| 2016 | + ( | |
| 2017 | + List(CoreAttrs) attrs, | |
| 2018 | + HTML_Off_Form element | |
| 2019 | + )= | |
| 2020 | + ul(attrs, [element]) | |
| 2021 | +. | |
| 2022 | + | |
| 2023 | +public define HTML_Off_Form | |
| 2024 | + ul | |
| 2025 | + ( | |
| 2026 | + HTML_Off_Form element | |
| 2027 | + )= | |
| 2028 | + ul([], [element]) | |
| 2029 | +. | |
| 2030 | + | |
| 2031 | +public define HTML_Off_Form | |
| 2032 | + ol | |
| 2033 | + ( | |
| 2034 | + List(HTML_Off_Form) elements | |
| 2035 | + )= | |
| 2036 | + ol([], elements) | |
| 2037 | +. | |
| 2038 | + | |
| 2039 | +public define HTML_Off_Form | |
| 2040 | + ol | |
| 2041 | + ( | |
| 2042 | + List(CoreAttrs) attrs, | |
| 2043 | + HTML_Off_Form element | |
| 2044 | + )= | |
| 2045 | + ol(attrs, [element]) | |
| 2046 | +. | |
| 2047 | + | |
| 2048 | +public define HTML_Off_Form | |
| 2049 | + ol | |
| 2050 | + ( | |
| 2051 | + HTML_Off_Form element | |
| 2052 | + )= | |
| 2053 | + ol([], [element]) | |
| 2054 | +. | |
| 2055 | + | |
| 2056 | +public define HTML_Off_Form | |
| 2057 | + paragraph | |
| 2058 | + ( | |
| 2059 | + List(HTML_Off_Form) elements | |
| 2060 | + )= | |
| 2061 | + paragraph([], elements) | |
| 2062 | +. | |
| 2063 | + | |
| 2064 | +public define HTML_Off_Form | |
| 2065 | + paragraph | |
| 2066 | + ( | |
| 2067 | + List(Text_Option) attrs, | |
| 2068 | + HTML_Off_Form element | |
| 2069 | + )= | |
| 2070 | + paragraph(attrs, [element]) | |
| 2071 | +. | |
| 2072 | + | |
| 2073 | +public define HTML_Off_Form | |
| 2074 | + paragraph | |
| 2075 | + ( | |
| 2076 | + HTML_Off_Form element | |
| 2077 | + )= | |
| 2078 | + paragraph([], [element]) | |
| 2079 | +. | |
| 2080 | + | |
| 1881 | 2081 | public define HTML_Off_Form |
| 1882 | 2082 | span |
| 1883 | 2083 | ( |
| ... | ... | @@ -1906,38 +2106,87 @@ public define HTML_In_Form |
| 1906 | 2106 | hr([]) |
| 1907 | 2107 | . |
| 1908 | 2108 | |
| 2109 | +public define HTML_In_Form | |
| 2110 | + button | |
| 2111 | + ( | |
| 2112 | + List(HTML_In_Form) elements | |
| 2113 | + )= | |
| 2114 | + button([], elements) | |
| 2115 | +. | |
| 2116 | + | |
| 2117 | +public define HTML_In_Form | |
| 2118 | + button | |
| 2119 | + ( | |
| 2120 | + List(CoreAttrs) attrs, | |
| 2121 | + HTML_In_Form element | |
| 2122 | + )= | |
| 2123 | + button(attrs, [element]) | |
| 2124 | +. | |
| 2125 | + | |
| 2126 | +public define HTML_In_Form | |
| 2127 | + button | |
| 2128 | + ( | |
| 2129 | + HTML_In_Form element | |
| 2130 | + )= | |
| 2131 | + button([], [element]) | |
| 2132 | +. | |
| 2133 | + | |
| 2134 | +public define HTML_Off_Form | |
| 2135 | + button | |
| 2136 | + ( | |
| 2137 | + List(HTML_Off_Form) elements | |
| 2138 | + )= | |
| 2139 | + button([], elements) | |
| 2140 | +. | |
| 2141 | + | |
| 2142 | +public define HTML_Off_Form | |
| 2143 | + button | |
| 2144 | + ( | |
| 2145 | + List(CoreAttrs) attrs, | |
| 2146 | + HTML_Off_Form element | |
| 2147 | + )= | |
| 2148 | + button(attrs, [element]) | |
| 2149 | +. | |
| 2150 | + | |
| 2151 | +public define HTML_Off_Form | |
| 2152 | + button | |
| 2153 | + ( | |
| 2154 | + HTML_Off_Form element | |
| 2155 | + )= | |
| 2156 | + button([], [element]) | |
| 2157 | +. | |
| 1909 | 2158 | - Cell a gap between two other cells : |
| 1910 | 2159 | |
| 1911 | 2160 | public define HTML_Cell(HTML_Off_Form) |
| 1912 | - width_gap | |
| 1913 | - ( | |
| 1914 | - Int w | |
| 1915 | - ) = | |
| 1916 | - cell([width(w)],text([],"")). | |
| 2161 | + width_gap | |
| 2162 | + ( | |
| 2163 | + Int w | |
| 2164 | + )= | |
| 2165 | + cell([width(w)], empty). | |
| 1917 | 2166 | |
| 1918 | 2167 | public define HTML_Cell(HTML_In_Form) |
| 1919 | - width_gap | |
| 1920 | - ( | |
| 1921 | - Int w | |
| 1922 | - ) = | |
| 1923 | - cell([width(w)],text([],"")). | |
| 1924 | - | |
| 1925 | - | |
| 2168 | + width_gap | |
| 2169 | + ( | |
| 2170 | + Int w | |
| 2171 | + )= | |
| 2172 | + cell([width(w)],empty) | |
| 2173 | +. | |
| 1926 | 2174 | - Row a gap between two other rows : |
| 1927 | 2175 | |
| 1928 | 2176 | public define HTML_Row(HTML_Off_Form) |
| 1929 | - height_gap | |
| 1930 | - ( | |
| 1931 | - Int h | |
| 1932 | - ) = | |
| 1933 | - row([],[cell([height(h)],text([],""))]). | |
| 2177 | + height_gap | |
| 2178 | + ( | |
| 2179 | + Int h | |
| 2180 | + )= | |
| 2181 | + row([],[cell([height(h)],empty)]). | |
| 1934 | 2182 | |
| 1935 | 2183 | public define HTML_Row(HTML_In_Form) |
| 1936 | - height_gap | |
| 1937 | - ( | |
| 1938 | - Int h | |
| 1939 | - ) = | |
| 1940 | - row([],[cell([height(h)],text([],""))]). | |
| 2184 | + height_gap | |
| 2185 | + ( | |
| 2186 | + Int h | |
| 2187 | + )= | |
| 2188 | + row([],[cell([height(h)],empty)]) | |
| 2189 | +. | |
| 1941 | 2190 | |
| 1942 | 2191 | |
| 1943 | 2192 | Notice that the two types have alternatives in common (same name, same arguments types, |
| ... | ... | @@ -3017,11 +3266,11 @@ define HTTP_Answer |
| 3017 | 3266 | |
| 3018 | 3267 | // content of page |
| 3019 | 3268 | sequence([ |
| 3020 | - text([size(16)], "Anubis Web Server 1.14"), | |
| 3269 | + preformated([size(16)], "Anubis Web Server 1.14"), | |
| 3021 | 3270 | br, |
| 3022 | - text([size(16)],"Error "+to_String(http_status)), | |
| 3271 | + preformated([size(16)],"Error "+to_String(http_status)), | |
| 3023 | 3272 | br, |
| 3024 | - text([], "Internal message :"+message), | |
| 3273 | + preformated([size(14)],"Internal message :"+message), | |
| 3025 | 3274 | br,br, |
| 3026 | 3275 | in_form(html_Id(""),text_area(wan(""), init(dump(_session)), 120, 60)) |
| 3027 | 3276 | ]) |
| ... | ... | @@ -3100,10 +3349,12 @@ define Maybe(WEB_Controller) |
| 3100 | 3349 | )= |
| 3101 | 3350 | if controllers is |
| 3102 | 3351 | { |
| 3103 | - [] then failure, | |
| 3352 | + [] then | |
| 3353 | + println("Can't find controller ["+controller_name+"]"); | |
| 3354 | + failure, | |
| 3104 | 3355 | [h . t] then |
| 3105 | 3356 | if h.name = controller_name then |
| 3106 | - | |
| 3357 | + println("Controller ["+controller_name+"] found"); | |
| 3107 | 3358 | success(h) |
| 3108 | 3359 | else |
| 3109 | 3360 | get_controller(controller_name, t) |
| ... | ... | @@ -3177,6 +3428,8 @@ define (Maybe(WEB_Session), HTTP_Answer) |
| 3177 | 3428 | apply_controller_action(new_controller, controllers, web_session(lang, entries, previous, previous), failure, initial_session), |
| 3178 | 3429 | }, |
| 3179 | 3430 | ajax(answer) then (failure, answer), |
| 3431 | + //ajax with modified session that must be saved | |
| 3432 | + ajax(session, answer) then (success(session), answer), | |
| 3180 | 3433 | } |
| 3181 | 3434 | } |
| 3182 | 3435 | . |
| ... | ... | @@ -3494,9 +3747,9 @@ public define One |
| 3494 | 3747 | parameter $T becomes either 'HTML_Off_Form' or 'HTML_In_Form'. |
| 3495 | 3748 | |
| 3496 | 3749 | type HTML_Any($T): |
| 3497 | - any_text (List(Text_Option), String the_text), | |
| 3750 | + any_text (List(CoreAttrs), String the_text), | |
| 3498 | 3751 | any_preformated (List(Text_Option), String), |
| 3499 | - any_paragraph (List(Text_Option), $T content), | |
| 3752 | + any_paragraph (List(Text_Option), List($T) content), | |
| 3500 | 3753 | any_image (List(CoreAttrs), String url, String alternate), |
| 3501 | 3754 | any_image (List(CoreAttrs), String url, String alternate, Int width, Int height), |
| 3502 | 3755 | any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T)), HTML_Footer_Row($T)), |
| ... | ... | @@ -3519,13 +3772,13 @@ type HTML_Any($T): |
| 3519 | 3772 | any_foreign_link (List(Text_Option), String url, String name), |
| 3520 | 3773 | any_private_download (String abs_path, String name, String extra_ext, |
| 3521 | 3774 | Maybe((String,List((String,String))))), |
| 3522 | - any_div (List(CoreAttrs), $T element), | |
| 3775 | + any_div (List(CoreAttrs), List($T) element), | |
| 3523 | 3776 | any_div_empty (List(CoreAttrs)), |
| 3524 | 3777 | any_coreattrs (List(CoreAttrs)), |
| 3525 | - any_ol (List(CoreAttrs), $T content), | |
| 3526 | - any_ul (List(CoreAttrs), $T content), | |
| 3527 | - any_li (List(CoreAttrs), $T content), | |
| 3528 | - any_button (List(CoreAttrs), $T element), | |
| 3778 | + any_ol (List(CoreAttrs), List($T) content), | |
| 3779 | + any_ul (List(CoreAttrs), List($T) content), | |
| 3780 | + any_li (List(CoreAttrs), List($T) content), | |
| 3781 | + any_button (List(CoreAttrs), List($T) element), | |
| 3529 | 3782 | any_i (List(CoreAttrs), String text), |
| 3530 | 3783 | any_span (List(CoreAttrs), String text), |
| 3531 | 3784 | any_hr (List(CoreAttrs)) |
| ... | ... | @@ -3850,6 +4103,8 @@ define List(Text_Option) |
| 3850 | 4103 | get_text_options(t) |
| 3851 | 4104 | else if h is title(_) then |
| 3852 | 4105 | get_text_options(t) |
| 4106 | + else if h is core_attrs(_) then | |
| 4107 | + get_text_options(t) | |
| 3853 | 4108 | else |
| 3854 | 4109 | [ h . get_text_options(t) ] |
| 3855 | 4110 | |
| ... | ... | @@ -3884,6 +4139,24 @@ define List(CoreAttrs) |
| 3884 | 4139 | get_css_class(t) |
| 3885 | 4140 | } |
| 3886 | 4141 | . |
| 4142 | + | |
| 4143 | + | |
| 4144 | +define List(CoreAttrs) | |
| 4145 | + get_core_attrs | |
| 4146 | + ( | |
| 4147 | + List(Text_Option) l | |
| 4148 | + ) | |
| 4149 | + = | |
| 4150 | + if l is | |
| 4151 | + { | |
| 4152 | + [] then [], | |
| 4153 | + [h . t ] then | |
| 4154 | + if h is core_attrs(attrs) then | |
| 4155 | + attrs + get_core_attrs(t) | |
| 4156 | + else | |
| 4157 | + get_core_attrs(t) | |
| 4158 | + } | |
| 4159 | + . | |
| 3887 | 4160 | |
| 3888 | 4161 | define Printable_tree |
| 3889 | 4162 | format |
| ... | ... | @@ -4065,18 +4338,11 @@ define String |
| 4065 | 4338 | ) |
| 4066 | 4339 | = |
| 4067 | 4340 | with text_options = get_text_options(l), |
| 4068 | - css_classes = get_css_class(l), | |
| 4069 | - if text_options is | |
| 4070 | - { | |
| 4071 | - [] then "", | |
| 4072 | - [_ . _] then " style=\"" + format(text_options) + "\" " | |
| 4073 | - } | |
| 4074 | - + | |
| 4075 | - if css_classes is | |
| 4076 | - { | |
| 4077 | - [] then "", | |
| 4078 | - [_ . _] then format_attrs(css_classes) | |
| 4079 | - }. | |
| 4341 | + core_attrs = get_css_class(l) + get_core_attrs(l), | |
| 4342 | + (if length(text_options)= 0 then "" else " style=\"" + format(text_options) + "\" ") | |
| 4343 | + + | |
| 4344 | + (if length(core_attrs) = 0 then "" else format_attrs(core_attrs)) | |
| 4345 | + . | |
| 4080 | 4346 | |
| 4081 | 4347 | //define String |
| 4082 | 4348 | // _format |
| ... | ... | @@ -4246,11 +4512,20 @@ define Printable_tree |
| 4246 | 4512 | |
| 4247 | 4513 | link(opt, text, mb_name) then |
| 4248 | 4514 | with name_tag = if mb_name is success(n) then " name=\"" + n + "\"" else "", |
| 4249 | - [ | |
| 4250 | - "<a href=\"", url, "\"", format_text_options(opt), name_tag, ">", | |
| 4251 | - text, | |
| 4252 | - "</a>" | |
| 4253 | - ], | |
| 4515 | + with action_name = if action is { | |
| 4516 | + no_action then "" | |
| 4517 | + controller_action(_, an) then an, | |
| 4518 | + action_name(an) then an, | |
| 4519 | + url(_) then "" | |
| 4520 | + }, | |
| 4521 | + if action_name = "" then | |
| 4522 | + ["<a ", format_text_options(opt), name_tag, ">", text, "</a>" ] | |
| 4523 | + else | |
| 4524 | + ["<a href=\"",url,"\"", | |
| 4525 | + format_text_options(opt), name_tag, ">", | |
| 4526 | + text, | |
| 4527 | + "</a>" | |
| 4528 | + ], | |
| 4254 | 4529 | img_link(options, img, alt_text) then |
| 4255 | 4530 | //if action name is empty, format options on image because maybe there onclick action |
| 4256 | 4531 | with action_name = if action is { |
| ... | ... | @@ -4627,6 +4902,7 @@ define String |
| 4627 | 4902 | [ ] then "", |
| 4628 | 4903 | [h . t] then if h is |
| 4629 | 4904 | { |
| 4905 | + core_attrs(core_attr_list) then format_attrs(core_attr_list), | |
| 4630 | 4906 | size(n) then "font-size:"+n+"pt", |
| 4631 | 4907 | font(fn) then "font-family:"+fn, |
| 4632 | 4908 | color(c) then if c is rgb(r,g,b) then |
| ... | ... | @@ -4871,13 +5147,13 @@ define Printable_tree |
| 4871 | 5147 | if opts is |
| 4872 | 5148 | { |
| 4873 | 5149 | [] then [t], |
| 4874 | - [_ . _] then ["<span", format_text_options(opts), ">",t,"</span>"] | |
| 5150 | + [_ . _] then ["<span", format_attrs(opts), ">",t,"</span>"] | |
| 4875 | 5151 | }, |
| 4876 | 5152 | any_preformated(opts,s) then |
| 4877 | 5153 | ["<span", format_text_options(opts), "><pre>",s,"</pre></span>"], |
| 4878 | 5154 | //["<pre>",s,"</pre>"], |
| 4879 | - any_paragraph(opts,e) then | |
| 4880 | - ["<p", format_text_options(opts), ">",format_element(e),"</p>\n"], | |
| 5155 | + any_paragraph(opts,l) then | |
| 5156 | + ["<p", format_text_options(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</p>\n"], | |
| 4881 | 5157 | any_image(opts, url, _alt) then |
| 4882 | 5158 | with alt = if _alt = "" then "" else "alt=\""+_alt+"\"", |
| 4883 | 5159 | ["<img ",alt," src=\"",url,"\" ", format_attrs(opts)," />"], |
| ... | ... | @@ -4918,20 +5194,20 @@ define Printable_tree |
| 4918 | 5194 | ["<a href=\"",url,"\"><span ", format_text_options(options), ">",name,"</span></a>"], |
| 4919 | 5195 | any_private_download(url,name,extra_ext,action) then |
| 4920 | 5196 | format_private_download(cinfo,url,name,extra_ext,action), |
| 4921 | - any_div(options, e) then | |
| 4922 | - [format_div_option(options), format_element(e),"</div>\n"], | |
| 5197 | + any_div(options, l) then | |
| 5198 | + [format_div_option(options), flat(map(($T e) |-> format_element(e), l)),"</div>\n"], | |
| 4923 | 5199 | any_div_empty(options) then |
| 4924 | 5200 | [format_div_option(options), "</div>\n"], |
| 4925 | 5201 | any_coreattrs(attributs) then |
| 4926 | 5202 | [format_attrs(attributs)], |
| 4927 | - any_ol(opts,e) then | |
| 4928 | - ["<ol", format_attrs(opts), ">",format_element(e),"</ol>\n"], | |
| 4929 | - any_ul(opts,e) then | |
| 4930 | - ["<ul", format_attrs(opts), ">",format_element(e),"</ul>\n"], | |
| 4931 | - any_li(opts,e) then | |
| 4932 | - ["<li", format_attrs(opts), ">",format_element(e),"</li>\n"], | |
| 4933 | - any_button(options, e) then | |
| 4934 | - [["<button" + format_attrs(options) + ">"], format_element(e),"</button>\n"], | |
| 5203 | + any_ol(opts, l) then | |
| 5204 | + ["<ol", format_attrs(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</ol>\n"], | |
| 5205 | + any_ul(opts, l) then | |
| 5206 | + ["<ul", format_attrs(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</ul>\n"], | |
| 5207 | + any_li(opts, l) then | |
| 5208 | + ["<li", format_attrs(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</li>\n"], | |
| 5209 | + any_button(options, l) then | |
| 5210 | + [["<button" + format_attrs(options) + ">"], flat(map(($T e) |-> format_element(e), l)),"</button>\n"], | |
| 4935 | 5211 | any_i(opts,t) then |
| 4936 | 5212 | if t = "" then |
| 4937 | 5213 | ["<i", format_attrs(opts), "></i>\n"] |
| ... | ... | @@ -5188,17 +5464,17 @@ define Printable_tree |
| 5188 | 5464 | |
| 5189 | 5465 | |
| 5190 | 5466 | define Bool |
| 5191 | - contains_an_upload | |
| 5192 | - ( | |
| 5193 | - HTML_In_Form form_content | |
| 5194 | - ). | |
| 5467 | + contains_an_upload | |
| 5468 | + ( | |
| 5469 | + HTML_In_Form form_content | |
| 5470 | + ). | |
| 5195 | 5471 | |
| 5196 | 5472 | define Bool |
| 5197 | - contains_an_upload | |
| 5198 | - ( | |
| 5199 | - HTML_Row(HTML_In_Form) row | |
| 5200 | - ) = | |
| 5201 | - mapor(contains_an_upload, | |
| 5473 | + contains_an_upload | |
| 5474 | + ( | |
| 5475 | + HTML_Row(HTML_In_Form) row | |
| 5476 | + ) = | |
| 5477 | + mapor(contains_an_upload, | |
| 5202 | 5478 | map(content,cells(row))). |
| 5203 | 5479 | |
| 5204 | 5480 | define Bool |
| ... | ... | @@ -5224,10 +5500,10 @@ define Bool |
| 5224 | 5500 | empty then false, |
| 5225 | 5501 | literal_pt(t) then false, |
| 5226 | 5502 | literal(t) then false, |
| 5227 | - sequence(l) then mapor(contains_an_upload,l) | |
| 5503 | + sequence(l) then mapor(contains_an_upload,l), | |
| 5228 | 5504 | text(o,t) then false, |
| 5229 | 5505 | preformated(o,s) then false, |
| 5230 | - paragraph(o,t) then false, | |
| 5506 | + paragraph(o,l) then mapor(contains_an_upload,l), | |
| 5231 | 5507 | image(o,u,a) then false, |
| 5232 | 5508 | image(o,u,a,w,h) then false, |
| 5233 | 5509 | table(o,_,rows,f_row) then if mapor(contains_an_upload,rows) then true |
| ... | ... | @@ -5253,15 +5529,15 @@ define Bool |
| 5253 | 5529 | radio_button_r(o,_,_,n,v,c) then false, |
| 5254 | 5530 | check_box(o,_,_,n,v,c) then false, |
| 5255 | 5531 | check_box_r(o,_,_,n,v,c) then false, |
| 5256 | - div(o,c) then contains_an_upload(c), | |
| 5532 | + div(o,l) then mapor(contains_an_upload,l), //contains_an_upload(c), | |
| 5257 | 5533 | div_empty(o) then false, |
| 5258 | 5534 | hidden(_,_,_) then false, |
| 5259 | 5535 | partial(_) then false, |
| 5260 | 5536 | br then false, |
| 5261 | 5537 | progress(_,_,_) then false, |
| 5262 | - ol(_,_) then false, | |
| 5263 | - ul(_,_) then false, | |
| 5264 | - li(_,_) then false, | |
| 5538 | + ol(_,l) then mapor(contains_an_upload,l), | |
| 5539 | + ul(_,l) then mapor(contains_an_upload,l), | |
| 5540 | + li(_,l) then mapor(contains_an_upload,l), | |
| 5265 | 5541 | button(_,_) then false, |
| 5266 | 5542 | i(_,_) then false, |
| 5267 | 5543 | span(_,_) then false, |
| ... | ... | @@ -5271,12 +5547,14 @@ define Bool |
| 5271 | 5547 | |
| 5272 | 5548 | define String |
| 5273 | 5549 | enctype |
| 5274 | - ( | |
| 5275 | - HTML_In_Form form_content | |
| 5276 | - ) = | |
| 5277 | - if contains_an_upload(form_content) | |
| 5278 | - then " enctype=\"multipart/form-data\"" | |
| 5279 | - else "". | |
| 5550 | + ( | |
| 5551 | + List(HTML_In_Form) form_contents | |
| 5552 | + )= | |
| 5553 | + if mapor(contains_an_upload, form_contents) then | |
| 5554 | + " enctype=\"multipart/form-data\"" | |
| 5555 | + else | |
| 5556 | + "" | |
| 5557 | +. | |
| 5280 | 5558 | |
| 5281 | 5559 | |
| 5282 | 5560 | |
| ... | ... | @@ -5333,29 +5611,29 @@ define Printable_tree |
| 5333 | 5611 | private_download(url,name,extra,action) then |
| 5334 | 5612 | format(cinfo,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags), |
| 5335 | 5613 | label(n) then ["<a name=\"",n,"\">"], |
| 5336 | - form(fn,attributs, c) then | |
| 5614 | + form(fn,attributs, l) then | |
| 5337 | 5615 | [ |
| 5338 | 5616 | "<form id=\"",fn,"\"", |
| 5339 | 5617 | format(cinfo,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags), |
| 5340 | 5618 | " method=\"post\"", |
| 5341 | - enctype(c), | |
| 5619 | + enctype(l), | |
| 5342 | 5620 | " action=\"http", |
| 5343 | 5621 | if is_https then "s" else "", |
| 5344 | 5622 | "://",common_name,":",to_decimal(http_port),"/\">", |
| 5345 | 5623 | // action is set dynamically by |
| 5346 | 5624 | // the actioner using JavaScript |
| 5347 | 5625 | if fn is html_Id(id) then |
| 5348 | - format(cinfo,id,ic_v,c,is_https, action_count, head_tags), | |
| 5626 | + flat(map((HTML_In_Form e) |-> format(cinfo,id,ic_v,e,is_https, action_count, head_tags), l)), | |
| 5349 | 5627 | "</form>" |
| 5350 | 5628 | ] |
| 5351 | - form(fn,attributs, action, extra_ops, c) then | |
| 5629 | + form(fn,attributs, action, extra_ops, l) then | |
| 5352 | 5630 | with url = make_actioner_url(cinfo, same, same, |
| 5353 | 5631 | action, extra_ops, is_https), |
| 5354 | 5632 | [ |
| 5355 | 5633 | "<form id=\"",fn,"\"", |
| 5356 | 5634 | format(cinfo,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags), |
| 5357 | 5635 | " method=\"post\"", |
| 5358 | - enctype(c), | |
| 5636 | + enctype(l), | |
| 5359 | 5637 | " action=\"" + url + "\">", |
| 5360 | 5638 | // " action=\"http", |
| 5361 | 5639 | // if is_https then "s" else "", |
| ... | ... | @@ -5363,7 +5641,7 @@ define Printable_tree |
| 5363 | 5641 | // action is set dynamically by |
| 5364 | 5642 | // the actioner using JavaScript |
| 5365 | 5643 | if fn is html_Id(id) then |
| 5366 | - format(cinfo,id,ic_v,c,is_https, action_count, head_tags), | |
| 5644 | + flat(map((HTML_In_Form e) |-> format(cinfo,id,ic_v,e,is_https, action_count, head_tags),l)), | |
| 5367 | 5645 | "</form>" |
| 5368 | 5646 | ], |
| 5369 | 5647 | in_form(fn, content) then |
| ... | ... | @@ -5374,7 +5652,7 @@ define Printable_tree |
| 5374 | 5652 | div(options, p_content) then |
| 5375 | 5653 | if p_content is partial_content(tags, html_elements) then |
| 5376 | 5654 | head_tags <- *head_tags +tags; |
| 5377 | - format(cinfo, ic_v, any_div(options, html_elements), format_element, is_https, action_count, head_tags), | |
| 5655 | + format(cinfo, ic_v, any_div(options, [html_elements]), format_element, is_https, action_count, head_tags), | |
| 5378 | 5656 | div_empty(options) then |
| 5379 | 5657 | format(cinfo, ic_v, any_div_empty(options), format_element, is_https, action_count, head_tags), |
| 5380 | 5658 | iframe(options, css_styles, css_files, js_files, body) then | ... | ... |
web/CXM_multihost_http_server.anubis
| ... | ... | @@ -1020,17 +1020,6 @@ define Result(Error,String) |
| 1020 | 1020 | else read_string(connection,[c . so_far]) |
| 1021 | 1021 | }. |
| 1022 | 1022 | |
| 1023 | - | |
| 1024 | - | |
| 1025 | - | |
| 1026 | - | |
| 1027 | - | |
| 1028 | - | |
| 1029 | - | |
| 1030 | - | |
| 1031 | - | |
| 1032 | - | |
| 1033 | - | |
| 1034 | 1023 | *** [2.7] Converting web arguments to ASCII. |
| 1035 | 1024 | |
| 1036 | 1025 | The function 'web_to_ascii' gets a character string and replaces web encoding by normal |
| ... | ... | @@ -1044,42 +1033,47 @@ define Result(Error,String) |
| 1044 | 1033 | |
| 1045 | 1034 | |
| 1046 | 1035 | define Word8 |
| 1047 | - web_decode | |
| 1048 | - ( | |
| 1049 | - Word8 x1, | |
| 1050 | - Word8 x2 | |
| 1051 | - ) = | |
| 1052 | - with n1 = if x1 +=< '9' then (x1 - '0') else if x1 +=< 'F' then (x1 - 'A' + 10) else (x1 - 'a' + 10), | |
| 1036 | + web_decode | |
| 1037 | + ( | |
| 1038 | + Word8 x1, | |
| 1039 | + Word8 x2 | |
| 1040 | + ) = | |
| 1041 | + with n1 = if x1 +=< '9' then (x1 - '0') else if x1 +=< 'F' then (x1 - 'A' + 10) else (x1 - 'a' + 10), | |
| 1053 | 1042 | n2 = if x2 +=< '9' then (x2 - '0') else if x2 +=< 'F' then (x2 - 'A' + 10) else (x2 - 'a' + 10), |
| 1054 | 1043 | (n1 << 4) + n2. |
| 1055 | 1044 | |
| 1056 | 1045 | |
| 1057 | 1046 | |
| 1058 | 1047 | define String |
| 1059 | - web_to_ascii | |
| 1060 | - ( | |
| 1061 | - String web_string, | |
| 1062 | - Int n, // current position in web_string | |
| 1063 | - List(Word8) so_far | |
| 1064 | - ) = | |
| 1065 | - if nth(n,web_string) is | |
| 1066 | - { | |
| 1067 | - failure then implode(reverse(so_far)), | |
| 1068 | - success(c) then | |
| 1069 | - if c = '+' | |
| 1070 | - then web_to_ascii(web_string,n+1,[' ' . so_far]) | |
| 1071 | - else if c = '%' | |
| 1072 | - then if nth(n+1,web_string) is | |
| 1073 | - { | |
| 1074 | - failure then implode(reverse(so_far)), | |
| 1075 | - success(x1) then if nth(n+2,web_string) is | |
| 1076 | - { | |
| 1077 | - failure then implode(reverse(so_far)), | |
| 1078 | - success(x2) then web_to_ascii(web_string,n+3,[web_decode(x1,x2) . so_far]) | |
| 1079 | - } | |
| 1080 | - } | |
| 1081 | - else web_to_ascii(web_string,n+1,[c . so_far]) | |
| 1082 | - }. | |
| 1048 | + web_to_ascii | |
| 1049 | + ( | |
| 1050 | + String web_string, | |
| 1051 | + Int n, // current position in web_string | |
| 1052 | + List(Word8) so_far | |
| 1053 | + ) = | |
| 1054 | + if nth(n,web_string) is | |
| 1055 | + { | |
| 1056 | + failure then implode(reverse(so_far)), | |
| 1057 | + success(c) then | |
| 1058 | + if c = '+' then | |
| 1059 | + web_to_ascii(web_string, n+1, [' ' . so_far]) | |
| 1060 | + else if c = '%' then | |
| 1061 | + //println("=== % ==="); | |
| 1062 | + if nth(n+1, web_string) is | |
| 1063 | + { | |
| 1064 | + failure then implode(reverse(so_far)), | |
| 1065 | + success(x1) then | |
| 1066 | + //println("=== % 1 === ["+x1+"]"); | |
| 1067 | + if nth(n+2, web_string) is | |
| 1068 | + { | |
| 1069 | + failure then implode(reverse(so_far)), | |
| 1070 | + success(x2) then | |
| 1071 | + //println("=== % 2 === ["+x2+"]"); | |
| 1072 | + web_to_ascii(web_string,n+3,[web_decode(x1,x2) . so_far]) | |
| 1073 | + } | |
| 1074 | + } | |
| 1075 | + else web_to_ascii(web_string,n+1,[c . so_far]) | |
| 1076 | + }. | |
| 1083 | 1077 | |
| 1084 | 1078 | |
| 1085 | 1079 | |
| ... | ... | @@ -1547,48 +1541,55 @@ define Bool |
| 1547 | 1541 | either the end of the string or the first '&' or '='. |
| 1548 | 1542 | |
| 1549 | 1543 | define String |
| 1550 | - read_name_or_value | |
| 1551 | - ( | |
| 1552 | - String s, | |
| 1553 | - Int start, | |
| 1554 | - Int i | |
| 1555 | - ) = | |
| 1556 | - if nth(i,s) is | |
| 1557 | - { | |
| 1558 | - failure then substr(s,start,i - start), | |
| 1559 | - success(c) then | |
| 1560 | - if is_ampersand_or_equal(c) | |
| 1561 | - then substr(s,start,i-start) // the separator is not included | |
| 1562 | - else read_name_or_value(s,start,i+1) | |
| 1563 | - }. | |
| 1544 | + read_name_or_value | |
| 1545 | + ( | |
| 1546 | + String s, | |
| 1547 | + Int start, | |
| 1548 | + Int i | |
| 1549 | + ) = | |
| 1550 | + if nth(i,s) is | |
| 1551 | + { | |
| 1552 | + failure then substr(s,start,i - start), | |
| 1553 | + success(c) then | |
| 1554 | + if is_ampersand_or_equal(c) then | |
| 1555 | + substr(s, start, i-start) // the separator is not included | |
| 1556 | + else | |
| 1557 | + read_name_or_value(s,start,i+1) | |
| 1558 | + } | |
| 1559 | +. | |
| 1564 | 1560 | |
| 1565 | 1561 | |
| 1566 | 1562 | define List(Web_arg) |
| 1567 | - read_www_url_encoded_web_args | |
| 1568 | - ( | |
| 1569 | - String s, | |
| 1570 | - Int start, | |
| 1571 | - ) = | |
| 1572 | - with first = read_name_or_value(s,start,start), | |
| 1573 | - if first = "" | |
| 1574 | - then [] | |
| 1575 | - else with i = start+length(first), | |
| 1576 | - if nth(i,s) is | |
| 1577 | - { | |
| 1578 | - failure then [web_arg(first,"")], | |
| 1579 | - success(c) then | |
| 1580 | - if c = '&' | |
| 1581 | - then [web_arg(first,"") . read_www_url_encoded_web_args(s,i+1)] | |
| 1582 | - else if c = '=' | |
| 1583 | - then with second1 = read_name_or_value(s,i+1,i+1), | |
| 1584 | - // print("\""+second1+"\"\n"); | |
| 1585 | - with second = web_to_ascii(second1,0,[]), | |
| 1586 | - //println("first ["+first+"] second ["+second+"]"); | |
| 1587 | - with _first = if substr(first,0,4) = "amp;" then substr(first, 4, length(first) - 4) else first, | |
| 1588 | - [web_arg(_first,second) . read_www_url_encoded_web_args(s,i+length(second1)+2)] | |
| 1589 | - else print("**** ALERT **** badly formatted argument [" + s + "]!!!\n"); | |
| 1590 | - [] | |
| 1591 | - }. | |
| 1563 | + read_www_url_encoded_web_args | |
| 1564 | + ( | |
| 1565 | + String s, //url_encoded string | |
| 1566 | + Int start //current position in string | |
| 1567 | + ) = | |
| 1568 | + with first = read_name_or_value(s, start, start), | |
| 1569 | + with name = web_to_ascii(first, 0, []), | |
| 1570 | + if first = "" then | |
| 1571 | + [] | |
| 1572 | + else | |
| 1573 | + with i = start + length(first), //jump to end of first word | |
| 1574 | + if nth(i,s) is | |
| 1575 | + { | |
| 1576 | + failure then [web_arg(name, "")], | |
| 1577 | + success(c) then | |
| 1578 | + if c = '&' then | |
| 1579 | + [web_arg(name, "") . read_www_url_encoded_web_args(s,i+1)] | |
| 1580 | + else if c = '=' then | |
| 1581 | + with second = read_name_or_value(s, i+1, i+1), | |
| 1582 | + // print("\""+second1+"\"\n"); | |
| 1583 | + with value = web_to_ascii(second, 0, []), | |
| 1584 | + //println("first ["+first+"] => name ["+name+"] second ["+second+"] => value ["+value+"]"); | |
| 1585 | + //here check the name starting with amp; which means it was "&" encoded and it must be removed | |
| 1586 | + with _name = if substr(name, 0, 4) = "amp;" then substr(name, 4, length(name) - 4) else name, | |
| 1587 | + [web_arg(_name, value) . read_www_url_encoded_web_args(s, i+length(value)+2)] | |
| 1588 | + else | |
| 1589 | + print("**** ALERT **** badly formatted argument [" + s + "]!!!\n"); | |
| 1590 | + [] | |
| 1591 | + } | |
| 1592 | +. | |
| 1592 | 1593 | |
| 1593 | 1594 | |
| 1594 | 1595 | |
| ... | ... | @@ -1618,9 +1619,9 @@ public define Result(Error, HTTP_RequestLine) |
| 1618 | 1619 | HTTP_BufferedConnection connection |
| 1619 | 1620 | ) = |
| 1620 | 1621 | if read_word(connection) is |
| 1621 | - { | |
| 1622 | - error(msg) then error(msg), | |
| 1623 | - ok(get_or_post) then | |
| 1622 | + { | |
| 1623 | + error(msg) then error(msg), | |
| 1624 | + ok(get_or_post) then | |
| 1624 | 1625 | if read_word(connection) is |
| 1625 | 1626 | { |
| 1626 | 1627 | error(msg) then error(msg), |
| ... | ... | @@ -1630,7 +1631,7 @@ public define Result(Error, HTTP_RequestLine) |
| 1630 | 1631 | ok(http_version) then if read_new_line(connection) is |
| 1631 | 1632 | { |
| 1632 | 1633 | error(msg) then error(msg), |
| 1633 | - ok(_) then if separate_uri_from_query_string(uri_and_query_string,0) is | |
| 1634 | + ok(_) then if separate_uri_from_query_string(uri_and_query_string,0) is | |
| 1634 | 1635 | (uri,query_string) then if identify_get_or_post(get_or_post) is |
| 1635 | 1636 | { |
| 1636 | 1637 | error(msg) then error(msg), | ... | ... |
web/CXM_page_message.anubis
| ... | ... | @@ -141,7 +141,7 @@ public define HTML_In_Form |
| 141 | 141 | String txt, |
| 142 | 142 | Alignment align |
| 143 | 143 | ) = |
| 144 | - div(get_info_line_attrbs(html_class, align), sequence([partial(partial_content(hide_info_line_btn)), partial(partial_content(literal(txt)))])). | |
| 144 | + div(get_info_line_attrbs(html_class, align), [partial(partial_content(hide_info_line_btn)), partial(partial_content(literal(txt)))]). | |
| 145 | 145 | |
| 146 | 146 | public define HTML_Off_Form |
| 147 | 147 | display_info_line | ... | ... |
web/CXM_web_arg_utils.anubis
| ... | ... | @@ -106,6 +106,26 @@ public define String |
| 106 | 106 | success(value) then value |
| 107 | 107 | }. |
| 108 | 108 | |
| 109 | +public define List(String) | |
| 110 | + get_String_list | |
| 111 | + ( | |
| 112 | + List(Web_arg) l, | |
| 113 | + String name | |
| 114 | + ) = | |
| 115 | + if l is | |
| 116 | + { | |
| 117 | + [] then [], | |
| 118 | + [h . t] then | |
| 119 | + if h is web_arg(n, v) then | |
| 120 | + if n = name then | |
| 121 | + [ v . get_String_list(t, name)] | |
| 122 | + else | |
| 123 | + get_String_list(t, name) | |
| 124 | + else | |
| 125 | + get_String_list(t, name) | |
| 126 | + } | |
| 127 | +. | |
| 128 | + | |
| 109 | 129 | public define Maybe(String) |
| 110 | 130 | get_Password |
| 111 | 131 | ( | ... | ... |
web/widgets/button.anubis
| ... | ... | @@ -52,7 +52,7 @@ public define HTML_Partial_Content |
| 52 | 52 | WEB_Action_Name url, |
| 53 | 53 | List((String, String)) extra_ops |
| 54 | 54 | )= |
| 55 | - partial_content(actioner(same, same, img_link(core_attrs+[style("cursor: pointer")], img_path, ""), url, extra_ops)). | |
| 55 | + partial_content(actioner(same, target, img_link(core_attrs+[style("cursor: pointer")], img_path, ""), url, extra_ops)). | |
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | public define HTML_Partial_Content |
| ... | ... | @@ -64,7 +64,7 @@ public define HTML_Partial_Content |
| 64 | 64 | String url, |
| 65 | 65 | List((String, String)) extra_ops |
| 66 | 66 | )= |
| 67 | - partial_content(actioner(same, same, img_link(core_attrs+[style("cursor: pointer")], img_path, ""), action_name(url), extra_ops)). | |
| 67 | + partial_content(actioner(same, target, img_link(core_attrs+[style("cursor: pointer")], img_path, ""), action_name(url), extra_ops)). | |
| 68 | 68 | |
| 69 | 69 | public define HTML_Partial_Content |
| 70 | 70 | img_button | ... | ... |
web/widgets/menu.anubis
| ... | ... | @@ -169,7 +169,7 @@ define List(HTML_Off_Form) |
| 169 | 169 | if is_empty(_sub_menu) then |
| 170 | 170 | empty |
| 171 | 171 | else |
| 172 | - (HTML_Off_Form)ul([class("submenu")], sequence(generate_menu(_T, _sub_menu, [], level+1))) | |
| 172 | + (HTML_Off_Form)ul([class("submenu")], generate_menu(_T, _sub_menu, [], level+1)) | |
| 173 | 173 | ])), |
| 174 | 174 | generate_menu(_T, t, [current_li . so_far], level), |
| 175 | 175 | |
| ... | ... | @@ -179,7 +179,7 @@ define List(HTML_Off_Form) |
| 179 | 179 | with current_li = (HTML_Off_Form)li([],partial(_content)), |
| 180 | 180 | generate_menu(_T, t, [current_li . so_far], level), |
| 181 | 181 | menu_separator then |
| 182 | - with current_li = (HTML_Off_Form)li([],text("--- SEPARATOR ---")), | |
| 182 | + with current_li = (HTML_Off_Form)li([class("cxm_menu_sep")],text("--- SEPARATOR ---")), | |
| 183 | 183 | generate_menu(_T, t, [current_li . so_far], level) |
| 184 | 184 | |
| 185 | 185 | } |
| ... | ... | @@ -209,7 +209,7 @@ define List(HTML_Off_Form) |
| 209 | 209 | String direction |
| 210 | 210 | )= |
| 211 | 211 | [literal("<nav id=\"nav-"+direction+"\" role=\"navigation\">")] + |
| 212 | - [ul([class("menu")], sequence(generate_menu(_T, menu_items, [], 0)))] + | |
| 212 | + [ul([class("menu")], generate_menu(_T, menu_items, [], 0))] + | |
| 213 | 213 | [literal(" <span class=\"menu-collapse\"><i class=\"fa fa-step-backward\" aria-hidden=\"true\"></i></span>"), |
| 214 | 214 | literal("</nav>")]. |
| 215 | 215 | ... | ... |