making_a_web_site.anubis
236 KB
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
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
*Project* Anubis
*Title* Making interactive Web sites.
*Copyright* Copyright (c) Alain Prouté 2004-2005.
Copyright (c) Calexium 2007-2017.
Copyright (c) David René 2007-2021.
*Authors* Alain Prouté
David René
Jérémy Larrieu
Julien Verneuil
*Revised* May 2015
*Overview*
In this file we propose simple tools for making well structured interactive and secured
web sites.
----------------------------------- Table of Contents ---------------------------------
* (1) Structure of a web site.
** (1.1) Three sorts of data.
** (1.2) How requests are handled.
** (1.3) What web pages are made of.
** (1.4) Actions.
** (1.5) States.
* (2) Carrying on.
** (2.1) Describing your web sites.
** (2.2) Directories on the server's disk.
** (2.3) Starting your web sites.
* (3) The HTML interface.
** (3.1) Types used by the HTML interface.
** (3.2) ``in form'' versus ``off form''.
** (3.3) Defining your own style.
** (3.4) Actioners and forms.
** (3.5) Local popup.
---------------------------------------------------------------------------------------
transmit tools/basis.anubis
read tools/printable_tree.anubis
read tools/base64.anubis
read tools/random.anubis
read tools/avlt_dictionaries.anubis
read system/lists.anubis
read system/string.anubis
read system/logger.anubis
transmit xlib/web/common.anubis
transmit xlib/web/multihost_http_server.anubis
read web/mime.anubis
read xlib/web/cookies.anubis
read xlib/web/json.anubis
transmit xlib/web/web_dump.anubis
transmit xlib/web/web_arg_utils.anubis
transmit xlib/web/web_session.anubis
transmit xlib/web/web_action.anubis
transmit xlib/web/types/web_action_name.anubis
transmit xlib/web/types/making_a_web_site.anubis
//TODO move anywhere
define List(Word8)
/** Test for HTML entity which must be encoded
* and return the encoded entity if needed
*/
get_entity
(
Word8 _char,
List(Word8) tail
)=
//test for the ampersand
if _char = '&' then
//test if it's already an encoded string like & < etc. In that case we do nothing
if insensitive_equal(['&','a','m','p',';'], tail, 0) then [_char]
else if insensitive_equal(['&','l','t',';'], tail, 0) then [_char]
else if insensitive_equal(['&','g','t',';'], tail, 0) then [_char]
else if insensitive_equal(['&','q','u','o','t',';'], tail, 0) then [_char]
else
[';','p','m','a','&']
//test for '<' etc.
else if _char = '<' then [';','t','l','&']
else if _char = '>' then [';','t','g','&']
else if _char = '\"' then [';','t','o','u','q','&']
else [_char]
.
define String
_HTML_encode_entities
(
List(Word8) source,
List(Word8) current
)=
if source is
{
[] then implode(reverse(current)),
[c . t] then
_HTML_encode_entities(t, get_entity(c, t) + current)
}
.
public define String
encode_HTML_entities
(
String source
)=
_HTML_encode_entities(explode(source), [])
.
define List(Word8)
/** Test for HTML entity which must be encoded
* and return the encoded entity if needed
*/
get_entity_quote
(
Word8 _char,
List(Word8) tail
)=
//test for the ampersand
if _char = '&' then
//test if it's already an encoded string like & < etc. In that case we do nothing
if insensitive_equal(['&','a','m','p',';'], tail, 0) then [_char]
else if insensitive_equal(['&','l','t',';'], tail, 0) then [_char]
else if insensitive_equal(['&','g','t',';'], tail, 0) then [_char]
else if insensitive_equal(['&','q','u','o','t',';'], tail, 0) then [_char]
else
[';','p','m','a','&']
//test for '"' only.
else if _char = '\"' then [';','t','o','u','q','&']
else [_char]
.
define String
_HTML_encode_quote
(
List(Word8) source,
List(Word8) current
)=
if source is
{
[] then implode(reverse(current)),
[c . t] then
_HTML_encode_quote(t, get_entity_quote(c, t) + current)
}
.
public define String
encode_HTML_quote
(
String source
)=
_HTML_encode_quote(explode(source), [])
.
* (1) Structure of a web site.
First of all we need to explain what a web site should be made of. Ideally, the
visitor (also called the 'client') should see the web site working as any other
interactive computer software. So, it should be clear that a 'session' (i.e. a visit
to the web site, including the consultation of several pages) is some kind of
conversation between the visitor and the web site, and that the web site should
maintain a 'current state' of this conversation. At each new request (click) from the
visitor, this state must be updated. This whole conversation is called a 'session' and
should not be confused with a single request.
** (1.1) Three sorts of data.
All the data needed for putting a web site at work may be dispatched into three
categories:
1. Constant data (data that never change). These data may be hard coded into the
Anubis source files of the web site.
2. Permanent data (data which always exist independantly of the users connected to
the web site). These data are normally recorded into data bases.
3. Session data (data which depend on a particular visitor and which exist only
during the time he visits the web site). These data are stored into so-called
'states'.
It is important to determine which data belongs to which category. This is part of your
design decisions.
** (1.2) How requests are handled.
We want to separate the following two functionalities (which are used at each request
(click) during a single session):
- computing the new state from the previous state and from the client request, and
updating the data base,
- computing the page to be sent to the client from the new current state and from
the informations in the data base.
The next picture shows the structure we have in mind:
request +---------+ HTML page (with state name in cookie)
.-------------------| client |<--------------.
| .-----------------| | |
| | session +---------+ |
| | in cookie |
| | | client side
............................................................................
| | | server side
| | |
| | .-------------------. |
| | | previous session | |
V V V | |
+---------------+ +---------------+ +--------------+
| compute state | | server's disk | | compute page |
+---------------+ +---------------+ +--------------+
^ | | ^ ^ ^ ^ ^
| | | | | | | |
| | `--------------------+--------------------' | |
| | new state | | |
read | `------------------------+--------------------' |
write | new state name |
update V |
+-----------+ |
| data base |--------------------------------------------'
+-----------+ read only
When the client begins a session, there is no previous state. In this case, a default
'initial state' is used instead.
The data base may be updated by 'compute state' box, but should not be update by the
'compute page' box. The 'compute page' box should be allowed only to read the data
base.
In this file, all the above stuff is defined, except the 'compute state' and 'compute
page' boxes. You just have to provide the function for computing a new state (compute
state) and the function for computing the page (compute page) from the new state. You
don't have to worry about state names, saving and retrieving states and the like.
** (1.3) What web pages are made of.
What the client can see in his browser's window may be called a 'page'. Within a page,
we have several sorts of components:
- 'local' components, i.e. all components which do not open a connection, like
texts, images, etc... possibly using JavaScript programmation,
- 'actioners', which, when clicked upon, open a connection with our web site; they
may appear as links or buttons, etc...
- 'foreign links', which when clicked upon, open a connection with another web site
(or ours eventually).
Of course, what an actioner does is just ask our web site to perform an action. To that
end, the actioner essentially sends the name of the action to be performed. However, it
may be necessary to provide additional informations which may be seen as 'operands' of
the action. In order to attach operands to an action, HTML provides the notion of
'form'. Indeed, a form contains essentially a set of input fields into which the client
may put values for the required operands of the action, and a submit button, which is
the actioner itself. Notice that a single form may contain several submit buttons,
which simply means that there are several distincts actions taking the same set of
operands.
Restrictions must be put on the use of all theses gadgets. Indeed, for example,
putting a form within another form is officially meaningless in HTML, and the client's
browser may be seriously disturbed by this. In this file, we propose an interface to
the HTML language, which forbids such meaningless things, simply by imposing a strict
typing of HTML concepts.
Each web site may be accessible through two communication channels:
- a non secured channel (HTTP),
- a secured channel (HTTPS).
Nevertheless, the whole thing should be considered as a single web site. For example,
you may have a secured page, obtained through HTTPS, containing public images obtained
through HTTP. An actioner in a non secured page may open a secured connection, and
conversely.
Summarizing, a web page is made of local elements, foreign links and actioners.
Actioners receive operands from forms, and they also choose to communicate through the
non secured or through the secured channel.
+-------------------+
| page |
| | +---------------+
| +--------------+ | | next page |
| | form | | | (non secured) |
| | +----------+ | | HTTP | |
| | | actioner |---------------------------->| |
| | +----------+ | | +---------------+
| | | |
| | +----------+ | | +---------------+
| | | actioner |---------------------------->| next page |
| | +----------+ | | HTTPS | (secured) |
| | | | | |
| +--------------+ | | |
| | +---------------+
| |
+-------------------+
Notice that actioners need no be necessarily put into forms. In that case, they work as
ordinary links, but they still may receive operands as we shall see.
** (1.4) Actions.
The client opens a new connection with our web site whenever he clicks on an
actioner. The result is that a request is sent, essentially made of a list of 'web
arguments'. Each web argument is a pair (name,value). One of these web arguments, the
'action' web argument (whose name is "a"), determines the action to be performed. The
other web arguments (not including "s", used to identify the state) are the operands
for this action.
Hence, the 'compute state' box in the picture above, splits naturally into as many
sub-boxes as there are actions. For this reason, we define the following type for
representing actions (where '$State' is the type representing session informations):
'http_action's are executed only under HTTP, and 'https_action's are executed only
under HTTPS. 'http_https_action's may be executed under both types of connections.
Each action has a name, which is used to identify the action. Each action also has a
function 'allow' whose job is to verify that the action is allowed in the current
state, and a function 'do_it' for performing the action. The function 'do_it' receives
a lot of informations:
- 'HTTP informations':
- the IP address of the client,
- the URI requested by the client (after redirection),
- the list of HTTP headers generated by the client's browser,
- the list of web arguments sent by the client (except "s" and "a"),
- the previous state (or the 'initial' or 'ticket expired' state if no previous
state can be found).
In most cases, HTTP informations are not used. This is the reason why they are gathered
for simplicity into a unique datum of type 'HTTP_Info'.
When you define your web site, you must provide the list of all the actions of the
site. When a new state has been computed, a graphical representation of this state
must be sent to the client. To that end, you must provide a function (named below
'compute_page') of type:
$State -> HTTP_Answer
where the type 'HTTP_Answer' (defined below in this file) abstractly represents HTML
pages.
//public type HTTP_Answer:...
It should be clear that states and pages are deeply linked together. Indeed, we really
understand the page shown to the client as a representation of the current state of the
conversation between the client and the web site, but also containing informations
taken from the data bases.
//public type HTML_Partial_Content:...
public define List(HTTP_header)
make_session_cookie_headers
(
String website_name,
String session_name
)
=
//println("Set-Cookie state_"+website_name+"="+state_name);
[
http_header("Set-Cookie", "session_"+website_name+"="+session_name+"; SameSite=Strict")
]
.
When a request arrives, we need to retrieve the previous state from the server's
disk. We receive the name of that state. If the state is out of date, the state file is
kept 3 days, and then deleted.
define One
delete_out_of_date_sessions // for all web sites
(
List((String, List(String) -> One)) directories_and_functions
)=
if directories_and_functions is
{
[ ] then unique,
[h . t] then
since h is (state_directory, function),
function(directory_list(state_directory,"*"));
delete_out_of_date_sessions(t)
}
.
** (1.5) States.
Now, we explain how you can define the type (say 'State') to be used as an instance of
the type parameter '$State'. The following is just a suggestion.
Each state determines a page (since 'compute_page' computes a page from a
state). However, some components of the state may be independant of the page. It may be
the case for example for the indication of the natural language used by the
client. Hence, a state should be made of (at least) two parts:
- informations which are the same for all pages,
- informations which are particular to each page.
For example, you could define:
type Page: // one alternative per page, with particular informations
login(...), // in the components
main_page(...),
...etc...
Now, the type 'State' could be defined as follows:
type State:
state(Language, // informations valid for all pages
...,
Page). // informations particular to a page
However, if you are making a secured web site within which clients should be identified
(by id and password), it may be a good idea to have two sorts of states, one for non
identified clients and one for identified clients. In this case, define the type
'State' as follows (this is just a suggestion):
type State:
non_identified(Language),
identified(String id,
Language,
Page).
When a request arrives, check if the previous state is 'identified(...)' or
'non_identified(...)', and don't provide access to certain pages to non identified
clients. This is required for security.
Some more words on security. If your site needs to identify clients, define the
initial state as 'non_identified(...)'. Construct a 'login' page, and check the id and
password of the client. If the id and password are correct, then change the state of
the client to 'identified(...)'. No other action should be able to do that. Now, be
confident that clients cannot forge states. The only information they have is the name
of a state, not the state itself which is never sent over the network, but only stored
on the server's disk. The name of the state is constructed using strong cryptographical
methods (sha1). If everything (since the 'login' page) is performed under HTTPS, even
state names cannot be seen by a third party. So, if the system retrieves a previous
state of the form 'identified(...)', you can be confident that your client is well
identified, and you can send him confidential informations.
States have a limited life time. It may happen that a client clicks on a button at a
time its state is out of date. In this case, this system considers that the new state
is a special state named 'ticket expired'. You must provide a function producing this
state when you describe your web site. The page corresponding to this state must just
inform the client that he/she waited a too long time before clicking on a button, and
has to restart (a new conversation) from the begining.
* (2) Carrying on.
** (2.1) Describing your web sites.
Before you may start your web site, you must describe it, i.e. produce a datum of the
opaque type 'Web_Site'.
public type Web_Site:...
Producing such a datum may be performed by:
public define Web_Site
make_web_site_description
(
List(String) common_names, // for example: ["www.our-business.com",
// "192.168.0.1"]
// the second one is just for testing
String site_directory, // where 'public' and other directories are
// located (should NOT end with '/')
String state_directory,
One -> One init,
(HTTP_Info,
List(Web_arg),
Bool is_https) -> $State initial_state,
($State expired,
Maybe(String),
HTTP_Info,
List(Web_arg),
Bool is_https) -> $State ticket_expired_state,
(Maybe(String),
HTTP_Info,
List(Web_arg),
Bool is_https) -> $State ticket_lost_state,
List(Web_Action($State)) actions,
$State -> HTTP_Answer compute_page,
$State -> List(HTTP_header) additional_headers,
List(HTTP_header) constant_additional_headers,
Int timeout, // seconds (todo: minutes)
Redirections redirections,
String charset,
List(String) journal_extensions,
List(String) journal_headers,
String authorization_secret,
List(MIME) known_mime_types,
(String action_name,
List(Web_arg) args)-> One before_send_file
).
Explanations:
'common_names' is the list of names of the site (the name the browser must send as the
value of the 'Host' HTTP header in order to access the site must be in that list). Such
a name generally looks like this:
www.somewhere.com
If you are using HTTPS, you also have an 'X.509 SSL server certificate'. The name of
the site must be exactly the same as the name on the certificate (which is precisely
called the 'common name' in the X.509 jargon). If the two names do not match, the site
will still work, but the transaction will not be transparent to the client. His browser
will complain that the name of the certificate does not match the name of the site, and
he will have to accept the certificate manually.
'site_directory' is the absolute path to the directory where the files needed by the
site are located. Usually this directory looks like:
my_anubis/web_sites/www.somewhere.com
However, this information is not computed from 'common_name', so that you can change
the common name (for example temporarily, for networking reasons) without loosing
access to the files.
'ticket_expired_state(expired_state,http_info,lwa,is_https)' must produce the state
whose graphical representation is a page explaining to the user that its 'ticket' (or
'session information') has expired, and that he/she must close all popup windows and
start a new session. The arguments of the function contain the previous (expired)
state and all current informations concerning the user. This arguments may be useful
for example for producing the expiration message in the language chosen by the user.
You can also (and this may be much smarter) send a 'ticket prolongation page'
(including a new login for example), and resume the same conversation, since you have
all the pertinent informations at hand. In the case the ticket is definitely lost, the
second fonction 'ticket_lost_state' is used.
Notice that despite the fact that the parameter $State is involved in the arguments of
the above function, the type 'Web_Site' does not depend on this parameter. This allows
to produce lists of web site descriptions, where each description may be constructed
with a different instance of $State. This is required because distinct sites must have
distinct types of session informations. This is made possible by the fact that the
type is obscure, and the constructor replaced by a function which assembles
'ticket_expired_state', ticket_lost_state', 'actions' and 'compute_page' into a single
entity not depending on $State. You should have a look to the private part of this file
if you want more precisions about this programming technique.
'charset' is a string which will determine the character encoding to be used by the
browser. Typically, this string is one of: "UTF-8", "ISO-8859-1", "Windows-1252",
etc...
'before_send_file' is a function which is executed just before the HTTP server sends a
file. It gets an action name and the web arguments received with the request for that
file. Notice that this action name and these web arguments may be put into a
'private_download' element, and will come back to the server at the time of the
download.
** (2.2) Directories on the server's disk.
The description of your site contains the name of the directory within which the
required files are located. This may be for example:
my_anubis/web_sites/www.our-business.com/
This is called the 'site directory' (for the given site). Within the site directory,
the following directories are created by this program:
states
public
journal
private_download
upload_temporary
The directory 'states' is used for storing states (session informations). Out of date
states are automatically removed after some time.
The tree rooted at 'public' contains files that the server is allowed to send to the
clients. For security reasons, the server never sends a file which is not within the
tree whose root is this 'public' directory (except for the 'private download' mecanism;
see 'web/multihost_http_server.anubis'). Also, the MIME type (see 'web/mime.anubis')
must have been recognized before the file may be sent.
The directory 'journal' contains the jounal files. The roles of the remaining
directories 'private_download' and 'upload_temporary' is explained in
'multihost_http_server.anubis', where you will also find further informations on
'public' and 'journal'.
** (2.3) Web servers parameters.
The web servers have several parameters useful for administration. They are described
as follows:
public type WebServersParameters:
wsparms(Var(Bool) shutdown_required,
** (2.4) Starting your web sites.
When you have described all your web sites (you may want to have several web sites, and
they are distinguished by their 'common name'), you may start them all together using
'start_web_sites' below. This function returns a result of the following type:
public type Start_Web_Sites_Result:
cannot_bind_to_port(Word32),
cannot_bind_to_port(Word32,Word32),
ok(Server http_server,
Server https_server).
Indeed, it may happen that the system cannot bind (begin to listen) to one of the two
ports (or to both). The main reason is that another server is already listening on that
port. Another reason may be that 'anbexec' has not been correctly installed, i.e. that
the 's' bit has not been set for 'user' and 'group' (there is not such problem under
Windows). Also notice that the Linux kernel may need a rather long time (up to several
minutes) before liberating a listening port. Now, if the system can bind to the two
ports, the pair of the two servers is returned. Two tools are useful for manipulating
servers:
shutdown of type Server -> One
is_down of type Server -> Bool
They are defined in 'predefined.anubis' (together with the type 'Server').
public define Start_Web_Sites_Result
start_web_sites
(
Word32 ip_address, // the IP address shared by the web sites
Word32 http_port, // usually: 80
Word32 https_port, // usually: 443
String ssl_certificate_common_name,
List(Web_Site) web_sites, // web sites to be started
(One) -> Bool shutdown_required
).
'ip_address' is the IP address on which the two servers listen. If you put 0, the
servers listen on all the IP addresses of the machine. This may be useful if the
machine has several network interfaces.
'ssl_certificate_common_name' is the common name of the SSL certificate that 'anbexec'
loads when it starts. One instance of 'anbexec' cannot handle more than one SSL server
certificate. This is due to a problem of conception of SSL itself. See the book 'SSL
and TLS' by Eric Rescorla (at Addison Wesley) for more explanations.
Notice that the number of servers is always 2, regardless of the number of web sites
you are starting.
The dynamic variable 'shutdown_required' may be used to control the shutdown of the two
servers from within the web site (typically the administration part). The servers will
shutdown as soon as this variable contains 'true'. So you must provide a variable
containing 'false' otherwise your servers will not run. You may also use the primitive
'must_restart' (see 'predefined.anubis') to control the restarting of your servers.
* (3) The HTML interface.
We propose an interface to dynamic HTML. Dynamic HTML includes HTML, and a combination
of CSS (Cascading Style Sheet) and JavaScript techniques for making HTML elements more
reactive and attractive on the client side.
** (3.1) Types used by the HTML interface.
For easy reference, we gather below the definitions of all the types used by the HTML
interface, and we comment them immediately.
//public type HTML_Off_Form:...
public define Printable_tree [HTML_Id x . Printable_tree y] = str_pt(x.id, y).
public define Printable_tree [HtmlClass x . Printable_tree y] = str_pt(x.class, y).
public define Printable_tree [WebArgName x . Printable_tree y] = str_pt(x.name, y).
public define Printable_tree [WebArgValue x . Printable_tree y] = str_pt(x.value, y).
public define Printable_tree [InitialValue x . Printable_tree y] = str_pt(x.value, y).
public define CoreAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false").
public define CoreAttrs attr(String name, Int value) = attr(name, to_String(value)).
public define InputAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false").
public define Text_Option
tooltip(String s) = title(s).
A list of 'Text_Option' must be given with each text you want to put in your page.
public define CoreAttrs
tooltip(String s) = title(s).
public define InputAttrs
tooltip(String s) = title(s).
public type I18n:
lang (String),
dir (Reading_Way).
A list of 'DIV_Option' must be given with each DIV you want to put in your page.
public define String
event_name
(
HtmlEvents e
) =
if e is
{
onafterprint then "onafterprint", //HTML5 Script to be run after the document is printed
onbeforeprint then "onbeforeprint", //HTML5 Script to be run before the document is printed
onbeforeunload then "onbeforeunload", //HTML5 Script to be run when the document is about to be unloaded
onerror then "onerror", //HTML5 Script to be run when an error occurs
onhashchange then "onhashchange", //HTML5 Script to be run when there has been changes to the anchor part of the a URL
onload then "onload", // Fires after the page is finished loading
onmessage then "onmessage", //HTML5 Script to be run when the message is triggered
onoffline then "onoffline", //HTML5 Script to be run when the browser starts to work offline
ononline then "ononline", //HTML5 Script to be run when the browser starts to work online
onpagehide then "onpagehide", //HTML5 Script to be run when a user navigates away from a page
onpageshow then "onpageshow", //HTML5 Script to be run when a user navigates to a page
onpopstate then "onpopstate", //HTML5 Script to be run when the window's history changes
onresize then "onresize", //HTML5 Fires when the browser window is resized
onstorage then "onstorage", //HTML5 Script to be run when a Web Storage area is updated
onunload then "onunload", // Fires once a page has unloaded (or the browser window has been closed)
// Form element events
onblur then "onblur", // Fires the moment that the element loses focus
onchange then "onchange", // Fires the moment when the value of the element is changed
oncontextmenu then "oncontextmenu", //HTML5 Script to be run when a context menu is triggered
onfocus then "onfocus", // Fires the moment when the element gets focus
oninput then "oninput", //HTML5 Script to be run when an element gets user input
oninvalid then "oninvalid", //HTML5 Script to be run when an element is invalid
onreset then "onreset", // Fires when the Reset button in a form is clicked
onsearch then "onsearch", // Fires when the user writes something in a search field (for <input="search">)
onselect then "onselect", // Fires after some text has been selected in an element
onsubmit then "onsubmit", // Fires when a form is submitted
// Keyboard events (Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.)
onkeydown then "onkeydown", // Fires when a user is pressing a key
onkeypress then "onkeypress", // Fires when a user presses a key
onkeyup then "onkeyup", // Fires when a user releases a key
// Mouse events (Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.)
onclick then "onclick", // Fires on a mouse click on the element
ondblclick then "ondblclick", // Fires on a mouse double-click on the element
onmousedown then "onmousedown", // Fires when a mouse button is pressed down on an element
onmousemove then "onmousemove", // Fires when the mouse pointer is moving while it is over an element
onmouseout then "onmouseout", // Fires when the mouse pointer moves out of an element
onmouseover then "onmouseover", // Fires when the mouse pointer moves over an element
onmouseup then "onmouseup", // Fires when a mouse button is released over an element
onwheel then "onwheel", //HTML5 Fires when the mouse wheel rolls up or down over an element
//Drag Events
ondrag then "ondrag", //HMTL5 Script to be run when an element is dragged
ondragend then "ondragend", //HTML5 Script to be run at the end of a drag operation
ondragenter then "ondragenter", //HTML5 Script to be run when an element has been dragged to a valid drop target
ondragleave then "ondragleave", //HTML5 Script to be run when an element leaves a valid drop target
ondragover then "ondragover", //HTML5 Script to be run when an element is being dragged over a valid drop target
ondragstart then "ondragstart", //HTML5 Script to be run at the start of a drag operation
ondrop then "ondrop", //HTML5 Script to be run when dragged element is being dropped
onscroll then "onscroll", //HTML5 Script to be run when an element's scrollbar is being scrolled
//Clipboard Events
oncopy then "oncopy", //HTML5 Fires when the user copies the content of an element
oncut then "oncut", //HTML5 Fires when the user cuts the content of an element
onpaste then "onpaste", //HTML5 Fires when the user pastes some content in an element
//Media Events
onabort then "onabort", //HTML5 Script to be run on abort
oncanplay then "oncanplay", //HTML5 Script to be run when a file is ready to start playing (when it has buffered enough to begin)
oncanplaythrough then "oncanplaythrough", //HTML5 Script to be run when a file can be played all the way to the end without pausing for buffering
oncuechange then "oncuechange", //HTML5 Script to be run when the cue changes in a <track> element
ondurationchange then "ondurationchange", //HTML5 Script to be run when the length of the media changes
onemptied then "onemptied", //HTML5 Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects)
onended then "onended", //HTML5 Script to be run when the media has reach the end (a useful event for messages like "thanks for listening")
onerror then "onerror", //HTML5 Script to be run when an error occurs when the file is being loaded
onloadeddata then "onloadeddata", //HTML5 Script to be run when media data is loaded
onloadedmetadata then "onloadedmetadata", //HTML5 Script to be run when meta data (like dimensions and duration) are loaded
onloadstart then "onloadstart", //HTML5 Script to be run just as the file begins to load before anything is actually loaded
onpause then "onpause", //HTML5 Script to be run when the media is paused either by the user or programmatically
onplay then "onplay", //HTML5 Script to be run when the media is ready to start playing
onplaying then "onplaying", //HTML5 Script to be run when the media actually has started playing
onprogress then "onprogress", //HTML5 Script to be run when the browser is in the process of getting the media data
onratechange then "onratechange", //HTML5 Script to be run each time the playback rate changes (like when a user switches to a slow motion or fast forward mode)
onseeked then "onseeked", //HTML5 Script to be run when the seeking attribute is set to false indicating that seeking has ended
onseeking then "onseeking", //HTML5 Script to be run when the seeking attribute is set to true indicating that seeking is active
onstalled then "onstalled", //HTML5 Script to be run when the browser is unable to fetch the media data for whatever reason
onsuspend then "onsuspend", //HTML5 Script to be run when fetching the media data is stopped before it is completely loaded for whatever reason
ontimeupdate then "ontimeupdate", //HTML5 Script to be run when the playing position has changed (like when the user fast forwards to a different point in the media)
onvolumechange then "onvolumechange", //HTML5 Script to be run each time the volume is changed which (includes setting the volume to "mute")
onwaiting then "onwaiting", //HTML5 Script to be run when the media has paused but is expected to resume (like when the media pauses to buffer more data)
//Misc Events
onshow then "onshow", //HTML5 Fires when a <menu> element is shown as a context menu
ontoggle then "ontoggle"
}.
public define Table_Option nude = border(0,0,0,rgb(0,0,0)).
A list of 'Table_Option' must be given with each table.
A list of 'Cell_Option' must be given with each cell and each row in a table. Options
given with a row apply to all the cells in the row, but are superseded by options given
with cells, which apply only to the cell they are given with.
The parameter $T is later instantiated either to 'HTML_In_Form' or to 'HTML_Off_Form',
depending on where you put your table (within a form or not within a form). For your
convenience, we define the following particular case:
public define HTML_Cell($T)
cell
(
$T content
)=
cell([],content)
.
public define HTML_Cell($T)
cell
(
Cell_Option option,
$T content
) =
cell([option],content)
.
public define HTML_Header_Cell($T)
header_cell
(
$T content
) =
header_cell([],content).
Same remark as for 'HTML_Cell($T)'. We define several convenience functions:
public define HTML_Row($T)
row
(
List(HTML_Cell($T)) cells
)=
row([],cells).
public define HTML_Row($T)
row
(
HTML_Cell($T) cell
)=
row([],[cell]).
public define HTML_Row($T)
row
(
List(Cell_Option) options,
HTML_Cell($T) cell
)=
row(options,[cell]).
public define HTML_Row($T)
row
(
Cell_Option option,
HTML_Cell($T) cell
)=
row([option],[cell]).
public define HTML_Header_Row($T)
header_row
(
List(HTML_Header_Cell($T)) cells
) =
header_row([],cells).
public define HTML_Header_Row($T)
header_row
(
HTML_Header_Cell($T) cell
) =
header_row([],[cell]).
public define Actioner_Aspect
immediate_selector
(
List(CoreAttrs) core_attrs,
WebArgName name,
Int size,
List((List(CoreAttrs),WebArgValue,String)) choices
)=
immediate_selector(core_attrs, name, size, choices, failure, "")
.
public define Actioner_Aspect
immediate_selector
(
List(CoreAttrs) core_attrs,
WebArgName name,
Int size,
List((List(CoreAttrs),WebArgValue,String)) choices,
Maybe(InitialValue) selected
)=
immediate_selector(core_attrs, name, size, choices, selected, "")
.
public define Actioner_Aspect
link
(
List(Text_Option) options,
String text
)=
link(options, text, failure).
public define Actioner_Aspect
link
(
String text
) =
link([], text, failure).
public define Actioner_Aspect
link
(
List(Text_Option) options,
Int i
) =
link(options, to_decimal(i), failure).
public define Actioner_Aspect
link
(
Int i
) =
link([], i).
public define Actioner_Aspect
button
(
String url_img
) =
button(url_img,url_img).
Actioners are explained in details below.
public define String
to_String
(
CSS_File_Media css_file_media
)=
if css_file_media is
{
screen then "screen",
tty then "tty",
tv then "tv",
projection then "projection",
handheld then "handheld",
print then "print",
braille then "braille",
aural then "aural",
all then "all"
}.
//public type HTML_Meta:...
public define HTML_Head_Tag
js_script
(
String script_content
)=
js_inline(script("text/javascript", script_content))
.
/* Label with help */
public define HTML_tooltip
html_tooltip
(
String keyword,
Int width
)=
html_tooltip("", keyword, width).
public define HTML_tooltip
html_tooltip
(
String title,
String keyword
)=
html_tooltip(title, keyword, 0).
public define HTML_Help
tooltip
(
HTML_tooltip h_tooltip
)=
tooltip(h_tooltip, left)
.
/* It contains
* - a List of HTML_Head_Tag representing necessaries head tags for the content. ex: jquery js files, js script, css specific styles, ...
* - a HTML_Off_Form representing the HTML code for the part of the page we want to display
*/
//public type HTML_In_Form:...
public define List(HTML_Head_Tag)
to_HTML_Head_Tag
(
List(CSS_File) css_file_list
)=
map((CSS_File css_f) |-> css(css_f), css_file_list).
public define List(HTML_Head_Tag)
to_HTML_Head_Tag
(
List(JS_File) js_file_list
)=
map((JS_File js_f) |-> js(js_f), js_file_list).
'HTML_In_Form' defines all the elements you may put within a form. We define a
convenience function:
public define HTML_In_Form text_input(HTML_Label label, HTML_Id id, WebArgName name, InitialValue init, Int width) = text_input([], label, id, name, init, width).
public define HTML_In_Form literal(Printable_tree t) = literal_pt(t).
public define HTML_In_Form image(String url) = image([], url, url).
public define HTML_In_Form image(String url, Int width, Int height) = image([], url, url, width, height).
public define HTML_In_Form
foreign_link
(
Int tsize,
String url,
String name
) =
foreign_link([size(tsize)],url,name).
public define HTML_In_Form
/* Older call with String as action instead of WEB_Action_Name.
* This function exists only for compatibility with older project.
* Please condiser to use above function instead
*/
actioner
(
Actioner_Connection conn,
Actioner_Target targ,
Actioner_Aspect asp,
String action,
List((String,String)) extra_ops,
List(Actioner_Local_Action) local_actions
)=
actioner(conn,targ,asp,action_name(action),extra_ops,local_actions)
.
public define HTML_In_Form
actioner
(
Actioner_Connection conn,
Actioner_Target targ,
Actioner_Aspect asp,
WEB_Action_Name action,
List((String,String)) extra_ops
)=
actioner(conn,targ,asp,action,extra_ops,[])
.
public define HTML_In_Form
/* Older call with String as action instead of WEB_Action_Name.
* This function exists only for compatibility with older project.
* Please condiser to use above function instead
*/
actioner
(
Actioner_Connection conn,
Actioner_Target targ,
Actioner_Aspect asp,
String action,
List((String,String)) extra_ops
)=
actioner(conn,targ,asp,action_name(action),extra_ops,[])
.
public define HTML_In_Form
actioner
(
Actioner_Connection conn,
Actioner_Target targ,
Actioner_Aspect asp,
)=
actioner(conn, targ, asp, action_name(""), [], []).
public define HTML_In_Form
text_area
(
WebArgName name,
InitialValue init,
Int width,
Int height
) =
text_area([], no_label, html_Id(""), name,init,width,height).
public define HTML_In_Form
text_area
(
List(TextAreaOption) options,
WebArgName name,
InitialValue init,
Int width,
Int height
) =
text_area(options, no_label, html_Id(""), name,init,width,height).
public define HTML_In_Form
table
(
List(HTML_Row(HTML_In_Form)) rows
) =
table([],empty,rows,empty).
public define HTML_In_Form
table
(
List(Table_Option) options,
List(HTML_Row(HTML_In_Form)) rows
) =
table(options,empty,rows,empty).
public define HTML_In_Form
table
(
HTML_Header_Row(HTML_In_Form) h_row,
List(HTML_Row(HTML_In_Form)) rows
) =
table([],h_row,rows,empty).
public define HTML_In_Form
table
(
List(Table_Option) options,
HTML_Header_Row(HTML_In_Form) h_row,
List(HTML_Row(HTML_In_Form)) rows
) =
table(options,h_row,rows,empty).
public define HTML_In_Form
private_download
(
String abs_path,
String name,
String extra_ext
) =
private_download(abs_path,name,extra_ext,failure).
public define HTML_In_Form
private_download
(
String abs_path,
String name,
String extra_ext,
String action_name,
List((String,String)) args
) =
private_download(abs_path,name,extra_ext,success((action_name,args))).
public define HTML_In_Form
text
(
List(CoreAttrs) l,
Int i
) =
text(l, to_decimal(i)).
public define HTML_In_Form
text
(
String s
)=
text([],s)
.
public define HTML_In_Form
text
(
Int i
) =
text([], i)
.
public define HTML_In_Form
div
(
HTML_In_Form element
)=
div([], [element])
.
public define HTML_In_Form
div
(
List(CoreAttrs) attrs,
HTML_In_Form element
)=
div(attrs, [element])
.
public define HTML_In_Form
span
(
String s
)=
span([],s)
.
public define HTML_In_Form
span
(
Int i
) =
span([], to_decimal(i))
.
public define HTML_In_Form
radio_button (List(CoreAttrs) options, HTML_Label label, WebArgName n, WebArgValue value, Bool checked)
= radio_button (options, label, html_Id(n.name), n, value, checked).
public define HTML_In_Form
radio_button_r (List(CoreAttrs) options, HTML_Label label, WebArgName n, WebArgValue value, Bool checked)
= radio_button_r (options, label, html_Id(n.name), n, value, checked).
public define HTML_In_Form
check_box (List(CoreAttrs) options, HTML_Label label, WebArgName n, Bool checked)
= check_box (options, label, html_Id(n.name), n, checked).
public define HTML_In_Form
check_box_r (List(CoreAttrs) options, HTML_Label label, WebArgName n, Bool checked)
= check_box_r (options, label, html_Id(n.name), n, checked).
public define HTML_In_Form
file_upload (WebArgName n, Int width)
= file_upload([], no_label, html_Id(n.name), n, width).
public define HTML_In_Form
hidden (WebArgName name, WebArgValue value)
=
hidden(html_Id(""), name, value).
public type Input_Type:
button,
checkbox,
color,
date,
datetime_local,
email,
file,
hidden,
image,
month,
number,
password,
radio,
range,
reset,
search,
submit,
tel,
text,
time,
url,
week
.
public type FormMethod:
get,
post
.
//public type HTML_Body:...
public define CoreAttrs formaction(WEB_Action_Name action, List((String,String)) extra_ops) = attr("formaction", format_web_action_name(action, extra_ops)).
public define CoreAttrs formaction(WEB_Action_Name action, (String,String) extra_op) = attr("formaction", format_web_action_name(action, extra_op)).
public define CoreAttrs formaction(WEB_Action_Name action) = attr("formaction", format_web_action_name(action)).
public define CoreAttrs formmethod(FormMethod method) = attr("formmethod", if method is { get then "get", post then "post"}).
'HTML_Off_Form' defines all the elements you may put outside any form.
public define CoreAttrs method(String value) = attr("method", value).
public define CoreAttrs action(WEB_Action_Name action)= attr("action", "/"+format_web_action_name(action)).
public define CoreAttrs action(WEB_Action_Name action, List((String,String)) extra_ops)= attr("formaction", "/"+format_web_action_name(action, extra_ops)).
public define CoreAttrs formmethod(String value) = attr("formmethod", value).
public define CoreAttrs form(String value) = attr("form", value).
public define HTML_Off_Form text(List(CoreAttrs) attrs, Int i) = text(attrs, to_decimal(i)).
public define HTML_Off_Form text(CoreAttrs attr, Int i) = text([attr], i).
public define HTML_Off_Form text(Int i) = text([], i).
public define HTML_Off_Form text(String s) = text([], s).
public define HTML_Off_Form text(CoreAttrs attr, String s) = text([attr], s).
public define HTML_Off_Form a(A_href _href) = a([], _href, _self, []).
public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href) = a(attrs, _href, _self, []).
public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href, HTML_Off_Form content) = a(attrs, _href, _self, [content]).
public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href, List(HTML_Off_Form) content) = a(attrs, _href, _self, content).
public define HTML_Off_Form a(A_href _href, HTML_Off_Form content) = a([], _href, _self, [content]).
public define HTML_Off_Form a(A_href _href, List(HTML_Off_Form) content) = a([], _href, _self, content).
public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href, A_target _target, HTML_Off_Form content) = a(attrs, _href, _target, [content]).
public define HTML_Off_Form a(CoreAttrs attr, A_href _href, A_target _target, HTML_Off_Form content) = a([attr], _href, _target, [content]).
public define HTML_Off_Form a(A_href _href, A_target _target, HTML_Off_Form content) = a([], _href, _target, [content]).
public define HTML_Off_Form a(A_href _href, A_target _target, List(HTML_Off_Form) content) = a([], _href, _target, content).
public define HTML_Off_Form a(CoreAttrs attr, A_href _href, A_target _target, List(HTML_Off_Form) content) = a([attr], _href, _target, content).
// <article>
public define HTML_Off_Form article(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("article", attrs, content).
public define HTML_Off_Form article(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("article", attrs, [content]).
public define HTML_Off_Form article(List(HTML_Off_Form) content) = html_tag("article", [], content).
public define HTML_Off_Form article(HTML_Off_Form content) = html_tag("article", [], [content]).
// <aside>
public define HTML_Off_Form aside(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("aside", attrs, content).
public define HTML_Off_Form aside(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("aside", attrs, [content]).
public define HTML_Off_Form aside(List(HTML_Off_Form) content) = html_tag("aside", [], content).
public define HTML_Off_Form aside(HTML_Off_Form content) = html_tag("aside", [], [content]).
// <b> text in bold face
public define HTML_Off_Form b(String string) = html_tag("b", [], [text(string)]).
public define HTML_Off_Form b(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("b", attrs, [content]).
public define HTML_Off_Form b(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("b", [attr], content).
public define HTML_Off_Form b(CoreAttrs attr, HTML_Off_Form content) = html_tag("b", [attr], [content]).
public define HTML_Off_Form b(List(CoreAttrs) attrs, String string) = html_tag("b", attrs, [text(string)]).
public define HTML_Off_Form b(CoreAttrs attr, String string) = html_tag("b", [attr], [text(string)]).
// <br>
public define HTML_Off_Form br = html_void_tag("br", []).
public define HTML_Off_Form br(List(CoreAttrs) attrs) = html_void_tag("br", attrs).
// <button>
public define HTML_Off_Form button(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("button", attrs, content).
public define HTML_Off_Form button(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("button", attrs, [content]).
public define HTML_Off_Form button(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("button", [attr], content).
public define HTML_Off_Form button(CoreAttrs attr, HTML_Off_Form content) = html_tag("button", [attr], [content]).
public define HTML_Off_Form button(List(CoreAttrs) attrs) = html_tag("button", attrs, []).
public define HTML_Off_Form button(List(CoreAttrs) attrs, String string) = html_tag("button", attrs, [text(string)]).
public define HTML_Off_Form button(List(HTML_Off_Form) content) = html_tag("button", [], content).
public define HTML_Off_Form button(HTML_Off_Form content) = html_tag("button", [], [content]).
// <canvas>
public define HTML_Off_Form canvas(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("canvas", attrs, content).
public define HTML_Off_Form canvas(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("canvas", attrs, [content]).
public define HTML_Off_Form canvas(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("canvas", [attr], content).
public define HTML_Off_Form canvas(CoreAttrs attr, HTML_Off_Form content) = html_tag("canvas", [attr], [content]).
public define HTML_Off_Form canvas(List(CoreAttrs) attrs) = html_tag("canvas", attrs, []).
public define HTML_Off_Form canvas(List(HTML_Off_Form) content) = html_tag("canvas", [], content).
public define HTML_Off_Form canvas(HTML_Off_Form content) = html_tag("canvas", [], [content]).
public define HTML_Off_Form canvas(CoreAttrs cattr, Int width, Int height) = html_tag("canvas", [cattr,
attr("width", to_String(width)),
attr("height", to_String(height))
], []).
public define HTML_Off_Form canvas(List(CoreAttrs) attrs, Int width, Int height) = html_tag("canvas", [
attr("width", to_String(width)),
attr("height", to_String(height)).
attrs
], []).
// <datalist>
public define HTML_Off_Form datalist(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("datalist", attrs, content).
public define HTML_Off_Form datalist(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("datalist", attrs, [content]).
public define HTML_Off_Form datalist(List(HTML_Off_Form) content) = html_tag("datalist", [], content).
public define HTML_Off_Form datalist(HTML_Off_Form content) = html_tag("datalist", [], [content]).
// <div>
public define HTML_Off_Form div(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("div", attrs, content).
public define HTML_Off_Form div(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("div", attrs, [content]).
public define HTML_Off_Form div(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("div", [attr], content).
public define HTML_Off_Form div(CoreAttrs attr, HTML_Off_Form content) = html_tag("div", [attr], [content]).
public define HTML_Off_Form div(List(HTML_Off_Form) content) = html_tag("div", [], content).
public define HTML_Off_Form div(HTML_Off_Form content) = html_tag("div", [], [content]).
public define HTML_Off_Form div(List(CoreAttrs) attrs) = html_tag("div", attrs, []).
public define HTML_Off_Form div(CoreAttrs attr) = html_tag("div", [attr], []).
public define HTML_Off_Form div(String string) = html_tag("div", [], [text(string)]).
public define HTML_Off_Form div(CoreAttrs attr, String string) = html_tag("div", [attr], [text(string)]).
public define HTML_Off_Form div(List(CoreAttrs) attrs, String string) = html_tag("div", attrs, [text(string)]).
public define HTML_Off_Form div(List(CoreAttrs) attrs, HTML_Partial_Content content) = div(attrs, [content]).
public define HTML_Off_Form div(List(HTML_Partial_Content) content) = div([], content).
public define HTML_Off_Form div(CoreAttrs attr, HTML_Partial_Content content) = div([attr], [content]).
public define HTML_Off_Form div(HTML_Partial_Content content) = div([], [content]).
//public define HTML_Partial_Content div(List(CoreAttrs) attrs, HTML_Partial_Content content) = partial_content([], div(attrs, [content])).
//public define HTML_Partial_Content div(CoreAttrs attr, HTML_Partial_Content content) = partial_content([], div([attr], [content])).
//public define HTML_Partial_Content div(List(HTML_Partial_Content) content) = partial_content([], div([], content)).
//public define HTML_Partial_Content div(HTML_Partial_Content content) = partial_content([], div([], [content])).
// <dd>
public define HTML_Off_Form dd(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("dd", attrs, content).
public define HTML_Off_Form dd(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("dd", attrs, [content]).
public define HTML_Off_Form dd(List(HTML_Off_Form) content) = html_tag("dd", [], content).
public define HTML_Off_Form dd(HTML_Off_Form content) = html_tag("dd", [], [content]).
// <dl>
public define HTML_Off_Form dl(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("dl", attrs, content).
public define HTML_Off_Form dl(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("dl", attrs, [content]).
public define HTML_Off_Form dl(List(HTML_Off_Form) content) = html_tag("dl", [], content).
public define HTML_Off_Form dl(HTML_Off_Form content) = html_tag("dl", [], [content]).
// <dt>
public define HTML_Off_Form dt(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("dt", attrs, content).
public define HTML_Off_Form dt(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("dt", attrs, [content]).
public define HTML_Off_Form dt(List(HTML_Off_Form) content) = html_tag("dt", [], content).
public define HTML_Off_Form dt(HTML_Off_Form content) = html_tag("dt", [], [content]).
// <em>
public define HTML_Off_Form em(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("em", attrs, content).
public define HTML_Off_Form em(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("em", attrs, [content]).
public define HTML_Off_Form em(List(HTML_Off_Form) content) = html_tag("em", [], content).
public define HTML_Off_Form em(HTML_Off_Form content) = html_tag("em", [], [content]).
// <footer>
public define HTML_Off_Form footer(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("footer", attrs, content).
public define HTML_Off_Form footer(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("footer", attrs, [content]).
public define HTML_Off_Form footer(List(HTML_Off_Form) content) = html_tag("footer", [], content).
public define HTML_Off_Form footer(HTML_Off_Form content) = html_tag("footer", [], [content]).
// <form>
public define HTML_Off_Form form(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("form", attrs, content).
public define HTML_Off_Form form(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("form", attrs, [content]).
public define HTML_Off_Form form(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("form", [attr], content).
public define HTML_Off_Form form(CoreAttrs attr, HTML_Off_Form content) = html_tag("form", [attr], [content]).
public define HTML_Off_Form form(List(CoreAttrs) attrs) = html_tag("form", attrs, []).
public define HTML_Off_Form form(CoreAttrs attr) = html_tag("form", [attr], []).
public define HTML_Off_Form form(List(HTML_Off_Form) content) = html_tag("form", [], content).
public define HTML_Off_Form form(HTML_Off_Form content) = html_tag("form", [], [content]).
// <header>
public define HTML_Off_Form header(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("header", attrs, content).
public define HTML_Off_Form header(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("header", attrs, [content]).
public define HTML_Off_Form header(List(HTML_Off_Form) content) = html_tag("header", [], content).
public define HTML_Off_Form header(HTML_Off_Form content) = html_tag("header", [], [content]).
// <h1>
public define HTML_Off_Form h1(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h1", attrs, content).
public define HTML_Off_Form h1(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h1", attrs, [content]).
public define HTML_Off_Form h1(List(HTML_Off_Form) content) = html_tag("h1", [], content).
public define HTML_Off_Form h1(HTML_Off_Form content) = html_tag("h1", [], [content]).
// <h2>
public define HTML_Off_Form h2(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h2", attrs, content).
public define HTML_Off_Form h2(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h2", attrs, [content]).
public define HTML_Off_Form h2(List(HTML_Off_Form) content) = html_tag("h2", [], content).
public define HTML_Off_Form h2(HTML_Off_Form content) = html_tag("h2", [], [content]).
// <h3>
public define HTML_Off_Form h3(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h3", attrs, content).
public define HTML_Off_Form h3(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h3", attrs, [content]).
public define HTML_Off_Form h3(List(HTML_Off_Form) content) = html_tag("h3", [], content).
public define HTML_Off_Form h3(HTML_Off_Form content) = html_tag("h3", [], [content]).
// <h4>
public define HTML_Off_Form h4(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h4", attrs, content).
public define HTML_Off_Form h4(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h4", attrs, [content]).
public define HTML_Off_Form h4(List(HTML_Off_Form) content) = html_tag("h4", [], content).
public define HTML_Off_Form h4(HTML_Off_Form content) = html_tag("h4", [], [content]).
// <h5>
public define HTML_Off_Form h5(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h5", attrs, content).
public define HTML_Off_Form h5(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h5", attrs, [content]).
public define HTML_Off_Form h5(List(HTML_Off_Form) content) = html_tag("h5", [], content).
public define HTML_Off_Form h5(HTML_Off_Form content) = html_tag("h5", [], [content]).
// <h6>
public define HTML_Off_Form h6(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("h6", attrs, content).
public define HTML_Off_Form h6(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("h6", attrs, [content]).
public define HTML_Off_Form h6(List(HTML_Off_Form) content) = html_tag("h6", [], content).
public define HTML_Off_Form h6(HTML_Off_Form content) = html_tag("h6", [], [content]).
// <hr>
public define HTML_Off_Form hr = html_void_tag("hr", []).
public define HTML_Off_Form hr(List(CoreAttrs) attrs) = html_void_tag("hr", attrs).
public define HTML_Off_Form hr(CoreAttrs attr) = html_void_tag("hr", [attr]).
// <iframe>
public define HTML_Off_Form iframe(CoreAttrs _attr, String src, Int width, Int height) =
html_tag("iframe", [_attr, attr("src",src), width_px(width), height_px(height)], []).
public define HTML_Off_Form iframe(String src, Int width, Int height) =
html_tag("iframe", [attr("src",src), width_px(width), height_px(height)], []).
public define HTML_Off_Form iframe(String src) = html_tag("iframe", [attr("src",src)], []).
// <input>
public define HTML_Off_Form input(List(CoreAttrs) attrs) = html_void_tag("input", attrs).
public define HTML_Off_Form input(CoreAttrs attr) = html_void_tag("input", [attr]).
public define CoreAttrs type(String value)= attr("type", value).
public define CoreAttrs name(String value)= attr("name", value).
public define CoreAttrs value(String value)= attr("value", value).
public define CoreAttrs init(String value)= attr("value", encode_HTML_entities(value)).
//-- BEGIN of <input> preset type
/// Radio button
public define HTML_Off_Form radio(List(CoreAttrs) attrs, String name, String value, String form, Bool checked) = input([type("radio"), attr("name",name), attr("value",value), attr("form", form), bool_attr(checked, "checked") . attrs]).
public define HTML_Off_Form radio(List(CoreAttrs) attrs, String name, String value, String form) = radio(attrs, name, value, form, false).
public define HTML_Off_Form radio(String name, String value, String form, Bool checked) = radio([], name, value, form, checked).
public define HTML_Off_Form radio(String name, String value, String form) = radio([], name, value, form, false).
/// hidden value
public define HTML_Off_Form hidden(List(CoreAttrs) attrs, String name, String value, String form) = input([type("hidden"), attr("name",name), attr("value",value), attr("form", form) . attrs]).
public define HTML_Off_Form hidden(CoreAttrs attr, String name, String value, String form) = hidden([attr], name, value, form).
public define HTML_Off_Form hidden(String name, String value, String form) = hidden([], name, value, form).
public define HTML_Off_Form hidden(String _name, String _value) = input([type("hidden"), name(_name), value(_value)]).
//-- END of <input> preset type
// <img>
public define HTML_Off_Form img(List(CoreAttrs) attrs, String src, String alt) = html_void_tag("img", attrs + [attr("src",src), attr("alt",alt)] ).
public define HTML_Off_Form img(CoreAttrs _attr, String src, String alt) = html_void_tag("img", [_attr, attr("src",src), attr("alt",alt)] ).
public define HTML_Off_Form img(String src) = img([], src, "").
public define HTML_Off_Form img(String src, String alt) = img([], src, alt).
public define HTML_Off_Form img(List(CoreAttrs) attrs, String src) = img(attrs, src, "").
public define HTML_Off_Form img(CoreAttrs attr, String src) = img([attr], src, "").
public define HTML_Off_Form img(String src, Int width, Int height) = img([attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")], src, src).
public define HTML_Off_Form img(String src, String alt, Int width, Int height) =
html_void_tag("img", [attr("src",src), attr("alt",alt), attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")]).
public define HTML_Off_Form img(List(CoreAttrs) attrs, String src, String alt, Int width, Int height) =
html_void_tag("img", attrs + [attr("src",src), attr("alt",alt), attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")]).
public define HTML_Off_Form img(CoreAttrs _attr, String src, String alt, Int width, Int height) =
html_void_tag("img", [_attr, attr("src",src), attr("alt",alt), width_px(width), height_px(height)]).
// <label>
public define HTML_Off_Form label(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("label", attrs, content).
public define HTML_Off_Form label(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("label", [attr], content).
public define HTML_Off_Form label(List(HTML_Off_Form) content) = html_tag("label", [], content).
public define HTML_Off_Form label(HTML_Off_Form content) = html_tag("label", [], [content]).
public define HTML_Off_Form label(String string) = html_tag("label", [], [text(string)]).
public define HTML_Off_Form label(CoreAttrs attr, String string) = html_tag("label", [attr], [text(string)]).
public define HTML_Off_Form label(List(CoreAttrs) attrs, String string) = html_tag("label", attrs, [text(string)]).
// <li>
public define HTML_Off_Form li(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("li", attrs, content).
public define HTML_Off_Form li(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("li", attrs, [content]).
public define HTML_Off_Form li(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("li", [attr], content).
public define HTML_Off_Form li(CoreAttrs attr, HTML_Off_Form content) = html_tag("li", [attr], [content]).
public define HTML_Off_Form li(List(HTML_Off_Form) content) = html_tag("li", [], content).
public define HTML_Off_Form li(HTML_Off_Form content) = html_tag("li", [], [content]).
public define HTML_Off_Form li(String string) = html_tag("li", [], [text(string)]).
public define HTML_Off_Form li(CoreAttrs attr, String string) = html_tag("li", [attr], [text(string)]).
public define HTML_Off_Form li(List(CoreAttrs) attrs, String string) = html_tag("li", attrs, [text(string)]).
// <main>
public define HTML_Off_Form main(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("main", attrs, content).
public define HTML_Off_Form main(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("main", attrs, [content]).
public define HTML_Off_Form main(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("main", [attr], content).
public define HTML_Off_Form main(CoreAttrs attr, HTML_Off_Form content) = html_tag("main", [attr], [content]).
public define HTML_Off_Form main(List(HTML_Off_Form) content) = html_tag("main", [], content).
public define HTML_Off_Form main(HTML_Off_Form content) = html_tag("main", [], [content]).
// <nav>
public define HTML_Off_Form nav(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("nav", attrs, content).
public define HTML_Off_Form nav(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("nav", attrs, [content]).
public define HTML_Off_Form nav(List(HTML_Off_Form) content) = html_tag("nav", [], content).
public define HTML_Off_Form nav(HTML_Off_Form content) = html_tag("nav", [], [content]).
// <ol>
public define HTML_Off_Form ol(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("ol", attrs, content).
public define HTML_Off_Form ol(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("ol", attrs, [content]).
public define HTML_Off_Form ol(List(HTML_Off_Form) content) = html_tag("ol", [], content).
public define HTML_Off_Form ol(HTML_Off_Form content) = html_tag("ol", [], [content]).
// <option>
public define HTML_Off_Form option(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("option", attrs, content).
public define HTML_Off_Form option(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("option", attrs, [content]).
public define HTML_Off_Form option(List(HTML_Off_Form) content) = html_tag("option", [], content).
public define HTML_Off_Form option(HTML_Off_Form content) = html_tag("option", [], [content]).
// <p>
public define HTML_Off_Form p(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("p", attrs, content).
public define HTML_Off_Form p(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("p", attrs, [content]).
public define HTML_Off_Form p(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("p", [attr], content).
public define HTML_Off_Form p(CoreAttrs attr, HTML_Off_Form content) = html_tag("p", [attr], [content]).
public define HTML_Off_Form p(List(HTML_Off_Form) content) = html_tag("p", [], content).
public define HTML_Off_Form p(HTML_Off_Form content) = html_tag("p", [], [content]).
// <pre> preformatted
public define HTML_Off_Form pre(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("pre", attrs, content).
public define HTML_Off_Form pre(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("pre", attrs, [content]).
public define HTML_Off_Form pre(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("pre", [attr], content).
public define HTML_Off_Form pre(CoreAttrs attr, HTML_Off_Form content) = html_tag("pre", [attr], [content]).
public define HTML_Off_Form pre(List(HTML_Off_Form) content) = html_tag("pre", [], content).
public define HTML_Off_Form pre(HTML_Off_Form content) = html_tag("pre", [], [content]).
public define HTML_Off_Form pre(String string) = html_tag("pre", [], [text(string)]).
public define HTML_Off_Form pre(CoreAttrs attr, String string) = html_tag("pre", [attr], [text(string)]).
public define HTML_Off_Form pre(List(CoreAttrs) attrs, String string) = html_tag("pre", attrs, [text(string)]).
// <progress>
public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, List(HTML_Off_Form) content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], content).
public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], [content]).
public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max) , _attr], [content]).
public define HTML_Off_Form progress(Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max)], [content]).
public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], [text(content)]).
public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max), _attr], [text(content)]).
public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], []).
public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max), _attr], []).
public define HTML_Off_Form progress(Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max)], [text(content)]).
public define HTML_Off_Form progress(Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max)], []).
// <section>
public define HTML_Off_Form section(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("section", attrs, content).
public define HTML_Off_Form section(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("section", attrs, [content]).
public define HTML_Off_Form section(List(HTML_Off_Form) content) = html_tag("section", [], content).
public define HTML_Off_Form section(HTML_Off_Form content) = html_tag("section", [], [content]).
// <select>
public define HTML_Off_Form select(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("select", attrs, content).
public define HTML_Off_Form select(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("select", attrs, [content]).
public define HTML_Off_Form select(List(CoreAttrs) attrs) = html_tag("select", attrs, []).
public define HTML_Off_Form select(List(HTML_Off_Form) content) = html_tag("select", [], content).
public define HTML_Off_Form select(HTML_Off_Form content) = html_tag("select", [], [content]).
// <span>
public define HTML_Off_Form span(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("span", attrs, content).
public define HTML_Off_Form span(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("span", attrs, [content]).
public define HTML_Off_Form span(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("span", [attr], content).
public define HTML_Off_Form span(CoreAttrs attr, HTML_Off_Form content) = html_tag("span", [attr], [content]).
public define HTML_Off_Form span(List(HTML_Off_Form) content) = html_tag("span", [], content).
public define HTML_Off_Form span(HTML_Off_Form content) = html_tag("span", [], [content]).
public define HTML_Off_Form span(Int i) = html_tag("span", [], [text(to_decimal(i))]).
public define HTML_Off_Form span(List(CoreAttrs) attrs, String s) = html_tag("span", attrs, [text(s)]).
public define HTML_Off_Form span(CoreAttrs attr, String s) = html_tag("span", [attr],[text(s)]).
public define HTML_Off_Form span(String s) = html_tag("span", [], [text(s)]).
public define HTML_Off_Form span(List(CoreAttrs) attrs) = html_tag("span", attrs, []).
public define HTML_Off_Form span(CoreAttrs attr) = html_tag("span", [attr],[]).
// <strong>
public define HTML_Off_Form strong(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("strong", attrs, content).
public define HTML_Off_Form strong(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("strong", attrs, [content]).
public define HTML_Off_Form strong(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("strong", [attr], content).
public define HTML_Off_Form strong(CoreAttrs attr, HTML_Off_Form content) = html_tag("strong", [attr], [content]).
public define HTML_Off_Form strong(List(HTML_Off_Form) content) = html_tag("strong", [], content).
public define HTML_Off_Form strong(HTML_Off_Form content) = html_tag("strong", [], [content]).
// <svg>
public define HTML_Off_Form svg(List(CoreAttrs) attrs) = html_tag("svg", attrs, []).
// <table>
public define HTML_Off_Form table(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("table", attrs, content).
public define HTML_Off_Form table(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("table", attrs, [content]).
public define HTML_Off_Form table(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("table", [attr], content).
public define HTML_Off_Form table(CoreAttrs attr, HTML_Off_Form content) = html_tag("table", [attr], [content]).
public define HTML_Off_Form table(List(HTML_Off_Form) content) = html_tag("table", [], content).
public define HTML_Off_Form table(HTML_Off_Form content) = html_tag("table", [], [content]).
// <thead>
public define HTML_Off_Form thead(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("thead", attrs, content).
public define HTML_Off_Form thead(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("thead", attrs, [content]).
public define HTML_Off_Form thead(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("thead", [attr], content).
public define HTML_Off_Form thead(CoreAttrs attr, HTML_Off_Form content) = html_tag("thead", [attr], [content]).
public define HTML_Off_Form thead(List(HTML_Off_Form) content) = html_tag("thead", [], content).
public define HTML_Off_Form thead(HTML_Off_Form content) = html_tag("thead", [], [content]).
// <tbody>
public define HTML_Off_Form tbody(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("tbody", attrs, content).
public define HTML_Off_Form tbody(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("tbody", attrs, [content]).
public define HTML_Off_Form tbody(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("tbody", [attr], content).
public define HTML_Off_Form tbody(CoreAttrs attr, HTML_Off_Form content) = html_tag("tbody", [attr], [content]).
public define HTML_Off_Form tbody(List(HTML_Off_Form) content) = html_tag("tbody", [], content).
public define HTML_Off_Form tbody(HTML_Off_Form content) = html_tag("tbody", [], [content]).
// <tfoot>
public define HTML_Off_Form tfoot(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("tfoot", attrs, content).
public define HTML_Off_Form tfoot(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("tfoot", attrs, [content]).
public define HTML_Off_Form tfoot(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("tfoot", [attr], content).
public define HTML_Off_Form tfoot(CoreAttrs attr, HTML_Off_Form content) = html_tag("tfoot", [attr], [content]).
public define HTML_Off_Form tfoot(List(HTML_Off_Form) content) = html_tag("tfoot", [], content).
public define HTML_Off_Form tfoot(HTML_Off_Form content) = html_tag("tfoot", [], [content]).
// <th>
public define HTML_Off_Form th(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("th", attrs, content).
public define HTML_Off_Form th(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("th", attrs, [content]).
public define HTML_Off_Form th(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("th", [attr], content).
public define HTML_Off_Form th(CoreAttrs attr, HTML_Off_Form content) = html_tag("th", [attr], [content]).
public define HTML_Off_Form th(List(HTML_Off_Form) content) = html_tag("th", [], content).
public define HTML_Off_Form th(HTML_Off_Form content) = html_tag("th", [], [content]).
public define HTML_Off_Form th(String string) = html_tag("th", [], [text(string)]).
public define HTML_Off_Form th(CoreAttrs attr, String string) = html_tag("th", [attr], [text(string)]).
public define HTML_Off_Form th(List(CoreAttrs) attrs, String string) = html_tag("th", attrs, [text(string)]).
// <td>
public define HTML_Off_Form td(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("td", attrs, content).
public define HTML_Off_Form td(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("td", attrs, [content]).
public define HTML_Off_Form td(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("td", [attr], content).
public define HTML_Off_Form td(CoreAttrs attr, HTML_Off_Form content) = html_tag("td", [attr], [content]).
public define HTML_Off_Form td(List(HTML_Off_Form) content) = html_tag("td", [], content).
public define HTML_Off_Form td(HTML_Off_Form content) = html_tag("td", [], [content]).
public define HTML_Off_Form td(List(CoreAttrs) attrs, String string) = html_tag("td", attrs, [text(string)]).
public define HTML_Off_Form td(CoreAttrs attr, String string) = html_tag("td", [attr], [text(string)]).
public define HTML_Off_Form td(String string) = html_tag("td", [], [text(string)]).
public define HTML_Off_Form td(List(CoreAttrs) attrs, Int i) = html_tag("td", attrs, [text(to_decimal(i))]).
public define HTML_Off_Form td(CoreAttrs attr, Int i) = html_tag("td", [attr], [text(to_decimal(i))]).
public define HTML_Off_Form td(Int i) = html_tag("td", [], [text(to_decimal(i))]).
// <tr>
public define HTML_Off_Form tr(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("tr", attrs, content).
public define HTML_Off_Form tr(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("tr", attrs, [content]).
public define HTML_Off_Form tr(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("tr", [attr], content).
public define HTML_Off_Form tr(CoreAttrs attr, HTML_Off_Form content) = html_tag("tr", [attr], [content]).
public define HTML_Off_Form tr(List(HTML_Off_Form) content) = html_tag("tr", [], content).
public define HTML_Off_Form tr(HTML_Off_Form content) = html_tag("tr", [], [content]).
// <textarea>
// CoreAttrs for textarea
public define CoreAttrs wrap_lines = attr("wrap", "hard").
public define CoreAttrs read_only = bool_attr(true, "readonly").
public define HTML_Off_Form textarea(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("textarea", attrs, content).
public define HTML_Off_Form textarea(List(CoreAttrs) attrs, Int cols, Int rows, List(HTML_Off_Form) content)
= html_tag("textarea", [attr("cols",to_String(cols)), attr("rows",to_String(rows)) . attrs], content).
public define HTML_Off_Form textarea(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("textarea", attrs, [content]).
public define HTML_Off_Form textarea(List(CoreAttrs) attrs, Int cols, Int rows, HTML_Off_Form content)
= html_tag("textarea", [attr("cols",to_String(cols)), attr("rows",to_String(rows)) . attrs], [content]).
public define HTML_Off_Form textarea(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("textarea", [attr], content).
public define HTML_Off_Form textarea(CoreAttrs attr, HTML_Off_Form content) = html_tag("textarea", [attr], [content]).
// <ul>
public define HTML_Off_Form ul(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("ul", attrs, content).
public define HTML_Off_Form ul(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("ul", attrs, [content]).
public define HTML_Off_Form ul(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("ul", [attr], content).
public define HTML_Off_Form ul(CoreAttrs attr, HTML_Off_Form content) = html_tag("ul", [attr], [content]).
public define HTML_Off_Form ul(List(HTML_Off_Form) content) = html_tag("ul", [], content).
public define HTML_Off_Form ul(HTML_Off_Form content) = html_tag("ul", [], [content]).
public define HTML_Off_Form
form
(
String form_name,
List(CoreAttrs) options,
HTML_In_Form content
) =
form(html_Id(form_name), options, [content]).
public define HTML_Off_Form
form
(
String form_name,
List(CoreAttrs) options,
List(HTML_In_Form) contents
) =
form(html_Id(form_name), options, contents).
public define HTML_Off_Form
form
(
String form_name,
List(CoreAttrs) options,
WEB_Action_Name action,
List((String,String)) extra_ops,
HTML_In_Form content
) =
form(html_Id(form_name), options, action, extra_ops, [content]).
public define HTML_Off_Form
form
(
HTML_Id form_id,
List(CoreAttrs) options,
WEB_Action_Name action,
List((String,String)) extra_ops,
HTML_In_Form content
) =
form(form_id, options, action, extra_ops, [content]).
public define HTML_Off_Form
form
(
String form_name,
List(CoreAttrs) options,
WEB_Action_Name action,
List((String,String)) extra_ops,
List(HTML_In_Form) contents
) =
form(html_Id(form_name), options, action, extra_ops, contents).
public define HTML_Off_Form
form
(
String form_name,
List(CoreAttrs) options,
String action,
List((String,String)) extra_ops,
HTML_In_Form content
) =
form(html_Id(form_name), options, action_name(action), extra_ops, [content]).
public define HTML_Off_Form
form
(
String form_name,
List(CoreAttrs) options,
String action,
List((String,String)) extra_ops,
List(HTML_In_Form) contents
) =
form(html_Id(form_name), options, action_name(action), extra_ops, contents).
public define HTML_Off_Form literal(Printable_tree t) = literal_pt(t).
//public define HTML_Off_Form fixed_size(HTML_Size width, HTML_Size height, String name_of_HTML_file)
// = fixed_size_2(width,height,name_of_HTML_file).
public define HTML_Off_Form
foreign_link
(
Int tsize,
String url,
String name
) =
foreign_link([size(tsize)],url,name).
public define HTML_Off_Form
actioner
(
Actioner_Connection conn,
Actioner_Target targ,
Actioner_Aspect asp,
WEB_Action_Name action,
List((String,String)) extra_ops
) =
actioner(conn,targ,asp,action,extra_ops,[]).
public define HTML_Off_Form
actioner
(
Actioner_Connection conn,
Actioner_Target targ,
Actioner_Aspect asp,
WEB_Action_Name action,
List((String,String)) extra_ops,
String form_name
) =
actioner(conn,targ,asp,action,extra_ops,[], form_name).
public define HTML_Off_Form
actioner
(
Actioner_Aspect asp,
WEB_Action_Name action,
List((String,String)) extra_ops
) =
actioner(same, same, asp, action, extra_ops, []).
public define HTML_Off_Form
actioner
(
Actioner_Aspect asp,
WEB_Action_Name action,
List((String,String)) extra_ops,
String form_name
) =
actioner(same, same, asp, action, extra_ops, [], form_name).
public define HTML_Off_Form
/* Older call with String as action instead of WEB_Action_Name.
* This function exists only for compatibility with older project.
* Please condiser to use above function instead
*/
actioner
(
Actioner_Connection conn,
Actioner_Target targ,
Actioner_Aspect asp,
String action,
List((String,String)) extra_ops,
List(Actioner_Local_Action) local_actions
)=
actioner(conn,targ,asp,action_name(action),extra_ops,local_actions)
.
public define HTML_Off_Form
/* Older call with String as action instead of WEB_Action_Name.
* This function exists only for compatibility with older project.
* Please condiser to use above function instead
*/
actioner
(
Actioner_Connection conn,
Actioner_Target targ,
Actioner_Aspect asp,
String action,
List((String,String)) extra_ops,
List(Actioner_Local_Action) local_actions,
String form_name
)=
actioner(conn, targ, asp, action_name(action), extra_ops, local_actions, form_name)
.
public define HTML_Off_Form
/* Older call with String as action instead of WEB_Action_Name.
* This function exists only for compatibility with older project.
* Please condiser to use above function instead
*/
actioner
(
Actioner_Connection conn,
Actioner_Target targ,
Actioner_Aspect asp,
String action,
List((String,String)) extra_ops
)=
actioner(conn,targ,asp,action_name(action),extra_ops,[])
.
public define HTML_Off_Form
/* Older call with String as action instead of WEB_Action_Name.
* This function exists only for compatibility with older project.
* Please condiser to use above function instead
*/
actioner
(
Actioner_Connection conn,
Actioner_Target targ,
Actioner_Aspect asp,
String action,
List((String,String)) extra_ops,
String form_name
)=
actioner(conn, targ, asp, action_name(action), extra_ops, [], form_name)
.
public define HTML_Off_Form
table
(
List(HTML_Row(HTML_Off_Form)) rows
)=
table([], empty, rows,empty)
.
public define HTML_Off_Form
table
(
List(Table_Option) options,
List(HTML_Row(HTML_Off_Form)) rows
) =
table(options,empty,rows,empty)
.
public define HTML_Off_Form
table
(
Table_Option option,
HTML_Row(HTML_Off_Form) row
) =
table([option], empty, [row], empty)
.
public define HTML_Off_Form
table
(
HTML_Header_Row(HTML_Off_Form) h_row,
List(HTML_Row(HTML_Off_Form)) rows
) =
table([],h_row,rows,empty)
.
public define HTML_Off_Form
table
(
List(Table_Option) options,
HTML_Header_Row(HTML_Off_Form) h_row,
List(HTML_Row(HTML_Off_Form)) rows
) =
table(options,h_row,rows,empty)
.
public define HTML_Off_Form
table
(
Table_Option option,
HTML_Header_Row(HTML_Off_Form) h_row,
List(HTML_Row(HTML_Off_Form)) rows
) =
table([option], h_row, rows,empty)
.
We add two convenience functions for 'row'. The reason why we add two functions, one
for 'HTML_In_Form' and one for 'HTML_Off_Form', is that adding a schema with an
arbitrary '$T' creates too many ambiguities. This is due to the fact that, if we do so,
the arguments of the function do not refer to any of the types defined here.
public define HTML_Row(HTML_In_Form)
row
(
HTML_In_Form content
) =
row([],[cell([],content)]).
public define HTML_Row(HTML_Off_Form)
row
(
HTML_Off_Form content
) =
row([],[cell([],content)]).
public define HTML_Cell(HTML_Off_Form)
cells_to_column_in_cell
(
List(HTML_Cell(HTML_Off_Form)) cells
)=
cell(
table(
map( (HTML_Cell(HTML_Off_Form) current_cell) |-> row(current_cell), cells)
)).
public define HTML_Off_Form
cells_to_line
(
List(HTML_Off_Form) cells
)=
table([row(
map (((HTML_Off_Form) current_cell) |-> cell(current_cell), cells))])
.
public define HTML_Off_Form
private_download
(
String abs_path,
String name,
String extra_ext
) =
private_download(abs_path,name,extra_ext,failure).
public define HTML_Off_Form
private_download
(
String abs_path,
String name,
String extra_ext,
String action_name,
List((String,String)) args
) =
private_download(abs_path,name,extra_ext,success((action_name,args))).
.
public define HTML_In_Form
hr
=
hr([])
.
public define HTML_In_Form
button
(
List(HTML_In_Form) elements
)=
button([], elements)
.
public define HTML_In_Form
button
(
List(CoreAttrs) attrs,
HTML_In_Form element
)=
button(attrs, [element])
.
public define HTML_In_Form
button
(
HTML_In_Form element
)=
button([], [element])
.
- Cell a gap between two other cells :
public define HTML_Cell(HTML_Off_Form)
width_gap
(
Int w
)=
cell([width(w)], empty).
public define HTML_Cell(HTML_In_Form)
width_gap
(
Int w
)=
cell([width(w)],empty)
.
- Row a gap between two other rows :
public define HTML_Row(HTML_Off_Form)
height_gap
(
Int h
)=
row([],[cell([height(h)],empty)]).
public define HTML_Row(HTML_In_Form)
height_gap
(
Int h
)=
row([],[cell([height(h)],empty)])
.
Notice that the two types have alternatives in common (same name, same arguments types,
up to the value of the parameter $T), which correspond to elements which may be put
anywhere in the page.
public define HTML_Partial_Content
partial_content
(
List(HTML_Head_Tag) tags,
List(HTML_Off_Form) content
)=
partial_content(tags, sequence(content)).
public define HTML_Partial_Content
partial_content
(
HTML_Off_Form content
)=
partial_content([], content).
public define HTML_Partial_Content
partial_content
(
List(HTML_Off_Form) content
)=
partial_content([], sequence(content)).
public define HTML_Partial_Content
partial_content
(
List(HTML_Head_Tag) tags,
HTML_Partial_Content p_content
)=
if p_content is partial_content(ptags, html) then
partial_content(tags + ptags, html).
define HTML_Partial_Content
list_to_pcontent
(
List(HTML_Partial_Content) l_p_content,
List(HTML_Head_Tag) so_far_tags,
List(HTML_Off_Form) so_far_html
)=
if l_p_content is
{
[] then partial_content(so_far_tags, sequence(reverse(so_far_html))),
[h . t] then
//extract resurgent type and symbols of h
if h is partial_content(tags, html) then
list_to_pcontent(t, so_far_tags + tags, [html . so_far_html])
}.
public define HTML_Partial_Content
partial_content
(
List(HTML_Partial_Content) l_p_content
)=
list_to_pcontent(l_p_content, [], []).
public define HTML_Partial_Content
partial_empty
=
partial_content(empty)
.
define String
format
(
List(Text_Option) l
).
define Printable_tree
format_css_styles
(
List(CSS_Style) l
) =
if l is
{
[ ] then [ ],
[h . t] then
[ if h is
{
text_options(tos) then
[" body, span, p { ", format(tos), " }\n" ]
}
. format_css_styles(t)]
}.
Meta tags are put in the 'head' of the HTML page.
public define HTML_Meta
refresh
(
Actioner_Connection connection,
Actioner_Target target,
String action,
Int delay
)=
refresh(connection, target, action_name(action), delay)
.
public define HTTP_Answer
html_page
(
String title,
List(HTML_Meta) metas,
HTML_Body body
) =
html_page(http_ok, title,metas,[],[],[],[],body).
public define HTTP_Answer
html_page
(
String title,
List(HTML_Meta) metas,
List(CSS_Style) styles,
HTML_Body body
) =
html_page(http_ok, title, metas, styles, [], [], [], body).
public define HTTP_Answer
web_controller_error_page
(
String name
)
=
html_page
(
name+" Controller error", // title of web site
[], // list of 'META' tags (empty for this site)
body // body of page
(
// list of body options
[
background_color(rgb(255,200,200))
// add more body options here
],
// content of page
text(name+" Controller error")
)
)
.
'HTTP_Answer' represents the final product of the construction of a web page.
*** (3.2) ``in form'' versus ``off form''.
There is a variety of HTML elements: texts, buttons, links, forms, inputs, etc... Some
of them may have a content, which is yet another HTML element (or several). Hence, it
is meaningful to say that an element is 'within' another one. Now, putting any element
within any other one may be meaningless. For example, an input element must be put
within a form (otherwise, it is useless), and a from within another form has no precise
meaning (and is forbidden by the HTML specification).
Actually, the main criterium is ``within a form or not within a form''. So, HTML
elements in a given page are separated into two categories: those who are within a
form, and the others. Nevertheless, there are elements which may belong to both
categories, like images and texts. We want to make use of the strong typing mecanism of
Anubis in order to forbid non meaningful placement of elements.
The type 'HTML_In_Form' defines elements to be put within forms. Similarly,
'HTML_Off_Form' defines elements not to be put within forms. Both types are recursive,
and 'HTML_Off_Form' refers to 'HTML_In_Form' (via the 'form' alternative, of course),
but the two types are not cross recursive. This is the reason why it is impossible to
put a form within a form. In order to construct a web page, you essentially have to
produce a datum of type 'HTML_Off_Form' (maybe containing data of type 'HTML_In_Form').
In practice, you don't have to worry so much about these two types, because elements
which may be put anywhere are constructed for both types by functions with the same
name and the same arguments. Hence, for both types, you just write the same thing. You
are warned by the compiler only when you try to put an element at a place it is not
allowed.
*** (3.3) Defining your own style.
We provide generic tools for constructing HTML elements. However, your web site needs
to have a ``style''.
To that end, you need to write down a set of ``styling functions'', using the tools
defined here. These styling functions allow the introduction of your colors and other
visual characteristics into the constructed elements once and for all. For example, you
may want all your texts to be rendered in the ``Helvetica'' font, in size 14 and using
some 'text_color'. You may write something like this:
define RGB text_color = rgb(10,40,40).
define HTML_Off_Form
text
(
String the_text
) =
text([font("helvetica"),size(14),color(text_color)],
the_text).
(and the same one for type 'HTML_In_Form') so that in order to put a piece of text in a
page, you just write:
text("... some text ...")
and you don't have to provide the font, size and color for each text. If you want to
have several styles of text presentation, you just write several sets of such
convenience functions. This also suggests a trick. You may want for example different
colors for 'in form' texts and 'off form' texts. This may be achieved automatically by
defining two functions as above, with the same name and same argument type, but
returning either a 'HTML_In_Form' or a 'HTML_Off_Form'.
If this preliminary work is well done, you will not waste your time later when you
concentrate on the actual informational content of your pages.
This general principle should be applied to all sorts of elements. This is the best
thing to do in order to separate the functions defining the visual style from the
functions defining the informational content itself, so that changing the style without
changing the content becomes easy. This is also the best way for having a clean and
easily readable source for your web site.
*** (3.4) Actioners and forms.
We have gathered several notions from HTML into that of an 'actioner'. An actioner is
an HTML element which opens a connection to our server when clicked upon. Actioners may
have different visual aspects. They may look like hypertext links or like buttons
(rollovers), or even like selectors (with immediate action). In any case, their
behavior is the same: they open a connection to our server, and send a set of 'web
arguments', i.e. pairs 'name=value'. Among these web arguments, one of them denotes
the action to be performed, and the others should be considered as operands for this
action. Actually, the precise behavior of the actioner has several variants.
The connection with the server may be secured (HTTPS) or non secured (HTTP). See the
type 'Actioner_Connection' above.
You must also choose where the answer must be rendered. This may be in the same window
or in another window (or frame). If it is in another window, the name of that window
must be given. If the window does not exist, the browser will create it. Optionally,
you may give the dimensions of the new window and other characteristics. See the type
'Actioner_Target' above.
The actioner also has a visual aspect. See the type 'Actioner_Aspect' above. In the
case of a rollover button, you provide the URLs of two images (of the same size)
representing the button:
url_off: to be used when the mouse is not over the button,
url_on: to be used when the mouse is over the button.
You can also create rollover buttons without creating images. Just use the second
alternative named 'button'. The server creates the images automatically.
The purpose of forms is just to give operands to actioners. If the actioner is placed
within a form, all the input elements which are within this form provide operands to
the actioner (except sometimes when they are not set by the client). If it is not put
within a form, the actioner gets no operand, except if the name of a form is explicitly
given, in which case the actioner gets all the inputs from that form as
operands. Furthermore, you may want to give extra operands to the actioner. This may be
useful for separating families of actioners with the same action name. Extra operands
'name=value' must be given in the form of pairs '(name,value)'.
Notice that the name of a form may be used by an actioner which is off the form, so as
to get the operands provided by this form. Also notice that several actioners may refer
to the same form, being either in the form, or referring to the form from the
outside. These actioners simply get the same set of operands, even if they correspond
to distinct actions.
Input elements may be put only within a form.
*** (3.5) Local popup.
This element looks like a link or a rollover button. When this button is clicked upon,
a 'popup window' appears. Actually, this popup window is just a layer in the same HTML
page, which becomes suddenly visible. It is realized with a '<div>' HTML tag. In
particular, clicking on the button does not open any connection. This is why it is
called 'local'. The arguments have the following roles:
Actioner_Aspect aspect of the button (same semantics as for actioners)
content content of the popup window
x, y, position of the popup window on the HTML page (not relative
to the button but to the page itself)
title title of the popup window
color color of the title bar and close button in the popup window.
A lightened version of this color is used for the background
of the popup window.
width width of the title bar
--- That's all for the public part ! --------------------------------------------------
----------------------------------- Table of Contents ---------------------------------
*** [1] States.
*** [1.1] Saving and retrieving states.
*** [1.2] Deleting out of date states.
*** [2] Sessions.
*** [2.1] Saving and retrieving sessions.
*** [2.2] Deleting out of date sessions.
*** [3] Tools.
*** [3.1] Directories.
*** [3.2] Secondary documents.
*** [4] Managing web arguments.
*** [3.1] Prefixing web arguments names.
*** [3.2] Separating web arguments.
*** [3.3] Applying an action.
*** [5] Web site descriptions and the 'awp handlers'.
*** [4.1] The type 'Web_Site'.
*** [4.2] Making a web site description.
*** [4.3] Starting the servers.
*** [6] HTML Formating.
*** [5.1] The type 'HTML_Any($T)'.
*** [5.2] Formating a color.
*** [5.3] Creating buttons.
*** [5.4] Formating an actioner.
*** [5.5] Formating a private download link.
*** [5.6] Formating rows and cells in a table.
*** [5.7] Formating elements which may be put anywhere.
*** [5.8] Formating 'in form' elements.
*** [5.9] Formating 'off form' elements.
*** [5.10] Formating meta-tags.
---------------------------------------------------------------------------------------
public type CommonInfo:...
define Printable_tree
format
(
CommonInfo cinfo,
//String sn, // state_name
Var(Int) ic_v, // 'idnum' counter variable
HTML_Off_Form element,
Bool is_https,
Var(Int) action_count,
Var(List(HTML_Head_Tag)) head_tags
).
public define String
doctype_w3c_header
=
"<!DOCTYPE html>\n". //html 5
*** [1] States.
We have to define functions for saving a state, retrieving a state, deleting out of
date states. We need one such function per web site. The types of the first two
functions depend on the parameter $State. This is not the case of the third one. The
fact that the instance of $State is variable from one web sites to the other implies
rather subtle manipulations using full functionality.
*** [1.1] Saving and retrieving states.
Each state is saved into a file on the server's disk (in the directory represented by
the symbol 'state_directory', which is 'my_anubis/web_sites/common_name/states'). The
state is saved together with a time stamp whose value is obtained by adding the current
time to the given timeout for states. The state receives a name obtained by hashing
(using sha1) the content of the file itself, and then encoding the hash with
'web_arg_encode'. The name of the file into which the state is saved is the
concatenation of "s" and the name of the state.
read web_arg_encode.anubis
The tool below constructs the function which is able to save a state on the server's
disk.
define ($State s) -> String // the function constructed returns the name of the state
make_save_state_function
(
Int timeout,
String state_directory,
(LogLevel, String) -> One logger
)=
($State s) |->
with time_stamp = now+timeout,
to_be_saved = (time_stamp,s),
state_name = to_ascii(sha1(s)),
//println("make_save_state_function " + state_directory+"/s"+state_name);
if save(to_be_saved,state_directory+"/s"+state_name) is ok then
state_name
else
logger(logError, "Cannot create state file in '"+state_directory+"'.\n");
""
.
When a request arrives, we need to retrieve the previous state from the server's
disk. We receive the name of that state. If the state is out of date, the state file is
kept 3 days, and then deleted.
type PreviousState($State):
not_found, // cannot retrieve the previous state
out_of_date($State), // the previous state is out of date
still_valid($State). // the previous state is still valid
define (String state_name) -> PreviousState($State)
make_retrieve_state_function
(
String state_directory
) =
(String state_name) |->
with file_path = state_directory+"/s"+state_name,
if (RetrieveResult((Int,$State)))retrieve(file_path) is ok(d)
then (
if d is (time_stamp,s) then
if time_stamp < now
then (
forget(remove(file_path));
out_of_date(s)
)
else still_valid(s) // state has been successfully retrieved
)
else
forget(remove(file_path));
not_found.
*** [1.2] Deleting out of date states.
We also need to delete states which are out of date and which will never be deleted by
the above method. This may be performed by a machine doing this periodically (say once
per states life time period).
define (List(String) file_names) -> One
make_delete_out_of_date_states_function
(
Maybe($State) dummy,
String state_directory
) =
(List(String) file_names) |-df->
if file_names is
{
[ ] then unique,
[h . t] then
with file_path = state_directory+"/"+h,
if (RetrieveResult((Int,$State)))retrieve(file_path) is ok(d)
then (
if d is (time_stamp,data) then
if time_stamp < now
then (forget(remove(file_path)); df(t))
else df(t)
)
else (forget(remove(file_path)); df(t))
}.
The 'labelled arrow' |-df-> is documented in 'documentation/en/anubis_doc.txt'.
Note: The argument 'dummy' (of type Maybe($State)) is not used in the body of the
function (hence its name). Nevertheless, it is required. Indeed, the Anubis compiler
does not accept a parameter in the body of a function (here the parameter is required
by the use of 'retrieve') if this parameter does not appear in the type of the
function. This is because this would create ambiguities that no explicit typing may
ever resolve. If you put a double slash in front of the declaration of 'dummy' above,
and if you compile this file, you will get a message like this one:
Error in 'making_a_web_site.anubis', line 1300, column 7:
A definition may not contain parameters which are not present
in the declaration part (hidden parameters):
$State
The type of the function constructed by 'make_delete_out_of_date_states_function' is
independant of the parameter $State. This is important because this allows to create
the list of such functions for all web sites. From this list, it is possible to call
the functions one after the other, so deleting out of date states for all web
sites. Actually, the next function receives a list of pairs (state_directory,function),
one for each web site.
define One
delete_out_of_date_states // for all web sites
(
List((String, List(String) -> One)) directories_and_functions
) =
if directories_and_functions is
{
[ ] then unique,
[h . t] then if h is (state_directory,function) then
function(directory_list(state_directory,"*"));
delete_out_of_date_states(t)
}.
The above function must be called periodically in a separate virtual machine. The
period we have choosen is (rather logically) the life time of states itself. This may
be achieved by an 'infinite' loop, using a 'sleep(timeout)'. However, the loop must not
be really infinite, because the servers may be shutdown. Hence, our loop must test
(rather frequently; say every second) if the servers are down. If they are, the loop
must be exited.
define One
delete_states_loop
(
List((String,List(String) -> One)) directories_and_functions,
Int timeout,
Int next_time,
Server http_server,
Server https_server,
(One) -> Bool shutdown_required
) =
if shutdown_required(unique)
then (shutdown(http_server); shutdown(https_server))
else unique;
if (is_down(http_server) & is_down(https_server))
then unique
else if now > next_time
then
(
delete_out_of_date_states(directories_and_functions);
delete_states_loop(directories_and_functions,
timeout,
now+timeout,
http_server,
https_server,
shutdown_required)
)
else
(
sleep(1000); // sleep just one second and try again
delete_states_loop(directories_and_functions,
timeout,
next_time,
http_server,
https_server,
shutdown_required)
).
The above loop must be run in a separate virtual machine. This will be done just after
the two servers are started.
*** [2] Tools.
*** [2.1] Directories.
We need a tool for creating directories (if needed).
(This tool has been moved to 'tools/basis.anubis').
*** [2.2] Secondary documents.
Some HTML elements (like '<object>', '<frame>') cannot receive their content directly
from the current document, but only through an URL. For this reason, we implement a
mecanism for creating secondary documents on the fly. To that end we use the 'private
download' mecanism.
A secondary document is formated by the same functions as the main document itself. The
next function takes an 'off form' element, creates the file containing the secondary
document in HTML format, and returns the URL at which the document will be available.
define String
create_secondary_document
(
String sd, // site directory
String as, // authorization_secret
$T -> Printable_tree format_element,
$T content,
HTML_Size width
) =
with private_download_directory = sd+"/private_download",
hash = web_arg_encode(sha1(content)),
file_content = (Printable_tree)
[doctype_w3c_header,
"<html><body><table ",
if width is
{
absolute(w) then ["width=\"",w-25],
percentage(w) then ["width=\"95%\""]
},"\"><tbody><tr><td align=right>",
format_element(content),
"</td></tr></tbody></table></body></html>"
],
file_name = "sd"+hash+".html",
file_path = private_download_directory+"/"+file_name,
if write_to_file(file_path,file_content) is
{
cannot_open_file then print("Cannot open file '"+file_path+"'.\n"); "",
write_error(n) then print("Error writing file '"+file_path+"'.\n"); "",
ok then file_name+"?zauth="+
make_authorization(sd,as,private_download_directory+"/"+file_name)
}.
*** [2.3] Generating unique ids.
In order to uniquely name object for JavaScript we generate unique ids from a counter.
define Int
new_idnum
(
Var(Int) ic_v // 'idnum' counter variable
) =
protect
with result = *ic_v+1,
ic_v <- result;
result.
*** [3] Managing web arguments.
Web arguments are those pairs 'name=value' which are transmitted through the HTTP
protocol. We need precise naming conventions for these web arguments.
*** [3.2] Separating web arguments.
When a new request arrives, we need to separate the web arguments, that is to say:
- find the value of "s", and recover the corresponding state,
- find the value of "a", which is the name of the action to be performed,
- get the list of all the remaining web arguments (operands of the action).
We must also determine if the previous state may be recovered. If it is not the case
(either because the previous state name is invalid, or the previous state is out of
date), we must check if there is an action name. Indeed, the presence of an action name
indicates that the user has clicked on one of our buttons or links. If on the contrary
there is no action name the user has just entered our address in his browser. In this
last case, we must send the first page of our site (maybe a 'login' page), but if there
is an action, we must send a page just saying that the session ticket has expired. If
the previous state is recovered and there is no action, the new state is the same as
the previous state.
The result of the separation of the web arguments is of type:
type Separated_Web_Args($State):
swa(PreviousState($State) previous_state,
Maybe(String) action_name,
List(Web_arg) operands).
The next function constructs the function which separates the web arguments.
define (List(Web_arg) lwa, HTTP_Info info) -> Separated_Web_Args($State)
make_separate_web_args_function
(
String state_directory,
String -> PreviousState($State) retrieve_state,
String website_name
) =
(List(Web_arg) lwa, HTTP_Info info) |-swaf->
if lwa is
{
[ ] then
//
// no web arg found => no previous state and no action
//
//println("find_cookie(\"state_"+website_name+"\", ...");
if find_cookie("state_"+website_name, server_get_cookies(http_headers(info))) is
{
failure then
//println("find_cookie(\"state_"+website_name+"\" failure");
swa(not_found,failure,[]),
success(cookie) then
//println("find_cookie(\"state_"+website_name+"\" success");
swa(retrieve_state(value(cookie)),failure,[])
},
//swa(failure,failure,[]),
[wa_1 . wa_others] then
//
// at least one web arg =>
// separate other web args, and insert the first one as needed
//
if (Separated_Web_Args($State))swaf(wa_others, info) is
{
swa(ps1, // possible previous state
an1, // maybe an action name
op1) // operands so far
then
if wa_1 is
{
web_arg(n, value) then
with name = if substr(n,0,4) = "amp;" then substr(n, 4, length(n) - 4) else n,
if name = "a" then
swa(ps1,success(value),op1)
else if name = "aws_action" | name = "aws_a" then
swa(ps1,success(value),op1)
//else if name = "t" then
// swa(ps1,an1,[web_arg("target",value) . op1])
else
swa(ps1,an1,[web_arg(name,value) . op1]),
upload(n,v,t) then
swa(ps1,an1,[wa_1 . op1])
}
}
}.
*** [3.3] Applying an action.
When the web arguments are separated (and their names cleaned up from prefixes), we may
apply the action to the operands and the current state. We search for the action to be
applied in the list of actions. If no action is found, the new state is the same as
the previous state. Also, we deny the application of an HTTP action if the request
arrives through the HTTPS channel and conversely.
define ($State previous,
String action_name,
HTTP_Info http_info,
List(Web_arg) lwa,
Bool is_https) -> $State
make_apply_action_function
(
List(Web_Action($State)) actions_list,
(LogLevel, String) -> One logger //logger
)=
with f =
($State previous,
String action_name,
HTTP_Info http_info,
List(Web_arg) lwa,
Bool is_https,
List(Web_Action($State)) actions) |-f->
//println("Looking for action ["+action_name+"]");
if actions is
{
[ ] then
logger(logError, "action '"+action_name+"' not found.\n"); previous,
[ac1 . others] then if ac1 is
{
//check for http action
http_action(an, allow, do_it) then
//Action name found
if an = action_name then
if is_https then
(logger(logError, "HTTP action '"+an+"' called through HTTPS (denied).\n"); previous)
else
if allow(previous) then
do_it(http_info,lwa,previous)
else
previous
else
f(previous,action_name,http_info,lwa,is_https,others),
//check https action
https_action(an,allow,do_it) then
if an = action_name
then if is_https
then if allow(previous)
then do_it(http_info,lwa,previous)
else previous
else (logger(logError, "HTTPS action '"+an+"' called through HTTP (denied).\n");
previous)
else f(previous,action_name,http_info,lwa,is_https,others),
http_https_action(an,allow,do_it) then
if an = action_name then
println("Action ["+action_name+"] found");
if allow(previous)
then do_it(http_info,lwa,previous)
else
println("user not allowed to execute that Action ["+action_name+"]");
previous
else f(previous,action_name,http_info,lwa,is_https,others),
}
},
($State previous,
String action_name,
HTTP_Info http_info,
List(Web_arg) lwa,
Bool is_https) |->
f(previous, action_name, http_info, lwa, is_https, actions_list).
*** [4] Web site descriptions and the 'awp handlers'.
*** [4.1] The type 'Web_Site'.
The type 'Web_Site_Description' is defined in 'web/multihost_http_server.anubis'. We
need another one, because, we have some extra informations to record for each site.
public type Web_Site:
web_site((Word32,Word32) -> Web_Site_Description description,
List(String) -> One delete_out_of_date).
*** [4.2] Making a web site description.
Below is the function which creates a web site description. It first creates (if
needed) the directories for the site, then constructs the tool functions for the site,
and the site handler. Finally, it constructs the web site description.
We gather common (constant) informations in the following type:
public type CommonInfo:
info(String common_name,
Word32 http_port,
Word32 https_port,
String site_directory,
String authorization_secret
).
We need a forward declaration.
public define AWP_Handler_Answer
format
(
CommonInfo cinfo,
List(HTTP_header) headers,
HTTP_Answer page,
Bool is_https,
String charset
).
define Printable_tree
format
(
HTML_Size s
) =
if s is
{
absolute(x) then ["\"",x,"\""],
percentage(x) then ["\"",x,"%\""]
}.
define List(HTTP_header)
make_state_cookie_headers
(
String website_name,
String state_name
)
=
//println("Set-Cookie state_"+website_name+"="+state_name);
[
http_header("Set-Cookie", "state_"+website_name+"="+state_name)
]
.
public define Web_Site
make_web_site_description
(
String website_name, // site_UID
List(String) common_names, // for example: ["www.our-business.com"]
String site_directory,
String state_directory,
One -> One init,
(HTTP_Info,
List(Web_arg),
Bool is_https) -> $State initial_state,
($State expired,
Maybe(String),
HTTP_Info,
List(Web_arg),
Bool is_https) -> $State ticket_expired_state,
(Maybe(String),
HTTP_Info,
List(Web_arg),
Bool is_https) -> $State ticket_lost_state,
List(Web_Action($State)) actions,
$State -> HTTP_Answer compute_page,
$State -> List(HTTP_header) additional_headers,
List(HTTP_header) constant_additional_headers,
Int timeout,
Redirections redirections,
String charset,
List(String) journal_extensions,
List(String) journal_headers,
(LogLevel, String) -> One logger, //logger
String secret,
List(MIME) known_mime_types,
(String action_name,
List(Web_arg) args) -> One before_send_file
)=
init(unique);
//
// make required directories (if needed)
//
with //web_sites_directory = (String) make_directory(my_anubis_directory+"/web_sites"),
base_directory = (String) make_directory(site_directory),
// state_directory = make_directory(site_directory+"/states"),
forget((String)make_directory(site_directory+"/public"));
//
// construct tool functions
// TODO 'make_separate_web_args_function' must retrieve state_cookies before parsing web_args if using_state_cookies is true
with save_state = make_save_state_function(timeout, state_directory, logger),
retrieve_state = make_retrieve_state_function(state_directory),
separate_web_args = make_separate_web_args_function(state_directory, retrieve_state, website_name),
apply_action = make_apply_action_function(actions, logger),
//
// construct the site handler
//
site_handler = (Word32 http_port, Word32 https_port) |->
((String host_name,
HTTP_Info http_info,
List(Web_arg) lwa,
Bool is_https) |->
//println(dump_web_arg_values(lwa));
since separate_web_args(lwa, http_info) is swa(mb_previous_state, mb_action_name, operands),
with new_state = if mb_previous_state is
{
not_found then
//println("previous state not found");
if mb_action_name is
{
failure then initial_state(http_info, operands, is_https),
success(_) then
ticket_lost_state(mb_action_name, http_info,operands,is_https)
},
out_of_date(state) then
//println("previous out_of_date");
ticket_expired_state(state, mb_action_name, http_info,operands,is_https),
still_valid(state) then
//println("previous still_valid");
if mb_action_name is
{
failure then state,
success(action_name) then
apply_action(state,action_name,http_info,operands,is_https)
}
},
//if state_and_headers is (session_ticket, mb_new_state, headers) then
with state_name = save_state(new_state),
//println("Cookie new STATE NAME "+state_name);
with cookie_headers = if mb_action_name is
{
failure then
make_state_cookie_headers(website_name, state_name),
success(action_name) then
if action_name = "none" then
[]
else if substr(action_name, 0, 5)="ajax_" then
[]
else
make_state_cookie_headers(website_name, state_name)
},
format(info(host_name, http_port, https_port, site_directory, secret),
additional_headers(new_state) + cookie_headers,
compute_page(new_state),
is_https,
charset)
),
//
// make the delete_out_of_date function
//
delete_out_of_date =
make_delete_out_of_date_states_function((Maybe($State))failure,
site_directory+"/states"),
//
// construct the web site description
//
web_site((Word32 http_port, Word32 https_port) |->
web_site_description(common_names,
site_directory,
redirections,
charset,
journal_extensions,
journal_headers,
logger,
secret,
known_mime_types,
site_handler(http_port, https_port),
constant_additional_headers,
(HTTP_Info http_info, List(Web_arg) lwa) |-> if separate_web_args(lwa, http_info ) is
swa(mb_previous_state,mb_action_name,operands) then
if mb_action_name is
{
failure then unique
success(an) then before_send_file(an,operands)
}
//using_state_cookies
),
delete_out_of_date).
public type WEB_Controller:
web_controller(
String name, //controller name
(HTTP_Info http_info,
List(Web_arg) lwa,
Bool is_https
) -> HTTP_Answer view //view renderer
)
public define JsonValue to_html_ajax_content(Printable_tree content_HTML, String additional_script).
public define JsonValue to_html_ajax_content(HTML_Partial_Content content_HTML, CommonInfo cinfo, String additional_script).
define String
get_site_uid
(
String site_path,
(LogLevel, String) -> One logger //logger
)=
with file_name = site_path+"/site_UID",
if read_from_file(file_name) is
{
cannot_find_file then
logger(logInfo,"site UID doesn't exists. Generating one now");
with uid = generate_random_string(9),
if write_to_file(file_name, to_byte_array(uid)) is
{
cannot_open_file then logger(logError, "Can't create site UID here "+file_name);"",
write_error(_) then logger(logError, "Can't write site UID here "+file_name);"",
ok then uid
}
read_error(_) then
logger(logError, "cannot read site UID from "+file_name);""
ok(ba) then to_string(ba)
}
.
// Compatibility function for older websites
public define Web_Site
make_web_site_description
(
List(String) common_names, // for example: ["www.our-business.com"]
String site_directory,
String state_directory,
One -> One init,
(HTTP_Info,
List(Web_arg),
Bool is_https) -> $State initial_state,
($State expired,
Maybe(String),
HTTP_Info,
List(Web_arg),
Bool is_https) -> $State ticket_expired_state,
(Maybe(String),
HTTP_Info,
List(Web_arg),
Bool is_https) -> $State ticket_lost_state,
List(Web_Action($State)) actions,
$State -> HTTP_Answer compute_page,
$State -> List(HTTP_header) additional_headers,
List(HTTP_header) constant_additional_headers,
Int timeout,
Redirections redirections,
String charset,
List(String) journal_extensions,
List(String) journal_headers,
(LogLevel, String) -> One logger, //logger
String secret,
List(MIME) known_mime_types,
(String action_name,
List(Web_arg) args) -> One before_send_file
//Bool using_state_cookies
)
=
//generate an unique ID if doesn't exist in root of site_directory
with site_UID = get_site_uid(site_directory, logger),
make_web_site_description(site_UID, common_names, site_directory, state_directory, init, initial_state, ticket_expired_state, ticket_lost_state, actions, compute_page, additional_headers, constant_additional_headers, timeout, redirections, charset, journal_extensions, journal_headers, logger, secret, known_mime_types, before_send_file)
.
*** [4.3] Starting the servers.
public define Start_Web_Sites_Result
start_web_sites
(
Word32 ip_address, // the IP address shared by the web sites
Word32 http_port, // usually: 80
Word32 https_port, // usually: 443
String ssl_certificate_common_name,
List(Web_Site) web_sites, // web sites to be started
(One) -> Bool shutdown_required
) =
with get_description = (Web_Site ws) |-> description(ws)(http_port,https_port),
with http_server_r =
start_http_server(ip_address,http_port,
map(get_description,web_sites),
//load_denial_of_service_info,
shutdown_required),
with https_server_r =
start_https_server(ip_address,https_port,
ssl_certificate_common_name,
map(get_description,web_sites),
shutdown_required),
if http_server_r is ok(http_server)
then
(
if https_server_r is ok(https_server)
then
(
start_http_servers_tasks(map(get_description,web_sites),
[http_server,https_server],
600); // period of 10 minutes
delegate
delete_states_loop(
map((Web_Site ws) |->
(site_directory(description(ws)(http_port,https_port))+
"/states",delete_out_of_date(ws)),
web_sites),
3600*24*3, // keep out of date states 3 days
now,
http_server,
https_server,
shutdown_required),
ok(http_server,https_server)
)
else cannot_bind_to_port(https_port)
)
else
(
if https_server_r is ok(https_server)
then cannot_bind_to_port(http_port)
else cannot_bind_to_port(http_port,https_port)
).
public define One
start_web_sites
(
Word32 ip_address, // the IP address shared by the web sites
Word32 http_port, // usually: 80
Word32 https_port, // usually: 443
String ssl_certificate_common_name,
List(Web_Site) web_sites, // web sites to be started
(One) -> Bool shutdown_required,
(LogLevel, String) -> One logger //logger where to report the error
)=
if (Start_Web_Sites_Result)start_web_sites(ip_address,
http_port,
https_port,
ssl_certificate_common_name,
web_sites,
shutdown_required) is
{
cannot_bind_to_port(n) then logger(logError, "Cannot bind to port: "+n),
cannot_bind_to_port(n,m) then logger(logError, "Cannot bind to ports: "+n+", "+m),
ok(s1,s2) then logger(logInfo, "Servers started on ports "+http_port+" (HTTP) and "+https_port+" (HTTPS).")
}.
*** [5] HTML Formating.
We need to translate HTML elements as defined above into actual HTML text.
Actioners require special informations, which must be transmitted when needed by the
'format' functions:
- the 'common name', which is used for URLs,
- the HTTP/HTTPS port number,
- the 'state name', which must be transmitted when the actioner is clicked upon,
- the 'form name' (if any) to which the actioner refers.
If the actioner is off form, and if it refers to a form, the name of that form is
already known by the actioner. On the contrary, if the actioner is 'in form', it refers
implicitly to the form containing it. The name of that form is transmitted to the
'format' functions called from within the formating of that form.
*** [5.1] The type 'HTML_Any($T)'.
The type 'HTML_Any($T)' gathers elements which may be put anywhere in the page. The
parameter $T becomes either 'HTML_Off_Form' or 'HTML_In_Form'.
type HTML_Any($T):
any_text (List(CoreAttrs), String the_text),
any_preformated (List(Text_Option), String),
any_paragraph (List(Text_Option), List($T) content),
any_image (List(CoreAttrs), String url, String alternate),
any_image (List(CoreAttrs), String url, String alternate, Int width, Int height),
any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T)), HTML_Footer_Row($T)),
any_center ($T),
any_mail_to (String email, $T element),
any_scroller (Int width, Int height,
Int content_width, Int content_height,
$T content),
any_fixed_size (HTML_Size width, HTML_Size height, $T content),
any_fixed_size_2 (HTML_Size width, HTML_Size height, String name_of_HTML_file),
any_actioner (Actioner_Connection,
Actioner_Target,
Actioner_Aspect,
WEB_Action_Name action,
List((String,String)) extra_ops,
List(Actioner_Local_Action),
Maybe(String) form_name),
any_foreign_link_new (Actioner_Target, Actioner_Aspect, String url),
any_foreign_link (List(Text_Option), String url),
any_foreign_link (List(Text_Option), String url, String name),
any_private_download (String abs_path, String name, String extra_ext,
Maybe((String,List((String,String))))),
any_div (List(CoreAttrs), List($T) element),
any_div_empty (List(CoreAttrs)),
any_coreattrs (List(CoreAttrs)),
any_ol (List(CoreAttrs), List($T) content),
any_ul (List(CoreAttrs), List($T) content),
any_li (List(CoreAttrs), List($T) content),
any_button (List(CoreAttrs), List($T) element),
any_i (List(CoreAttrs), String text),
any_span (List(CoreAttrs), String text),
any_hr (List(CoreAttrs))
.
*** [5.2] Formating a color.
RGB colors are formatted as '#rrggbb' where rr, gg and bb are two characters
hexadecimal values.
define String
html_format
(
RGB color
) =
if color is rgb(r,g,b) then
"#" + to_hexa(r)
+ to_hexa(g)
+ to_hexa(b).
The following is a very arbitrary definition of the opposite color. The thing which is
important is that it is far from the original, so that characters in 'opposite' color
are clearly visible over the original.
define RGB
opposite
(
RGB color
) =
if color is rgb(r,g,b) then
rgb(255-r,
255-g,
255-b).
Converting RGB to RGBA.
define RGBA
to_rgba
(
RGB color
) =
if color is rgb(r,g,b) then rgba(r,g,b,255).
*** [5.4] Formating an actioner.
An actioner works as follows. Assume first that it refers to a form. When it is clicked
upon, the actioner puts (via 'onMouseDown') the URL into the 'action' attribute of the
form, and submits the form, using the JavaScript command 'form_name.submit()'. If the
actioner does not refer to a form, it fires the URL directly via 'href', because in
that case, the actioner is always an <a> tag.
The URL itself is composed using the connection sort (same, http or https), the common
name and port number (if needed), the state name, the action name, and the extra
operands, which are put into a query string. It may look like this:
http://common_name:port/?s=state_name&a=action_name&oname=value...
Each extra operand is a pair of strings: (name,value). It is formated as:
&oname=value
public define String
format_attrs
(
List(CoreAttrs) attributs
).
//public define String
// format_extra_operands
// (
// List((String,String)) l
// ) =
// if l is
// {
// [ ] then "",
// [h . t] then if h is (n,v) then
// "&"+n+"="+v+format_extra_operands(t)
// }
//.
It seams that the standard requires "&" instead of "&" !
In case the target is another window, we need to format the options for this window.
define String
format
(
List(Other_Window_Option) l
) =
if l is
{
[ ] then "",
[h . t] then if h is
{
resizable then "resizable",
scrollbars then "scrollbars",
width(w) then "width="+w,
height(h2) then "height="+h2
} + if t is [ ] then "" else (","+format(t))
}
.
Formating choices for a <select> tag.
public define Printable_tree
format_choices
(
List(String) l
) =
if l is
{
[ ] then [ ],
[h . t] then ["<option>", h, "</option>\n" . format_choices(t)]
}.
public define Printable_tree
format_choices
(
List(String) l,
InitialValue selected
) =
if l is
{
[ ] then [ ],
[h . t] then if h = selected.value
then ["<option selected=\"selected\">", h, "</option>\n" . format_choices(t)]
else ["<option>", h, "</option>\n" . format_choices(t,selected)]
}.
public define Printable_tree
format_choices
(
List((List(CoreAttrs),WebArgValue,String)) l
) =
if l is
{
[ ] then [ ],
[h . t] then
if h is (attrs,val,item)
then ["<option value=\""+encode_HTML_entities(val.value)+"\" "+format_attrs(attrs)+">", item, "</option>\n" . format_choices(t)]
}.
public define Printable_tree
format_choices
(
List((List(CoreAttrs),WebArgValue,String)) l,
InitialValue selected
) =
if l is
{
[ ] then [ ],
[h . t] then
if h is (attrs,val,item) then
if val.value = selected.value
then ["<option value=\""+encode_HTML_entities(val.value)+"\" "+format_attrs(attrs)+" selected=\"selected\">", item, "</option>\n" . format_choices(t)]
else ["<option value=\""+encode_HTML_entities(val.value)+"\" "+format_attrs(attrs)+" >", item, "</option>\n" . format_choices(t,selected)]
}.
Note: this counter is private to the virtual machine, hence there is one counter by
client and by page : it seems that a new VM (simply a delegate) is started for each request.
define Int
new_count
(
Var(Int) count
)
=
count <- *count+1;
*count.
The next function composes the URL. It is a JavaScript URL when the target is another
window.
//public define String
// format_web_action_name
// (
// WEB_Action_Name action
// )=
// if action is
// {
// no_action then "",
// controller_action(controller, action_name) then "?aws_controller="+controller+"&aws_action="+action_name,
// action_name(action_name) then "?aws_action="+action_name,
// url(url) then url
// }
//.
//
//public define String
// format_web_action_name
// (
// WEB_Action_Name action,
// List((String,String)) extra_ops,
// )=
// format_web_action_name(action)
// +
// format_extra_operands(extra_ops)
//.
define String
make_actioner_url
(
CommonInfo cinfo,
Actioner_Connection connection,
Actioner_Target target,
WEB_Action_Name action,
List((String,String)) extra_ops,
Bool is_https
) =
if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
with strict_url =
if connection is
{
same then "/",
http then
if http_port = 80 then
"http://"+common_name+"/"
else
"http://"+common_name+":"+http_port+"/",
https then
if https_port = 443 then
"https://"+common_name+"/"
else
"https://"+common_name+":"+https_port+"/",
} +
//with action_string =
format_web_action_name(action, extra_ops),
if target is
{
same then strict_url,
same(label) then strict_url+"#"+label,
other(wn,ops) then
"javascript:void window.open('"+strict_url+"&t="+wn+"','"+
"w"+to_ascii(sha1(wn))+"','"+format(ops)+"')"
}.
define String
make_foreign_link_url
(
Actioner_Target target,
String url
) =
if target is
{
same then "/",
same(label) then "/#"+label,
other(wn,ops) then
"javascript:void window.open('"+url+"','"+
"w"+to_ascii(sha1(wn))+"','"+format(ops)+"')"
}.
Depending on the fact that the actioner refers to a form or not, the URL is used in two
different ways. If the actioner does not refer to a form, it is realized by a '<a>'
tag, with a 'href' attribute. If it refers to a form, it is still realized by a '<a>'
tag, but with no href attribute. In this case, we use the 'onMouseDown' or 'onChange'
event handler. The handler calls a JavaScript function which puts the URL as the value
of the 'action' attribute of the form, and submits the form.
type URL_or_JavaScript:
url (String),
javascript (Printable_tree script, Printable_tree handler).
It was as shown below, in order to allow submission of a form from outside the form,
but this makes problems:
define URL_or_JavaScript
format_action
(
String the_url,
Actioner_Aspect aspect,
Maybe(String) mb_id,
Maybe(String) mb_form_name,
Var(Int) action_count
) =
if mb_form_name is
{
failure then
url(the_url),
success(form_name) then
with n = new_count(action_count),
fn_name = "pfu_" + if mb_id is
{
failure then form_name + "_" + n,
success(id) then id,
},
javascript(
[
"<script type=\"text/javascript\" language =\"JavaScript\">\n",
"function ", fn_name, "() {\n",
" var fa = document.forms.",form_name,";\n",
" var u = \"",the_url,"\";\n",
" fa.action = u;",
if aspect is submit(_, _) then " }\n"
else "\n fa.submit(); }\n",
"</script>\n"
],
[fn_name,"();"]
)
}.
Now, we format the actioner according to its aspect.
define List(Text_Option)
get_text_options
(
List(Text_Option) l
)
=
if l is
{
[] then [],
[h . t ] then
if h is class(_) then
get_text_options(t)
else if h is id(_) then
get_text_options(t)
else if h is style(_) then
get_text_options(t)
else if h is title(_) then
get_text_options(t)
else if h is core_attrs(_) then
get_text_options(t)
else
[ h . get_text_options(t) ]
}.
/**
* Extract the CSS class list from the list of Text_Option
*/
define List(CoreAttrs)
get_css_class
(
List(Text_Option) l
)
=
if l is
{
[] then [],
[h . t ] then
if h is class(name) then
[ class(name) . get_css_class(t) ]
else if h is id(name) then
[ id(name) . get_css_class(t) ]
else if h is style(the_style) then
[ style(the_style) . get_css_class(t) ]
else if h is title(name) then
[ tooltip(name) . get_css_class(t) ]
else if h is attr(name, value) then
[ attr(name, value) . get_css_class(t) ]
else
get_css_class(t)
}
.
define List(CoreAttrs)
get_core_attrs
(
List(Text_Option) l
)
=
if l is
{
[] then [],
[h . t ] then
if h is core_attrs(attrs) then
attrs + get_core_attrs(t)
else
get_core_attrs(t)
}
.
define Printable_tree
format
(
List(Actioner_Local_Action) l
) =
if l is
{
[ ] then [ ],
[h . t] then [if h is
{
close_window then [" window.close(); "]
}
. format(t)]
}.
define String
format_attrs
(
List(InputAttrs) attributs,
List(String) classes,
List(String) styles
)=
if attributs is
{
[] then
if length(classes) = 0 then "" else " class=\""+join(" ",classes)+"\""+
if length(styles) = 0 then "" else " style=\""+join(";",styles)+"\"",
[h . t] then
with new_classes = if h is class(class_name) then [class_name. classes] else classes,
new_styles = if h is style(style_string) then [style_string . styles] else styles,
current = if h is
{
id(id_name) then
" id=\"" + id_name + "\"",
class(class_name) then "",
style(style_string) then "",
title(title_string) then
" title=\"" + title_string + "\"",
lang(lang) then
" xml:lang=" + lang,
dir(reading_Way) then
if reading_Way is
{
ltr then " dir=ltr",
rtl then " dir=rtl"
},
accesskey(key) then
" accesskey=\"" + key + "\"",
tabindex(index) then
" tabindex=\"" + index + "\"",
attr(name, value) then
" " + name + "=\"" + value + "\"",
event(e, value) then
" " + event_name(e) + "=\"" + value + "\"",
data(name, value) then
" data-" + to_lower(name) + "=\"" + value + "\"",
},
current + format_attrs(t, classes, styles)
}.
public define List(CoreAttrs) extract_attributes(HTML_tooltip htt).
define String
format_attrs
(
List(CoreAttrs) attributs,
List(String) classes,
List(String) styles
)=
if attributs is
{
[] then
(if length(classes) = 0 then "" else " class=\""+join(" ",classes)+"\"")+
if length(styles) = 0 then "" else " style=\""+join(";",styles)+"\"",
[h . t] then
with new_classes = if h is class(class_name) then [class_name. classes] else classes,
new_styles = if h is style(style_string) then [style_string . styles] else styles,
new_attrs = if h is tooltip(tt) then extract_attributes(tt) else [],
current = if h is
{
empty then "",
id(id_name) then
" id=\"" + id_name + "\"",
class(class_name) then "", //do nothing here, because we accumulate the class until we have some other attributes
style(style_string) then "", //do nothing here, because we accumulate the style until we have some other attributes
title(title_string) then
" title=\"" + title_string + "\"",
lang(lang) then
" xml:lang=" + lang,
dir(reading_Way) then
if reading_Way is
{
ltr then " dir=ltr",
rtl then " dir=rtl"
},
accesskey(key) then
" accesskey=\"" + key + "\"",
tabindex(index) then
" tabindex=\"" + index + "\"",
attr(name, value) then
" " + name + "=\"" + value + "\"",
bool_attr(bool, value)then
if bool then " "+value+" " else "",
event(e, value) then
" " + event_name(e) + "=\"" + value + "\"",
tooltip(_) then "", //do nothing here, because we extract attributes at first in new_attrs
data(name, value) then
" data-" + to_lower(name) + "=\"" + value + "\"",
contenteditable(value)then //boolean value
" contenteditable=\""+ to_String(value)+ "\""
contextmenu(id_name) then //ID value
" contextmenu=\"" + id_name + "\"",
draggable(value) then //boolean value
" draggable=\""+ to_String(value)+ "\""
hidden(value) then //boolean value
" hidden=\""+ (if value then "hidden" else "") + "\""
spellcheck(value) then //boolean value
" spellcheck=\""+ to_String(value)+ "\""
},
current + format_attrs(t + new_attrs, new_classes, new_styles)
}.
define String
format_attrs
(
List(InputAttrs) attributs
)=
format_attrs(attributs, [], []).
public define String
format_attrs
(
List(CoreAttrs) attributs
)=
format_attrs(attributs, [], []).
define String
format_text_options
(
List(Text_Option) l
)
=
with text_options = get_text_options(l),
core_attrs = get_css_class(l) + get_core_attrs(l),
(if length(text_options)= 0 then "" else " style=\"" + format(text_options) + "\" ")
+
(if length(core_attrs) = 0 then "" else format_attrs(core_attrs))
.
define Printable_tree
format_div_option
(
List(CoreAttrs) options
)=
["<div" + format_attrs(options) + ">"]
.
define Maybe(String)
extract_id
(
List(CoreAttrs) attrbs
) =
if attrbs is
{
[] then failure,
[h . t] then
if h is id(value) then success(value)
else extract_id(t)
}
.
define Maybe(String)
extract_id
(
Actioner_Aspect aspect
) =
if aspect is
{
link(_,_,_) then failure,
img_link(_,_,_) then failure,
push_button(opts,_) then extract_id(opts),
button(_,_) then failure,
button(_,_,_,_) then failure,
submit(opts,_) then extract_id(opts),
//immediate_selector(_,_,_,_) then failure,
immediate_selector(_,_,_,_,_,_) then failure,
html(_, _) then failure,
}.
to do Complete format_foreign_link
//TODO Complete format_foreign_link
CommonInfo cinfo,
String state_name,
Var(Int) action_count,
Var(Int) ic_v // 'idnum' counter variable
define Printable_tree
format_foreign_link
(
// CommonInfo cinfo,
Actioner_Target target,
Actioner_Aspect aspect,
String url,
Bool is_https,
CommonInfo cinfo,
// String state_name,
Var(Int) action_count,
Var(Int) ic_v, // 'idnum' counter variable
Var(List(HTML_Head_Tag)) head_tags
) =
//if cinfo is info(common_name,http_port,https_port,site_dir,secret) then
with full_url = make_foreign_link_url(target,url),
// with action = format_action(full_url, aspect, extract_id(aspect), mb_form_name),
if aspect is
{
link(opt, text, mb_name) then
with name_tag = if mb_name is success(n) then " name=\"" + n + "\"" else "",
[
"<a href=\"", full_url, "\"", format_text_options(opt), name_tag, ">",
text,
"</a>"
],
img_link(opt, img, alt_text) then
[
"<a href=\"", full_url ,"\"", format_attrs(opt),"><img src=\"", img,
"\" alt=\"" + alt_text + "\" border=\"0\"></a>"
],
push_button(options, text) then
["<a href=\"",full_url,"\"", format_attrs(options), ">",
text, "</a>"
],
button(url_off,url_on) then
[ ],
button(url_off,url_on,w,h) then
[ ],
submit(options, text) then
[ ],
//immediate_selector(opt,name,size,choices) then
// [ ],
immediate_selector(opt,name,size,choices,selected,function) then
[ ],
html(options, html_off_form) then
[
"<a href=\"", full_url,"\"", format_attrs(options), ">",
format(cinfo, ic_v, html_off_form, is_https, action_count, head_tags),
"</a>"
]
}.
define Printable_tree
format_actioner
(
CommonInfo cinfo,
Actioner_Connection connection,
Actioner_Target target,
Actioner_Aspect aspect,
WEB_Action_Name action,
List((String,String)) extra_ops,
List(Actioner_Local_Action) local_actions,
Maybe(String) mb_form_name,
Bool is_https,
Var(Int) action_count,
Var(Int) ic_v, // 'idnum' counter variable
Var(List(HTML_Head_Tag)) head_tags
) =
if cinfo is info(common_name,http_port,https_port,site_dir,secret) then
with url = make_actioner_url(cinfo,connection,target,
action,extra_ops,is_https),
with formatted_action = format_action(url, aspect, extract_id(aspect), mb_form_name, action_count),
if aspect is
{
link(opt, text, mb_name) then
with name_tag = if mb_name is success(n) then " name=\"" + n + "\"" else "",
with action_name = if action is {
no_action then ""
controller_action(_, an) then an,
action_name(an) then an,
url(_) then ""
},
if action_name = "" then
["<a ", format_text_options(opt), name_tag, ">", text, "</a>" ]
else
["<a href=\"",url,"\"",
format_text_options(opt), name_tag, ">",
text,
"</a>"
],
img_link(options, img, alt_text) then
//if action name is empty, format options on image because maybe there onclick action
with action_name = if action is {
no_action then ""
controller_action(_, an) then an,
action_name(an) then an,
url(_) then ""
},
if action_name ="" then
[
"<img src=\"", img,"\"",
format_attrs(options)," alt=\"" + alt_text + "\" border=\"0\">"
]
else
[
"<a href=\"", url,"\"", format_attrs(options),"><img src=\"", img,
"\" alt=\"" + alt_text + "\" border=\"0\"></a>"
],
push_button(options, text) then
[
if formatted_action is
{
url(u) then ["<a href=\"",u,"\"", format_attrs(options), ">",
text, "</a>"
],
javascript(s,h) then
with action_name =
if action is
{
no_action then "",
controller_action(_, an) then an,
action_name(an) then an,
url(_) then ""
},
if action_name = "" then
["<input type=\"button\" value=\"",encode_HTML_entities(text),"\"", format_attrs(options), " />"]
else
[s,"<input type=\"button\" value=\"",encode_HTML_entities(text),"\"", format_attrs(options), " onclick=\"",h,"\" />"]
}
],
button(url_off,url_on) then
[ if formatted_action is
{
url(u) then ["<a href=\"",u],
javascript(s,h) then [s,"<a onMouseDown=\"",h]
},
"\" style=\"text-decoration:none\">",
"<img alt=\"",url_off,"\" src=\"",url_off,"\" border=0",
" onMouseOver=\"this.src='",url_on,"'\" ",
" onMouseOut=\"this.src='",url_off,"'\">",
"</a>"
],
button(url_off,url_on,w,h) then
[ if formatted_action is
{
url(u) then ["<a href=\"",u],
javascript(s,h2) then [s,"<a onMouseDown=\"",h2]
},
"\" style=\"text-decoration:none\">",
"<img width=",w," height=",h," alt=\"",url_off,"\" src=\"",url_off,"\" border=0",
" onMouseOver=\"this.src='",url_on,"'\" ",
" onMouseOut=\"this.src='",url_off,"'\">",
"</a>"
],
submit(options, text) then
[
if formatted_action is
{
url(u) then ["<a href=\"",u,"\"", format_attrs(options), ">",
text, "</a>"
],
javascript(s,h) then
with action_name = if action is {
no_action then "",
controller_action(_, an) then an,
action_name(an) then an,
url(_) then ""
},
if action_name = "" then // special case where URL (so the action_name) is provided by the form itself
// so javascript isn't needed. This is the standard HMTL way.
["<input type=\"submit\" value=\"",text,"\"", format_attrs(options), " />"]
else
[s,"<input type=\"submit\" value=\"",text,"\"", format_attrs(options), " onclick=\"",h,"\" />"]
}
],
// immediate_selector(options,name,size,choices) then
// [ if action is
// {
// url(u) then ["<select href=\"",u]
// javascript(s,h) then [s,"<select onchange=\"",h]
// },
// "\" name=\"",name,"\" size=\"",size,"\"", format_attrs(options), ">",
// format_choices(choices),"</select>"
// ],
immediate_selector(options, name, size, choices, mb_selected, custom_function_name) then
[
//if custom function name is provided, that name is used instead of autogenerated js function
if custom_function_name = "" then
if formatted_action is
{
url(u) then ["<select href=\"",u]
javascript(s,h) then [s,"<select onchange=\"",h]
}
else
["<select onchange=\"",custom_function_name],
"\" name=\"",name,"\" size=\"",size,"\"", format_attrs(options), ">",
if mb_selected is success(selected) then format_choices(choices, selected) else format_choices(choices),"</select>"
],
html(options, html_off_form) then
[
"<a href=\"", url,"\"", format_attrs(options), ">",
format(cinfo, ic_v, html_off_form, is_https, action_count, head_tags),
"</a>"
]
}.
*** [5.5] Formating a private download link.
We get the absolute path of the file to be downloaded, and the name under which it
should appear to the client. The function 'format_private_download' creates an
hypertext link for downloading the file. The secured mecanism of private download is
used. This function is called by the function which formats HTML_Any($T) elements.
define Printable_tree
format_private_download
(
CommonInfo cinfo,
String abs_path, // absolute file path on server
String name, // name of file as it appears in the browser
String extra, // extra extension
Maybe((String,List((String,String)))) action
) =
if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
with private_download_directory = site_directory+"/private_download",
with auth = make_authorization(site_directory,secret,abs_path),
[
"<a href=\"",name,extra,"?zauth=",auth,
if action is
{
failure then [ ]
success(a) then if a is (an,args) then
["&a=",an,format_extra_operands(args)]
},
"\">",
name,
"</a>"
].
*** [5.6] Formating rows and cells in a table.
define Int
percent
(
Int p
) =
if p < 0 then 0 else if p > 100 then 100 else p.
Formating cell options.
define String
format
(
BackgroundOption o
) =
if o is
{
repeat then "",
repeat_horizontal then "; background-repeat: repeat-x",
repeat_vertical then "; background-repeat: repeat-y",
no_repeat then "; background-repeat: no-repeat",
center then "; background-position: center top"
}.
define String
format
(
List(BackgroundOption) l
) =
if l is
{
[ ] then "",
[h . t] then format(h)+format(t)
}.
define String
format
(
List(Cell_Option) options
) =
if options is
{
[ ] then "",
[h . t] then
if h is
{
core_attrs(core_attr_list) then format_attrs(core_attr_list),
left then " align=\"left\"",
h_center then " align=\"center\"",
right then " align=\"right\"",
top then " valign=\"top\"",
v_center then " valign=\"middle\"",
bottom then " valign=\"bottom\"",
base_line then " valign=\"baseline\"",
background_color(c) then " bgcolor=\""+html_format(c)+"\"",
background_image(n,o) then " style=\"background: url("+n+")"+format(o)+"\"",
width(w) then " width=\""+w+"\"",
percentage_width(n) then " width=\""+percent(n)+"%\"",
height(h2) then " height=\""+h2+"\"",
columns(n) then " colspan=\""+n+"\"",
rows(n) then " rowspan=\""+n+"\"",
nowrap then " nowrap",
style(style_string) then " style=\"" + style_string + "\"",
class(class_name) then " class=\""+class_name+"\""
}
+ format(t)
}.
Normalizing a list of cell options (horizontal position must be specified; the default
is 'left').
Formating cells in a row.
define Printable_tree
format
(
List(HTML_Cell($T)) cells,
$T -> Printable_tree format_element
) =
if cells is
{
[ ] then [ ],
[h . t] then if h is cell(options,element) then
["<td",format(reverse(options)),">",
format_element(element),
"</td>"
. format(t,format_element)]
}.
define Printable_tree
format
(
List(HTML_Header_Cell($T)) cells,
$T -> Printable_tree format_element
) =
if cells is
{
[ ] then [ ],
[h . t] then if h is header_cell(options,element) then
["<th ",format(reverse(options)),">",
format_element(element),
"</th>"
. format(t,format_element)]
}.
Formating the rows in a table.
define Printable_tree
format
(
List(HTML_Row($T)) rows,
$T -> Printable_tree format_element,
)=
if rows is
{
[ ] then [ ],
[h . t] then
if h is
{
empty then format(t, format_element),
row(options, cells) then
["<tr",format(reverse(options)),">", format(cells, format_element), "</tr>\n"
. format(t, format_element)]
}
}
.
define Printable_tree
format
(
HTML_Header_Row($T) row,
$T -> Printable_tree format_element
) =
if row is
{
empty then [ ],
header_row(options,cells) then
["<thead> <tr",format(reverse(options)),">",
format(cells,format_element),
"</tr> </thead>\n"
]
}.
define Printable_tree
format
(
HTML_Footer_Row($T) row,
$T -> Printable_tree format_element
) =
if row is
{
empty then [ ],
footer_row(options,cells) then
["<tfoot> <tr",format(reverse(options)),">",
format(cells,format_element),
"</tr> </tfoot>\n"
]
}.
define Printable_tree
format1
(
List(TextAreaOption) l
) =
if l is
{
[] then [],
[h . t] then if h is
{
input_attrs(input_attr_list) then [format_attrs(input_attr_list) . format1(t)],
disabled then [" disabled=\"disabled\" " . format1(t)]
read_only then [" readonly=\"readonly\" " . format1(t)]
wrap_lines then [" wrap=\"wrap\" " . format1(t)]
}
}.
define Printable_tree
format
(
List(TextAreaOption) l
)=
if member(l, wrap_lines) then
format1(l)
else
[" wrap=\"off\" " . format1(l)]
.
*** [5.7] Formating elements which may be put anywhere.
The function below involves the parameter $T which is later instantiated as
'HTML_In_Form' or as 'HTML_Off_Form'. Now, since there are dictinct 'format' functions
for these two types, and because formating of tables requires recursive calls of such
functions, it is necessary to provide the 'format' function to be called recursively as
an argument. Putting naively a call to 'format' will not work, because the compiler
will look for a function able to format data of type $T (which is at that time distinct
from any other type, including our two types). Such a function does not exist. Hence
the function to be called for formating elements must be passed as a functional
argument (called 'format_element' below). Actually, what we pass is a function taking
a unique argument of type $T. Other informations (like the name of the state) are
already in the function by way of full functionality.
Formating text options. They are formated in CSS syntax, to be used within a
'style=...'.
define String
format
(
List(Text_Option) l
) =
if l is
{
[ ] then "",
[h . t] then if h is
{
core_attrs(core_attr_list) then format_attrs(core_attr_list),
size(n) then "font-size:"+n+"pt",
font(fn) then "font-family:"+fn,
color(c) then if c is rgb(r,g,b) then
"color:rgb("+to_decimal(r)+","+to_decimal(g)+","+to_decimal(b)+")",
italic then "font-style:italic",
oblique then "font-style:oblique",
small_capitals then "font-variant:small-caps",
bold then "font-weight:bold",
underlined then "text-decoration:underline",
left_justified then "text-align:left",
right_justified then "text-align:right",
justified then "text-align:justify",
line_through then "text-decoration:line-through",
nowrap then "white-space:nowrap",
class(class_name)then " class=\"" + class_name +"\"",
id(id_name) then " id=\"" + id_name +"\"",
style(style_string) then " style=\"" + style_string + "\"",
title(s) then " title=\"" + s +"\""
attr(n,v) then " " + n + "=\"" + v +"\""
} + if t is [ ] then "" else ("; "+format(t))
}.
Formating table options.
define String
format
(
List(Table_Option) l,
Bool border_seen
) =
if l is
{
[ ] then if border_seen then "" else " border=\"0\" cellspacing=\"0\" cellpadding=\"0\"",
[h . t] then if h is
{
core_attrs(core_attr_list) then format_attrs(core_attr_list),
background_color(c) then " bgcolor=\""+html_format(c)+"\""+format(t,border_seen),
background_image(url) then " background="+url+format(t,border_seen),
border(o,top,i,c) then " border=\""+o+"\" cellspacing=\""+top+"\" cellpadding=\""+i+"\""+
//" bordercolor="+format(c)+
format(t,true),
width(w) then " width=\""+w+"\""+format(t,border_seen),
percentage_width(p) then " width=\""+percent(p)+"%\""+format(t,border_seen),
attr(name, value) then " " + name + "=\"" + value + "\"" +format(t,border_seen),
class(name) then " class=\""+name+"\""
}
}.
define Printable_tree
format_scroller
(
Int width,
Int height,
Int content_width,
Int content_height,
Int idnum, // identifying the scroller
$T content,
$T -> Printable_tree format_element
) =
[
"<script type = \"text/javascript\" language=\"JavaScript\">",
"function doscroll_",idnum,"(dx,dy) {\n",
" if (document.layers) { var c_",idnum," = eval(document.cs_",idnum,"); } else\n",
" if (document.getElementById) {var c_",idnum," = eval(\"document.getElementById('cs_",
idnum,"').style\"); } else\n",
" if (document.all) { var c_",idnum," = eval(document.all.cs_",idnum,".style); };\n",
" var x_",idnum," = parseInt(c_",idnum,".left);\n",
" var y_",idnum," = parseInt(c_",idnum,".top);\n",
" if ((x_",idnum,"+dx <= 0) && (x_",idnum,"+dx > ",width-content_width,"))\n",
" { x_",idnum," += dx; }\n",
" if ((y_",idnum,"+dy <= 0) && (y_",idnum,"+dy > ",height-content_height,"))\n",
" { y_",idnum," += dy; }\n",
" c_",idnum,".left = x_",idnum,";\n",
" c_",idnum,".top = y_",idnum,";\n",
" }\n",
"</script>\n",
"<table>",
"<tbody>",
"<tr>",
"<td align=left valign=top",
" width=",width,
" height=",height,
">",
"<div id=\"ws_",idnum,"\" style=\"position:absolute; width:",width,"px; height:",height,"px;",
" clip:rect(0px ",width,"px ",height,"px 0px)\">",
"<div id=\"cs_",idnum,"\" style=\"position:absolute; left:0px; top:0px\">",
format_element(content),
"</div>",
"</div>",
"</td>",
"<td valign=bottom>",
"<table>",
"<tbody>",
"<tr><td><img alt=\"sroll up\" src=\"scrollup.gif\" onmousedown=\"doscroll_", idnum,"(0,20);\"></td></tr>",
"<tr><td><img alt=\"scroll down\" src=\"scrolldown.gif\" onmousedown=\"doscroll_", idnum,"(0,-20);\"></td></tr>",
"</tbody>",
"</table>",
"</td>",
"</tr>",
(if content_width > width then
[
"<tr>",
"<td align=right>",
"<table>",
"<tbody>",
"<tr>",
"<td><img alt=\"scroll left\" src=\"scrollleft.gif\" onmousedown=\"doscroll_", idnum,"(20,0);\"></td>",
"<td><img alt=\"scroll right\" src=\"scrollright.gif\" onmousedown=\"doscroll_", idnum,"(-20,0);\"></td>",
"</tr>",
"</tbody>",
"</table>",
"</td>",
"</tr>",
] else [ ]),
"</tbody>",
"</table>"
].
define Printable_tree
format
(
Body_Option o
) =
if o is
{
core_attrs(core_attr_list) then [" " + format_attrs(core_attr_list)],
background_color(c) then [" bgcolor=\"" , (String)html_format(c), "\""],
background_image(n) then [" background=", n],
background_image(n,o2) then [" style=\"background: url(",n,")",format(o2),"\""]
}.
define Printable_tree
format
(
List(Body_Option) l
) =
if l is
{
[ ] then [ ],
[h . t] then [format(h) . format(t)]
}.
define Printable_tree
add_css_files
(
List(CSS_File) l
) =
if l is
{
[ ] then [ ],
[h . t] then
since h is css_file(file_name, media),
[ ["<link rel=\"stylesheet\" type=\"text/css\" href=\"" + file_name + "\" media=\""+to_String(media)+"\"/>\n" ]
. add_css_files(t)]
}.
define Printable_tree
add_js_files_attributes
(
List(JS_Attribute) l
) =
if l is
{
[ ] then [ ],
[h . t] then
if h is attr(name, value) then
[ " " + name + "=\"" + value + "\""
. add_js_files_attributes(t)]
}.
define Printable_tree
add_js_files
(
List(JS_File) l
) =
if l is
{
[ ] then [ ],
[h . t] then
[ ["<script src=\""+ file_name(h) +"\" type=\"text/javascript\""
. add_js_files_attributes(attributes(h)) ]
. ["></script>\n"
. add_js_files(t)] ]
}
.
define Printable_tree
add_script
(
List(Script) l
) =
if l is
{
[ ] then [ ],
[h . t] then [ "<script type=\""+ script_type(h) +"\">\n"+ content(h) + "\n</script>\n" . add_script(t) ]
}.
define Printable_tree
add_css_styles
(
List(CSS_Style) css_styles
) =
if css_styles is
{
[] then [],
[_ . _] then [ "<style type=\"text/css\"><!--\n",
format_css_styles(css_styles),
" --></style>\n"
]
}.
// The function below formats a datum of type 'HTML_Any($T)'.
define Printable_tree
format
(
CommonInfo cinfo,
Var(Int) ic_v,
HTML_Any($T) element,
$T -> Printable_tree format_element, // able to format a datum of type $T
Bool is_https,
Var(Int) action_count,
Var(List(HTML_Head_Tag)) head_tags
) =
if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
if element is
{
any_text(opts , t) then
if opts is
{
[] then [t],
[_ . _] then ["<span", format_attrs(opts), ">",t,"</span>"]
},
any_preformated(opts,s) then
["<span", format_text_options(opts), "><pre>",s,"</pre></span>"],
//["<pre>",s,"</pre>"],
any_paragraph(opts,l) then
["<p", format_text_options(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</p>\n"],
any_image(opts, url, _alt) then
with alt = if _alt = "" then "" else "alt=\""+_alt+"\"",
["<img ",alt," src=\"",url,"\" ", format_attrs(opts)," />"],
any_image(opts, url, alt, w, h) then
["<img alt=\"",alt,"\" src=\"",url,"\" width=\"",w,"\" height=\"",h,"\" ", format_attrs(opts)," />"],
any_table(opts,h_row, rows, f_row) then
["<table",format(reverse(opts),false),">",
format(h_row, format_element),
"<tbody>",format(rows,format_element),"</tbody>",
format(f_row, format_element),
"</table>\n"],
any_center(e) then
["<center>",format_element(e),"</center>"],
any_mail_to(email,elem) then
["<a href=\"mailto:",email,"\">",format_element(elem),"</a>"],
any_scroller(w,h,cw,ch,c) then
format_scroller(w,h,cw,ch,new_idnum(ic_v),c,format_element),
any_fixed_size(w,h,c) then
with url = create_secondary_document(site_directory,secret,format_element,c,w),
["<object data=\"",url,"\" type=\"text/html\" width=\"",format(w),"\" height=\"",format(h),"\" >",
"secondary document",
"</object>"],
any_fixed_size_2(w,h,fn) then
with url = fn+"?zauth="+make_authorization(site_directory,secret,
fn),
["<object data=\"",url,"\" type=\"text/html\" width=\"",format(w),"\" height=\"",format(h),"\" >",
"secondary document",
"</object>"],
any_actioner(c,t,a,an,eo,ja,fn) then
format_actioner(cinfo,c,t,a,an,eo,ja,fn,is_https, action_count, ic_v, head_tags),
any_foreign_link_new(target, aspect, url) then
format_foreign_link(target, aspect, url, is_https, cinfo, action_count, ic_v, head_tags),
any_foreign_link(options,url) then
["<a href=\"",url,"\" ", format_text_options(options), "></a>"], // IE7 doesn't support the form <a href="..." />
any_foreign_link(options,url,name) then
["<a href=\"",url,"\"><span ", format_text_options(options), ">",name,"</span></a>"],
any_private_download(url,name,extra_ext,action) then
format_private_download(cinfo,url,name,extra_ext,action),
any_div(options, l) then
[format_div_option(options), flat(map(($T e) |-> format_element(e), l)),"</div>\n"],
any_div_empty(options) then
[format_div_option(options), "</div>\n"],
any_coreattrs(attributs) then
[format_attrs(attributs)],
any_ol(opts, l) then
["<ol", format_attrs(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</ol>\n"],
any_ul(opts, l) then
["<ul", format_attrs(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</ul>\n"],
any_li(opts, l) then
["<li", format_attrs(opts), ">", flat(map(($T e) |-> format_element(e), l)),"</li>\n"],
any_button(options, l) then
[["<button" + format_attrs(options) + ">"], flat(map(($T e) |-> format_element(e), l)),"</button>\n"],
any_i(opts,t) then
if t = "" then
["<i", format_attrs(opts), "></i>\n"]
else
["<i", format_attrs(opts), ">",t,"</i>\n"],
any_span(opts , t) then
["<span", format_attrs(opts), ">",t,"</span>"]
any_hr(opts) then
["<hr", format_attrs(opts),">"]
}
.
// *** [5.8] Formating 'in form' elements.
//public define Printable_tree
// format
// (
// HTML_tooltip tooltip
// )=
// if tooltip is
// {
// html_tooltip(title, keyword, width) then
// ["<a id=\"help_",keyword,"\" class=\"jTipu jTip_help\" name=\"",title,"\" href=\"/?a=ajax_show_tooltip&tooltip_id=",keyword,(if width > 0 then ["&width=",width,"\""] else ["\""]), "></a>"],
//
// html_tooltip_ext(title, extend_type, class_suffix, ext_args) then
// with extra_args = format_extra_operands(ext_args),
// ["<a id=\"jTip\" class=\"jTipu jTip_",class_suffix,"\" name=\"",title,"\" href=\"/?a=ajax_show_tooltip&tooltip_ext=",extend_type+extra_args,"\"></a>"]
// }.
public define List(CoreAttrs)
extract_attributes
(
HTML_tooltip tooltip
)=
if tooltip is
{
html_tooltip(title, keyword, width) then //TODO
[]
//["<a id=\"help_",keyword,"\" class=\"jTipu \" name=\"",title,"\" href=\"/?a=ajax_show_tooltip&tooltip_id=",keyword,(if width > 0 then ["&width=",width,"\""] else ["\""]), "><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"],
html_tooltip_ext(title, extend_type, class_suffix, ext_args) then //TODO
//[]
with extra_args = format_extra_operands(ext_args),
[id("jTip"), class("jTipu jTip_"+class_suffix), data("name",title), data("href", "/?a=ajax_show_tooltip&tooltip_ext="+extend_type+extra_args)]
html_tooltip_ext(title, extend_type, ext_args) then //TODO
with extra_args = format_extra_operands(ext_args),
[id("jTip"), class("jTipu"), data("name",title), data("href", "/?a=ajax_show_tooltip&tooltip_ext="+extend_type+extra_args)]
// []
//with extra_args = format_extra_operands(ext_args),
//["<a id=\"jTip\" class=\"jTipu \" name=\"",title,"\" href=\"/?a=ajax_show_tooltip&tooltip_ext=",extend_type+extra_args,"\"><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"],
html_tooltip(title, web_action, extra_args) then
[ id("jTip"), class("jTipu"), data("name", title), data("href", "/"+format_web_action_name(web_action, extra_args))
]
//["<a id=\"jTip\" class=\"jTipu \" name=\"",title,"\" href=\"/", format_web_action_name(web_action, extra_args) ,"\"><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"],
}
.
literal_pt(["<span id=\"jTip\" class=\"jTipu\" data-name=\"",title,"\" data-href=\"/", format_web_action_name(web_action, extra_args) ,"\">"]),
public define Printable_tree
format
(
HTML_tooltip tooltip
)=
if tooltip is
{
html_tooltip(title, keyword, width) then
["<a id=\"help_",keyword,"\" class=\"jTipu \" data-name=\"",title,"\" data-href=\"/?a=ajax_show_tooltip&tooltip_id=",keyword,(if width > 0 then ["&width=",width,"\""] else ["\""]), "><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"],
html_tooltip_ext(title, extend_type, class_suffix, ext_args) then
with extra_args = format_extra_operands(ext_args),
["<a id=\"jTip\" class=\"jTipu jTip_",class_suffix,"\" data-name=\"",title,"\" data-href=\"/?a=ajax_show_tooltip&tooltip_ext=",extend_type+extra_args,"\"></a>"]
html_tooltip_ext(title, extend_type, ext_args) then
with extra_args = format_extra_operands(ext_args),
["<a id=\"jTip\" class=\"jTipu \" data-name=\"",title,"\" data-href=\"/?a=ajax_show_tooltip&tooltip_ext=",extend_type+extra_args,"\"><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"],
html_tooltip(title, web_action, extra_args) then
["<a id=\"jTip\" class=\"jTipu \" data-name=\"",title,"\" data-href=\"/", format_web_action_name(web_action, extra_args) ,"\"><i class=\"fa fa-info\" aria-hidden=\"true\" style=\"color:#2e6da4\"></i></a>"],
}
.
public define HTML_Off_Form
html_tooltip
(
String title,
WEB_Action_Name web_action,
List((String,String)) extra_args,
HTML_Off_Form html_element,
)=
sequence([
literal_pt(["<span id=\"jTip\" class=\"jTipu\" data-name=\"",title,"\" data-href=\"/", format_web_action_name(web_action, extra_args) ,"\">"]),
html_element,
literal_pt(["</span>"])
])
.
public define HTML_Off_Form
html_tooltip
(
String title,
String keyword,
) =
literal_pt(format(html_tooltip(title, keyword, 0))).
public define HTML_In_Form
html_tooltip
(
String title,
String keyword,
) =
literal_pt(format(html_tooltip(title, keyword, 0))).
public define HTML_Off_Form
html_tooltip
(
String keyword,
Int size,
) =
literal_pt(format(html_tooltip("", keyword, size))).
public define HTML_In_Form
html_tooltip
(
String keyword,
Int size,
) =
literal_pt(format(html_tooltip("", keyword, size))).
public define Printable_tree
format_help
(
Printable_tree label,
HTML_Help _help
) =
if _help is
{
no_help then label,
tooltip(html_tooltip, position) then
if position is
{
left then pt_pt(format(html_tooltip),label),
right then pt_pt(label, format(html_tooltip))
}
}.
public define HTML_Label
label
(
String text
)=
label(text, no_help).
public define Printable_tree
format_label
(
HTML_Label _label,
HTML_Id _id
) =
if _label is
{
no_label then [],
label(text, help) then
format_help(
["<label"+(if _id.id ="" then "" else " for=\""+_id.id+"\"")+">",text,"</label>"],
help
)
}.
define Printable_tree
format
(
CommonInfo cinfo,
String fn, // form_name
Var(Int) ic_v, // idnum counter variable
HTML_In_Form element,
Bool is_https,
Var(Int) action_count,
Var(List(HTML_Head_Tag)) head_tags
) =
if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
with format_element = (HTML_In_Form e) |-> format(cinfo, fn, ic_v, e, is_https, action_count, head_tags),
if element is
{
empty then [],
literal_pt(t) then t,
literal(t) then [t],
sequence(l) then flat(map(format_element,l))
text(opts,t) then
format(cinfo,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags),
preformated(o,s) then
format(cinfo,ic_v,any_preformated(o,s),format_element,is_https, action_count, head_tags),
paragraph(opts,t) then
format(cinfo,ic_v,any_paragraph(opts,t),format_element,is_https, action_count, head_tags),
image(opts, url, alt) then
format(cinfo,ic_v,any_image(opts, url, alt),format_element,is_https, action_count, head_tags),
image(opts, url, alt, w, h) then
format(cinfo,ic_v,any_image(opts, url, alt, w, h),format_element,is_https, action_count, head_tags),
table(opts,header_row,rows,footer_row) then
format(cinfo,ic_v,any_table(opts, header_row, rows, footer_row),format_element,is_https, action_count, head_tags),
center(e) then
format(cinfo,ic_v,any_center(e),format_element,is_https, action_count, head_tags),
mail_to(a,e) then
format(cinfo,ic_v,any_mail_to(a,e),format_element,is_https, action_count, head_tags),
scroller(w,h,cw,ch,c) then
format(cinfo,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count, head_tags),
actioner(c,t,a,an,eo,ja) then
format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags),
foreign_link_new(target, aspect, url) then
format(cinfo,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags),
foreign_link(options,url) then
format(cinfo,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags),
foreign_link(options,url,name) then
format(cinfo,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags),
private_download(url,name,extra,action) then
format(cinfo,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags),
text_input(options, label_text, id, name, init, w) then
[ format_label(label_text, id),
"<input type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",encode_HTML_entities(init.value),"\"",format_attrs([class("in") . options])," />"],
text_input_ro(options, label_text, id, name, init, w) then
[ format_label(label_text, id),
"<input readonly=\"readonly\" type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",encode_HTML_entities(init.value),"\"",format_attrs([class("in") . options])," />"],
password_input(options, label_text, id, name, init, w) then
[ format_label(label_text, id),
"<input type=\"password\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",encode_HTML_entities(init.value),"\"",format_attrs([class("in") . options])," />"],
text_area(options,label_text, id, n, init, w, h) then
[ format_label(label_text, id), "<textarea ",format(options)," id=\"",id,"\" name=\"",n,"\" cols=\"",w,"\" rows=\"",h,"\">",encode_HTML_entities(init.value),"</textarea>"],
file_upload(options, label, id, n, w) then
[ format_label(label, id),
"<input type=\"file\" id=\"",id,"\" size=\"",w,"\" name=\"",n,"\"",format_attrs([class("in") . options])," />"],
selector(options, label, id, n,s,cs) then
[ format_label(label, id),
"<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs),"</select>"],
selector(options, label, id, n,s,cs,sd) then
[ format_label(label, id),
"<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs,sd),"</select>"],
selector_c(options, label, id, n,s,cs) then
[ format_label(label, id),
"<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs),"</select>"],
selector_c(options, label, id, n,s,cs,sd) then
[ format_label(label, id),
"<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs,sd),"</select>"],
radio_button(options, label, id, n, value, c) then
[ format_label(label, id),
"<input type=\"radio\" name=\"",n,"\" id=\"",id,"\" value=\"",value,"\"",(if c then " checked=\"checked\"" else ""),format_attrs([class("in") . options])," />"],
radio_button_r(options, label, id, n, value, c) then
[ "<input type=\"radio\" name=\"",n,"\" id=\"",id,"\" value=\"",value,"\"",(if c then " checked=\"checked\"" else ""),format_attrs([class("in") . options])," />",
format_label(label, id)],
check_box(options, label, id, n, c) then
[ format_label(label, id),
"<input type=\"hidden\" name=\"~",n,"\" value=\"~true\" /><input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"true\"",(if c then " checked=\"checked\" " else ""),format_attrs([class("in") . options])," />"]
check_box_r(options, label, id, n, c) then
[ "<input type=\"hidden\" name=\"~",n,"\" value=\"~true\" /><input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"true\"",(if c then " checked=\"checked\" " else ""),format_attrs([class("in") . options])," />",
format_label(label, id)]
div(options, e) then
format(cinfo,ic_v,any_div(options, e),format_element,is_https, action_count, head_tags),
div_empty(options) then
format(cinfo,ic_v,any_div_empty(options),format_element,is_https, action_count, head_tags),
hidden(_id, name, init) then
since _id is html_Id(id),
["<input type=\"hidden\"",(if id = "" then "" else " id=\""+id+"\"")," name=\"",name,"\" value=\"",encode_HTML_entities(init.value),"\" />"],
partial(p_content) then
if p_content is partial_content(tags, html_elements) then
head_tags <- *head_tags + tags;
format(cinfo, ic_v, html_elements, is_https, action_count, head_tags),
br then ["<br>"],
progress(options, value, max) then ["<progress max=\"",value,"\" value=\"",max,"\"",format_attrs(options),"></progress>"],
ol(opts, t) then
format(cinfo,ic_v,any_ol(opts,t),format_element,is_https, action_count, head_tags),
ul(opts, t) then
format(cinfo,ic_v,any_ul(opts,t),format_element,is_https, action_count, head_tags),
li(opts, t) then
format(cinfo,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
button(options, e) then
format(cinfo,ic_v,any_button(options, e),format_element,is_https, action_count, head_tags),
i(opts, t) then
format(cinfo,ic_v,any_i(opts,t),format_element,is_https, action_count, head_tags),
span(opts,t) then
format(cinfo,ic_v,any_span(opts,t),format_element,is_https, action_count, head_tags)
hr(opts) then
format(cinfo,ic_v,any_hr(opts),format_element,is_https, action_count, head_tags)
}.
*** [5.9] Formating 'off form' elements.
The encryption type 'multipart/form-data' is required for a form containing an upload.
define Bool
contains_an_upload
(
HTML_In_Form form_content
).
define Bool
contains_an_upload
(
HTML_Row(HTML_In_Form) row
) =
if row is
{
empty then false,
row(_, cells) then
mapor(contains_an_upload,
map(content, cells))
}
.
define Bool
contains_an_upload
(
HTML_Footer_Row(HTML_In_Form) row
)=
if row is
{
empty then false,
footer_row(_, cells) then
mapor(contains_an_upload,
map(content,cells))
}.
define Bool
contains_an_upload
(
HTML_In_Form form_content
) =
if form_content is
{
empty then false,
literal_pt(t) then false,
literal(t) then false,
sequence(l) then mapor(contains_an_upload,l),
text(o,t) then false,
preformated(o,s) then false,
paragraph(o,l) then mapor(contains_an_upload,l),
image(o,u,a) then false,
image(o,u,a,w,h) then false,
table(o,_,rows,f_row) then if mapor(contains_an_upload,rows) then true
else contains_an_upload(f_row),
center(e) then contains_an_upload(e),
mail_to(m,e) then false, // 'e' may but should not contain an upload
scroller(w,h,cw,ch,e) then contains_an_upload(e),
actioner(c,t,a,an,eo,ja) then false,
foreign_link_new(_,_,_) then false,
foreign_link(o,u) then false,
foreign_link(o,u,n) then false,
private_download(p,n,e,a) then false,
text_input(o,lt,l,n,i,w) then false,
text_input_ro(o,lt,l,n,i,w) then false,
password_input(o,lt,l,n,i,w) then false,
text_area(o,lt,id,n,i,w,h) then false,
file_upload(o,l,i,n,w) then true,
selector(o,l,i,n,s,c) then false,
selector(o,l,i,n,s,c,p) then false,
selector_c(o,l,i,n,s,c) then false,
selector_c(o,l,i,n,s,c,p) then false,
radio_button(o,_,_,n,v,c) then false,
radio_button_r(o,_,_,n,v,c) then false,
check_box(o,_,_,n,c) then false,
check_box_r(o,_,_,n,c) then false,
div(o,l) then mapor(contains_an_upload,l), //contains_an_upload(c),
div_empty(o) then false,
hidden(_,_,_) then false,
partial(_) then false,
br then false,
progress(_,_,_) then false,
ol(_,l) then mapor(contains_an_upload,l),
ul(_,l) then mapor(contains_an_upload,l),
li(_,l) then mapor(contains_an_upload,l),
button(_,_) then false,
i(_,_) then false,
span(_,_) then false,
hr(_) then false
}
.
define String
enctype
(
List(HTML_In_Form) form_contents
)=
if mapor(contains_an_upload, form_contents) then
" enctype=\"multipart/form-data\""
else
""
.
define Printable_tree
format_href
(
A_href _href
)=
if _href is
{
href(str) then if str = "" then [] else [" href=\"", str, "\""],
href(action, extra) then [" href=\"",format_web_action_name(action, extra), "\""]
}
.
define Printable_tree
format_target
(
A_target _target
)=
[" target=\"",
if _target is
{
_blank then "_blank",
_self then "_self",
_parent then "_parent",
_top then "_top",
framename(name) then name
},
"\""]
.
define Printable_tree
format
(
CommonInfo cinfo,
Var(Int) ic_v, // 'idnum' counter variable
HTML_Off_Form element,
Bool is_https,
Var(Int) action_count,
Var(List(HTML_Head_Tag)) head_tags
) =
if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
with format_element = (HTML_Off_Form e) |-> format(cinfo, ic_v, e, is_https, action_count, head_tags),
if element is
{
a(opts, _href, _target, l) then ["<a ", format_attrs(opts), format_href(_href), format_target(_target), ">",flat(map(format_element,l)),"</a>\n"],
empty then [],
literal_pt(t) then t,
literal(t) then [t],
sequence(l) then flat(map(format_element,l)),
text(opts,t) then
format(cinfo,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags),
// preformated(o,s) then
// format(cinfo,ic_v,any_preformated(o,s),format_element,is_https, action_count, head_tags),
// paragraph(opts,t) then
// format(cinfo,ic_v,any_paragraph(opts,t),format_element,is_https, action_count, head_tags),
// image(opts,url,alt) then
// format(cinfo,ic_v,any_image(opts,url,alt),format_element,is_https, action_count, head_tags),
// image(opts,url,alt,w,h) then
// format(cinfo,ic_v,any_image(opts,url,alt,w,h),format_element,is_https, action_count, head_tags),
table(opts,header_row, rows, footer_row) then
format(cinfo,ic_v,any_table(opts,header_row, rows, footer_row),format_element,is_https, action_count, head_tags),
// center(e) then
// format(cinfo,ic_v,any_center(e),format_element,is_https, action_count, head_tags),
// mail_to(a,e) then
// format(cinfo,ic_v,any_mail_to(a,e),format_element,is_https, action_count, head_tags),
// scroller(w,h,cw,ch,c) then
// format(cinfo,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count, head_tags),
// fixed_size(w,h,c) then
// format(cinfo,ic_v,any_fixed_size(w,h,c),format_element,is_https, action_count, head_tags),
// fixed_size_2(w,h,fn) then
// format(cinfo,ic_v,any_fixed_size_2(w,h,fn),format_element,is_https, action_count, head_tags),
actioner(c,t,a,an,eo,ja) then
format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,failure),format_element,is_https, action_count, head_tags),
actioner(c,t,a,an,eo,ja,fn) then
format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags),
foreign_link_new(target, aspect, url) then
format(cinfo,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags),
foreign_link(options,url) then
format(cinfo,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags),
foreign_link(options,url,name) then
format(cinfo,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags),
private_download(url,name,extra,action) then
format(cinfo,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags),
// label(n) then ["<a name=\"",n,"\">"],
form(fn,attributs, l) then
[
"<form id=\"",fn,"\"",
format(cinfo,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags),
" method=\"post\"",
enctype(l),
" action=\"http",
if is_https then "s" else "",
"://",common_name,":",to_decimal(http_port),"/\">",
// action is set dynamically by
// the actioner using JavaScript
if fn is html_Id(id) then
flat(map((HTML_In_Form e) |-> format(cinfo,id,ic_v,e,is_https, action_count, head_tags), l)),
"</form>"
]
form(fn,attributs, action, extra_ops, l) then
with url = make_actioner_url(cinfo, same, same,
action, extra_ops, is_https),
[
"<form id=\"",fn,"\"",
format(cinfo,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags),
" method=\"post\"",
enctype(l),
" action=\"" + url + "\">",
// " action=\"http",
// if is_https then "s" else "",
// "://",common_name,":",http_port,"/\">",
// action is set dynamically by
// the actioner using JavaScript
if fn is html_Id(id) then
flat(map((HTML_In_Form e) |-> format(cinfo,id,ic_v,e,is_https, action_count, head_tags),l)),
"</form>"
],
in_form(fn, content) then
if fn is html_Id(id) then
format(cinfo,id,ic_v, content,is_https, action_count, head_tags),
// div(options, e) then
// format(cinfo, ic_v, any_div(options, e), format_element, is_https, action_count, head_tags),
div(options, p_content) then
with html_elements = map((HTML_Partial_Content pc) |-> since pc is partial_content(tags, html_elem), head_tags <- *head_tags +tags; html_elem, p_content),
format(cinfo, ic_v, any_div(options, html_elements), format_element, is_https, action_count, head_tags),
// div_empty(options) then
// format(cinfo, ic_v, any_div_empty(options), format_element, is_https, action_count, head_tags),
iframe(options, css_styles, css_files, js_files, body) then
println("formating iframe");
if body is body(body_options,elem) then
[ "<iframe", format_attrs(options), " srcdoc=\"\n",
encode_HTML_quote(to_String([
"<html style=\"margin: 0pt; padding: 0pt;\">\n",
"<head>\n",
add_css_styles(css_styles),
add_css_files(css_files),
add_js_files(js_files),
"</head>\n",
"<body ", format(body_options), ">\n", // format body options
format(cinfo,ic_v,elem,is_https, action_count, head_tags),
"</body>\n",
"</html>\n",])),
"\"></iframe>\n",
],
partial(p_content) then
if p_content is partial_content(tags, html_elements) then
head_tags <- *head_tags + tags;
format(cinfo, ic_v, html_elements, is_https, action_count, head_tags),
// br then ["<br>"],
// progress(options, value, max) then ["<progress max=\"",max,"\" value=\"",value,"\"",format_attrs(options),"></progress>"],
// ol(opts, t) then
// format(cinfo,ic_v,any_ol(opts,t),format_element,is_https, action_count, head_tags),
// ul(opts, t) then
// format(cinfo,ic_v,any_ul(opts,t),format_element,is_https, action_count, head_tags),
// li(opts, t) then
// format(cinfo,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
// button(options, e) then
// format(cinfo, ic_v, any_button(options, e), format_element, is_https, action_count, head_tags),
i(opts, t) then
format(cinfo,ic_v,any_i(opts,t),format_element,is_https, action_count, head_tags),
// span(opts,t) then
// format(cinfo,ic_v,any_span(opts,t),format_element,is_https, action_count, head_tags),
// hr(opts) then
// format(cinfo,ic_v,any_hr(opts),format_element,is_https, action_count, head_tags),
// nav(opts, l) then ["<nav", format_attrs(opts), ">",flat(map(format_element,l)),"</nav>\n"],
html_tag(tag_name, opts, l) then ["<",tag_name, format_attrs(opts), ">",flat(map(format_element,l)),"</",tag_name,">\n"],
html_void_tag(tag_name, opts) then ["<",tag_name, format_attrs(opts), ">"],
}.
*** [5.10] Formating meta-tags.
define Printable_tree
format_keywords
(
List(String) l
) =
if l is
{
[] then [ ],
[h . t] then if t is []
then [h]
else [h , ", " . format_keywords(t)]
}.
define Printable_tree
format
(
CommonInfo cinfo,
HTML_Meta m,
Bool is_https
) =
if m is
{
keywords(l) then ["<meta name=\"keywords\" content=\"",format_keywords(l),"\" />\n"],
refresh(co,ta,an,delay) then
["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",
make_actioner_url(cinfo,co,ta,an,[],is_https),"\" />\n"],
refresh(url,delay) then
["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",url,"\" />\n"],
meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"],
http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"],
generic_meta(l) then ["<meta ",
flat(map(((String,String) p) |-> if p is (n,v) then [n,"=\"",v,"\" "],
l)),
" />\n"],
literal(s) then [s]
}
.
define Printable_tree // c'est le nôtre et c'est meilleur
format
(
HTML_Meta m,
) =
if m is
{
keywords(l) then ["<meta name=\"keywords\" content=\"",format_keywords(l),"\" />\n"],
refresh(co,ta,an,delay) then
["<!-- TODO refresh(co,ta,an,delay) --> "], // TODO
refresh(url,delay) then
["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",url,"\" />\n"],
meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"],
http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"],
generic_meta(l) then ["<meta ",
flat(map(((String,String) p) |-> if p is (n,v) then [n,"=\"",v,"\" "],
l)),
" />\n"],
literal(s) then [s]
}.
define Printable_tree
format
(
CommonInfo cinfo,
List(HTML_Meta) metas,
Bool is_https,
String charset
) =
if metas is
{
[] then [format(cinfo,http_equiv("content-type",
"text/html; charset="+charset),is_https)],
[h . t] then [format(cinfo,h,is_https)
. format(cinfo,t,is_https,charset)]
}.
define List(HTML_Head_Tag)
rebuild_html_head_tags
(
List(HTML_Head_Tag) lwf,
List(HTML_Head_Tag) so_far
) =
if lwf is
{
[] then so_far,
[h . t] then
rebuild_html_head_tags(t, append_once(so_far, h))
}.
define Printable_tree
_format_html_head
(
List(HTML_Head_Tag) lwf,
Printable_tree so_far,
Dictionary(String, Word32) js_dict
)
=
//with lwf_ = rebuild_html_head_tags(lwf, []),
if lwf is
{
[] then reverse(so_far),
[ h . t] then
if h is
{
meta(meta) then
[format(meta) . _format_html_head(t, so_far, js_dict)],
title(title) then
["<title>"+title+"</title>\n" . _format_html_head(t, so_far, js_dict)],
js(jsf) then
since jsf is js_file(filename, _),
if js_dict.get(filename) is
{
failure then
forget(js_dict.insert(filename, 0));
[add_js_files([jsf]) . _format_html_head(t, so_far, js_dict)],
success(_) then
_format_html_head(t, so_far, js_dict),
}
js_inline(jsi) then
if jsi is
{
script(type, _) then
["<script type=\"" + type + "\">"+content(jsi)+"</script>\n" . _format_html_head(t, so_far, js_dict)],
}
css(cssf) then
since cssf is css_file(file_name, media),
["<link rel=\"stylesheet\" type=\"text/css\" href=\""+file_name+"\" media=\""+to_String(media)+"\" />\n" . _format_html_head(t, so_far, js_dict)],
css_inline(cssi) then
["<style>"+cssi+"</style>\n" . _format_html_head(t, so_far, js_dict)]
}
}
.
public define Printable_tree
format_html_head
(
List(HTML_Head_Tag) lwf,
String charset
)
=
_format_html_head((List(HTML_Head_Tag))[ meta(http_equiv("content-type", "text/html; charset="+charset)) . lwf], [], make_dictionary((Word32)0, dictionaryComparerString)).
public define Printable_tree
format_html_head
(
List(HTML_Head_Tag) lwf
)
=
_format_html_head(lwf, [], make_dictionary((Word32)0, dictionaryComparerString)).
public type HTML_ajax_content:
html_ajax_content( String html_body, String script, List(String) js_file, List(String) css_file).
public define HTML_ajax_content
sort_head_tag
(
List(HTML_Head_Tag) lwf,
String script,
List(String) js_file,
List(String) css_file
)=
if lwf is
{
[] then html_ajax_content("", script, reverse(js_file), reverse(css_file)),
[ h . t ] then
if h is
{
meta(meta) then sort_head_tag(t, script, js_file, css_file),
title(title) then sort_head_tag(t, script, js_file, css_file),
js(jsf) then /*println("sort_head_tag jsf["+jsf.file_name+"]");*/sort_head_tag(t, script, [file_name(jsf) . js_file], css_file),
js_inline(jsi) then /*println("sort_head_tag jsi["+jsi.content+"]");*/sort_head_tag(t, script + content(jsi), js_file, css_file),
css(cssf) then sort_head_tag(t, script, js_file, [file_name(cssf) . css_file]),
css_inline(cssi) then sort_head_tag(t, script, js_file, css_file)
}
}.
public define HTML_ajax_content
to_html_ajax_content
(
HTML_Off_Form content_HTML,
CommonInfo cinfo
)=
//println("to_html_ajax_content(content_HTML, cinfo)");
with p_content_head_tags = var((List(HTML_Head_Tag))[]),
with content = format(cinfo, var((Int)0), content_HTML, false, var(0), p_content_head_tags),
if sort_head_tag(*p_content_head_tags, "", [], []) is html_ajax_content(_, script, js_file, css_file) then
html_ajax_content(to_String(content), script, js_file, css_file).
public define String
to_String
(
HTML_Off_Form content_HTML,
CommonInfo cinfo
)=
//println("to_html_ajax_content(content_HTML, cinfo)");
with p_content_head_tags = var((List(HTML_Head_Tag))[]),
with content = format(cinfo, var((Int)0), content_HTML, false, var(0), p_content_head_tags),
to_String(content)
.
public define JsonValue
to_html_ajax_content
(
HTML_Partial_Content content_HTML,
CommonInfo cinfo,
String additional_script
)=
//println("to_html_ajax_content(content_HTML, cinfo, additional_script)");
//println("additional_script"+additional_script);
since to_html_ajax_content(partial(content_HTML), cinfo) is html_ajax_content(html, script, js_files, css_files),
json_object([
json_member("html", json_string(html)),
json_member("js_files", to_json_array(js_files)),
json_member("css_files", to_json_array(css_files)),
json_member("script", json_string(additional_script+script)),
])
.
public define JsonValue
to_html_ajax_content
(
HTML_Partial_Content content_HTML,
CommonInfo cinfo
)= to_html_ajax_content(content_HTML, cinfo, "").
public define JsonValue
to_html_ajax_content
(
Printable_tree content_HTML,
String additional_script
)=
//since to_html_ajax_content(partial(content_HTML), cinfo) is html_ajax_content(html, script, js_files, css_files),
json_object([
json_member("html", json_string(to_String(content_HTML))),
json_member("js_files", to_json_array([])),
json_member("css_files", to_json_array([])),
json_member("script", json_string(additional_script)),
])
.
public define AWP_Handler_Answer //Printable_tree
format
(
CommonInfo cinfo,
List(HTTP_header) additional_headers,
HTTP_Answer page,
Bool is_https,
String charset
)=
if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
with ic_v = var((Int)0),
p_content_head_tags = var((List(HTML_Head_Tag))[]), //list of heat_tags extracted from partial_content during format of body content
if page is
{
html_page(status, head_tags, body) then
if body is body(options,element) then
if format(status) is (status_string, status_headers) then
with
answer_body_body = (Printable_tree)
[ "<body ", format(options), ">", // format body options
format(cinfo,ic_v,element,is_https, var(0), p_content_head_tags),
"</body>\n",
"</html>"],
answer_body_header =
[doctype_w3c_header,
// html_header,
"<head>\n", format_html_head(head_tags + *p_content_head_tags, charset),"</head>\n",
],
printable_tree([
"HTTP/1.1 " + status_string, crlf,
format_headers(standard_headers),
format_headers(standard_headers_for("text/html", length(answer_body_header) + length(answer_body_body), success(charset))),
format_headers(status_headers),
format_headers(additional_headers),
crlf,
answer_body_header .
answer_body_body
]),
html_page(status, title, metas, css_styles, css_files, js_files, script, body) then
if body is body(options,element) then
if format(status) is (status_string, status_headers) then
with
answer_body_body = (Printable_tree)
[ "<body ", format(options), ">", // format body options
format(cinfo,ic_v,element,is_https, var(0), p_content_head_tags),
"</body>\n",
"</html>"
],
answer_body_header =
[ doctype_w3c_header,
//html_header,
"<head>\n",
add_css_styles(css_styles),
add_css_files(css_files),
add_js_files(js_files),
add_script(script),
"<link rel=\"shortcut icon\" href=\"favicon.ico\" />\n",
"<script type = \"text/javascript\" language=\"JavaScript\">",
" function show_local_popup(divname,stvname) {",
" if (document.layers) { var d = eval(document.divname); } else\n",
" if (document.getElementById) { var d = eval(\"document.getElementById(divname)\"); } else\n",
" if (document.all) { var d = eval(document.all.divname.style)};\n",
// " alert(typeof(eval(stvname))); ",
" var s = eval(stvname); ",
" if (s[0]==0) ",
" { s[0]=1; d.style.visibility = 'visible'; d.zIndex = 100; } else\n",
" { s[0]=0; d.style.visibility = 'hidden'; }; }",
"</script>\n",
"<title>",title,"</title>\n", // put title
format(cinfo,metas,is_https,charset), // format the metas
format_html_head(*p_content_head_tags, charset),
"</head>\n"
],
printable_tree([
"HTTP/1.1 " + status_string, crlf,
format_headers(standard_headers),
format_headers(standard_headers_for("text/html", length(answer_body_header) + length(answer_body_body), success(charset))),
format_headers(status_headers),
format_headers(additional_headers),
crlf,
answer_body_header .
answer_body_body
]),
plain_text (HTTP_Status status, String text) then
if format(status) is (status_string, status_headers) then
printable_tree([
"HTTP/1.1 " + status_string, crlf,
format_headers(standard_headers),
format_headers(standard_headers_for("text/plain", length(text), success(charset))),
format_headers(status_headers),
format_headers(additional_headers),
crlf,
text . (Printable_tree)[]
]),
custom_text(HTTP_Status status, mime_type, String content) then
if format(status) is (status_string, status_headers) then
printable_tree([
"HTTP/1.1 " + status_string, crlf,
format_headers(standard_headers),
format_headers(standard_headers_for(to_String(mime_type), length(content), success(charset))),
format_headers(status_headers),
format_headers(additional_headers),
crlf,
content . (Printable_tree)[]
]),
custom_binary(HTTP_Status status, mime_type, ByteArray content, List(HTTP_header) other_headers) then
if format(status) is (status_string, status_headers) then
printable_tree([
"HTTP/1.1 " + status_string, crlf,
format_headers(status_headers),
format_headers(standard_headers_for(to_String(mime_type), length(content), failure)),
format_headers(status_headers),
format_headers(other_headers),
format_headers(additional_headers),
crlf,
content . (Printable_tree)[]
]),
custom_tree(HTTP_Status status, mime_type, Printable_tree content) then
if format(status) is (status_string, status_headers) then
printable_tree([
"HTTP/1.1 " + status_string, crlf,
format_headers(standard_headers),
format_headers(standard_headers_for(to_String(mime_type), length(content), success(charset))),
format_headers(status_headers),
format_headers(additional_headers),
crlf .
content
]),
json(HTTP_Status status, JsonValue json_content) then
//with start = unow,
with content = (Printable_tree)format_json(json_content),
//println(show_duration_string("HTTP json format json object ", start));
if format(status) is (status_string, status_headers) then
printable_tree([
"HTTP/1.1 " + status_string, crlf,
format_headers(standard_headers),
format_headers(standard_headers_for(to_String(mime_application_json), length(content), success(charset))),
format_headers(status_headers),
format_headers(additional_headers),
crlf .
content
])
,
send_file(file_path, c_disposition) then
send_file(file_path, c_disposition),
http_raw(Printable_tree content) then
printable_tree(content),
html_content(HTTP_Status status, HTML_Off_Form content_HTML) then
if format(status) is (status_string, status_headers) then
with content = format(cinfo, ic_v, content_HTML, is_https, var(0), p_content_head_tags),
printable_tree([
"HTTP/1.1 " + status_string, crlf,
format_headers(standard_headers),
format_headers(standard_headers_for("text/html", length(content), success(charset))),
format_headers(status_headers),
format_headers(additional_headers),
crlf .
content
]),
//HMTL content with some header
html_partial_content(HTTP_Status status, HTML_Partial_Content p_content) then
since p_content is partial_content(head_tags, html_content),
since format(status) is (status_string, status_headers),
with
answer_body = (Printable_tree)
[
format(cinfo, ic_v, html_content, is_https, var(0), p_content_head_tags),
],
answer_header = (Printable_tree)
[
// html_header,
format_html_head(head_tags + *p_content_head_tags),
],
printable_tree([
"HTTP/1.1 " + status_string, crlf,
format_headers(standard_headers),
format_headers(standard_headers_for("text/html", length(answer_header) + length(answer_body), success(charset))),
format_headers(status_headers),
format_headers(additional_headers),
crlf,
answer_header .
answer_body
]),
}.