/usr/lib/falcon/web/htmaker.fal is in libfalcon-engine1 0.9.6.9-git20120606-2.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 | /*
FALCON - The Falcon Programming Language.
Hyper Text Maker - XHTML generator
FILE: htmaker.fal
Main module file
-------------------------------------------------------------------
Author: Giancarlo Niccolai
Begin: Fri, 11 Jun 2010 21:44:23 +0200
-------------------------------------------------------------------
(C) Copyright 2010: the FALCON developers (see list in AUTHORS file)
See LICENSE file for licensing details.
*/
import HTMError from self.htmerror as HTMError
/******************************************************************
Options
******************************************************************/
/*# General module options. */
object HTMaker
/*# Determine if tree inseretions must be checked for DOM consistency.
If this switch is active, every inserted node must respect HTML 4.01
hierarcy constraints.
The check is relatively heavy, and once moving in a production phase,
it's hardly likely that generated trees will change. For those
application that are known to create well-formed XHTML trees, this
option can be turned to false to improve performance.
*/
checkTree = true
end
function _htmlEscape( text )
return text.replace( "&", "&" ).replace( "<", "<" ).replace( ">", ">" ).replace( "\"", """ )
end
/******************************************************************
Base common stuff
******************************************************************/
class AttribsBase()
/*# render the attributes */
function toString()
string = ""
for key, value in self.retrieve()
key = key.replace("_", "-" ).replace("__", ":" ).lower()
// boolean true values are rendered via attrib-name="attrib-name"
// false values are stripped out by removing the key too
if value == true
string += " " + key + "=\""+key+"\""
else
if value.typeId() != StringType: continue
string += " " + key +
"=\"" + value.replace( '"', '"' ).replace( '&', '&' ) +"\""
end
end
return string
end
end
/*# Class managing event related attributes */
class EventAttribs from AttribsBase
/*# Script to be run on a mouse click */
onclick = nil
/*# Script to be run on a mouse double-click */
ondblclick = nil
/*# Script to be run when a document load */
onload = nil
/*# Script to be run when mouse button is pressed */
onmousedown = nil
/*# Script to be run when mouse pointer moves */
onmousemove = nil
/*# Script to be run when mouse pointer moves out of an element */
onmouseout = nil
/*# Script to be run when mouse pointer moves over an element */
onmouseover = nil
/*# Script to be run when mouse button is released */
onmouseup = nil
/*# Script to be run when a key is pressed */
onkeydown = nil
/*# Script to be run when a key is pressed and released */
onkeypress = nil
/*# Script to be run when a key is released */
onkeyup = nil
/*# Script to be run when a document unload */
onunload = nil
end
class I18nAttribs from AttribsBase
/*# Specifies a language code for the content in an element */
lang = nil
/*# Specifies a language code for the content in an element, in XHTML documents */
xml__lang = nil
end
/*# Attributes for all the DomElements */
class CoreAttribs from AttribsBase
/*# Specifies a classname for an element.
Will be rendered as "class"
*/
CLASS = nil
/*# Specifies the text direction for the content in an element */
dir = nil
/*# Specifies a unique id for an element */
id = nil
/*# Specifies a language code for the content in an element */
style = nil
/*# Specifies extra information about an element */
title = nil
end
/*# Utility class exposing all the attributes */
class AllAttribs from CoreAttribs, I18nAttribs, EventAttribs
end
class DomList( parent )
parent = parent
items = []
function empty(): return self.children.len() == 0
function add( item )
if HTMaker.checkTree and item.hname and item.hname != "verbatim"
if self.parent.childTypeList and item.hname notin self.parent.childTypeList
pcls = self.parent.hname
cls = item.hname
raise HTMError( HTMError.parentship,
@i"Parenting element of class \"$(cls)\" in a parent of class \"$(pcls)\"" )
end
end
self.items += item
end
end
object ContentModel
fontstyle = .[ 'tt' 'i' 'b' 'big' 'small' ]
phrase = .[ 'em' 'strong' 'dfn' 'code' 'samp' 'kbd' 'var' 'cite' 'abbr' 'acronym' ]
special = .[ 'a' 'img' 'object' 'br' 'script' 'map' 'q' 'sub' 'sup' 'span' 'bdo' ]
formctrl = .[ 'input' 'select' 'textarea' 'label' 'button' ]
inline = .['text']
inline_pre = nil
inline_a = nil
inline_label = nil
heading = .[ 'h1' 'h2' 'h3' 'h4' 'h5' 'h6' ]
list = .[ 'ol' 'ul' ]
preformatted = .[ 'pre' ]
block = .['p' 'dl' 'div' 'noscript' 'blockquote' 'form' 'hr' 'table' 'fieldset' 'address' ]
block_form = nil
flow = nil
flow_body = nil
flow_object = nil
flow_fieldset = nil
flow_button = nil
listitem = .[ 'li' ]
defitems = .[ 'dd' 'dt' ]
tableitems = .[ 'caption' 'col' 'colgroup' 'thead' 'tfoot' 'tbody' ]
tablerow = .[ 'tr' ]
tablecol = .[ 'col' ]
tablecells = .[ 'th' 'td' ]
head_misc = .[ 'script' 'style' 'meta' 'link' 'object' 'base' ]
options = .[ 'option' 'optgroup' ]
init
self.inline = self.inline + self.fontstyle + self.phrase + self.special + self.formctrl
self.inline_pre = self.inline - .[ 'img' 'object' 'big' 'small' 'sub' 'sup' ]
self.inline_a = self.inline - .[ 'a' ]
self.inline_label = self.inline - .[ 'label' ]
self.block = self.block + self.heading + self.list + self.preformatted
self.block_form = (self.block + .[ 'script' ]) - .[ 'form' ]
self.flow = self.inline + self.block
self.flow_body = self.flow + .['ins' 'del']
self.flow_object = self.flow + .['param']
self.flow_fieldset = self.flow +.[ 'legend' ]
self.flow_button = self.flow - ( .['a' 'form' 'fieldset'] ) - self.formctrl
end
end
/*# Topmost node for XHTML documents.
In rendering, it creates an XHTML compilant document.
*/
class XHTMLFrame( encoding, version )
encoding = encoding ? encoding : "utf-8"
version = version ? version: "1.0"
html = HTML(self)
function render(stream)
if stream == nil: stream = stdOut()
stream.writeText( @'
<?xml version="$(self.version)" encoding="$(self.encoding)"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
')
self.html.render( stream )
end
end
/*# Topmost node for Transitional documents.
In rendering, it creates an HTML 4.01 (Transitional) compilant document.
*/
class TransitionalFrame
html = HTML(self)
function render(stream)
if stream == nil: stream = stdOut()
stream.writeText( '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
')
self.html.render(stream)
end
end
/*# Topmost node for HTML Strict documents.
In rendering, it creates an HTML 4.01 (Strict) compilant document.
*/
class StrictFrame
html = HTML(self)
function render(stream)
if stream == nil: stream = stdOut()
stream.writeText( @'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
')
self.html.render(stream)
end
end
/*# Topmost node for HTML Frameset documents.
In rendering, it creates an HTML 4.01 (Frameset) compilant document.
*/
class FramesetFrame
html = HTML(self)
function render(stream)
if stream == nil: stream = stdOut()
stream.writeText( @'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
')
self.html.render(stream)
end
end
/******************************************************************
* Dom Entities
******************************************************************/
/*# Base dom elements.
The basic dom element has a real parent and 0 or more
restrictions on the parents it could have.
*/
class BaseDom( hname, childTypeList, attribClass )
childTypeList = childTypeList
parent = nil
children = childTypeList ? DomList( self ) : nil
eattr = attribClass != nil ? attribClass() : nil
text = nil
hname = hname
_sepAfter = ""
_sepDecl = ""
function st_makesep( level )
return " " * (level * 3)
end
function render( level, stream )
if not level: level = 1
if not stream: stream = stdOut()
sep = self.st_makesep( level )
stream.writeText( "<" + self.hname )
if self.eattr
sattr = self.eattr.toString()
if sattr: stream.writeText( sattr )
end
// ending ?
if not self.text and not self.children
stream.writeText( "/>" )
if self._sepAfter: stream.writeText(self._sepAfter + sep)
return
end
stream.writeText( ">" )
if self._sepDecl: stream.writeText(self._sepDecl + sep)
if self.text.typeId() == StringType
// normally does not escapes, but oob text can be passed to escape automatically
if ^? self.text
stream.writeText( _htmlEscape( self.text ) )
else
stream.writeText( self.text )
end
end
if self.children
for item in self.children.items
item.render( level + 1, stream )
end
end
stream.writeText( "</" + self.hname + ">" )
if self._sepAfter: stream.writeText( self._sepAfter + sep )
end
function add()
if self.children
for i in [0:paramCount()]
item = parameter(i)
if item.typeId() == StringType
item = ^? item ? Verbatim(item) : Text( item )
elif not item.derivedFrom( BaseDom )
raise HTMError( HTMError.addnodom, self.hname, item.describe(1) )
end
self.children.add( item )
item.parent = self
end
else
raise HTMError( HTMError.nochildren, self.hname )
end
return self
end
/*# Method to set arbitrary attributes.
@param v Either a dictionary used to set the properties or a callable item.
@raise HTMError if the properties in @b v are not found.
@return self
If @b v is a dictioanry, then properties in this item matching the dictionary
kyes are searched and the corresponding values are set.
If @b v is a callable, then it is called with the properties instance as the
first parameter, and self as the second.
Returns the self item so it can be used in chains with other methods.
*/
function set( v )
if v.isCallable()
v( self.eattr, self )
elif v.typeId() == DictionaryType
for key, val in v
if key notin self.eattr
raise HTMError( HTMError.noattrib, key )
end
self.eattr.setProperty( key, val )
end
end
return self
end
/*# Method to set the item ID.
@param value The value of the ID.
@raise HTMError if this entity doesn't expose an ID property.
@return self
Even if not all the XHTML entities expose an ID, most do. This
method is a simple way to set it.
Returns the self item so it can be used in chains with other methods.
*/
function id( value )
if not self.eattr or not self.eattr provides id
raise HTMError( HTMError.noid, self.hname )
end
self.eattr.id = value
return self
end
/*# Method to set the entity class.
@param value The value of the class.
@raise HTMError if this entity doesn't expose a class property.
@return self
Even if not all the XHTML entities expose an class, most do. This
method is a simple way to set it.
Returns the self item so it can be used in chains with other methods.
*/
function CLASS( value )
if not self.eattr or not self.eattr provides CLASS
raise HTMError( HTMError.noclass, self.hname )
end
self.eattr.CLASS = value
return self
end
/*# Method to set the entity style.
@param value The value of the style.
@raise HTMError if this entity doesn't expose a style property.
@return self
Even if not all the XHTML entities expose a style, most do. This
method is a simple way to set it.
Returns the self item so it can be used in chains with other methods.
*/
function style( value )
if not self.eattr or not self.eattr provides style
raise HTMError( HTMError.nostyle, self.hname )
end
self.eattr.style = value
return self
end
/*# Return the stream associated with the frame. */
function getFrame()
p = self.parent
while p provides parent
p = p.parent
end
return p
end
end
class HTML(parent) from BaseDom( "html", nil, I18nAttribs )
/*# Language of this document */
lang = "en"
parent = parent
head = nil
body = nil
function render( stream )
if not stream: stream = stdOut()
if not self.head
self.head = Head().add( Title("") )
end
if not self.body
self.body = Body()
end
if self.parent and self.parent.derivedFrom( XHTMLFrame )
stream.writeText(
@"
<html xmlns=\"http://www.w3.org/1999/xhtml\"
xml:lang=\"$(self.lang)\" lang=\"$(self.lang)\" >\n" )
else
stream.writeText( "<html>\n" )
end
self.head.render(1, stream)
self.body.render(1, stream)
stream.writeText( "</html>\n" )
end
function add()
for i in [0:paramCount()]
item = parameter(i)
select item
case Head
if self.head != nil
raise HTMError( HTMError.headdef )
end
self.head = item
case Body, Frameset
if self.body != nil
raise HTMError( HTMError.bodydef )
end
self.body = item
default
raise HTMError( HTMError.nottoplevel )
end
item.parent = self
end
end
end
/******************************************************************
* Head entities
******************************************************************/
/*#
Attributes used for the @a Head class.
*/
class HeadAttribs from I18nAttribs
/*# Meta-profiles.
This attribute specifies the location of one or more meta data profiles, separated by
white space. For future extensions, user agents should consider the value to be a list
even though this specification only considers the first URI to be significant.
*/
profile = nil
end
/*# Class encapsulating the xhtml header.
If the title text (a string) is given, a Title node is automatically created.
*/
class Head( title ) from BaseDom( "head", ContentModel.head_misc + .['title'], HeadAttribs )
init
if title
self.add( Title( title ) )
end
end
end
/*# Class encapsulating the xhtml header.
If the title text (a string) is given, a Title node is automatically created.
*/
class Title( text ) from BaseDom( "title", nil, I18nAttribs )
hname = "title"
text = text
end
/*# Attributes used for the @a Meta class */
class MetaAttribs from I18nAttribs
/*# HTTP response header name */
http_equiv = nil
/*# Metainformation name */
name = nil
/*# associated information */
content = nil
/*# select form of content */
scheme = nil
end
class Meta( name, content, http_equiv, scheme ) \
from BaseDom( "meta", nil , MetaAttribs )
init
self.eattr.name = name
self.eattr.content = content
self.eattr.http_equiv = http_equiv
self.eattr.scheme = scheme
end
end
/******************************************************************
* Body entities
******************************************************************/
/*# Attributes used for the @a Body class */
class BodyAttribs from AllAttribs
/*# The onload event occurs when the user agent finishes loading a window or
all frames within a FRAMESET. This attribute
may be used with BODY and FRAMESET elements.
*/
onload = nil
/*# The onunload event occurs when the user agent removes a document from a window or frame.
This attribute may be used with BODY and FRAMESET elements.
*/
onunload = nil
end
/*# Body class */
class Body from BaseDom( "body", ContentModel.flow_body , BodyAttribs )
end
class FramesetAttribs from BodyAttribs
rows = nil
cols = nil
end
/*# Frameset class */
class Frameset from BaseDom( "frameset", .['frameset' 'frame' 'noframes'], FramesetAttribs )
end
/******************************************************************
* Boxing tags
******************************************************************/
class FrameAttribs from CoreAttribs
/*# Link to long description (complements title) */
longdesc = nil
/*# name of frame for targetting -- deprecated in XHTML*/
name = nil
/*# source of frame content */
src = nil
/*# request frame borders? Can be 0 or 1 */
frameborder = nil
/*# margin widths in pixels */
marginwidth = nil
/*# margin heights in pixels */
marginheight = nil
/*# allow users to resize frames? -- boolean value */
noresize = false
/*# Should we have the scrollbar? -- "yes", "no" or "auto" */
scrolling = nil
end
class Frame from \
BaseDom( 'frame', ContentModel.flow, FrameAttribs ) // also div and frameset
end
class Noframes from \
BaseDom( "noframes", ContentModel.flow, AllAttribs ) // also div and frameset
end
/******************************************************************
* Text data
******************************************************************/
/*# Class representing a DIV html element.
As "div" blocks are often used to express styles, classes or ids, they are
directly exposed as parameters for user convenience.
*/
class Div( id, CLASS, style ) from BaseDom( "div", ContentModel.flow, AllAttribs ) // also div and frameset
init
self.eattr.id = id
self.eattr.CLASS = CLASS
self.eattr.style = style
end
end
class IFrameAttribs from FrameAttribs
/*# (top|middle|bottom|left|right)" -- center? */
align = nil
end
class IFrame from \
BaseDom( "iframe", ContentModel.flow, IFrameAttribs ) // also div and frameset
end
class ObjectAttribs from AllAttribs
/*# declare but don't instantiate flag. Set to "declare" to enable */
declare = nil
/*# identifies an implementation */
classid = nil
/*# base URI for classid, data, archive */
codebase = nil
/*# reference to object's data */
data = nil
/*# content type for data */
type = nil
/*# content type for code */
codetype = nil
/*# space-separated list of URIs */
archive = nil
/*# message to show while loading */
standby = nil
/*# override height */
height = nil
/*# override width */
width = nil
/*# use client-side image map */
usemap = nil
/*# submit as part of form */
name = nil
/*# position in tabbing order */
tabindex = nil
end
/*# HTML embedding object class. */
class Object from \
BaseDom( "object", ContentModel.flow_object, ObjectAttribs )
end
class ParamAttribs from AttribsBase
/*# document-wide unique id */
id = nil
/*# property name */
name = nil
/*# property value */
value = nil
/*# How to interpret value (can be "data", "ref" or "object")*/
valuetype = nil
/*# content type for value */
type = nil
end
/*# Class representing a single parameter to be sent to an object.
@param name The name of the parameter.
@param value The value of the parameter.
@optparam vtype Valye type (data, ref or object).
@optparam ctype Content-type of the parameter value.
@optparam id The unique entity ID in the document.
*/
class Param( name, value, vtype, ctype, id ) from \
BaseDom( "param", nil, ParamAttribs )
init
self.eattr.name = name
self.eattr.value = value
self.eattr.valuetype = vtype
self.eattr.type = ctype
self.eattr.id = id
end
end
class ImgAttribs from AllAttribs
/*# URI of image to embed */
src = nil
/*# short description */
alt = nil
/*# link to long description */
longdesc = nil
/*# override height */
height = nil
/*# override width */
width = nil
/*# use client-side image map */
usemap = nil
/*# use server-side image map */
ismap = nil
end
/*# Hypertext embedded image. */
class Img( src, width, height, alt, usemap, ismap ) from \
BaseDom( "img", nil, ImgAttribs )
init
self.eattr.src = src ? src : "" // mandatory
self.eattr.width = width
self.eattr.height = height
self.eattr.alt = alt ? alt : "" // mandatory
self.eattr.usemap = usemap
self.eattr.ismap = ismap
end
end
class MapAttribs from AllAttribs
/*# for reference by usemap */
name = nil
end
/*# Image active link map. */
class Map(name) from \
BaseDom( "map", ContentModel.block + .['area'], MapAttribs )
init
self.eattr.name = name
end
end
class AreaAttribs from AllAttribs
/*# controls interpretation of coords */
shape = nil
/*# comma-separated list of lengths */
coords = nil
/*# URI for linked resource */
href = nil
/*# this region has no action */
nohref = nil
/*# short description */
alt = nil
/*# position in tabbing order */
tabindex = nil
/*# accessibility key character */
accesskey = nil
/*# the element got the focus */
onfocus = nil
/*# the element lost the focus */
onblur = nil
end
class Area( href, shape, coords,nohref, alt ) from \
BaseDom( "area", nil, AreaAttribs )
init
self.eattr.href = href
self.eattr.shape = shape
self.eattr.coords = coords
self.eattr.nohref = nohref
self.eattr.alt = alt
end
end
/******************************************************************
* Stylesheets and scripts
******************************************************************/
class EscapingData( name, attr ) from \
BaseDom( name, nil, attr )
function render( level, stream )
sep = self.st_makesep( level )
stream.writeText( sep + "<" + self.hname )
sattr = self.eattr.toString()
if sattr: stream.writeText( sattr )
if not self.text
// empty element -- closing mark is required by many browsers
stream.writeText( "></"+ self.hname + ">\n" )
return
end
item = self
while item and item provides parent
if item.parent.derivedFrom( XHTMLFrame )
use_cdata = true
break
end
item = item.parent
end
// we have a content
// CDATA markers must be at line begin.
if( use_cdata )
stream.writeText( ">\n<![CDATA[\n" + self.text + "\n" +
"]]>\n" + sep +
"</" + self.hname + ">\n")
else
stream.writeText( ">\n" + self.text + sep +
"</" + self.hname + ">\n")
end
end
end
class StyleAttribs from I18nAttribs
/*# content type of style language */
type = nil
/*# designed for use with these media.
(single or comma-separated list of media descriptors)
*/
media = nil
/*# advisory title */
title = nil
end
/*# Creates an embedded style sheet.
The style will be rendered wrapped in an XML CDATA element.
However, XHTML standard suggest not to use this tag and load
the stylesheet via link to other documents, to avoid compatibility
problems with not totally compliant browsers.
If @b type is not given, it will be defaulted to "text/css"
*/
class Style( data, type ) from \
EscapingData( "style", StyleAttribs )
text = data
init
self.eattr.type = type? type : "text/css"
end
end
class ScriptAttribs from AttribsBase
/*# char encoding of linked resource */
charset = nil
/*# content type of script language */
type = nil
/*# URI for an external script */
src = nil
/*# URI for an external script */
defer = nil
end
/*# Creates an embedded script.
The script will be rendered wrapped in an XML CDATA element.
The user should escape any "]]>" on its own before setting the
data.
However, XHTML standard suggest not to use this tag and load
the stylesheet via link to other documents, to avoid compatibility
problems with not totally compliant browsers.
If @b type is not given, it will be defaulted to "text/javascript"
*/
class Script( src, type, data ) from \
EscapingData( "script", ScriptAttribs )
text = data
init
self.eattr.src = src
self.eattr.type = type? type : "text/javascript"
end
end
/*# Node representing the things to do if the browser doesn't support scripts. */
class NoScript from \
BaseDom( "noscript", ContentModel.block, AllAttribs )
end
/******************************************************************
* Text data
******************************************************************/
/*# Class bounding the standard paragraph.
If @b text is specified, an automatic single text node is
added below the item.
*/
class P(text) from \
BaseDom( "p", ContentModel.inline, AllAttribs )
_sepAfter = "\n"
text = text
end
/*# Class bounding pre-formatted text.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Pre(text) from \
BaseDom( "pre", ContentModel.inline_pre, CoreAttribs )
_sepAfter = "\n"
text = text
end
/*# Terminal text node.
This class is meant to store a terminal text (a pure string)
which is directly rendered on the output.
The string is escaped so that html special characters are
correctly rendered.
*/
class Text(text) from \
BaseDom( "text", nil, nil )
text = text
function render( level, stream )
if self.text
stream.writeText( _htmlEscape(self.text) )
end
end
end
/*# Terminal unparsed node.
This class is meant to store a terminal text (a pure string)
which is directly rendered on the output.
The parsed string is included verbatim at required position
and never escaped.
*/
class Verbatim(text) from \
BaseDom( "verbatim", nil, nil )
text = text
function render( level, stream )
if self.text: stream.writeText( self.text )
end
end
class BDOAttribs from CoreAttribs
/*# Language code */
lang = nil
/*# directionality -- can be "ltr" or "rtl" */
dir = nil
end
/*# Class overriding directionality in documents
If @b text is specified, an automatic single text node is
added below the item.
*/
class BDO(text) from \
BaseDom( "bdo", ContentModel.inline, BDOAttribs )
text = text
end
/******************************************************************
* Lists
******************************************************************/
/*# Unordered list. */
class UL from \
BaseDom( "ul", ContentModel.listitem, AllAttribs )
end
/*# Ordered list. */
class OL from \
BaseDom( "ol", ContentModel.listitem, AllAttribs )
end
/*# List item
If @b text is specified, an automatic single text node is
added below the item.
*/
class LI(text) from \
BaseDom( "li", ContentModel.flow, AllAttribs )
_sepAfter = "\n"
text = text
end
/*# Definition list. */
class DL from \
BaseDom( "dl", ContentModel.defitems, AllAttribs )
_sepAfter = "\n"
_sepDecl = "\n"
end
/*# Definition term.
If @b text is specified, an automatic single text node is
added below the item.
*/
class DT(text) from \
BaseDom( "dt", ContentModel.inline, AllAttribs )
_sepAfter = "\n"
text = text
end
/*# Definition data.
If @b text is specified, an automatic single text node is
added below the item.
*/
class DD(text) from \
BaseDom( "dd", ContentModel.flow, AllAttribs )
_sepAfter = "\n"
text = text
end
/******************************************************************
* Tables
******************************************************************/
/*# Definition data.
If @b text is specified, an automatic single text node is
added below the item.
*/
class TableAttribs from AllAttribs
/*# purpose/structure for speech output */
summary = nil
/*# table width */
width = nil
/*# controls frame width around table */
border = nil
/*# which parts of frame to render */
frame = nil
/*# rulings between rows and cols */
rules = nil
/*# spacing between cells */
cellspacing = nil
/*# spacing within cells */
cellpadding = nil
end
/*# Hyper text Table class.
(As opposed to the Falcon language Table class).
*/
class TABLE from \
BaseDom( "table", ContentModel.tableitems, TableAttribs )
_sepAfter = "\n"
_sepDecl = "\n"
end
/*# Caption for the table.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Caption(text) from \
BaseDom( "caption", ContentModel.inline, AllAttribs )
text = text
end
class TElemAttribs from AllAttribs
/*# Cell horizontal aligment (left|center|right|justify|char) */
align = nil
/*# alignment char, e.g. char=':' */
char = nil
/*# offset for alignment char */
charoff = nil
/*# Vertical cell alignment (top|middle|bottom|baseline) */
valign = nil
end
/*# Table heading.
*/
class THead from \
BaseDom( "thead", ContentModel.tablerow, TElemAttribs )
_sepAfter = "\n"
end
/*# Table footer.
*/
class TFoot from \
BaseDom( "tfoot", ContentModel.tablerow, TElemAttribs )
_sepAfter = "\n"
end
/*# Table body.
*/
class TBody from \
BaseDom( "tbody", ContentModel.tablerow, TElemAttribs )
_sepAfter = "\n"
end
class ColAttribs from TElemAttribs
/*# default number of columns in group or size of a column */
span = nil
/*# default width for enclosed COLs or size of the column */
width = nil
end
/*# Group of columns.
Can contain only a list of Col items.
*/
class ColGroup from \
BaseDom( "colgroup", ContentModel.tablecol, ColAttribs )
end
/*# Defines attributes for a single column
Can contain only a list of Col items.
*/
class Col from \
BaseDom( "col", nil, ColAttribs )
end
/*# Group of columns.
Can contain only a list of Col items.
*/
class TR from \
BaseDom( "tr", ContentModel.tablecells, TElemAttribs )
_sepAfter = "\n"
end
class TCellAttribs from TElemAttribs
/*# abbreviation for header cell */
abbr = nil
/*# comma-separated list of related headers */
axis = nil
/*# list of id's for header cells */
headers = nil
/*# scope covered by header cells */
scope = nil
/*# number of rows spanned by cell */
rowspan = nil
/*# number of cols spanned by cell */
colspan = nil
end
/*# Table cell at header position.
If @b text is specified, an automatic single text node is
added below the item.
*/
class TH( text ) from \
BaseDom( "th", ContentModel.flow, TCellAttribs )
text = text
end
/*# Normal table cell.
If @b text is specified, an automatic single text node is
added below the item.
*/
class TD( text ) from \
BaseDom( "td", ContentModel.flow, TCellAttribs )
text = text
end
/******************************************************************
* Anchor
******************************************************************/
class CommonLinkAttribs from AllAttribs
/*# char encoding of linked resource */
charset = nil
/*# advisory content type */
type = nil
/*# named link end */
name = nil
/*# URI for linked resource */
href = nil
/*# language code */
hreflang = nil
/*# forward link types */
rel = nil
/*# reverse link types */
rev = nil
end
class AnchorAttribs from CommonLinkAttribs
/*# accessibility key character */
accesskey = nil
/*# for use with client-side image maps */
shape = nil
/*# for use with client-side image maps */
coords = nil
/*# position in tabbing order */
tabindex = nil
/*# the element got the focus */
onfocus = nil
/*# the element lost the focus */
onblur = nil
end
class LinkAttribs from CommonLinkAttribs
/*# for rendering on these media */
media = nil
end
/*# Anchor.
If @b text is specified, an automatic single text node is
added below the item.
*/
class A( href, text ) from \
BaseDom( "a", ContentModel.inline_a, AnchorAttribs )
text = text
init
self.eattr.href = href
end
end
/*# Document relationship (link).
*/
class Link( href, rel, type ) from \
BaseDom( "link", nil, LinkAttribs )
init
self.eattr.href = href
self.eattr.rel = rel
self.eattr.type = type
end
end
/******************************************************************
* Font/prhase control
******************************************************************/
/*# Base class for all the font and phrase control tags.
@param type The type of node (a valid HTML font/text control inline tag).
@optparam text An optional text to add immediately to this node.
*/
class FontControl( type, text ) from \
BaseDom( type, ContentModel.inline, AllAttribs )
text = text
end
/*# Class generating Typewriter/Tele Type text.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class TT(text) from \
FontControl( "tt", text )
end
/*# Class generating italic text.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class I(text) from \
FontControl( "i", text )
end
/*# Class generating bold text.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class B(text) from \
FontControl( "b", text )
end
/*# Class generating big (uppercase/caps) text.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Big(text) from \
FontControl( "big", text )
end
/*# Class generating small text.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Small(text) from \
FontControl( "small", text )
end
/*# Class generating emphathised phrases.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Em(text) from \
FontControl( "em", text )
end
/*# Class generating stronger phrases.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Strong(text) from FontControl( "strong", text )
end
/*# Class generating definition phrases.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Dfn(text) from \
FontControl( "dfn", text )
end
/*# Class generating a 'code' section.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Code(text) from \
FontControl( "code", text )
end
/*# Class generating a 'sample' section.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Samp(text) from \
FontControl( "samp", text )
end
/*# Class generating a 'text digited on keyboard' section.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Kbd(text) from \
FontControl( "kbd", text )
end
/*# Class generating a 'variable' phrase.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Var(text) from \
FontControl( "var", text )
end
/*# Class generating a citation phrase.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Cite(text) from \
FontControl( "cite", text )
end
/*# Class generating an abbreviation phrase.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Abbr(text) from \
FontControl( "abbr", text )
end
/*# Class indicating an acronym phrase.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Acronym(text) from \
FontControl( "acronym", text )
end
/*# Subscript phrase generator.
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Sub(text) from \
FontControl( "sub", text )
end
/*# Superscript phrase generator
@optparam text An optional text to add immediately to this node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Sup(text) from \
FontControl( "sup", text )
end
/*# Span text.
@optparam text An optional text to add immediately to this node.
Special flexible flex marker.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Span(text) from \
FontControl( "span", text )
end
/******************************************************************
* Quotations
******************************************************************/
class QuotAttribs from AllAttribs
/*# URI for source document or msg */
cite = nil
end
/*# Class used to specify a block quotation. */
class Blockquote from \
BaseDom( "blockquote", ContentModel.block + .['script'], QuotAttribs )
end
/*# Class used to specify a quotation.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Q(text) from \
BaseDom( "q", ContentModel.inline, QuotAttribs )
_sepAfter = "\n"
text = text
end
class InsDelAttribs from AllAttribs
/*# info on reason for change */
cite = nil
/*# date and time of change */
datetime = nil
end
/*# Node for text inserted in a document.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Ins(text) from \
BaseDom( "ins", ContentModel.inline, InsDelAttribs )
text = text
end
/*# Node for text removed from a document.
If @b text is specified, an automatic single text node is
added below the item.
*/
class Del(text) from \
BaseDom( "del", ContentModel.inline, InsDelAttribs )
text = text
end
/******************************************************************
* Headings
******************************************************************/
class Heading( type, text ) from \
BaseDom( type, ContentModel.inline, AllAttribs )
text = text
end
/*# Heading level 1 node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class H1(text) from \
Heading( "h1", text )
end
/*# Heading level 2 node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class H2(text) from \
Heading( "h2", text )
end
/*# Heading level 3 node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class H3(text) from \
Heading( "h3", text )
end
/*# Heading level 4 node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class H4(text) from \
Heading( "h4", text )
end
/*# Heading level 5 node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class H5(text) from \
Heading( "h5", text )
end
/*# Heading level 6 node.
If @b text is specified, an automatic single text node is
added below the item.
*/
class H6(text) from \
Heading( "h6", text )
end
/******************************************************************
* Forms
******************************************************************/
class FormAttribs from AllAttribs
/*# server-side form handler */
action = nil
/*# HTTP method used to submit the form ("get" or "post") */
method = nil
/*# Content type of the document */
enctype = nil
/*# list of MIME types for file upload */
accept = nil
/*# name of form for scripting -- deprecated in xhtml */
name = nil
/*# the form was submitted */
onsubmit = nil
/*# the form was reset */
onreset = nil
/*# list of supported charsets */
accept_charset = nil
end
/*# Creates a form node for data submission and file uploads.
@param action the action where to send the form.
@param method How to send the form ("get" or "post").
*/
class Form( action, method ) from \
BaseDom( "form", ContentModel.block_form, FormAttribs )
method_get = "get"
method_post = "post"
init
self.eattr.action = action
self.eattr.method = method
end
/*# Helper method configuring this object for upload.
@param href The URI that has to be set in the action
This method sets the following attributes of the form tag
so that the form can send files to Falcon remote server-side
scripts receiving the data.
- method = "post"
- enctype = "multipart/form-data"
- accept-charset="utf-8"
This settings are sensible also for generic file uploads.
*/
function forUpload( href )
self.eattr.action = href
self.eattr.method = "post"
self.eattr.enctype = "multipart/form-data"
self.eattr.accept_charset="utf-8"
return self
end
end
class InputAttribs from AllAttribs
/*# what kind of widget is needed.
Can be one of
- text
- password
- checkbox
- radio
- submit
- reset
- file
- hidden
- image
- button
types are declared as properties in the InputType enumeration
*/
type = nil
/*# submit as part of form */
name = nil
/*# Specify for radio buttons and checkboxes */
value = nil
/*# for radio buttons and check boxes (boolean)*/
checked = false
/*# unavailable in this context (boolean) */
disabled = false
/*# for text and passwd (boolean) */
readonly = false
/*# specific to each type of field */
size = nil
/*# max chars for text fields */
maxlength = nil
/*# for fields with images */
src = nil
/*# short description */
alt = nil
/*# use client-side image map */
usemap = nil
/*# use server-side image map */
ismap = nil
/*# position in tabbing order */
tabindex = nil
/*# accessibility key character */
accesskey = nil
/*# the element got the focus */
onfocus = nil
/*# the element lost the focus */
onblur = nil
/*# some text was selected */
onselect = nil
/*# the element value was changed */
onchange = nil
/*# list of MIME types for file upload */
accept = nil
end
enum InputType
text = "text"
password = "password"
checkbox = "checkbox"
radio = "radio"
submit = "submit"
reset = "reset"
file = "file"
hidden = "hidden"
image = "image"
button = "button"
end
/*# Base class for Input items with some common helpers. */
class BaseInput( type, at ) from \
BaseDom( type, nil, at )
/*# Helper method to disable this input.
Return the self object so it's possible to do
@code
s = Form("manage.ftd").add(
Input( "text", "the_field" ).disabled()
)
@endcode
*/
function disabled()
self.eattr.disabled = true
return self
end
/*# Helper method to set this field read-only.
Return the self object so it's possible to do
@code
s = Form("manage.ftd").add(
Input( "text", "the_field" ).readonly()
)
@endcode
*/
function readonly()
self.eattr.readonly = true
return self
end
end
/*# Creates an input, with an optional type.
@param type The type of the input.
@param name The name of the input (mandatory).
@param value The value of the item.
Input @b type should be in the @a InputType enumeration.
If not specified, the type will be set to 'hidden'.
*/
class Input( type, name, value ) from \
BaseInput( "input", InputAttribs )
init
if not type: type = InputType.hidden
self.eattr.name = name
self.eattr.type = type
self.eattr.value = value
end
end
/*# Creates a text input.
@param name The name that will be sent back in the form post.
@param value Initial value for the item.
@param size Width in characters on the screen.
@param maxlength Maximum allowed caracters that can be posted in this field.
*/
class TextInput( name, value, size, maxlength ) from Input( InputType.text, name, value )
init
// force to be a boolean
self.eattr.size = size
self.eattr.maxlength = maxlength
end
end
/*# Creates a masked text input.
@param name The name that will be sent back in the form post.
@param value Initial value for the item.
@param size Width in characters on the screen.
@param maxlength Maximum allowed caracters that can be posted in this field.
*/
class PasswordInput( name, value, size, maxlength ) from Input( InputType.password, name, value )
init
// force to be a boolean
self.eattr.size = size
self.eattr.maxsize = maxlength
end
end
/*# Creates a checkbox input.
@param name The name that will be sent back in the form post.
@param value Initial value for the item.
@param checked True to make this checkbox checked.
*/
class CheckboxInput( name, value, checked ) from Input( InputType.checkbox, name, value )
init
// force to be a boolean
self.eattr.checked = checked ? true : false
end
end
/*# Creates a radio input.
@param name The name that will be sent back in the form post.
@param value Initial value for the item.
@param checked True to make this radio button selected.
All the radio buttons having the same name will be selected
mutually exclusively.
*/
class RadioInput( name, value, checked ) from Input( InputType.radio, name, value )
init
// force to be a boolean
self.eattr.checked = checked ? true : false
end
end
/*# Creates a submit button.
@param name The name that will be sent back in the form post.
@param value Initial value for the item.
@optparam onclick The action to perform on click.
*/
class SubmitInput( name, value, onclick ) from Input( InputType.submit, name, value )
init
self.eattr.onclick = onclick
end
end
/*# Creates a reset button.
@param name The name that will be sent back in the form post.
@param value Initial value for the item.
@optparam onclick The action to perform on click.
*/
class ResetInput( name, value, onclick ) from Input( InputType.reset, name, value )
init
self.eattr.onclick = onclick
end
end
/*# Creates a file input for file upload.
@param name The name that will be sent back in the form post.
@param value Initial value for the item.
*/
class FileInput( name, value ) from Input( InputType.file, name, value )
end
/*# Creates a graphic button.
@param name The name that will be sent back in the form post.
@param value Initial value for the item.
@optparam onclick The action to perform on click.
*/
class ImageInput( name, value, onclick ) from Input( InputType.image, name, value )
init
self.eattr.onclick = onclick
end
end
/*# Creates an hidden input field (for parameter propagation in forms).
@param name The name that will be sent back in the form post.
@param value Initial value for the item.
*/
class HiddenInput( name, value ) from Input( InputType.hidden, name, value )
end
/*# Creates a generic button.
@param name The name that will be sent back in the form post.
@param value Initial value for the item.
@optparam onclick The action to perform on click.
*/
class ButtonInput( name, value, onclick ) from Input( InputType.button, name, value )
init
self.eattr.onclick = onclick
end
end
class SelectAttribs from AllAttribs
/*# Field name */
name = nil
/*# Rows visible */
size = nil
/*# Default is single selection */
multiple = false
/*# Unavailable in this context */
disabled = false
/*# Position in tabbing order */
tabindex = nil
/*# The element got the focus */
onfocus = nil
/*# The element lost the focus */
onblur = nil
/*# The element value was changed */
onchange = nil
end
class Select( name, size, multiple ) from \
BaseDom( "select", ContentModel.options, SelectAttribs )
init
self.eattr.name = name
self.eattr.size = size
self.eattr.multiple = multiple ? true : false
end
end
class OptGroupAttribs from AllAttribs
/*# Unavailable in this context. */
disabled = false
/*# For use in hierarchical menus. */
label = nil
end
/*# Group of otpions represented separated in the @a Select menu.
@param label The text to be displayed at the beginning of the group.
@optparam disabled Set to true to shade the group.
*/
class OptGroup( label, disabled ) from \
BaseDom( "optgroup", ContentModel.options, OptGroupAttribs )
init
self.eattr.label = label
self.eattr.disabled = disabled ? true : false
end
end
class OptionAttribs from AllAttribs
/*# Set to true to pre-select this option */
selected = false
/*# Unavailable in this context */
disabled = false
/*# For use in hierarchical menus */
label = nil
/*# Value that will be returned in the form if selected.
If nil, it defaults to element content.
*/
value = nil
end
/*# Single choice of a @a Select menu.
@param text Text of the component.
@optparam value The value to be sent in the form if selected -- defaults to @b text
@optparam label The text to be displayed in the menu -- defaults to @b text
@optparam selected true to mark this option as selected.
@optparam disabled Set to true to shade the option.
Even if both @b value and @b label are defined, the text element can still be used,
for example to display hints by browsers.
*/
class Option( text, value, label, selected, disabled ) from \
BaseDom( "option", nil, OptionAttribs )
text = text
_sepAfter = "\n"
init
self.eattr.label = label
self.eattr.value = value
if selected: self.eattr.selected = true
if disabled: self.eattr.disabled = true
end
/*# Helper method to set this option on.
Return the self object so it's possible to do
@code
s = Select("the select").add(
Option( "the option" ).selected()
)
@endcode
*/
function selected()
self.eattr.selected = true
return self
end
/*# Helper method to disable this option.
Return the self object so it's possible to do
@code
s = Select("the select").add(
Option( "the option" ).disabled()
)
@endcode
*/
function disabled()
self.eattr.disabled = true
return self
end
end
class TextAreaAttribs from AllAttribs
/*# Name of the field in the form. */
name = nil
/*# Displayed text rows */
rows = nil
/*# Displayed column numbers */
cols = nil
/*# Not available in this context */
disabled = false
/*# Set true to prevent changes */
readonly = false
/*# Position in tabbing order */
tabindex = nil
/*# Accessibility key character */
accesskey = nil
/*# The element got the focus */
onfocus = nil
/*# The element lost the focus */
onblur = nil
/*# Some text was selected */
onselect = nil
/*# The element value was changed */
onchange = nil
end
/*# Class representing a Text area in a form.
@param name The name of the field to be sent in the form.
@optparam text The text to be displayed in the area.
@optparam rows The number of rows for the visualization.
@optparam cols The number of columns for the visualization.
@optparam readonly set to true to make this text area read-only.
@optparam disabled set to true to make this text area grayed out.
*/
class TextArea( name, text, rows, cols, readonly, disabled ) from \
BaseInput( "textarea", TextAreaAttribs )
text = text ? text : ""
init
self.eattr.name = name
self.eattr.rows = rows
self.eattr.cols = cols
if readonly: self.eattr.readonly = true
if disabled: self.eattr.disabled = true
end
end
class LabelAttribs from AllAttribs
/*# matches field ID value (not NAME. It matches ID) */
FOR = nil
/*# the element lost the focus */
accesskey = nil
/*# the element lost the focus */
onfocus = nil
/*# the element lost the focus */
onblur = nil
end
/*# Class representing a Text label in input forms.
@optparam Text some text to be used as the label.
@optparam forid The ID of the target input element.
If @b forid is not given, the label should contain
the target input element.
The Label item can contain any other text
*/
class Label( text, forid ) from \
BaseDom( "label", ContentModel.inline_label, LabelAttribs )
_sepAfter = "\n"
text = text
init
self.eattr.FOR = forid
end
end
/*# Class used to group fields in forms */
class FieldSet from \
BaseDom( "fieldset", ContentModel.flow_fieldset, AllAttribs )
end
class LegendAttribs from AllAttribs
/*# accessibility key character */
accesskey = nil
end
/*# Used to specify a legend for a set of fields.
*/
class Legend(text) from \
BaseDom( "legend", ContentModel.inline, LegendAttribs )
text = text
end
class ButtonAttribs from AllAttribs
/*# Field name for submission. */
name = nil
/*# Sent to server when submitted */
value = nil
/*# For use as form button (button|submit|reset) */
type = nil
/*# Unavailable in this context */
disabled = nil
/*# Position in tabbing order */
tabindex = nil
/*# Accessibility key character */
accesskey = nil
/*# The element got the focus */
onfocus = nil
/*# The element lost the focus */
onblur = nil
end
/*# Used to create a button type container in a form. */
class Button( name, value, onclick, type, disabled ) from \
BaseDom( "button", ContentModel.flow_button, ButtonAttribs )
_sepAfter = "\n"
type_button = "button"
type_submit = "submit"
type_reset = "reset"
init
self.eattr.name = name
self.eattr.value = value
self.eattr.type = type ? type : self.type_button
self.eattr.onclick = onclick
if disabled: self.eattr.disabled = true
end
end
/******************************************************************
* Breaks
******************************************************************/
/*# Line Break
*/
class BR from \
BaseDom( "br", nil, CoreAttribs )
_sepAfter = "\n"
end
/*# Horizontal ruler
*/
class HR from \
BaseDom( "hr", nil, AllAttribs )
_sepAfter = "\n"
end
/******************************************************************
* Special elements
******************************************************************/
/*# Element rendering as the "Valid XHTML 1.0" official mark. */
class ValidXhtmlMark from BaseDom( "p" ) // fake to be a p
function render(level, stream)
stream.writeText( '
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
</p>
' )
end
end
/*# Element rendering as the "Valid HTML 4.01" official mark. */
class ValidHtmlMark from BaseDom( "p" ) // fake to be a p
function render(level, stream)
stream.writeText('
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-html401"
alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>
</p>
' )
end
end
/*# Creates a Falcon script node.
This can be used to create XHTML compliant FTD documents that need
a second-pass parsing server-side.
The data is wrapped in a '<?fal .... ?>' set of tags.
*/
class Falcon( data ) from BaseDom( "" ) // fake to be a i
text = data
function render( level, stream )
stream.write( "<?fal\n" + self.text + "\n?>" )
end
end
/*# Creates a Falcon "print variable" node.
This can be used to create XHTML compliant FTD documents that need
a second-pass parsing server-side.
The data is wrapped in a '<?fal >>.... ?>' set of tags.
*/
class FalconVar( variable ) from BaseDom( "" ) // fake to be a i
text = variable
function render( level, stream )
stream.writeText( "<?fal >> (" + self.text + ") ?>" )
end
end
/*# Includes a document verbatim.
@param fname an URI that can be read by InputStream.
@optparam encoding The text-encoding for the included file. Defaults to C (none -- read/write verbatim).
*/
class Include( fname, encoding ) from BaseDom( "" )
init
file = InputStream( fname )
if encoding: file.setEncoding( encoding )
data = ""
self.text = ""
while not file.eof()
file.readText( data, 4096 )
self.text += data
end
file.close()
end
function render(level, stream)
stream.writeText( self.text )
end
end
/*# Includes a falcon document.
@param fname an URI that can be passed in Falcon.
@optparam encoding The text-encoding for the included file. Defaults to C (none -- read/write verbatim).
*/
class IncludeFalcon( fname, encoding ) from BaseDom( "" )
init
ss = StringStream()
out = stdOut( ss )
try
include( fname, encoding )
self.text = ss.closeToString()
catch in error
end
stdOut(out)
if error: raise error
end
function render(level, stream)
stream.writeText( self.text )
end
end
/* end of htmaker.fal */
|