aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/misc.org
blob: 5e9fd2599e287bdeee648e9b492b57ebb67012a2 (plain)
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
-*- mode: org -*-
#+TITLE:       sisu misc
#+DESCRIPTION: documents - structuring, various output representations & search
#+FILETAGS:    :sisu:misc:
#+AUTHOR:      Ralph Amissah
#+EMAIL:       [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]]
#+COPYRIGHT:   Copyright (C) 2015 - 2021 Ralph Amissah
#+LANGUAGE:    en
#+STARTUP:     content hideblocks hidestars noindent entitiespretty
#+OPTIONS:     H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t
#+PROPERTY:    header-args  :exports code
#+PROPERTY:    header-args+ :noweb yes
#+PROPERTY:    header-args+ :eval no
#+PROPERTY:    header-args+ :results no
#+PROPERTY:    header-args+ :cache no
#+PROPERTY:    header-args+ :padline no
#+PROPERTY:    header-args+ :mkdirp yes

* misc sort
** air.rb

#+HEADER: :tangle "../lib/sisu/air.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Air
  require_relative 'se_hub_particulars'                 # se_hub_particulars.rb
  class Source
    @@ao_array=[]
    @@fns=nil
    def initialize(opt)
      @opt=opt
      @@fns||@opt.fns
      @particulars=SiSU_Particulars::Combined.new(opt)
      #@env=@particulars.env
      #@md=@particulars.md
      #@ao_array=@particulars.ao_array
    end
    def read
    end
  protected
    def print
      puts @particulars.md.inspect
      puts @particulars.env.inspect
      puts @particulars.ao_array
    end
  end
end
__END__
#+END_SRC

** embedded.rb

#+HEADER: :tangle "../lib/sisu/embedded.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Embedded
  require_relative 'dp'                                 # dp.rb
    include SiSU_Param
  require_relative 'se'                                 # se.rb
    include SiSU_Env
  class Source
    def initialize(opt)
      @opt=opt
      @md=SiSU_Param::Parameters.new(@opt).get
      @env=SiSU_Env::InfoEnv.new(@md.fns)
      @rhost=SiSU_Env::InfoRemote.new(@opt).remote_host_base
      @base_src_dir=@opt.f_pth[:pth].sub(/\/#{@opt.f_pth[:lng]}$/,'')
      @f=SiSU_Env::FileOp.new(@md)
    end
    def read
      songsheet
    end
    def songsheet
      images
      audio
      multimedia
      begin
      rescue
        SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
          __LINE__.to_s + ':' + __FILE__
        end
      ensure
      end
    end
    def images
      src="#{@base_src_dir}/_sisu/image"
      ldest=@env.path.output
      img_dir="#{@env.path.output}/_sisu/image"
      @rhost.each do |remote_conn|
        if (@md.opt.act[:verbose][:set]==:on \
        || @md.opt.act[:verbose_plus][:set]==:on \
        || @md.opt.act[:maintenance][:set]==:on \
        || @md.opt.act[:rsync][:set]==:on) \
        and FileTest.directory?(src)
          FileUtils::mkdir_p(img_dir) unless FileTest.directory?(img_dir)
          src_ec=@f.place_file.images.rel + '/' + @md.ec[:image].join(" #{@f.output_path.images.rel}/")
          unless @opt.fns =~/\.-sst$/
            SiSU_Env::SystemCall.new(src_ec,ldest,'q').rsync('--relative',@opt.base_path)
            #if @md.opt.selections.str.inspect =~/R/ #rsync to remote image directory
            #  SiSU_Env::SystemCall.new(src_ec,remote_rel,'q').rsync('--relative')
            #end
          end
        end
      end
    end
    def audio
      #p @md.ec[:audio]
      src="#{@base_src_dir}/_sisu/mm/audio"
      ldest="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/mm/audio"
      @rhost.each do |remote_conn|
        rdest="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/_sisu/mm/audio"
        if (@md.opt.act[:verbose][:set]==:on \
        || @md.opt.act[:verbose_plus][:set]==:on \
        || @md.opt.act[:maintenance][:set]==:on \
        || @md.opt.act[:rsync][:set]==:on) \
        and FileTest.directory?(src)
          FileUtils::mkdir_p(ldest) unless FileTest.directory?(ldest)
          src_ec="#{src}/" + @md.ec[:audio].join(" #{src}/")
          SiSU_Env::SystemCall.new(src_ec,"#{ldest}/.",'q').rsync
          if @md.opt.act[:rsync][:set]==:on #rsync to remote audio directory
            SiSU_Env::SystemCall.new(src_ec,"#{rdest}/.",'q').rsync
          end
        end
      end
    end
    def multimedia
      #p @md.ec[:multimedia]
      src="#{@base_src_dir}/_sisu/mm/video"
      ldest="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/mm/video"
      @rhost.each do |remote_conn|
        rdest="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/_sisu/mm/video"
        if (@md.opt.act[:verbose][:set]==:on \
        || @md.opt.act[:verbose_plus][:set]==:on \
        || @md.opt.act[:maintenance][:set]==:on \
        || @md.opt.act[:rsync][:set]==:on) \
        and FileTest.directory?(src)
          FileUtils::mkdir_p(ldest) unless FileTest.directory?(ldest)
          src_ec="#{src}/" + @md.ec[:multimedia].join(" #{src}/")
          SiSU_Env::SystemCall.new(src_ec,"#{ldest}/.",'q').rsync
          if @md.opt.act[:rsync][:set]==:on #rsync to remote video directory
            SiSU_Env::SystemCall.new(src_ec,"#{rdest}/.",'q').rsync
          end
        end
      end
    end
  end
end
__END__
#+END_SRC

** errors.rb

#+HEADER: :tangle "../lib/sisu/errors.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Errors
  require_relative 'se'                                 # se.rb
    include SiSU_Env; include SiSU_Screen
  class Rescued <CreateFile
    def initialize(error,errorlist,cmd,fns='')
      @fns,@cmd,@error,@errorlist=fns,cmd,error,errorlist
      @cmd=(cmd \
      && (cmd =~/c/)) \
      ?  'Vc'
      : 'V'
    end
    def location
      file=@fns \
      ? (SiSU_Env::CreateFile.new(@fns).file_error)
      : (File.new('/tmp/errorlog.sisu','w+'))
      file << @fns << "\n" << @error << "\n" << @errorlist
      file.close
      if @cmd=~/[vVM]/
        SiSU_Screen::Ansi.new('',$!,$@).rescue do
          (block_given?) ? yield : __LINE__.to_s + ':' + __FILE__
        end
      else
        SiSU_Screen::Ansi.new('',"rescued, exception raised, silenced").puts_grey
      end
    end
  end
end
__END__
#+END_SRC

** git.rb

#+HEADER: :tangle "../lib/sisu/git.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Git
  require_relative 'dp'                                 # dp.rb
  require_relative 'se'                                 # se.rb
  require_relative 'ao'                                 # ao.rb
  class Source
    def initialize(opt,process=:complete)
      @opt,@process=opt,process
      @env=SiSU_Env::InfoEnv.new
      @md=SiSU_Param::Parameters.new(@opt).get
      @file=SiSU_Env::FileOp.new(@md)
      l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language
      unless @opt.lng==l[:c] # @md.i18n[0]==l[:c]
        p "using: #{@opt.lng} (@make: :language:); filename #{@md.fns} filename language: #{l[:c]}, mismatch"
      end
      if @env.output_dir_structure.multilingual?
        m=/((.+?)(?:\~\w{2,3})?)\.((?:-|ssm\.)?sst|ssm)$/ #watch added match for sss
        fnb,fnt=@opt.fns[m,2],@opt.fns[m,3]
      else m=/(.+?)\.((?:-|ssm\.)?sst|ssm)$/
        fnb=@fnn=@opt.fns[m,1]
        fnt=@opt.fns[m,2]
      end
      git_path_fnb=@env.processing_path.git + '/' + fnb
      lng=(@md.opt.lng) ? (@md.opt.lng) : (@md.i18n[0])
      @git_path={
        fnb:       git_path_fnb,
        doc:       git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:doc] + '/' + lng,
        po:        git_path_fnb + '/' + Gt[:po] + '/' + lng,
        pot:       git_path_fnb + '/' + Gt[:pot],
        conf:      git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:conf],
        image:     git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:image],
        audio:     git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:audio],
        video:     git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:video],
        conf:      git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:conf]
      }
      SiSU_AO::Source.new(@opt,nil,@process).read                            # -m
    end
    def create_file_structure_git
      make_dir_fnb
      if program_found?
        git_init
      end
    end
    def read
      create_file_structure_git
      populate.sisusrc_files
      #if program_found?
      #  git_commit
      #end
      unless @opt.act[:quiet][:set]==:on
        (@opt.act[:verbose][:set]==:on \
        || @opt.act[:verbose_plus][:set]==:on \
        || @opt.act[:maintenance][:set]==:on) \
        ? SiSU_Screen::Ansi.new(
            @opt.act[:color_state][:set],
            'Git path',
            @git_path[:fnb]
          ).green_hi_blue
        : SiSU_Screen::Ansi.new(
            @opt.act[:color_state][:set],
            'Git path',
            @git_path[:fnb]
          ).green_title_hi
        if (@opt.act[:verbose][:set]==:on \
        || @opt.act[:verbose_plus][:set]==:on \
        || @opt.act[:maintenance][:set]==:on)
          SiSU_Screen::Ansi.new(
            @opt.act[:color_state][:set],
            "Git path",
            "#{@opt.fns} -> #{@git_path[:fnb]}"
          ).warn
        end
      end
    end
    def program_found?
      found=`whereis git`
      (found =~/bin\/git\b/) ? true : false
    end
    def make_dir_fnb
      FileUtils::mkdir_p(@git_path[:fnb]) \
        unless FileTest.directory?(@git_path[:fnb])
      FileUtils::mkdir_p(@git_path[:doc]) \
        unless FileTest.directory?(@git_path[:doc])
      FileUtils::mkdir_p(@git_path[:po]) \
        unless FileTest.directory?(@git_path[:po])
      FileUtils::mkdir_p(@git_path[:pot]) \
        unless FileTest.directory?(@git_path[:pot])
      FileUtils::mkdir_p(@git_path[:conf]) \
        unless FileTest.directory?(@git_path[:conf])
      FileUtils::mkdir_p(@git_path[:image]) \
        unless FileTest.directory?(@git_path[:image])
      #FileUtils::mkdir_p(@git_path[:audio]) \
      #  unless FileTest.directory?(@git_path[:audio])
      #FileUtils::mkdir_p(@git_path[:video]) \
      #  unless FileTest.directory?(@git_path[:video])
    end
    def git_init
      unless FileTest.directory?("#{@git_path[:fnb]}/.git")
        pwd=Dir.pwd
        Dir.chdir(@git_path[:fnb])
        system("git init ")
        Dir.chdir(pwd)
      end
    end
    def git_commit
      if program_found?
        if FileTest.directory?("#{@git_path[:fnb]}")
          pwd=Dir.pwd
          Dir.chdir(@git_path[:fnb])
          system("
            git add . \
            && git commit -a
          ")
          Dir.chdir(pwd)
        end
      end
    end
    def populate
      def identify_language_versions
        print __FILE__ + ':'
        p __LINE__
      end
      def copy_src_head
        if @opt.f_pth[:lng] \
        and File.exist?("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}")
          FileUtils::cp_r(
            "#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}",
            @git_path[:doc]
          )
        elsif @opt.fns =~/\.ssm\.sst/
          ssm=@opt.fns.gsub(/\.ssm\.sst/,'.ssm')
          FileUtils::cp_r(
            "#{@env.path.pwd}/#{ssm}",
            @git_path[:doc]
          )
        elsif File.exist?("#{@env.path.pwd}/#{@opt.fns}")
          FileUtils::cp_r(
            "#{@env.path.pwd}/#{@opt.fns}",
            @git_path[:doc]
          )
        end
      end
      def copy_related_sst_ssi
        doc_import=[]
        @rgx_doc_import=/^<<\s(\S+?\.ss[ti])/
        file_array=IO.readlines(@opt.fns,'')
        file_array.each do |f|
          if f =~@rgx_doc_import
            doc_import = doc_import \
            + f.scan(@rgx_doc_import).uniq.flatten
          end
        end
        doc_import.each do |f|
          if @opt.f_pth[:lng]
            FileUtils::cp_r(
              "#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{f}",
              @git_path[:doc]
            )
          else
            FileUtils::cp_r(
              "#{@env.path.pwd}/#{f}",
              @git_path[:doc]
            )
          end
        end
      end
      def locate_parse_file
        composite_src=@opt.fns=~/\.ssm$/ ? true : false
        if composite_src \
        and not @opt.act[:ao][:set]==:on
          ##SiSU_Assemble::Composite.new(@opt).read
          #SiSU_AO::Source.new(@opt).read                                         # -m
          @env.processing_path.composite_file \
          + '/' \
          + @opt.fnb \
          + '.ssm.sst'
        elsif composite_src
          @env.processing_path.composite_file \
          + '/' \
          + @opt.fnb \
          + '.ssm.sst'
        else
          @env.path.pwd
          + '/' \
          + @opt.fns
        end
      end
      def read_composite
        #print __FILE__ + ':'
        #p __LINE__
      end
      def sisuyaml_rc
        sisurc=@env.path.sisurc_path
        if FileTest.file?(sisurc)
          FileUtils::cp_r(sisurc,@git_path[:conf])
        end
      end
      def read_src
        print __FILE__ + ':'
        p __LINE__
      end
      def composite_src?
        @opt.fns=~/\.ssm$/ ? true : false
      end
      def sisusrc_files
        populate.copy_src_head
        if composite_src?
          populate.copy_related_sst_ssi
        end
        #parse_file_name=locate_parse_file
        #parse_file=IO.readlines(parse_file_name,'')
        populate.sisuyaml_rc #(parse_file)
        #populate.extract_composite_source
        #populate.read_composite # or read_each_composite
        populate.identify_language_versions
      end
      self
    end
  end
end
__END__
@file.output_path.sisugit
#+END_SRC

** qrcode.rb

#+HEADER: :tangle "../lib/sisu/qrcode.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_QRcode
  require_relative 'se'                                 # se.rb
    include SiSU_Env
  require_relative 'prog_text_translation'              # prog_text_translation.rb
  require_relative 'se_hub_particulars'                 # se_hub_particulars.rb
    include SiSU_Particulars
  require_relative 'html'                               # html.rb
  require_relative 'dp'                                 # dp.rb
    include SiSU_Param
  require_relative 'generic_parts'                      # generic_parts.rb
  require_relative 'i18n'                               # i18n.rb
  class Source
    def initialize(opt)
      @opt=opt
      @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
      l=SiSU_Env::StandardiseLanguage.new(@opt.lng).language
      @doc_language=l[:n]
    end
    def read
      begin
        @env=SiSU_Env::InfoEnv.new(@opt.fns,@opt)
        @md=SiSU_Param::Parameters.new(@opt).get
        xbrowser=@env.program.web_browser
        browser=@env.program.console_web_browser
        unless @opt.act[:quiet][:set]==:on
          url_html="file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}"
          (@opt.act[:verbose][:set]==:on \
          || @opt.act[:verbose_plus][:set]==:on \
          || @opt.act[:maintenance][:set]==:on) \
          ? SiSU_Screen::Ansi.new(
              @opt.act[:color_state][:set],
              'QR code',
              "#{xbrowser} #{url_html}"
            ).green_hi_blue
          : SiSU_Screen::Ansi.new(
              @opt.act[:color_state][:set],
              'QR code',
              "[#{@opt.f_pth[:lng_is]}] #{@opt.fns}"
            ).green_title_hi
          if (@opt.act[:verbose][:set]==:on \
          || @opt.act[:verbose_plus][:set]==:on \
          || @opt.act[:maintenance][:set]==:on)
            SiSU_Screen::Ansi.new(
              @opt.act[:color_state][:set],
              "#{browser} #{url_html}"
            ).grey_tab
          end
        end
        data=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions
        OutputInfo.new(@md).check_output(data)
      rescue
        SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
          __LINE__.to_s + ':' + __FILE__
        end
      ensure
      end
    end
    private
    class OutputInfo <Source
      include SiSU_Parts_Generic
      def initialize(md)
        @manifest={ txt: [], txt_title: [] }
        @md,@fns=md,md.fns
        @env=SiSU_Env::InfoEnv.new(@md.fns,@md.opt)
        @fnb=@md.fnb
        @base_url="#{@env.url.root}/#{@fnb}"
        @f=SiSU_Env::FileOp.new(@md)
        @base_path=@f.output_path.manifest.dir
        @@dg ||=SiSU_Env::InfoEnv.new.digest(@md.opt).type
        @dg=@@dg
        l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language
        @language=l[:n]
        @translate=SiSU_Translate::Source.new(@md,@language)
        @f.make_path(@f.output_path.qrcode.dir)
      end
      def spaces
        Ax[:spaces]
      end
      def output_metadata
        fn=@f.base_filename.manifest_txt
        mn=''
        if @md.opt.act[:maintenance][:set]==:on
          fn=@f.base_filename.manifest_txt
          manifest=@f.write_file.manifest_txt
        end
        @manifest[:txt].each do |x|
          x=x.gsub(/\\\\/m,"\n")
          puts x if @md.opt.act[:verbose_plus][:set]==:on
          manifest << x if @md.opt.act[:maintenance][:set]==:on
          mn += x
        end
        manifest.close if @md.opt.act[:maintenance][:set]==:on
        cmd=SiSU_Env::SystemCall.new(mn,@f.place_file.qrcode_md.dir,@md.opt.selections.str)
        cmd.qrencode
      end
      def output_metadata_short
        mn=''
        @manifest[:txt_title].each do |x|
          mn += x
        end
        cmd=SiSU_Env::SystemCall.new(mn,@f.place_file.qrcode_title.dir,@md.opt.selections.str)
        cmd.qrencode
      end
      def summarize(id,file,pth='',rel='',url='',img='● ')
        size=(File.size("#{pth}/#{file}")/1024.00).to_s
        kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1]
        @manifest[:txt] <<<<WOK
#{id} #{kb}
  #{the_text.url_open}#{url}/#{file}#{the_text.url_close}
WOK
      end
      def summarize_html_seg(id,file,pth='',rel='',url='',img='● ')
        size=(File.size("#{pth}/#{file}")/1024.00).to_s
        kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1]
        @manifest[:txt] <<<<WOK
#{id} #{kb}
  #{the_text.url_open}#{url}/#{file}#{the_text.url_close}
WOK
      end
      def summarize_sources(id,file,pth,rel,url)
        sys=SiSU_Env::SystemCall.new
        dgst=case @dg
        when :sha512
          (sys.sha512("#{pth}/#{file}")) #check
        when :md5
          (sys.md5("#{pth}/#{file}"))
        else
          (sys.sha256("#{pth}/#{file}"))
        end
        dgst=dgst ? dgst : [ '', 'n/a' ]
        if (@md.opt.act[:verbose][:set]==:on \
        || @md.opt.act[:verbose_plus][:set]==:on \
        || @md.opt.act[:maintenance][:set]==:on)
          SiSU_Screen::Ansi.new(
            @md.opt.selections.str,
            "#{dgst[1]} #{file}"
          ).warn
        end
        size=(File.size("#{pth}/#{file}")/1024.00).to_s
        kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1]
        @manifest[:txt] <<<<WOK
#{id} #{dgst[1]} #{kb}
  #{the_text.url_open}#{url}/#{file}#{the_text.url_close}
WOK
      end
      def published_manifests?
        @f=SiSU_Env::FileOp.new(@md) #.base_filename
        @m=[]
        url=@f.output_path.base.url
        manifests={}
        mp,mn,mt=nil,nil,nil
        ln=SiSU_i18n::Languages.new.language.list
        Px[:lng_lst].each do |lc|
          if @env.output_dir_structure.by_language_code?
            mp="#{@f.output_path.base.dir}/#{lc}/manifest"
            mn="#{@md.fnb}.html"
            mt="#{mp}/#{mn}"
            mu="#{url}/#{lc}/manifest/#{mn}"
          elsif @env.output_dir_structure.by_filetype?
            mp="#{@f.output_path.base.dir}/manifest"
            mn="#{@md.fnb}.#{lc}.html"
            mt="#{mp}/#{mn}"
            mu="#{url}/manifest/#{mn}"
          else
            mp="#{@f.output_path.base.dir}/#{@md.fnb}"
            mn="sisu_manifest.#{lc}.html"
            mt="#{mp}/#{mn}"
            mu="#{url}/#{mn}"
          end
          if FileTest.directory?(mp) \
          &&  FileTest.file?(mt)
            lng=ln[lc][:t]
            manifests[lc]={ ln: lng, fn: mn }
            @m << { mu: mu, l: lng }
          end
        end
        #manifests
        @m=@m.uniq
        @m
      end
      def languages(id,file)
        flv=published_manifests?
        flv.each do |l|
          SiSU_Translate::Source.new(@md,@language,l[:n]).language_list
          @manifest[:txt] << "#{l[:mu]} #{l[:l]}\n"
        end
      end
      def published_languages(id,file)
        flv=published_manifests?
        flv.each do |l|
          @manifest[:txt] << "#{l[:l]}  #{the_text.url_open}#{l[:mu]}#{the_text.url_close}\n"
        end
      end
      def metadata(id,info)
        info=info.to_s.gsub(/#{Mx[:br_line]}/,"\n")
        @manifest[:txt] << %{#{id}: #{info}\n}
      end
      def md_title_info(id,info)
        info=info.to_s.gsub(/#{Mx[:br_line]}/,"\n")
        @manifest[:txt_title] << %{#{info}\n}
      end
      def links(url,lnk,target)
        static=if url =~/^\.\// then url.gsub(/^\.(\.)?/,@base_url)
        elsif url =~/^\.\.\//   then url.gsub(/^\.(\.)?/,@env.url.root)
        else                         url
        end
        @manifest[:txt] << %{#{url} #{lnk} #{the_text.url_open}#{static}#{the_text.url_close}\n}
      end
      def output_tests
        if FileTest.file?(@f.place_file.html_segtoc.dir)==true
          pth=@f.output_path.html_seg.dir
          rel=@f.output_path.html_seg.rel_sm
          url=@f.output_path.html_seg.url
          id,file='HTML, table of contents (for segmented text)',@f.base_filename.html_segtoc
          summarize_html_seg(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.html_scroll.dir)==true
          pth=@f.output_path.html_scroll.dir
          rel=@f.output_path.html_scroll.rel_sm
          url=@f.output_path.html_scroll.url
          id,file='HTML, full length document',@f.base_filename.html_scroll
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.html_book_index.dir)==true
          pth=@f.output_path.html_seg.dir
          rel=@f.output_path.html_seg.rel_sm
          url=@f.output_path.html_seg.url
          id,file='HTML, (book type) index',@f.base_filename.html_book_index
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.html_concordance.dir)==true
          pth=@f.output_path.html_seg.dir
          rel=@f.output_path.html_seg.rel_sm
          url=@f.output_path.html_seg.url
          id,file='HTML, concordance file',@f.base_filename.html_concordance
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.epub.dir)==true
          id,file='EPUB (Electronic Publication, e-book standard)',@f.base_filename.epub
          pth=@f.output_path.epub.dir
          rel=@f.output_path.epub.rel_sm
          url=@f.output_path.epub.url
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_letter}")==true
          pth=@f.output_path.pdf.dir
          rel=@f.output_path.pdf.rel_sm
          url=@f.output_path.pdf.url
          id,file="PDF, U.S. letter size, portrait/vertical","#{@f.base_filename.pdf_p_letter}"
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_letter}")==true
          pth=@f.output_path.pdf.dir
          rel=@f.output_path.pdf.rel_sm
          url=@f.output_path.pdf.url
          id,file="PDF, U.S. letter size, landscape/horizontal","#{@f.base_filename.pdf_l_letter}"
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a4}")==true
          pth=@f.output_path.pdf.dir
          rel=@f.output_path.pdf.rel_sm
          url=@f.output_path.pdf.url
          id,file="PDF, A4 size, portrait/vertical","#{@f.base_filename.pdf_p_a4}"
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a4}")==true
          pth=@f.output_path.pdf.dir
          rel=@f.output_path.pdf.rel_sm
          url=@f.output_path.pdf.url
          id,file="PDF, A4 size, landscape/horizontal","#{@f.base_filename.pdf_l_a4}"
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a5}")==true
          pth=@f.output_path.pdf.dir
          rel=@f.output_path.pdf.rel_sm
          url=@f.output_path.pdf.url
          id,file="PDF, A5 (book) size, portrait/vertical","#{@f.base_filename.pdf_p_a5}"
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a5}")==true
          pth=@f.output_path.pdf.dir
          rel=@f.output_path.pdf.rel_sm
          url=@f.output_path.pdf.url
          id,file="PDF, A5 (book) size, landscape/horizontal","#{@f.base_filename.pdf_l_a5}"
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_b5}")==true
          pth=@f.output_path.pdf.dir
          rel=@f.output_path.pdf.rel_sm
          url=@f.output_path.pdf.url
          id,file="PDF, B5 (book) size, portrait/vertical","#{@f.base_filename.pdf_p_b5}"
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_b5}")==true
          pth=@f.output_path.pdf.dir
          rel=@f.output_path.pdf.rel_sm
          url=@f.output_path.pdf.url
          id,file="PDF, B5 (book) size, landscape/horizontal","#{@f.base_filename.pdf_l_b5}"
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_legal}")==true
          pth=@f.output_path.pdf.dir
          rel=@f.output_path.pdf.rel_sm
          url=@f.output_path.pdf.url
          id,file="PDF, U.S. legal size, portrait/vertical","#{@f.base_filename.pdf_p_legal}"
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_legal}")==true
          pth=@f.output_path.pdf.dir
          rel=@f.output_path.pdf.rel_sm
          url=@f.output_path.pdf.url
          id,file="PDF, U.S. legal size, landscape/horizontal","#{@f.base_filename.pdf_l_legal}"
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.odt.dir)==true
          pth=@f.output_path.odt.dir
          rel=@f.output_path.odt.rel_sm
          url=@f.output_path.odf.url
          id,file='ODF:ODT (Open Document Format)',@f.base_filename.odt
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.xhtml.dir)==true
          pth=@f.output_path.xhtml.dir
          rel=@f.output_path.xhtml.rel_sm
          url=@f.output_path.xhtml.url
          id,file='ODF:ODT (Open Document Format)',@f.base_filename.odt
          id,file='XHTML',@f.base_filename.xhtml
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.xml_sax.dir)==true
          pth=@f.output_path.xml_sax.dir
          rel=@f.output_path.xml_sax.rel_sm
          url=@f.output_path.xml_sax.url
          id,file='XML SAX',@f.base_filename.xml_sax
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.xml_dom.dir)==true
          pth=@f.output_path.xml_dom.dir
          rel=@f.output_path.xml_dom.rel_sm
          url=@f.output_path.xml_dom.url
          id,file='XML DOM',@f.base_filename.xml_dom
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.txt.dir)==true
          id='Plaintext (UTF-8)'
          #id=if @md.opt.selections.str =~/a/ then 'Plaintext (Unix (UTF-8) with footnotes)'
          #elsif @md.opt.selections.str =~/e/ then 'Plaintext (Unix (UTF-8) with endnotes)'
          #elsif @md.opt.selections.str =~/A/ then 'Plaintext (dos (UTF-8) with footnotes)'
          #elsif @md.opt.selections.str =~/E/ then 'Plaintext (dos (UTF-8) with endnotes)'
          #else                         'Plaintext (UTF-8)'
          #end
          pth=@f.output_path.txt.dir
          rel=@f.output_path.txt.rel_sm
          url=@f.output_path.txt.url
          file=@f.base_filename.txt
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@base_path}/#{@md.fns}.tex")==true
          id,file='LaTeX (portrait)',"#{@md.fns}.tex"
          pth,rel,url='','',''
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?("#{@base_path}/#{@md.fns}.tex")==true
          id,file='LaTeX (landscape)',"#{@md.fns}.landscape.tex"
          pth,rel,url='','',''
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.manpage.dir)==true
          pth=@f.output_path.manpage.dir
          rel=@f.output_path.manpage.rel_sm
          url=@f.output_path.manpage.url
          id,file='Manpage',@f.base_filename.manpage
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.texinfo.dir)==true
          pth=@f.output_path.texinfo.dir
          rel=@f.output_path.texinfo.rel_sm
          url=@f.output_path.texinfo.url
          id,file='Texinfo',@f.base_filename.texinfo
          summarize(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.hash_digest.dir)==true
          pth=@f.output_path.hash_digest.dir
          rel=@f.output_path.hash_digest.rel_sm
          url=@f.output_path.hash_digest.url
          id,file="Digest/DCC - Document Content Certificate (#{@dg})",@f.base_filename.hash_digest
          summarize(id,file,pth,rel,url)
        end
      end
      def published_versions
        id,file='Markup (SiSU source)',@md.fns
        #languages(id,file)
        published_languages(id,file)
      end
      def language_versions
        if FileTest.file?(@f.place_file.manifest.dir)==true
          id,file='Markup (SiSU source)',@md.fns
          published_languages(id,file)
        end
      end
      def source_tests
        if @md.fns =~/\.ssm\.sst$/                                                  #% decide whether to extract and include requested/required documents
          if FileTest.file?(@f.place_file.src.dir)==true
            pth=@f.output_path.src.dir
            rel=@f.output_path.src.rel
            url=@f.output_path.src.url
            id,file='Markup Composite File (SiSU source)',@f.base_filename.src
            summarize_sources(id,file,pth,rel,url)
          end
        else
          if FileTest.file?(@f.place_file.src.dir)==true
            pth=@f.output_path.src.dir
            rel=@f.output_path.src.rel
            url=@f.output_path.src.url
            id,file='Markup (SiSU source)',@f.base_filename.src
            summarize_sources(id,file,pth,rel,url)
          end
        end
        if FileTest.file?(@f.place_file.sisupod.dir)==true
          pth=@f.output_path.sisupod.dir
          rel=@f.output_path.sisupod.rel
          url=@f.output_path.sisupod.url
          id,file='SiSU doc (zip)',@f.base_filename.sisupod
          summarize_sources(id,file,pth,rel,url)
        end
        if FileTest.file?(@f.place_file.pot.dir)==true
          pth=@f.output_path.pot.dir
          rel=@f.output_path.pot.rel_sm
          url=@f.output_path.pot.url
          id,file='SiSU pot',@f.base_filename.pot
          summarize_sources(id,file,pth,rel,url)
        end
      end
      def metadata_tests
        if defined? @md.title.full \
        and @md.title.full=~/\S+/
          id,info=@translate.full_title,@md.title.full
          #id,info=@translate.full_title,%{"#{@md.title.full}"}
          metadata(id,info)
          md_title_info(id,info)
        end
        if defined? @md.creator.author \
        and @md.creator.author=~/\S+/
          id,info=@translate.author,@md.creator.author
          metadata(id,info)
          md_title_info(id,info)
        end
        if defined? @md.creator.editor \
        and @md.creator.editor=~/\S+/
          id,info=@translate.editor,@md.creator.editor
          metadata(id,info)
        end
        if defined? @md.creator.contributor \
        and @md.creator.contributor=~/\S+/
          id,info=@translate.contributor,@md.creator.contributor
          metadata(id,info)
        end
        if defined? @md.creator.translator \
        and @md.creator.translator=~/\S+/
          id,info=@translate.translator,%{(#{@md.creator.translator})}
          metadata(id,info)
          md_title_info(id,info)
        end
        if defined? @md.creator.illustrator \
        and @md.creator.illustrator=~/\S+/
          id,info=@translate.illustrator,@md.creator.illustrator
          metadata(id,info)
        end
        if defined? @md.publisher \
        and @md.publisher=~/\S+/ #dc
          id,info=@translate.publisher,@md.publisher
          metadata(id,info)
        end
        if defined? @md.creator.prepared_by \
        and @md.creator.prepared_by=~/\S+/
          id,info=@translate.prepared_by,@md.creator.prepared_by
          metadata(id,info)
        end
        if defined? @md.creator.digitized_by \
        and @md.creator.digitized_by=~/\S+/
          id,info=@translate.digitized_by,@md.creator.digitized_by
          metadata(id,info)
        end
        if defined? @md.rights.all \
        and @md.rights.all=~/\S+/ #dc
          id,info=@translate.rights,@md.rights.all
          metadata(id,info)
        end
        if defined? @md.date.published
          if defined? @md.date.published \
          and @md.date.published=~/\S+/ #dc
            id,info=@translate.date,@md.date.published
            metadata(id,info)
            md_title_info(id,info)
          end
          if defined? @md.date.created \
          and @md.date.created=~/\S+/ #dc
            id,info=@translate.date_created,@md.date.created
            metadata(id,info)
          end
          if defined? @md.date.issued \
          and @md.date.issued=~/\S+/ #dc
            id,info=@translate.date_issued,@md.date.issued
            metadata(id,info)
          end
          if defined? @md.date.available \
          and @md.date.available=~/\S+/ #dc
            id,info=@translate.date_available,@md.date.available
            metadata(id,info)
          end
          if defined? @md.date.modified \
          and @md.date.modified=~/\S+/ #dc
            id,info=@translate.date_modified,@md.date.modified
            metadata(id,info)
          end
          if defined? @md.date.valid \
          and @md.date.valid=~/\S+/ #dc
            id,info=@translate.date_valid,@md.date.valid
            metadata(id,info)
          end
        end
        if defined? @md.title.language \
        and @md.title.language=~/\S+/
          id,info=@translate.language,@md.title.language
          metadata(id,info)
        end
        if defined? @md.original.language \
        and @md.original.language=~/\S+/
          id,info=@translate.language_original,@md.original.language
          metadata(id,info)
        end
        if defined? @md.classify.subject \
        and @md.classify.subject=~/\S+/
          id,info=@translate.subject,@md.classify.subject
          metadata(id,info)
        end
        if defined? @md.classify.keywords \
        and @md.classify.keywords=~/\S+/
          id,info=@translate.keywords,@md.classify.keywords
          metadata(id,info)
        end
        if defined? @md.classify.loc \
        and @md.classify.loc=~/\S+/
          id,info=@translate.cls_loc,@md.classify.loc
          metadata(id,info)
        end
        if defined? @md.classify.dewey \
        and @md.classify.dewey=~/\S+/
          id,info=@translate.cls_dewey,@md.classify.dewey
          metadata(id,info)
        end
        if defined? @md.notes.description \
        and @md.notes.description=~/\S+/
          id,info=@translate.description,@md.notes.description
          metadata(id,info)
        end
        if defined? @md.notes.abstract \
        and @md.notes.abstract=~/\S+/
          id,info=@translate.abstract,@md.notes.abstract
          metadata(id,info)
        end
        if defined? @md.notes.comment \
        and @md.notes.comment=~/\S+/
          id,info=@translate.comments,@md.notes.comment
          metadata(id,info)
        end
        if defined? @md.notes.coverage \
        and @md.notes.coverage=~/\S+/
          id,info=@translate.coverage,@md.notes.coverage
          metadata(id,info)
        end
        if defined? @md.notes.relation \
        and @md.notes.relation=~/\S+/
          id,info=@translate.relation,@md.notes.relation
          metadata(id,info)
        end
        #if defined? @md.notes.source \
        #and @md.notes.source=~/\S+/
        #  id,info=@translate.source,@md.notes.source
        #  metadata(id,info)
        #end
        #if defined? @md.notes.history \
        #and @md.notes.history=~/\S+/
        #  id,info=@translate.history,@md.notes.history
        #  metadata(id,info)
        #end
        if defined? @md.notes.type \
        and @md.notes.type=~/\S+/ #dc
          id,info=@translate.type,@md.type
          metadata(id,info)
        end
        if defined? @md.notes.format \
        and @md.notes.format=~/\S+/
          id,info=@transate.format,@md.notes.format
          metadata(id,info)
        end
        if defined? @md.notes.prefix_a \
        and @md.notes.prefix_a=~/\S+/
          id,info=@translate.prefix_a,@md.notes.prefix_a
          metadata(id,info)
        end
        if defined? @md.notes.prefix_b \
        and @md.notes.prefix_b=~/\S+/
          id,info=@translate.prefix_b,@md.notes.prefix_b
          metadata(id,info)
        end
        if defined? @md.original.source \
        and @md.original.source=~/\S+/
          id,info=@translate.source,@md.original.source
          metadata(id,info)
        end
        if defined? @md.identifier.oclc \
        and @md.identifier.oclc=~/\S+/
          id,info=@translate.cls_oclc,@md.identifier.oclc
          @manifest[:txt] << %{#{id}:\n}
          @manifest[:txt] << %{#{info}\n}
        end
        if defined? @md.identifier.isbn \
        and @md.identifier.isbn=~/\S+/
          id,info=@translate.cls_isbn,@md.identifier.isbn
          metadata(id,info)
        end
        if defined? @md.topic_register_array \
        and @md.topic_register_array.length > 0
          @manifest[:txt] << %{#{@translate.topic_register}:\n}
          @md.topic_register_array.each do |t|
            t.each_with_index do |st,i|
              if st.is_a?(Array)
                st.each do |v|
                  @manifest[:txt] << %{#{spaces*i}#{v}\n}
                end
              else @manifest[:txt] << %{#{spaces*i}#{st}\n}
              end
            end
          end
        end
        if @md.fns
          id,info=@translate.sourcefile,@md.fns
          metadata(id,info)
        end
        if @md.en[:mismatch] > 0
          id,info='WARNING document error in endnote markup, number mismatch',"endnotes: #{@md.en[:note]} != endnote reference marks: #{@md.en[:mark]} (difference = #{@md.en[:mismatch]})"
          metadata(id,info)
        end
        if @md.wc_words
          id,info=@translate.word_count,@md.wc_words
          metadata(id,info)
        end
        if @md.dgst
          id,info="#{@translate.sourcefile_digest} (#{@dg})",@md.dgst[1]
          metadata(id,info)
        end
        if @md.sc_number
          id,info=@translate.sc_number,@md.sc_number
          metadata(id,info)
        end
        if @md.sc_date
          id,info=@translate.sc_date,"#{@md.sc_date} at #{@md.sc_time}"
          metadata(id,info)
        end
      end
      def check_output(data)
        begin
          @f=SiSU_Env::FileOp.new(@md) #.base_filename
          url=@f.output_path.base.url
          @en_manifest=if @env.output_dir_structure.by_language_code?
            "#{url}/en/manifest/#{@md.fnb}.html"
          elsif @env.output_dir_structure.by_filetype?
            "#{url}/manifest/#{@md.fnb}.#{@md.opt.lng}.html"
          else
            "#{url}/sisu_manifest.#{@md.opt.lng}.html"
          end
          @manifest[:txt] <<<<WOK
#{@translate.manifest_description_metadata}
  #{the_text.url_open}#{@en_manifest}#{the_text.url_close}
WOK
          metadata_tests
          @manifest[:txt_title] <<<<WOK
  #{the_text.url_open}#{@en_manifest}#{the_text.url_close}
WOK
          source_tests
          @manifest[:txt] <<<<WOK
#{@translate.language_version_list}
WOK
          language_versions
          output_metadata
          output_metadata_short
        rescue
          SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
            __LINE__.to_s + ':' + __FILE__
          end
        ensure
        end
      end
    end
  end
end
__END__
#+END_SRC

** relaxng.rb

#+HEADER: :tangle "../lib/sisu/relaxng.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Relaxng
  require_relative 'se'                                 # se.rb
  class RelaxNG
    def gpl3_or_later
      @gpl3_or_later =<<RELAXNG
=begin

 * Name: SiSU generated relaxng

 * Description: generated relaxng for SiSU
   (SiSU is a framework for document structuring, publishing and search)

 * Author: Ralph Amissah

 * Copyright: (C) 1997 - 2013 Ralph Amissah All Rights Reserved.

 * License: GPL 3 or later:

   SiSU, a framework for document structuring, publishing and search

   Copyright: (C) 1997 - 2013 Ralph Amissah

   This program is free software: you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the Free
   Software Foundation, either version 3 of the License, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   more details.

   You should have received a copy of the GNU General Public License along with
   this program. If not, see [http://www.gnu.org/licenses/].

   If you have Internet connection, the latest version of the GPL should be
   available at these locations:
   <http://www.fsf.org/licenses/gpl.html>
   [http://www.gnu.org/licenses/gpl.html]

 * SiSU uses:
   * Standard SiSU markup syntax,
   * Standard SiSU meta-markup syntax, and the
   * Standard SiSU object citation numbering and system

 * Homepages:
   [https://www.sisudoc.org]
   [https://git.sisudoc.org]

 * Ralph Amissah
   [ralph@amissah.com]
   [ralph.amissah@gmail.com]

=end
RELAXNG
    end
    def rnc_name
      def output_sax
        'sisu_sax.rnc'
      end
      def output_dom
        'sisu_dom.rnc'
      end
      def output_xhtml
        'sisu_xhtml.rnc'
      end
      def input_sax
        'sisu_sax.rnc'
      end
      def input_dom
        'sisu_dom.rnc'
      end
      def input_node
        'sisu_node.rnc'
      end
      self
    end
    def rng_name
      def output_sax
        'sisu_sax.rng'
      end
      def output_dom
        'sisu_dom.rng'
      end
      def output_xhtml
        'sisu_xhtml.rng'
      end
      def input_sax
        'sisu_sax.rng'
      end
      def input_dom
        'sisu_dom.rng'
      end
      def input_node
        'sisu_node.rng'
      end
      self
    end
    def xsd_name
      def output_sax
        'sisu_sax.xsd'
      end
      def output_dom
        'sisu_dom.xsd'
      end
      def output_xhtml
        'sisu_xhtml.xsd'
      end
      def input_sax
        'sisu_sax.xsd'
      end
      def input_dom
        'sisu_dom.xsd'
      end
      def input_node
        'sisu_node.xsd'
      end
      self
    end
    def rnc_sisu_object_input
      @relaxng =<<RELAXNG
#%% sisu object model: input
#{gpl3_or_later}
#%% definitions
# dublin core:
element-semantic =
  element semantic {
  # dublin core:
  element title { text }
  & element creator { text }?
  & element subject { text }?
  & element description { text }?
  & element publisher { text }?
  & element contributor { text }?
  & element date { text }?
  & element date.created { text }?
  & element date.issued { text }?
  & element date.available { text }?
  & element date.valid { text }?
  & element date.modified { text }?
  & element type { text }?
  & element format { text }?
  & element identifier { text }?
  & element source { text }?
  & element relation { text }?
  & element coverage { text }?
  & element rights { text }?
  & element keywords { text }?
  # extended semantic metadata:
  & attribute subtitle { text }?
  & attribute illustrator { text }?
  & attribute translator { text }?
  & attribute prepared_by { text }?
  & attribute digitized_by { text }?
  & attribute language { text }?
  & attribute language.original { text }?
  & attribute classify.pg { text }?
  & attribute classify.isbn { text }?
  & attribute classify.dewey { text }?
  & attribute classify.loc { text }?
  & attribute prefix.a { text }?
  & attribute prefix.b { text }?
  & attribute suffix { text }?
  & attribute comments { text }?
  & attribute abstract { text }?
  # & attribute information { text }?
  & attribute contact { text }?
  & attribute links { text }?
  }
element-processing =
  element processing {
  attribute structure { text }?
  & attribute level { text }?
  & attribute markup { text }?
  & attribute bold { text }?
  & attribute italics { text }?
  & attribute papersize { text }?
  & attribute vocabulary { text }?
  & element date_scheme { text }?
  & element date.issued.scheme { text }?
  & element date.available.scheme { text }?
  & element date.valid.scheme { text }?
  & element date.modified.scheme { text }?
  }?
element-head =
  element head {
    # processing instructions, and semantic data, distinguish?:
    element metadata {
      element title { text },
      element file { text },
      element generator { text },
      element-semantic,
      element-processing
    }+
  }
# body text/contents
# includes <b> <i> <u> <del> <ins> <indent1> <bullet> etc.
element-txt =
  element txt {
    text*
    & element b { text }*
    & element i { text }*
    & element u { text }*
    & element ins { text }*
    & element del { text }*
  }
element-endnote =
  element endnote {
    element number { text },
    element note { element-txt }+
  }+
element-para =
  element para {
    # attribute paragraph_format { text },
    element-txt+
    & element-endnote?
  }
element-external_space =
  element external_space {
    # ignored by sisu, provide program needs
    element program {
      # e.g. kdissert
      element name { text },
      element xpos { text },
      element ypos { text },
      element font { text },
      element outline_color { text },
      element text_color { text },
      element comment { text }
    }*
  }*,
#%% structure
  element document {
    # document head:
    element-head,
    # document body:
    element body {
      # object, a unit of text, usually a paragraph with any associated endnotes
      element node {
        element structure {
          # structure document using either node:heading levels or node:heading relationships:
          # (i) sisu default uses node:heading levels (1-6 or A-C,1-3) to build document structure
          element level { text }?,
          # (ii) sisu alternatively could use node:heading relationship information to build document structure
          element node.id { text },
          element node.parent { text },
          element node.child { text }*
        },
        element node.objects {
          element object.heading {
            # nametag used only in headings, especially important for segmented html
            element nametag { text },
            element-para
          },
          element object.para {
            element-para
          }*
        }+,
        element-external_space
      }+
    }
  }
RELAXNG
    end
    def rnc_sisu_object_ao
      @relaxng =<<RELAXNG
#%% sisu object model: ao
#{gpl3_or_later}
#%% definitions
# dublin core:
element-semantic =
  element semantic {
  # dublin core:
  element title { text }
  & element creator { text }?
  & element subject { text }?
  & element description { text }?
  & element publisher { text }?
  & element contributor { text }?
  & element date { text }?
  & element date.created { text }?
  & element date.issued { text }?
  & element date.available { text }?
  & element date.valid { text }?
  & element date.modified { text }?
  & element type { text }?
  & element format { text }?
  & element identifier { text }?
  & element source { text }?
  & element relation { text }?
  & element coverage { text }?
  & element rights { text }?
  & element keywords { text }?
  # extended semantic metadata:
  & attribute subtitle { text }?
  & attribute illustrator { text }?
  & attribute translator { text }?
  & attribute prepared_by { text }?
  & attribute digitized_by { text }?
  & attribute language { text }?
  & attribute language.original { text }?
  & attribute classify.pg { text }?
  & attribute classify.isbn { text }?
  & attribute classify.dewey { text }?
  & attribute classify.loc { text }?
  & attribute prefix.a { text }?
  & attribute prefix.b { text }?
  & attribute suffix { text }?
  & attribute comments { text }?
  & attribute abstract { text }?
  # & attribute information { text }?
  & attribute contact { text }?
  & attribute links { text }?
  }
element-processing =
  element processing {
  attribute structure { text }?
  & attribute level { text }?
  & attribute markup { text }?
  & attribute bold { text }?
  & attribute italics { text }?
  & attribute papersize { text }?
  & attribute vocabulary { text }?
  & element date_scheme { text }?
  & element date.issued.scheme { text }?
  & element date.available.scheme { text }?
  & element date.valid.scheme { text }?
  & element date.modified.scheme { text }?
  }?
element-head =
  element head {
    # processing instructions, and semantic data, distinguish?:
    element metadata {
      element title { text },
      element file { text },
      element generator { text },
      element-semantic,
      element-processing
    }+
  }
# body text/contents
# includes <b> <i> <u> <del> <ins> <indent1> <bullet> etc.
element-txt =
  element txt {
    text*
    & element b { text }*
    & element i { text }*
    & element u { text }*
    & element ins { text }*
    & element del { text }*
  }
element-checksum.endnote = element checksum.clean { text }
element-endnote =
  element endnote {
    element number { text },
    element note { element-txt }+,
    element-checksum.endnote
  }+
element-checksum.para =
  element checksum.para {
    element checksum.clean { text },
    element checksum.marked { text }
  }
element-para =
  element para {
    # attribute paragraph_format { text },
    element-txt+
    & element-endnote?
  }
element-object =
  element object {
    element-para,
    element-checksum.para
  }
# object citation number, unique sequential number for objects:
element-ocn = element ocn { text }
element-object_structure_summary =
  element-ocn,
  # type: heading level value 1 -6, or normal text
  element type { text },
  # type number: sequential number for designated type
  element type_number { text },
  # type category: sequential number for designated category, e.g. sequentially counting all headers
  element category_number { text }
element-external_space =
  element external_space {
    # ignored by sisu, provide program needs
    element program {
      # e.g. kdissert
      element name { text },
      element xpos { text },
      element ypos { text },
      element font { text },
      element outline_color { text },
      element text_color { text },
      element comment { text }
    }*
  }*,
#%% structure
  element document {
    # document head:
    element-head,
    # document body:
    element body {
      # object, a unit of text, usually a paragraph with any associated endnotes
      element node {
        element structure {
          # structure document using either node:heading levels or node:heading relationships:
          # (i) sisu default uses node:heading levels (1-6 or A-C,1-3) to build document structure
          element level { text }?,
          # (ii) sisu alternatively could use node:heading relationship information to build document structure
          element node.id { text },
          element node.parent { text },
          element node.child { text }*
        },
        element node.objects {
          element object.heading {
            element-object_structure_summary,
            # nametag used only in headings, especially important for segmented html
            element nametag { text },
            element-object
          },
          element object.para {
            element-object_structure_summary,
            element-object
          }*
        }+,
        element-external_space
      }+
    }
  }
RELAXNG
    end
    def rnc_model_output_sax
      @relaxng =<<RELAXNG
#% sax output model, part of SiSU and distributed under the same license
default namespace = ""
namespace xl = "http://www.w3.org/1999/xlink"
start =
  element document {
    element head {
      (br
       | meta
       | element creator {
           attribute class { xsd:NCName },
           (text
            | element link {
                attribute xl:href { xsd:anyURI },
                attribute xl:type { xsd:NCName },
                xsd:anyURI
              })+
         }
       | element date {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element date_available {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element date_created {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element date_issued {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element date_modified {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element date_valid {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element keywords {
           attribute class { xsd:NCName },
           text
         }
       | element language {
           attribute class { xsd:NCName },
           xsd:NCName
         }
       | element meta { xsd:NMTOKEN }
       | element rights {
           attribute class { xsd:NCName },
           (text | link)+
         }
       | element source {
           attribute class { xsd:NCName },
           text
         }
       | element structure {
           attribute class { xsd:NCName },
           text
         }
       | element subject {
           attribute class { xsd:NCName },
           text
         }
       | element title {
           attribute class { xsd:NCName },
           text
         }
       | element type {
           attribute class { xsd:NCName },
           text
         }
       | element source_control {
           (br
            | meta
            | element sc {
                attribute class { xsd:NCName },
                text
              })+
         })+
    },
    element body {
      element object {
        attribute id { text },
        element ocn {
          text
        },
        element text {
          attribute class { xsd:NCName },
          (text
           | b
           | br
           | del
           | en
           | i
           | link
           | sub
           | sup
           | u
           | element image {
               attribute alt { text }?,
               attribute height { xsd:integer }?,
               attribute width { xsd:integer }?,
               attribute xl:actuate { xsd:NCName },
               attribute xl:href { text },
               attribute xl:show { xsd:NCName },
               attribute xl:type { xsd:NCName }
             })+
        }?,
        element table {
          attribute align { xsd:NCName },
          attribute bgcolor { xsd:NCName },
          attribute border { xsd:integer },
          attribute cellpadding { xsd:integer },
          attribute summary { text },
          attribute width { text },
          element tr {
            element td {
              attribute valign { xsd:NCName },
              attribute width { text },
              (text | b | i)+
            }+
          }+
        }?,
        element endnote {
          attribute notenumber { xsd:integer }?,
          attribute symbol { text }?,
          (element number { xsd:integer }
           | element symbol { text }),
          element note {
            (text
             | b
             | br
             | del
             | i
             | link
             | sup
             | u
             | element em { xsd:NCName }
             | element sub { xsd:NCName })+
          }
        }*
      }+
    }
  }
meta = element meta { text }
br = element br { empty }
b = element b { (text | en | i | link | sup)+ }
i = element i { (text | b | br | sup)+ }
en = element en { text }
sub = element sub { xsd:NCName }
sup = element sup { xsd:NCName }
link =
  element link {
    attribute xl:href { xsd:anyURI },
    attribute xl:type { xsd:NCName },
    (xsd:anyURI | text | b | i | sup)+
  }
u = element u { (text | b | i)+ }
del = element del { (text | b | i | link)+ }
RELAXNG
    end
    def rnc_model_output_dom
      @relaxng =<<RELAXNG
#% dom output model, part of SiSU and distributed under the same license
default namespace = ""
namespace xl = "http://www.w3.org/1999/xlink"
start =
  element document {
    element head {
      element header {
        meta,
        (element creator { text }
         | element date { xsd:NMTOKEN }
         | element date_available { xsd:NMTOKEN }
         | element date_created { xsd:NMTOKEN }
         | element date_issued { xsd:NMTOKEN }
         | element date_modified { xsd:NMTOKEN }
         | element date_valid { xsd:NMTOKEN }
         | element keywords { text }
         | element language { xsd:NCName }
         | element rights { (text | link)+ }
         | element source { text }
         | element structure { text }
         | element subject { text }
         | element title { text }
         | element type { text }
         | element source_control {
             (br
              | meta
              | element sc {
                  attribute class { xsd:NCName },
                  text
                })+
           })
      }+
    },
    element body {
      element heading1 {
        heading,
        contents1*,
        element heading2 {
          heading,
          contents1*,
          element heading3 {
            heading,
            element contents1 {
              heading,
              content,
              element contents2 {
                heading,
                content,
                element contents3 { heading, content }*
              }*
            }+
          }*
        }*
      }+
    }
  }
meta = element meta { text }
br = element br { empty }
heading = element heading { object }
contents1 =
  element contents1 {
    heading,
    content,
    element contents2 {
      heading,
      content,
      element contents3 { heading, content }*
    }*
  }
content = element content { object* }
object =
  element object {
    attribute id { xsd:integer },
    element ocn { text },
    element nametag { text }?,
    (element table {
       attribute align { xsd:NCName },
       attribute bgcolor { xsd:NCName },
       attribute border { xsd:integer },
       attribute cellpadding { xsd:integer },
       attribute summary { text },
       attribute width { text },
       element tr {
         element td {
           attribute valign { xsd:NCName },
           attribute width { text },
           (text | b | i)+
         }+
       }+
     }
     | element text {
         attribute class { xsd:NCName }?,
         (text
          | b
          | del
          | endnote
          | i
          | link
          | element br { empty }
          | element endnote {
              element number { xsd:integer },
              element note { (text | i | link)+ }
            }
          | element image {
              attribute height { xsd:integer },
              attribute width { xsd:integer },
              attribute xl:actuate { xsd:NCName },
              attribute xl:href { text },
              attribute xl:show { xsd:NCName },
              attribute xl:type { xsd:NCName }
            }
          | element sub { text })+
       })
  }
i = element i { text }
b = element i { text }
u = element u { (text | b | i)+ }
sub = element sub { xsd:NCName }
sup = element sup { xsd:NCName }
del = element del { (text | b | i | link)+ }
link =
  element link {
    attribute xl:href { xsd:anyURI },
    attribute xl:type { xsd:NCName },
    xsd:anyURI
  }
endnote =
  element endnote {
    (element number { xsd:integer }
     | element symbol { text }),
    element note {
      (text
       | b
       | br
       | del
       | i
       | link
       | sub
       | sup
       | u
       | element em { xsd:NCName }
       | element sub { xsd:NCName })+
    }
  }
RELAXNG
    end
    def rnc_model_output_xhtml #not done
      @relaxng =<<RELAXNG
#% xhtml output model, part of SiSU and distributed under the same license
default namespace = ""
namespace xl = "http://www.w3.org/1999/xlink"
start =
  element document {
    element head {
      (br
       | element creator {
           attribute class { xsd:NCName },
           (text
            | element link {
                attribute xl:href { xsd:anyURI },
                attribute xl:type { xsd:NCName },
                xsd:anyURI
              })+
         }
       | element date {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element date_available {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element date_created {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element date_issued {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element date_modified {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element date_valid {
           attribute class { xsd:NCName },
           xsd:NMTOKEN
         }
       | element language {
           attribute class { xsd:NCName },
           xsd:NCName
         }
       | element keywords {
           attribute class { xsd:NCName },
           text
         }
       | element meta {
           attribute content { text }?,
           attribute http-equiv { xsd:NCName }?,
           text
         }
       | element rights {
           attribute class { xsd:NCName },
           (text | link)+
         }
       | element source {
           attribute class { xsd:NCName },
           text
         }
       | element structure {
           attribute class { xsd:NCName },
           text
         }
       | element subject {
           attribute class { xsd:NCName },
           text
         }
       | element title {
           attribute class { xsd:NCName },
           text
         }
       | element type {
           attribute class { xsd:NCName },
           xsd:NCName
         })+
    },
    element body {
      element object {
        attribute id { xsd:integer },
        (element endnote {
           attribute notenumber { xsd:integer }?,
           attribute symbol { text }?,
           (text
            | b
            | br
            | del
            | i
            | link
            | sup
            | u
            | element em { xsd:NCName }
            | element sub { xsd:NCName })+
         }
         | element ocn { text }
         | element text {
             attribute class { xsd:NCName },
             (text
              | b
              | br
              | del
              | en
              | i
              | link
              | sup
              | u
              | element image {
                  attribute alt { text }?,
                  attribute height { xsd:integer }?,
                  attribute width { xsd:integer }?,
                  attribute xl:actuate { xsd:NCName },
                  attribute xl:href { text },
                  attribute xl:show { xsd:NCName },
                  attribute xl:type { xsd:NCName }
                }
              | element sub { text })+
           })+,
        element table {
          attribute align { xsd:NCName },
          attribute bgcolor { xsd:NCName },
          attribute border { xsd:integer },
          attribute cellpadding { xsd:integer },
          attribute summary { text },
          attribute width { text },
          element tr {
            element td {
              attribute valign { xsd:NCName },
              attribute width { text },
              (text | b | i)+
            }+
          }+
        }?
      }+
    }
  }
br = element br { empty }
en = element en { text }
sup = element sup { xsd:NCName }
i = element i { (text | b | br | sup)+ }
link =
  element link {
    attribute xl:href { xsd:anyURI },
    attribute xl:type { xsd:NCName },
    (text | b | i | sup)+
  }
b = element b { (text | en | i | link | sup)+ }
u = element u { (text | b | i)+ }
del = element del { (text | b | i | link)+ }
RELAXNG
    end
    def rnc_model_input_sax
      @relaxng =<<RELAXNG
#% sax input model, part of SiSU and distributed under the same license
default namespace = ""
start =
  element document {
    element head {
      element header {
        attribute class { xsd:NCName },
        (element creator { text }
         | element date { xsd:NMTOKEN }
         | element date.available { xsd:NMTOKEN }
         | element date.created { xsd:NMTOKEN }
         | element date.issued { xsd:NMTOKEN }
         | element date.modified { xsd:NMTOKEN }
         | element date.valid { xsd:NMTOKEN }
         | element italicize { text }
         | element language { xsd:NCName }
         | element links { text }
         | element markup { text }
         | element rights { text }
         | element subject { text }
         | element title { text }
         | element type { xsd:NCName }
         | element vocabulary { xsd:NCName })
      }+
    },
    element body {
      element object {
        element text {
          attribute class { xsd:NCName },
          (text
           | b
           | i
           | element endnote {
               attribute symbol { xsd:NCName },
               (text
                | i
                | element br { empty })+
             }
           | element u { i }
           | element image.path { text })+
        }?
      }+
    }
  }
i = element i { text }
b = element b { text }
RELAXNG
    end
    def rnc_model_input_dom
      @relaxng =<<RELAXNG
#% dom input model, part of SiSU and distributed under the same license
default namespace = ""
start =
  element document {
    element head {
      element header {
        attribute class { xsd:NCName },
        (element creator { text }
         | element date { xsd:NMTOKEN }
         | element date.available { xsd:NMTOKEN }
         | element date.created { xsd:NMTOKEN }
         | element date.issued { xsd:NMTOKEN }
         | element date.modified { xsd:NMTOKEN }
         | element date.valid { xsd:NMTOKEN }
         | element italicize { text }
         | element language { xsd:NCName }
         | element links { text }
         | element markup { text }
         | element rights { text }
         | element subject { text }
         | element title { text }
         | element type { xsd:NCName }
         | element vocabulary { xsd:NCName })
      }+
    },
    element body {
      element heading1 {
        heading,
        element heading2 {
          heading,
          contents1+,
          element heading3 { heading, contents1+ }+
        }
      }
    }
  }
heading = element heading { object }
contents1 =
  element contents1 {
    heading,
    content,
    element contents2 {
      heading,
      content,
      element contents3 { heading, content }*
    }*
  }
object =
  element object {
    element text {
      (text
       | italic
       | element bold { xsd:NMTOKEN }
       | element endnote {
           element symbol { text }?,
           element note {
             (text
              | italic
              | element br { empty })+
           }
         }
       | element underscore { italic }
       | element image.path { text }
       | element italic { text })+
    }
  }
italic = element italic { text }
content = element content { object+ }
RELAXNG
    end
    def rnc_model_input_node
      @relaxng =<<RELAXNG
#% node input model, part of SiSU and distributed under the same license
default namespace = ""
start =
  element document {
    element head {
      element header {
        attribute class { xsd:NCName },
        (element creator { text }
         | element date { xsd:NMTOKEN }
         | element date.available { xsd:NMTOKEN }
         | element date.created { xsd:NMTOKEN }
         | element date.issued { xsd:NMTOKEN }
         | element date.modified { xsd:NMTOKEN }
         | element date.valid { xsd:NMTOKEN }
         | element italicize { (text | i)+ }
         | element language { xsd:NCName }
         | element links { text }
         | element markup { text }
         | element rights { text }
         | element subject { text }
         | element title { text }
         | element type { xsd:NCName }
         | element vocabulary { xsd:NCName })
      }+
    },
    element body {
      element object {
        (element text {
           attribute class { xsd:NCName },
           (text
            | b
            | i
            | element br { empty }
            | element endnote {
                attribute symbol { xsd:NCName },
                (text | i)+
              }
            | element image.path { text }
            | element sub { text })+
         }
         | (element ocn { empty },
            element table {
              attribute align { xsd:NCName },
              attribute bgcolor { xsd:NCName },
              attribute border { xsd:integer },
              attribute cellpadding { xsd:integer },
              attribute summary { text },
              attribute width { text },
              element tr {
                element td {
                  attribute valign { xsd:NCName },
                  attribute width { text },
                  (text | b)+
                }+
              }+
            })),
        element node {
          element id { xsd:integer },
          element parent { xsd:integer },
          element offspring { text }?
        }
      }+
    }
  }
b = element b { text }
i = element i { text }
RELAXNG
    end
  end
end
__END__
needs updating
#+END_SRC

** remote.rb

#+HEADER: :tangle "../lib/sisu/remote.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Remote
  require_relative 'se'                                 # se.rb
    include SiSU_Env
  class Put
    def initialize(opt)
      @opt=opt
      @dir=SiSU_Env::InfoEnv.new(@opt.fns)
      @put=(@opt.fns =~/\.ssm\.sst$/) \
      ? opt.fns.gsub(/(.+)?\.ssm\.sst$/,'\1.ssm')
      : opt.fns
      @remote=SiSU_Env::InfoRemote.new(opt)
    end
    def rsync
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'Remote placement ->',
        @put
      ).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on
      @remote.rsync.document
    end
    def rsync_base
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'Remote placement ->',
        'rsync'
      ).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on
      @remote.rsync.site_base
    end
    def rsync_base_sync
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'Remote placement ->',
        'rsync and sync'
      ).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on
      @remote.rsync.site_base_sync
    end
    def rsync_sitemaps
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'Remote placement sitemaps ->',
        'rsync'
      ).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on
      @remote.rsync_sitemaps
    end
    def rsync_harvest
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'Remote placement metadata harvest ->',
        'rsync_harvest'
      ).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on
      @remote.rsync.site_harvest
    end
    def scp
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'Remote placement ->',
        @put
      ).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on
      @remote.scp.document
    end
    def scp_base
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'Remote placement of base site ->',
        'excluding images'
      ).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on
      @remote.scp.site_base
    end
    def scp_base_all
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'Remote placement ->',
        'complete'
      ).dark_grey_title_hi unless @opt.act[:quiet][:set]==:on
      @remote.scp.site_base_all
    end
  end
  class Get
    def initialize(opt,get_s)
      @opt,@get_s=opt,get_s
      @msg,@msgs='',nil
      @tell=lambda {
        SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],
        @msg,
        "#{@msgs.inspect if @msgs}")
      }
    end
    def fns
      begin
        require 'open-uri'
        require 'pp'
      rescue LoadError
        SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
          error('open-uri or pp NOT FOUND (LoadError)')
      end
      require_relative 'ao_composite'                   # ao_composite.rb
      @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/
      threads=[]
      for requested_page in @get_s
        re_fnb=/((?:https?|file):\/\/[^\/ ]+?\/[^\/ ]+?)\/\S+?\/([^\/]+?)\.ss(t)/ #revisit and remove DO
        threads << Thread.new(requested_page) do |url|
          open(url) do |f|
            raise "#{url} not found" unless f
            base_uri,fnb=re_fnb.match(url)[1..2] if re_fnb
            imagedir=base_uri + '/_sisu/image' #check on
            downloaded_file=File.new("#{fnb}.-sst",'w+')
            image_download_url=SiSU_Assemble::RemoteImage.new.image(imagedir)
            images=[]
            f.collect.each do |r|                            # work area
              unless r =~/^%+\s/
                if r !~/^%+\s/ \
                and r =~@rgx_image
                  images << r.scan(@rgx_image).uniq
                end
              end
              downloaded_file << r
            end
            if images \
            and images.length > 1
              images=images.flatten.uniq
              images.delete_if {|x| x =~/https?:\/\// }
              images=images.sort
              @msg,@msgs='downloading images:', [ images.join(',') ]
              @tell.call.warn unless @opt.act[:quiet][:set]==:on
              image_info=image_download_url + images
              SiSU_Assemble::RemoteImage.new.download_images(image_info)
              #SiSU_Assemble::RemoteImage.new.download_images(image_download_url,images)
              @msg,@msgs='downloading done',nil
              @tell.call.warn unless @opt.act[:quiet][:set]==:on
            end
            downloaded_file.close
          end
        end
      end
      threads.each {|thr| thr.join} if threads #and threads.length > 0
    end
    def sisupod
      get_p=@get_s
      if get_p.length > 0                                     #% remote sisupod
        begin
          require 'net/http'
        rescue LoadError
          SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
            error('net/http NOT FOUND (LoadError)')
        end
        for requested_pod in get_p
          pod_info=RemoteDownload.new(requested_pod)
          Net::HTTP.start(pod_info.pod.site) do |http|
            resp=http.get("#{pod_info.pod.path}/#{pod_info.pod.name_source}")
            open(pod_info.pod.name,'wb') do |file|
              file.write(resp.body)
             end
          end
        end
      end
    end
  end
  class RemoteDownload
    def initialize(requested_file)
      @requested_file=requested_file
    end
    def pod
      re_p_div=/https?:\/\/([^\/]+)(\/\S+)\/(sisupod\.(?:txz|zip)|\S+?(?:\.ss[mt]\.(?:txz|zip))?|[^\/]+?\.ssp)$/
      re_p=/(sisupod\.(?:txz|zip)|\S+?\.ss[mt]\.(?:txz|zip)?|[^\/]+?\.ssp)$/
      if @requested_file =~ re_p_div
        @site,@pth,@pod= re_p_div.match(@requested_file).captures
      elsif @requested_file =~ re_p
        @pod=re_p.match(@requested_file).captures.join
      end
      def site
        @site
      end
      def path
        @pth
      end
      def dir_stub
        re_p_stub=/.+?([^\/]+)$/
        re_p_stub.match(path).captures.join if path
      end
      def name_source
        @pod
      end
      def name
        name_source
      end
      self
    end
  end
end
__END__
#+END_SRC

** rexml.rb

#+HEADER: :tangle "../lib/sisu/rexml.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Rexml
  # load XML file for REXML parsing
  begin
    require 'rexml/document' \
      if FileTest.directory?("#{RbConfig::CONFIG['rubylibdir']}/rexml") #RbConfig::CONFIG['sitedir']
  rescue LoadError
    SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
      error('rexml/document NOT FOUND (LoadError)')
  end
  require_relative 'dp'                                 # dp.rb
    include SiSU_Param
  require_relative 'se'                                 # se.rb
    include SiSU_Env
  class Rexml
    begin
      require 'rexml/document' \
        if FileTest.directory?("#{RbConfig::CONFIG['rubylibdir']}/rexml") #RbConfig::CONFIG['sitedir']
    rescue LoadError
      SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
        error('rexml/document NOT FOUND (LoadError)')
    end
    def initialize(md,fno)
      @md,@fno=md,fno
      @env=SiSU_Env::InfoEnv.new(@md.fns)
      @prog=SiSU_Env::InfoProgram.new #(md.fns) #if md
      if File.file?(@fno)
        @fnap=@fno #index.xml causes problems with index.html in server config
      end
      @e_head='/document/head'
      @e_title='/document/head/title'
      @e_object='/document/body/object'
      @e_ocn='/document/body/object/ocn'
      @e_text='/document/body/object/text'
      @e_endnote='/document/body/object/endnote'
    end
    def xml
      begin
        if FileTest.file?(@fnap)
          if @prog.rexml !=false \
          and FileTest.directory?('/usr/lib/ruby/1.8/rexml/') #note values can be other than true
            xmlfile=IO.readlines(@fnap,'').join
            begin
              @xmldoc=REXML::Document.new xmlfile
              SiSU_Screen::Ansi.new(
                @md.opt.act[:color_state][:set],
                'invert',
                'REXML',
                "XML document #{@fnap} loaded"
              ).colorize unless @md.opt.act[:quiet][:set]==:on
              if (@opt.act[:verbose][:set]==:on \
              || @opt.act[:verbose_plus][:set]==:on)
                @xmldoc.elements.each(@e_head) do |e|
                  SiSU_Screen::Ansi.new(
                    @md.opt.act[:color_state][:set],
                    'brown',
                    e
                  ).colorize unless @md.opt.act[:quiet][:set]==:on
                end
              end
            rescue REXML::ParseException
              puts 'broken XML'
            end
          end
        else
          SiSU_Screen::Ansi.new(
            @md.opt.act[:color_state][:set],
            'fuchsia',
            "File Not Found #{xmlfile}",
            'requested XML processing skipped'
          ).colorize unless @md.opt.act[:quiet][:set]==:on
          exit
        end
      rescue
        SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
          __LINE__.to_s + ':' + __FILE__
        end
      ensure
      end
    end
  end
end
__END__
 misc
e.each do |element|
  element.each do |child|
    if child.is_a?(REXML::Text)
      puts "Text: #{child.to_s.inspect}"
    else
      puts "SubElement: #{child.name}"
    end
  end
end
#+END_SRC

** sitemaps.rb

#+HEADER: :tangle "../lib/sisu/sitemaps.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Sitemaps
  require_relative 'dp'                                 # dp.rb
    include SiSU_Param
  require_relative 'se'                                 # se.rb
    include SiSU_Env
  require_relative 'xml_shared'                         # xml_shared.rb
    include SiSU_XML_Munge
  class Source
    def initialize(opt)
      @opt=opt
    end
    def read
      songsheet
    end
    def songsheet
      begin
        @sys=SiSU_Env::SystemCall.new
        fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language
        @fn=SiSU_Env::EnvCall.new(@opt.fns).lang(fn_set_lang[:c])
        if @opt.act[:sitemap][:set]==:on
          @md=SiSU_Param::Parameters.new(@opt).get
          @trans=SiSU_XML_Munge::Trans.new(@md) #check @md is required
          @env=SiSU_Env::InfoEnv.new(@md.fns)
#         @file=SiSU_Env::FileOp.new(@md)
          @rdf=SiSU_XML_Tags::RDF.new(@md)
          @fnb_utf8_xml=@md.fnb.dup
          @trans.char_enc.utf8(@fnb_utf8_xml) \
            if @sys.locale =~/utf-?8/i
          output_map(sitemap)
        elsif @opt.selections.str =~/--sitemaps/
          @sitemap_idx_fn='sitemapindex.xml'
          @env=SiSU_Env::InfoEnv.new
          output_idx(sitemap_index)
          SiSU_Screen::Ansi.new(
            @opt.act[:color_state][:set],
            'sitemap index:',
            "#{@env.path.output}/#{@sitemap_idx_fn}"
          ).result unless @opt.act[:quiet][:set]==:on
        end
      rescue
        SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do
          __LINE__.to_s + ':' + __FILE__
        end
      ensure
      end
    end
    def make_file(path,filename)
      (File.writable?("#{path}/.")) \
      ? (File.new("#{path}/#{filename}",'w+'))
      : (SiSU_Screen::Ansi.new(
           '',
           "is the file or directory writable?, could not create #{filename}"
         ).warn)
    end
    def output_map(sitemap)
      path=@md.file.output_path.sitemaps.dir
      filename=@fn[:sitemap]
      touch_path=@md.file.output_path.sitemaps.dir
      touch_filename=@fn[:sitemap_touch]
      SiSU_Env::FileOp.new(@md).make_path(path)
      file=SiSU_Env::FileOp.new(@md).make_file(path,filename)
      file << sitemap
      if FileTest.file?("#{touch_path}/#{touch_filename}")
        FileUtils::rm("#{touch_path}/#{touch_filename}")
      end
    end
    def output_idx(sitemap)
      path=@env.path.output
      filename=@sitemap_idx_fn
      make_path(path)
      file=make_file(path,filename)
      file << sitemap
    end
    def sitemap_index
      sitemap_files=Dir.glob("#{@env.path.sitemaps}/sitemap_*.xml")
      sitemap_idx=[]
      sitemap_idx << <<WOK
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemaps/0.9
   http://www.sitemaps.org/schemas/sitemaps/sitemap.xsd"
     xmlns="http://www.sitemaps.org/schemas/sitemapindex/0.9">
WOK
      sitemap_files.each do |s|
        f=s.gsub(/.+?\/sitemap_([^\/]+?)\.xml$/,'\1')
        @trans.char_enc.utf8(f) \
          if @sys.locale =~/utf-?8/i
sitemap_idx << <<WOK
  <sitemap>
    <loc>#{@env.path.url.remote}/#{f}/sitemap.xml</loc>
  </sitemap>
WOK
      end
      sitemap_idx << <<WOK
</sitemapindex>
WOK
      sitemap_idx.join
    end
    def sitemap
      if defined? @md.date.modified \
      and @md.date.modified=~/\d{4}-\d{2}-\d{2}/
        sitemap_date_modified
      else sitemap_no_date
      end
    end
    def sitemap_date_modified
<<WOK
<?xml version='1.0' encoding='UTF-8'?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemaps/0.9
  http://www.sitemaps.org/schemas/sitemaps/sitemap.xsd"
  xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
#{@rdf.comment_xml}
  <url>
    <loc>#{@env.path.url.remote}/#{@fnb_utf8_xml}/#{@fn[:toc]}</loc>
    <lastmod>#{@md.date.modified}</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.7</priority>
  </url>
  <url>
    <loc>#{@env.path.url.remote}/#{@fnb_utf8_xml}/#{@fn[:doc]}</loc>
    <lastmod>#{@md.date.modified}</lastmod>
    <priority>0.5</priority>
  </url>
  <url>
    <loc>#{@env.path.url.remote}/#{@fnb_utf8_xml}/#{@fn[:manifest]}</loc>
    <lastmod>#{@md.date.modified}</lastmod>
    <priority>0.5</priority>
  </url>
</urlset>
WOK
    end
    def sitemap_no_date
<<WOK
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
#{@rdf.comment_xml}
  <url>
    <loc>#{@env.path.url.remote}/#{@fnb_utf8_xml}/#{@fn[:toc]}</loc>
    <changefreq>monthly</changefreq>
    <priority>0.7</priority>
  </url>
  <url>
    <loc>#{@env.path.url.remote}/#{@fnb_utf8_xml}/#{@fn[:doc]}</loc>
    <priority>0.5</priority>
  </url>
  <url>
    <loc>#{@env.path.url.remote}/#{@fnb_utf8_xml}/#{@fn[:manifest]}</loc>
    <priority>0.5</priority>
  </url>
</urlset>
WOK
    end
  end
end
__END__
,* sanitize xml, pass through filter to ensure is valid - done but needs testing
,* remote placement of sitemaps --sitemaps -R (probably makes more sense than doing against -Y [filename/wildcard]) - done but needs testing
,* gzip sitemaps - not before testing / after testing
,* issue with master documnts, naming and mapping, check multilingual

<!-- Document processing information:
     * Generated by: SiSU 0.48.6 of 2006w45/6 (20061111)
     * Ruby version: ruby 1.8.5 (2006-08-25) [i486-linux]
     *
     * Last Generated on: Sat Nov 18 15:28:08 +0000 2006
     * SiSU https://git.sisudoc.org
-->
#+END_SRC

** termsheet.rb

#+HEADER: :tangle "../lib/sisu/termsheet.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
require_relative 'se'                                   # se.rb
require_relative 'dp'                                   # dp.rb
  include SiSU_Param
@do,@done,@used,@html_output,@txt_input,@txt_output,@@report=Array.new(7){[]}
@@info=nil
@c=0
@cX=SiSU_Screen::Ansi.new('yes').cX
@done << "\n#{@cX.blue_hi}#{@cX.black}Summary#{@cX.off*2}"
def talent(termsheet,flag)
  @@info=nil
  @@info=termsheet.gsub(/(.+?)\.termsheet\.rb/,'../facility_data/\1.html')
  @env=SiSU_Env::InfoEnv.new
  @dir_fd="#{@env.path.output}/facility_data"
  FileUtils::mkdir_p(@dir_fd) unless FileTest.directory?(@dir_fd)==true
  html_output=[]
  case termsheet
  when /.+?\.(termsheet)\.rb$/
    @basename=termsheet[/(.+?)\.termsheet\.rb/, 1]
    @standard_form={}
    require termsheet
    include Termsheet
    @standard_form=Termsheet::StandardForms.new.standardforms
    puts %{\n#{@@cX.yellow_hi}#{@@cX.black}From#{@@cX.off*2}: #{@@cX.grey_hi}#{@@cX.black}#{@basename}.termsheet.rb#{@@cX.off*3}\n\n}
    @standard_form.each do |k,v|
      @c+=1
      require v
      puts %{\n#{@@cX.blue_hi}#{@@cX.black}Producing the following#{@@cX.off*2}: #{@@cX.green}#{@basename}.#{k}#{@@cX.off}\n\n}
      @done << %{\n\t#{@@cX.grey}Documents generated#{@@cX.off}: #{@@cX.cyan}#{@basename}.#{k}#{@@cX.off}\n}
      @used << %{\n\t#{@@cX.grey}Using#{@@cX.off}: #{@@cX.ruby}#{v}#{@@cX.off}\n}
      html_output=<<WOK
<br /><a href="../#{@basename}.#{k}/landscape.pdf">
<img border="0" width="18" height="15" src="../_sisu/image/b_pdf.png" alt="pdf landscape"></a>&nbsp;
<a href="../#{@basename}.#{k}/portrait.pdf">
<img border="0" width="15" height="18" src="../_sisu/image/b_pdf.png" alt="pdf portrait"></a>&nbsp;
<a href="../#{@basename}.#{k}/sisu_manifest.html">#{@basename}.#{k}.sisu_manifest.html</a>
WOK
      @html_output << html_output
      @txt_input << %{\n\tForm #{@c}: <url:#{Dir.pwd}/#{v}>\n\t        |#{Dir.pwd}/#{v}|@|^|\n}
      @txt_output << %{\n\t#{k}: |../#{@basename}.#{k}/sisu_manifest.html|@|^|\n}
      @report_file_i=File.new("#{@dir_fd}/#{@basename}.txt",'w+')
      @report_file_o=File.new("#{@dir_fd}/#{@basename}.html",'w+')
      @filename_new=File.new("#{@basename}.#{k}.sst",'w+')
      @do << %{#{k}}
      @filename_new << @document
        # "require v" pulls in the composite @document
        # "termsheet" having all the variables required to complete the standard form @document
      @filename_new.close
    end
    @do.each do |x|
      system %{sisu -Nhwpo #{@basename}.#{x}.sst\n}
    end
  else print "not processed --> ", termsheet, "\n"
  end
  @done << %{\n\t#{@@cX.green}Summary:#{@@cX.off} #{@@cX.blue}#{@env.path.output}/facility_data/#{@basename}.html#{@@cX.off}\n}
  @done << %{\n\t#{@@cX.grey}From details provided in#{@@cX.off}: #{@@cX.green}#{termsheet}#{@@cX.off}\n}
  terms=%{\nTermsheet: <url:#{Dir.pwd}/#{termsheet}>\n           |#{Dir.pwd}/#{termsheet}|@|^|\n}
  @report_file_i << "<url:all.txt>\n|all.txt|@|^|\n" << terms << "\nForms:\n" << @txt_input  << "\nOutput Files\n" << @txt_output
  @report_file_o << %{<a href="toc.html">^</a><br />\n} << @html_output
  @@report << @done << @used << "\n"
  @done,@used=[],[]
end
require_relative 'dp'                                   # dp.rb
@argv=$*
@proc="#{@argv[0].to_s}"
if @proc =~  /^-?[wft]/
  @argv.shift
  @argv.each do |termsheet|
    talent(termsheet,@proc)
  end
end
@env=SiSU_Env::InfoEnv.new
@dir_fd="#{@env.path.output}/facility_data"
@url="#{@env.url.webserv}/facility_data"
@@report << %{\n#{@@cX.grey}See#{@@cX.off}: #{@@cX.blue}#{@dir_fd}/all.txt\t#{@dir_fd}/toc.html\t#{@dir_fd}/#{@@cX.off}\n\n#{@@cX.grey}See#{@@cX.off}: #{@@cX.blue}#{@url}/all.txt\t#{@url}/toc.html\t#{@url}/#{@@cX.off}\n\n}
puts @@report
File.unlink("#{@dir_fd}/all.txt") if FileTest.file?("#{@dir_fd}/all.txt")
File.unlink("#{@dir_fd}/toc.html") if FileTest.file?("#{@dir_fd}/toc.html")
summary_file=File.new("#{@dir_fd}/all.txt",'w+')
summary_html=File.new("#{@dir_fd}/toc.html",'w+')
ls_txt=%x{ls #{@dir_fd}/*.txt}
report_thlnk=[]
ls_txt.scan(/.+/)
ls_txt.each {|x| report_thlnk << x.gsub!(/#{@dir_fd}\/(.+)/,"<url:\\1>\n|\\1|@|^|")}
report_thlnk.join("\n")
ls_html=%x{ls #{@dir_fd}/*.html}
report_html=[]
ls_html.split(/.+/)
ls_html.each {|x| report_html << x.gsub!(/#{@dir_fd}\/(.+)/,'<a href="\1">\1</a><br />')}
report_html.join("\n")
summary_file << "#{report_thlnk}"
summary_html << "#{report_html}"
__END__
,** NOTE wrapper makes little sense without additional components, additional
   sample files must be provided - (saved till later as may confuse)
,*** bits
sisu -t x_bank.and.*
e.g. sisu -t x_bank.and.*.termsheet.rb
e.g. sisu_termsheet.rb -t x_bank.and.c*.termsheet.rb
program calls upon termsheet file with extension termsheet.rb
termsheet.rb calls upon relevant standard form files (to be used) with extension .sForm.rb
there is also a standard_terms.rb file - with terms/details that are  constant
the file produced is named after the termsheet.rb with that extension replaced with .er30
from there scribbler.rb is called upon its usual metaVerse html and pdf  creation
! :-)
to test run
termsheet.rb -f dev.export.import.trade.facility.termsheet.rb
the term sheet calls the standard form or template that is to be run against it.
#+END_SRC

** update.rb

#+HEADER: :tangle "../lib/sisu/update.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_UpdateControlFlag
  require_relative 'se'                                 # se.rb
    include SiSU_Env
  include SiSU_Param
  class Check
    def initialize(opt)
      @opt=opt
      @md=SiSU_Param::Parameters.new(@opt).get
    end
    def read
      begin
        @env=SiSU_Env::InfoEnv.new(@md.fns)
        out=@env.path.output
        base_path="#{out}/#{@md.fnb}"
        SiSU_Screen::Ansi.new(
          @md.opt.act[:color_state][:set],
          'Checking previous output',
          base_path
        ).green_hi_blue unless @md.opt.act[:quiet][:set]==:on
        SetCF.new(@md).set_flags
      rescue
        SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
          __LINE__.to_s + ':' + __FILE__
        end
      ensure
      end
    end
    private
    class SetCF
      def initialize(md)
        @md=md
        @env=SiSU_Env::InfoEnv.new(@md.fns)
        out=@env.path.output
        @base_path="#{out}/#{@md.fnb}"
        @pdf_fn=SiSU_Env::FileOp.new(@md).base_filename
      end
      def set_flags #-mNhwpoabxXyv
        flag='-v'
        if FileTest.file?("#{@md.file.output_path.txt.dir}/#{@md.file.base_filename.txt}")==true
          flag=flag + 'a'
        end
        if FileTest.file?("#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_seg}")==true \
        or FileTest.file?("#{@md.file.output_path.html_scroll.dir}/#{@md.file.base_filename.html_scroll}")==true
          flag=flag + 'h'
        end
        if FileTest.file?("#{@md.file.output_path.xhtml.dir}/#{@md.file.base_filename.xhtml}")==true
          flag=flag + 'b'
        end
        if FileTest.file?("#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}")==true
          flag=flag + 'x'
        end
        if FileTest.file?("#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}")==true
          flag=flag + 'X'
        end
        if FileTest.file?("#{@md.file.output_path.epub.dir}/#{@md.file.base_filename.epub}")==true
          flag=flag + 'e'
        end
        if FileTest.file?("#{@md.file.output_path.odt.dir}/#{@md.file.base_filename.odt}")==true
          flag=flag + 'o'
        end
        if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_p_a4}")==true \
        or FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_l_a4}")==true \
        or FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_p_letter}")==true \
        or FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_l_letter}")==true
          flag=flag + 'p'
        end
        if FileTest.file?("#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}")==true
          flag=flag + 'w'
        end
        if FileTest.file?("#{@md.file.output_path.digest.dir}/#{@md.file.base_filename.digest}")==true
          flag=flag + 'N'
        end
        if FileTest.file?("#{@md.file.output_path.src.dir}/#{@md.file.base_filename.src}")==true
          flag=flag + 's'
        end
        if FileTest.file?("#{@md.file.output_path.sisupod.dir}/#{@md.file.base_filename.sisupod}")==true
          flag=flag + 'S'
        end
        puts flag
        flag
      end
    end
  end
end
__END__
#+END_SRC

** urls.rb

#+HEADER: :tangle "../lib/sisu/urls.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Urls
  require_relative 'se_hub_particulars'                 # se_hub_particulars.rb
    include SiSU_Particulars
  require_relative 'se'                                 # se.rb
    include SiSU_Env; include SiSU_Screen
  class Source
    attr_reader :opt
    def initialize(opt)
      @opt=opt
    end
    def read
      begin
        SiSU_Urls::OutputUrls.new(@opt).songsheet if @opt.fnb
      rescue
        SiSU_Errors::Rescued.new($!,$@,@opt.selections.str).location do
          __LINE__.to_s + ':' + __FILE__
        end
      ensure
      end
    end
  end
  class OutputUrls
    attr_reader :fns,:fnb,:act,:dir,:m_regular,:u
    def initialize(opt)
      @opt=opt
      @particulars=SiSU_Particulars::CombinedSingleton.instance.get_env_md(opt)
      if @particulars.is_a?(NilClass)
        if @opt.act[:verbose_plus][:set]==:on \
        or @opt.act[:maintenance][:set]==:on
          SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
            mark("@particulars is NilClass, acceptable e.g. for --harvest")
        end
        exit
      end
      @selections=@opt.selections.str
      @act=@opt.act
      @md=@particulars.md
      @env=@particulars.env
      @fnb=@env.fnb
      fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language
      @fnl=@env.i18n.lang_filename(fn_set_lang[:c])
      @fn=SiSU_Env::EnvCall.new(@opt.fns).lang(fn_set_lang[:c])
      @m_regular=/(.+?)\.(?:(?:-|ssm\.)?sst|ssm)$/
      @prog=@env.program
    end
    def songsheet
      begin
        (@opt.act[:urls_all][:set]==:on) \
        ? urls_all \
        : (urls_select unless @opt.act[:quiet][:set]==:on)
      rescue
        SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
          __LINE__.to_s + ':' + __FILE__
        end
      ensure
      end
    end
    def show
      def report(x)
        SiSU_Screen::Ansi.new(
          @opt.act[:color_state][:set],
          "[#{@opt.f_pth[:lng_is]}]",
          x[:cmd],
          x[:viewer] + ' ' \
          + x[:f_pth]
        ).result
      end
      def maintenance(x)
        if @opt.act[:maintenance][:set]==:on
          SiSU_Screen::Ansi.new(
            @opt.act[:color_state][:set],
            "[#{@opt.f_pth[:lng_is]}]",
            x[:cmd],
            x[:p_pth]
          ).maintenance
        end
      end
      self
    end
    def report_info
      def dal
        {
          cmd: '--ao',
          p_pth: @env.processing_path.ao + '/' \
          + @opt.fns + '.meta',
          fn: 'ao',
         }
      end
      def hash_digests
        {
          cmd: '--hash-digests (sha512/sha256/md5)',
          viewer: @prog.web_browser,
          f_pth: @md.file.output_path.hash_digest.dir + '/' \
          + @md.file.base_filename.hash_digest,
          fn: @fn[:digest],
         }
      end
      def text
        def txt
          {
            cmd: '--txt',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.txt.dir + '/' \
            + @md.file.base_filename.txt,
            fn: @fn[:plain],
           }
        end
        def asciidoc
          {
            cmd: '--asciidoc',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.asciidoc.dir + '/' \
            + @md.file.base_filename.asciidoc,
            fn: @fn[:txt_asciidoc],
           }
        end
        def markdown
          {
            cmd: '--markdown',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.markdown.dir + '/' \
            + @md.file.base_filename.markdown,
            fn: @fn[:txt_markdown],
           }
        end
        def rst
          {
            cmd: '--rst',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.rst.dir + '/' \
            + @md.file.base_filename.rst,
            fn: @fn[:txt_rst],
           }
        end
        def textile
          {
            cmd: '--textile',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.textile.dir + '/' \
            + @md.file.base_filename.textile,
            fn: @fn[:txt_textile],
           }
        end
        def orgmode
          {
            cmd: '--orgmode',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.orgmode.dir + '/' \
            + @md.file.base_filename.orgmode,
            fn: @fn[:txt_orgmode],
           }
        end
        self
      end
      def html
        def seg
          {
            cmd: '--html-seg',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.html_seg.dir + '/' \
            + @md.file.base_filename.html_segtoc,
            p_pth: @env.processing_path.tune + '/' \
            + @md.fns + '.tune',
            fn: @fn[:toc],
           }
        end
        def scroll
          {
            cmd: '--html-scroll',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.html_scroll.dir + '/' \
            + @md.file.base_filename.html_scroll,
            p_pth: @env.processing_path.tune + '/' \
            + @md.fns + '.tune',
            fn: @fn[:doc],
           }
        end
        def concordance
          {
            cmd: '--concordance',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.html_concordance.dir + '/' \
            + @md.file.base_filename.html_concordance,
            fn: @fn[:concordance],
           }
        end
        self
      end
      def xhtml
        def xhtml
          {
            cmd: '--xhtml',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.xhtml.dir + '/' \
            + @md.file.base_filename.xhtml,
            p_pth: @env.processing_path.tune + '/' \
            + @md.fns + '.tune',
            fn: @fn[:xhtml],
           }
        end
        def epub
          {
            cmd: '--epub',
            viewer: @prog.epub_viewer,
            f_pth: @md.file.output_path.epub.dir + '/' \
            + @md.file.base_filename.epub,
            p_pth: @env.processing_path.epub + '/' \
            + Ep[:d_oebps] + '/' \
            + 'index.xhtml',
            fn: @fn[:epub],
           }
        end
        self
      end
      def xml
        def odt
          {
            cmd: '--odt (ODF:ODT)',
            viewer: @prog.odf_viewer,
            f_pth: @md.file.output_path.odt.dir + '/' \
            + @md.file.base_filename.odt,
            p_pth: @env.processing_path.odf + '/' \
            + @opt.fns + '/' \
            + 'odt/content.xml',
            fn: @fn[:odf],
           }
        end
        def docbook
          {
            cmd: '--docbook',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.xml_docbook_book.dir + '/' \
            + @md.file.base_filename.xml_docbook_book,
            fn: @fn[:xml_docbook_book],
           }
        end
        def fictionbook
          {
            cmd: '--fictionbook',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.xml_fictionbook.dir + '/' \
            + @md.file.base_filename.xml_fictionbook,
            fn: @fn[:xml_fictionbook],
           }
        end
        def sax
          {
            cmd: '--xml-sax',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.xml_sax.dir + '/' \
            + @md.file.base_filename.xml_sax,
            fn: @fn[:sax],
           }
        end
        def dom
          {
            cmd: '--xml-dom',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.xml_dom.dir + '/' \
            + @md.file.base_filename.xml_dom,
            fn: @fn[:dom],
           }
        end
        def scaffold_sisu
          {
            cmd: '--xml-scaffold-sisu',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.xml_scaffold_structure_sisu.dir + '/' \
            + @md.file.base_filename.xml_scaffold_structure_sisu,
            fn: @fn[:xml_scaffold_structure_sisu],
           }
        end
        def scaffold_collapse
          {
            cmd: '--xml-scaffold-collapse',
            viewer: @prog.web_browser,
            f_pth: @md.file.output_path.xml_scaffold_structure_collapse.dir + '/' \
            + @md.file.base_filename.xml_scaffold_structure_collapse,
            fn: @fn[:xml_scaffold_structure_collapse],
           }
        end
        self
      end
      def json
        {
          cmd: '--js (json)',
          viewer: @prog.web_browser,
          f_pth: @md.file.output_path.json.dir + '/' \
          + @md.file.base_filename.json,
          fn: @fn[:json],
        }
      end
      def pdf
        def landscape
          {
            cmd: '--pdf (landscape)',
            viewer: @prog.pdf_viewer,
            f_pth: @md.file.output_path.pdf.dir + '/' \
            + @md.file.base_filename.pdf_l \
            + @md.papersize_array[0] + '.pdf',
            p_pth: @env.processing_path.tex + '/' \
            + @opt.fns.gsub(/~/,'-') + '.' \
            + @md.papersize_array[0] \
            + '.landscape.tex',
            fn: @fn[:pdf_l],
           }
        end
        def portrait
          {
            cmd: '--pdf (portrait)',
            viewer: @prog.pdf_viewer,
            f_pth: @md.file.output_path.pdf.dir + '/' \
            + @md.file.base_filename.pdf_p \
            + @md.papersize_array[0] + '.pdf',
            p_pth: @env.processing_path.tex + '/' \
            + @opt.fns.gsub(/~/,'-') + '.' \
            + @md.papersize_array[0] \
            + '.tex',
            fn: @fn[:pdf_p],
           }
        end
        self
      end
      def manpage
        {
          cmd: '--manpage',
          viewer: @prog.manpage_viewer,
          f_pth: @md.file.output_path.manpage.dir + '/' \
          + @md.file.base_filename.manpage,
          fn: 'manpage',
         }
      end
      def texinfo
        {
          cmd: '--texinfo',
          viewer: '',
          f_pth: 'cd ' \
          + @md.file.output_path.texinfo.dir + ' && ' \
          + @env.program.texinfo + ' ' \
          + @md.file.base_filename.info \
          + '; cd -',
          fn: 'info',
         }
      end
      def db
        def psql
          {
            cmd: '--psql --update/--import',
            viewer: '',
            f_pth: @pwd_stub + '::' \
            + @opt.fns \
            + 'dbi psql',
            p_pth: @env.processing_path.postgresql + '/' \
            + @md.fns \
            + '.sql',
            fn: 'dbi psql',
           }
        end
        def sqlite
          {
            cmd: '--sqlite --update/--import',
            viewer: 'sqlite3 ',
            f_pth: @env.path.webserv + '/' \
            + @md.opt.f_pth[:pth_stub] + '/' \
            + 'sisu_sqlite.db',
            p_pth: @env.processing_path.sqlite + '/' \
            + @md.fns \
            + '.sql',
            fn: 'dbi sqlite3',
           }
        end
        def sqlite_discrete
          {
            cmd: '--sqlite',
            viewer: 'sqlite3 ',
            f_pth: @md.file.output_path.sqlite_discrete.dir + '/' \
            + @md.file.base_filename.sqlite_discrete,
            p_pth: @env.processing_path.sqlite + '/' \
            + @md.fns \
            + '.sql',
            fn: 'dbi sqlite3',
           }
        end
        self
      end
      def po4a
        def po
          {
            cmd: '--po4a/--pot',
            viewer: @prog.web_browser,
            f_pth: @prog.text_editor + ' ' \
            + @md.file.output_path.po.dir \
            + '/' + y,
            fn: @fn[:pot],
           }
        end
        def pot
          {
            cmd: '--po4a/--pot',
            viewer: @prog.web_browser,
            f_pth: @prog.text_editor + ' ' \
            + @md.file.output_path.pot.dir \
            + '/' + y,
            fn: @fn[:pot],
           }
        end
        self
      end
      def source
        {
          cmd: '--source (sisu markup)',
          viewer: @prog.text_editor,
          f_pth: @md.file.output_path.src.dir + '/' \
          + @opt.fno,
          p_pth: @md.file.output_path.src.dir + '/' \
          + @opt.fno,
          fn: @opt.fno,
         }
      end
      def sisupod
        {
          cmd: '--sisupod',
          viewer: '',
          f_pth: @md.file.output_path.sisupod.dir + '/' \
          + @opt.fno \
          + '.txz',
          p_pth: @md.file.output_path.sisupod.dir + '/' \
          + @opt.fno + '/' \
          + 'sisupod/',
          fn: @fn[:sisupod],
         }
      end
      def ruby_profile
        {
          cmd: '--profile (ruby profiler)',
          fn: 'profile',
         }
      end
      def qrcode
        {
          cmd: '--qrcode',
          viewer: @prog.web_browser,
          f_pth: @md.file.output_path.manifest.dir + '/' \
          + @md.file.base_filename.manifest,
          fn: @fn[:qrcode],
         }
      end
      def manifest
        {
          cmd: '--manifest',
          viewer: @prog.web_browser,
          f_pth: @md.file.output_path.manifest.dir + '/' \
          + @md.file.base_filename.manifest,
          fn: @fn[:manifest],
         }
      end
      def sitemap
        {
          cmd: '--sitemap',
          viewer: @prog.web_browser,
          f_pth: @md.file.output_path.sitemaps.dir + '/' \
          + @md.file.base_filename.sitemap,
          fn: @fn[:sitemap],
         }
      end
      self
    end
    def urls_select
      unless @opt.act[:quiet][:set]==:on
        i1='[' + @opt.f_pth[:lng_is] + ']'
        i2='file://' \
        + @md.file.output_path.manifest.dir + '/' \
        + @md.file.base_filename.manifest
        (@opt.act[:verbose][:set]==:on \
        || @opt.act[:verbose_plus][:set]==:on \
        || @opt.act[:maintenance][:set]==:on) \
        ? SiSU_Screen::Ansi.new(
            @opt.act[:color_state][:set],
            'URLs'
          ).green_title_hi
        : SiSU_Screen::Ansi.new(
            @opt.act[:color_state][:set],
            'URL (output manifest)',
            i1, i2
          ).grey_title_grey_blue
        if (@opt.act[:verbose][:set]==:on \
        || @opt.act[:verbose_plus][:set]==:on \
        || @opt.act[:maintenance][:set]==:on)
          SiSU_Screen::Ansi.new(
            @opt.act[:color_state][:set],
            i1, i2,
          ).flow
        end
      end
      m=/.+\/(?:src\/)?(\S+)/im
      @pwd_stub="#{@env.url.output_tell}"[m,1]
      unless @opt.act[:quiet][:set]==:on
        if @opt.fns =~ @m_regular
          if (@opt.act[:verbose][:set]==:on \
          || @opt.act[:verbose_plus][:set]==:on \
          || @opt.act[:maintenance][:set]==:on)
            if @opt.act[:txt][:set]==:on
              show.report(report_info.text.txt)
              #show.maintenance(report_info.text.txt)
            end
            if @opt.act[:txt_textile][:set]==:on
              show.report(report_info.text.textile)
              #show.maintenance(report_info.text.textile)
            end
            if @opt.act[:txt_asciidoc][:set]==:on
              show.report(report_info.text.asciidoc)
              #show.maintenance(report_info.text.asciidoc)
            end
            if @opt.act[:txt_markdown][:set]==:on
              show.report(report_info.text.markdown)
              #show.maintenance(report_info.text.markdown)
            end
            if @opt.act[:txt_rst][:set]==:on
              show.report(report_info.text.rst)
              #show.maintenance(report_info.text.rst)
            end
            if @opt.act[:txt_orgmode][:set]==:on
              show.report(report_info.text.orgmode)
              #show.maintenance(report_info.text.orgmode)
            end
            if (@opt.act[:html][:set]==:on \
            or @opt.act[:html_scroll][:set]==:on \
            or @opt.act[:html_seg][:set]==:on)
              if @opt.act[:html_scroll][:set]==:on
                show.report(report_info.html.scroll)
                show.maintenance(report_info.html.scroll)
              end
              if @opt.act[:html_seg][:set]==:on
                show.report(report_info.html.seg)
                show.maintenance(report_info.html.seg)
              end
            end
            if @opt.act[:concordance][:set]==:on
              show.report(report_info.html.concordance)
              #show.maintenance(report_info.html.concordance)
            end
            if @opt.act[:xhtml][:set]==:on
              show.report(report_info.xhtml.xhtml)
              show.maintenance(report_info.xhtml.xhtml)
            end
            if @opt.act[:epub][:set]==:on
              show.report(report_info.xhtml.epub)
              show.maintenance(report_info.xhtml.epub)
            end
            if @opt.act[:odt][:set]==:on
              show.report(report_info.xml.odt)
              show.maintenance(report_info.xml.odt)
            end
            if @opt.act[:xml_dom][:set]==:on
              show.report(report_info.xml.dom)
              #show.maintenance(report_info.xml.dom)
            end
            if @opt.act[:xml_sax][:set]==:on
              show.report(report_info.xml.sax)
              #show.maintenance(report_info.xml.sax)
            end
            if @opt.act[:xml_docbook_book][:set]==:on
              show.report(report_info.xml.docbook)
              #show.maintenance(report_info.xml.docbook)
            end
            if @opt.act[:xml_fictionbook][:set]==:on
              show.report(report_info.xml.fictionbook)
              #show.maintenance(report_info.xml.fictionbook)
            end
            if @opt.act[:xml_scaffold_structure_sisu][:set]==:on
              show.report(report_info.xml.scaffold_structure_sisu)
              #show.maintenance(report_info.xml.scaffold_structure_sisu)
            end
            if @opt.act[:xml_scaffold_structure_collapse][:set]==:on
              show.report(report_info.xml.scaffold_collapse)
              #show.maintenance(report_info.xml.scaffold_collapse)
            end
            if @opt.act[:json][:set]==:on
              show.report(report_info.json)
              #show.maintenance(report_info.json)
            end
            if (@opt.act[:pdf][:set]==:on \
            or @opt.act[:pdf_p][:set]==:on \
            or @opt.act[:pdf_l][:set]==:on)
              if @opt.act[:pdf_p][:set]==:on
                show.report(report_info.pdf.portrait)
                show.maintenance(report_info.pdf.portrait)
              end
              if @opt.act[:pdf_l][:set]==:on
                show.report(report_info.pdf.landscape)
                show.maintenance(report_info.pdf.landscape)
              end
            end
            if @opt.act[:psql][:set]==:on
              show.report(report_info.db.psql)
              show.maintenance(report_info.db.psql)
            end
            if @opt.act[:sqlite_discrete][:set]==:on
              show.report(report_info.db.sqlite_discrete)
              show.maintenance(report_info.db.sqlite_discrete)
            end
            if @opt.act[:sqlite][:set]==:on
              show.report(report_info.db.sqlite)
              show.maintenance(report_info.db.sqlite)
            end
            if @opt.act[:texinfo][:set]==:on
              show.report(report_info.texinfo)
              #show.maintenance(report_info.texinfo)
            end
            if @opt.act[:manpage][:set]==:on
              show.report(report_info.manpage)
              #show.maintenance(report_info.manpage)
            end
            if @opt.act[:hash_digests][:set]==:on
              show.report(report_info.hash_digests)
              #show.maintenance(report_info.hash_digests)
            end
            if @opt.act[:po4a_shelf][:set]==:on
              #if @opt.fns =~/\S+?~\S{2}(?:_\S{2})?\.ss[mt]/
              #else
              #end
            end
            if @opt.act[:share_source][:set]==:on
              show.report(report_info.source)
              show.maintenance(report_info.source)
            end
            if @opt.act[:sisupod][:set]==:on
              show.report(report_info.sisupod)
              show.maintenance(report_info.sisupod)
            end
            if @opt.act[:qrcode][:set]==:on
              show.report(report_info.qrcode)
              #show.maintenance(report_info.qrcode)
            end
            if @opt.act[:manifest][:set]==:on
              show.report(report_info.manifest)
              show.maintenance(report_info.manifest)
            end
          end
        end
      end
    end
    def urls_all
      i="(output manifest) [#{@opt.f_pth[:lng_is]}] #{@env.url.output_tell}/#{@fnb}/sisu_manifest.html"
      SiSU_Screen::Ansi.new(
        @opt.act[:color_state][:set],
        'URLs',
        i
      ).grey_title_hi
    end
  end
end
__END__
#+END_SRC

** webrick.rb

#+HEADER: :tangle "../lib/sisu/webrick.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Webserv
  class WebrickStart
    begin
      require 'time'
      require 'webrick'
        include WEBrick
    rescue LoadError
      SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
        error('time or webrick NOT FOUND (LoadError)')
    end
    require_relative 'se'                                 # se.rb
      include SiSU_Env
      include SiSU_Screen
    def initialize
      @cX=SiSU_Screen::Ansi.new('yes').cX
      @env=SiSU_Env::InfoEnv.new
      port=SiSU_Env::InfoPort.new
      @host=@env.url.webrick
      @port=port.webrick
      @serve=[]
      Dir.foreach(@env.path.webserv) do |x|
        if x !~/^\./ \
        and FileTest.directory?("#{@env.path.webserv}/#{x}")
          @serve << x
        end
      end
      @mount=[]
      @serve.each {|x| @mount << ["/#{x}", "#{@env.path.webserv}/#{x}"]}
      @pwd=Dir.pwd
      @week=Time.now.strftime(%{%Yw%W})
      puts "\n"
      @mount.each { |x,y|
        puts "  * #{@cX.blue}#{@host}:#{@port}#{x}/#{@cX.off}"
      }
      get=Dir.pwd
      brick(@port,get)
    end
    def brick(port,get='')
      cgidir=if get=~/pwd/ then Dir.pwd
      else                      '/usr/lib/cgi-bin'
      end
      port=SiSU_Env::InfoPort.new.webrick
      begin
        s=HTTPServer.new(
          Port:         port,
          DocumentRoot: Dir::pwd + '/htdocs',
          CGIPathEnv:   ENV['PATH']
        )
        cgi_dir=File.expand_path(cgidir)
        @mount.each { |x,y|                                                        # mount subdirectories
          s.mount(x, HTTPServlet::FileHandler, y, true)
        }
        s.mount('/cgi-bin', HTTPServlet::FileHandler, cgi_dir, { FancyIndexing: true })
        trap("INT"){ s.shutdown }
        s.start
      rescue
        SiSU_Errors::Rescued.new($!,$@,'-W',nil).location do #fix
          __LINE__.to_s + ':' + __FILE__
        end
      ensure
      end
    end
    def wb_cgi
      begin                                                                          #%
        wb_s2=''
                                                                 #% writes file wb.cgi to shared directories ...
                                                                 #% wb_top
        wb_top=%q(#!/usr/bin/env ruby
        # * arch-tag: webrick info on environment, mounted directories, and contents of pwd
        begin
          require 'time'
          require 'cgi'
          require 'fcgi'
        rescue LoadError
          puts 'time, cgi or fcgi NOT FOUND (LoadError)'
        end
        ls=Dir.entries('./')
        dir_contents=[]
        ls.each { |x| dir_contents << "<a href=\"./#{x}/\">#{x}</a><br>" unless x =~/^(\.)+$/ }
        dir_contents=dir_contents.sort.join(' ')
        #host=ENV['HOSTNAME']
        #host=%x{echo $HOSTNAME}
        )
        wb_s1=<<-WOK

  page=CGI.new "html3"
  page.out {
    page.html {
      page.head { page.title {"#{@host} Webrick Report"} } +
      page.body {
        page.h1 {"Webrick #{@host}"} +
        page.p {"Webrick is Ruby's built in webserver."} +
        page.center {"Host name: " + page.b{"#{@host} "} + "(#{@host})  port: " + page.b{"#{@port}"}} +
        page.center {"#{Time.now}"} +
        page.center {"#{Time.now.strftime(%{%Yw%W})}"} +
        page.p {''} +
        page.p {''} +
        page.p {page.b{"Webrick Served Directories: "}} +
        WOK
                                                               #% wb_s2 (mounts)
        @mount.each do |x,y| wb_s2 += <<-WOK
          page.p {%{<a href="#{@host}:#{@port}#{x}/">#{x}</a> } +
            %{<a href="#{@host}:#{@port}#{x}/">#{@host}:#{@port}#{x}</a> (mounts: #{y}/)   <a href="#{@host}:#{@port}#{x}/wb.cgi">info (wb.cgi)</a>}} +
          WOK
        end
                                                               #% wb_end
        wb_end=<<-WOK
        page.p {page.b{"Contents of PWD (see URL): "}} +
        page.p {"#\{dir_contents}"}
      }
    }
  }
        WOK
        @mount.each { |x,y|                                      #% wb puts
          puts y
            filename=File.new("#{y}/wb.cgi",'w')
            filename << wb_top
            filename << wb_s1
            filename << wb_s2
            filename << wb_end
            filename.close
            FileUtils::chmod(0755,"#{y}/wb.cgi &") if FileTest.file?("#{y}/wb.cgi &")
        }
      rescue
        SiSU_Errors::Rescued.new($!,$@,'-W',nil).location do #fix
          __LINE__.to_s + ':' + __FILE__
        end
      ensure
      end
    end
  end
ensure
end
__END__
#+END_SRC

** wikispeak.rb

#+HEADER: :tangle "../lib/sisu/wikispeak.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Wikispeak
  require_relative 'ao'                                 # ao.rb
  require_relative 'se'                                 # se.rb
    include SiSU_Env
  include SiSU_Param
  require_relative 'plaintext_format'                   # plaintext_format.rb
    include Format
  require_relative 'html_parts'                         # html_parts.rb
  require_relative 'txt_shared'
  @@alt_id_count,@@alt_id_count=0,0
  @@tablefoot=''
  class Source
    def initialize(opt)
      @opt=opt
      @@dostype='msdos footnotes'
    end
    def read
      begin
        @md=SiSU_Param::Parameters.new(@opt).get
        @env=SiSU_Env::InfoEnv.new(@opt.fns)
        path=@env.path.output_tell
        tool=(@opt.act[:verbose][:set]==:on \
        || @opt.act[:verbose_plus][:set]==:on \
        || @opt.act[:maintenance][:set]==:on) \
        ? "#{@env.program.text_editor} #{path}/#{@md.fnb}/#{@md.fn[:wiki]}"
        : ''
        SiSU_Screen::Ansi.new(
          @opt.act[:color_state][:set],
          'Wikispeak',
          tool
        ).green_hi_blue unless @opt.act[:quiet][:set]==:on
        if (@opt.act[:verbose_plus][:set]==:on \
        || @opt.act[:maintenance][:set]==:on)
          SiSU_Screen::Ansi.new(
            @opt.act[:color_state][:set],
            @opt.fns,
            "#{@env.path.output_tell}/#{@md.fnb}/#{@md.fn[:wiki]}"
          ).flow
        end
        @ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here
        SiSU_Wikispeak::Source::Scroll.new(@ao_array,@md).songsheet
      rescue
        SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
          __LINE__.to_s + ':' + __FILE__
        end
      ensure
      end
    end
    private
    class SplitTextObject <Source
      require_relative 'plaintext_format'               # plaintext_format.rb
        include Format
      @@alt_id_count=0
      @@dp=nil
      attr_reader :format,:lev,:text,:ocn,:lev_para_ocn
      def initialize(para)
        @para=para
        @format,@ocn='ordinary','ordinary'
        @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern
      end
      def lev_segname_para_ocn
        @text=nil
        if @para =~/^(\d~|<:.+?>).+?#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/
          if /^(([1-6])~(\S+))\s+(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
            @format,@lev,segname,@text,@ocn=$1,$2,$3,$4,$5
          elsif  /^(([1-6])~)\s+(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
            @format,@lev,@text,@ocn=$1,$2,$3,$4
          elsif /<:(.+?)>\s*(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
            @format,@text,@ocn=$1,$2,$3
          elsif /^(([1-6])~(\S+))\s+(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;[um]\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
            @@alt_id_count+=1
            @format,@lev,segname,@text,@ocn=$1,$2,$3,$4,"x#{@@alt_id_count}"
          elsif  /^(([1-6])~)\s+(\S.+?)#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
            @@alt_id_count+=1
            @format,@lev,@text,@ocn=$1,$2,$3,"x#{@@alt_id_count}"
          end
        else
          if /(.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
            @text,@ocn=$1,$2
          end
          if @para !~/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$|^$/ #added 2002w06
            @text=/(.+?)/m.match(@para)[1]
          end
          if /^((\d)~(?:~\S+)?)\s+(.+)/m.match(@para)
            @format,@lev,@text=$1,$2,$3
          end
        end
        format=@format.dup
        @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/
          Format::FormatTextObject.new(format,@text,@ocn)
        else
          Format::FormatTextObject.new(format,@text,"#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}")
        end
        self
      end
    end
    class Scroll <Source
      include SiSU_TextUtils
      include SiSU_Parts_HTML
      @@endnotes_para=[]
      @@wiki={ body: [], open: [], close: [], head: [], metadata: [], tail: [], endnotes: [] }
      @@dp=nil
      def initialize(data,md)
        @data,@md=data,md
        @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern
        @regx=/^(?:(?:#{Mx[:br_line]}\s*|#{Mx[:br_nl]}\s*)?#{Mx[:lv_o]}\d:(\S*?)#{Mx[:lv_c]}\s*)?(.+)/ #fix Mx[:lv_o] #m # 2004w18 pb pn removal added
        @tab="\t"
        @@dostype='unix footnotes'
        @br="\n"
      end
      def songsheet
        markup
        publish
      end
      # Used for extraction of endnotes from paragraphs
      def extract_endnotes(para='') #check
        para.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+\s+.+?)\s*#{Mx[:id_o]}#{@dp}#{Mx[:id_c]}(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/)
      end
      def wiki_metadata(meta)
        util=SiSU_TextUtils::Wrap.new(meta.text,70,15,1)
        txt=util.line_wrap
        @@wiki[:metadata] <<= if meta.type=='meta'
          <<WOK

#{@tab}#{meta.el}: #{txt}
WOK
        else ''
        end
      end
      def wiki_tail
        generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})"  if @md.project_details.version
        lastdone="Last Generated on: #{Time.now}"
        rubyv="Ruby version: #{@md.ruby_version}"
        sc=if @md.sc_info
          "Source file:    #{@md.sc_filename}#{@br}Version number: #{@md.sc_number}#{@br}Version date:   #{@md.sc_date}#{@br}"
        else ''
        end
        @@wiki[:tail] <<<<WOK
#{@br}
Other versions of this document: #{@br}
manifest:
   #{vz.url_root_http}/#{@md.fnb}/#{@md.fn[:manifest]}#{@br}
html:
   #{vz.url_root_http}/#{@md.fnb}/#{@md.fn[:toc]}#{@br}
pdf:
   #{vz.url_root_http}/#{@md.fnb}/#{@md.fn[:pdf_p]}
   #{vz.url_root_http}/#{@md.fnb}/#{@md.fn[:pdf_l]}#{@br}
plaintext (plain text):
   #{vz.url_root_http}/#{@md.fnb}/#{@md.fn[:plain]}#{@br}
at:
   #{vz.url_site}#{@br}

#{sc}
,* #{generator}
,* #{rubyv}
,* #{lastdone}
,* SiSU #{vz.url_sisu}
WOK
      end
      def wiki_structure(para='',lv='',ocn='',hname='') #% Used to extract the structure of a document
        lv=lv.to_i
        lv=nil if lv==0
        extract_endnotes(para)
        para.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(?:[\d*+]+)\s+(.+?)#{Mx[:id_o]}#{@dp}#{Mx[:id_c]}(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,'<ref>\1</ref>') # endnote marker marked up
        para.gsub!(/^#{Rx[:lv]}\S*\s+/,'') # endnote marker marked up
        para.gsub!(/<\S+?>#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}/,'') # endnote marker marked up
        if lv
          @@wiki[:body] << case lv
          when 1    then '='*2 << para.strip << @br*2
          when 2..3 then '='*2 << para.strip << @br*2
          when 4    then '='*4 << para.strip << @br*2
          when 5..6 then '='*4 << para.strip << @br*2
          end
        else @@wiki[:body] << para << @br*2 # main text, contents, body KEEP
        end
      end
      def markup                                                               # Used for major markup instructions
        data=@data
        SiSU_Env::InfoEnv.new(@md.fns)
        @data_mod,@endnotes,@level,@cont,@copen,@wiki_contents_close=Array.new(6){[]}
        (0..6).each { |x| @cont[x]=@level[x]=false }
        (4..6).each { |x| @wiki_contents_close[x]='' }
        wiki_tail
        table_message='[table omitted, see other document formats]'
        data.each do |para|
          para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{@br}#{table_message}") #fix
          para.gsub!(/.+?<-#>/,'')                                           # remove dummy headings (used by html) #check
          para.gsub!(/_\*\s+/,'* ')                                           # bullet markup, marked down
          para.gsub!(/&#169;/,'©')                                           # bullet markup, marked down
          para.gsub!(/&amp;/,'&')                                           # bullet markup, marked down
          para.gsub!(/<sup>(.+?)<\/sup>/,'^\1^')
          para.gsub!(/<sub>(.+?)<\/sub>/,'[\1]')
          para.gsub!(/<i>(.+?)<\/i>/,"''\\1''")
          para.gsub!(/<b>(.+?)<\/b>/,"'''\\1'''")
          para.gsub!(/<u>(.+?)<\/u>/,'_\1_')
          para.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'[\2 \1]')
          para.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'[\1]')
          para.gsub!(/<:(?:block|group|verse|alt|code)(?:-end)?>(?:\s+#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]})?/,'')
          para.gsub!(/<:p[bn]>/,'')                                         # remove page breaks
          para.gsub!(/^\s*#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/,'') # remove empty lines - check
          para.gsub!(/<a href=".+?">(.+?)<\/a>/m,'\1')
          para.gsub!(/<:name#\S+?>/,'')                                       # remove name links
          para.gsub!(/&nbsp;|#{Mx[:nbsp]}/,' ')                               # decide on
          para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,'    [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]")
          para.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]')
          if para =~/^@(\S+?):\s+(.+?)\Z/m # for headers
            d_meta=SiSU_TextUtils::HeaderScan.new(@md,para).meta
            if d_meta; wiki_metadata(d_meta)
            end
          end
          if para !~/(^@\S+?:|#{Mx[:br_endnotes]}|#{Mx[:br_eof]})/
            if para =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change
              paranum=para[@regx,3]
              @p_num=Format::ParagraphNumber.new(paranum)
            end
            @sto=SplitTextObject.new(para).lev_segname_para_ocn
            ### problem in scroll, it appears tables are getting paragraph numbers
            m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/
            if para =~m \
            and para=~/\S+/
              para=case @sto.format
              when /^(1)~(?:(\S+))?/
                wiki_structure(para,$1,@sto.ocn,$2)
                @sto.lev_para_ocn.heading_body1
              when /^(2)~(?:(\S+))?/
                wiki_structure(para,$1,@sto.ocn,$2)
                @sto.lev_para_ocn.heading_body2
              when /^(3)~(?:(\S+))?/
                wiki_structure(para,$1,@sto.ocn,$2)
                @sto.lev_para_ocn.heading_body3
              when /^(4)~(\S+)/ # work on see SiSU_text_parts::SplitTextObject
                wiki_structure(para,$1,@sto.ocn,$2)
                @sto.lev_para_ocn.heading_body4
              when /^(5)~(?:(\S+))?/
                wiki_structure(para,$1,@sto.ocn,$2)
                @sto.lev_para_ocn.heading_body5
              when /^(6)~(?:(\S+))?/
                wiki_structure(para,$1,@sto.ocn,$2)
                @sto.lev_para_ocn.heading_body6
              else
                wiki_structure(para,nil,nil,nil) #watch may be problematic
                para
              end
            elsif para =~/#{table_message}/
              @@wiki[:body] << para << @br
            elsif para =~/(Note|Endnotes?)/ \
            and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/
            elsif para =~/(MetaData)/ \
            and para =~/#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/ #debug 2003w46 add rc info ####suspect visit
            elsif para.include? 'Owner Details' \
            and para !~/#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/
            elsif para =~/(#{Mx[:tc_p]}|#{Mx[:gr_o]}Th?)/u #tables ! #fix
            elsif para =~/(.*)<!#!>(.*)/
              one,two=$1,$2
              format_text=FormatTextObject.new(one,two)
              para=format_text.seg_no_paranum
            end
            if (para =~/<a name="n\d+">/ \
            and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote
              para=''
            end
            case para
            when /<:i1>/
              if para =~/.*<:#>.*$/
                format_text=FormatTextObject.new(para,'')
                para=format_text.scr_indent_one_no_paranum
              end
            when /<:i2>/
              if para =~/.*<:#>.*$/
                format_text=FormatTextObject.new(para,'')
                para=format_text.scr_indent_one_no_paranum
              end
            end
            if para !~/#{the_margin.txt_0}|#{the_margin.txt_1}|#{the_margin.txt_2}/
              # i don't get the condition for no paranum
            end
            if para =~/<:center>/
              one,two=/(.*)<:center>(.*)/.match(para)[1,2]
              format_text=FormatTextObject.new(one,two)
              para=format_text.center
            end
            para.gsub!(/<!.+!>/,' ') if para ## Clean Prepared Text
            para.gsub!(/<:\S+>/,' ') if para ## Clean Prepared Text
          end
        end
      end
      def publish
        content=[]
        content << @@wiki[:open]
        content << @@wiki[:head]
        content << @@wiki[:body]
        Output.new(content.join,@md).wiki
        @@wiki[:head],@@wiki[:body],@@wiki[:tail],@@wiki[:metadata]=[],[],[],[]
      end
    end
    class Output <Source
      include SiSU_Param
      include SiSU_Env
      def initialize(content,md)
        @content,@md=content,md
      end
      def wiki                                                            #%wiki output
        SiSU_Env::FileOp.new(@md).mkdir
        filename_wiki=SiSU_Env::FileOp.new(@md,@md.fn[:wiki]).mkfile
        @sisu=[]
        @content.each do |para|                                                # this is a hack
          if para =~/^\S/
            if para !~/^([*=-]|\.){5}/; filename_wiki.puts para           #unix wiki
            else                        filename_wiki.puts para           #unix wiki
            end
          else filename_wiki.puts para # if para =~/^\s/
          end
        end
      end
    end
  end
end
__END__
#+END_SRC

** zap.rb

#+HEADER: :tangle "../lib/sisu/zap.rb"
#+BEGIN_SRC ruby
#<<sisu_document_header>>
module SiSU_Zap
  require_relative 'se'                                 # se.rb
    include SiSU_Env
  class Source
    def initialize(opt)
      @opt=opt
      @env=SiSU_Env::InfoEnv.new(opt.fns)
    end
    def read
      zap_path="#{@env.path.output}/#{@env.fnb}"
      z=SiSU_Env::CleanOutput.new(@opt)
      if SiSU_Env::InfoSettings.new.permission?('zap')
        unless @opt.act[:quiet][:set]==:on
          tell=SiSU_Screen::Ansi.new(
            @opt.act[:color_state][:set],
            "Clean files related to processing #{@opt.selections.str} ->",
            "#{@opt.fns} -> #{zap_path}"
          )
          tell.warn
        end
        z.zap.remove_output
      else
        unless @opt.act[:quiet][:set]==:on
          tell=SiSU_Screen::Ansi.new(
            @opt.act[:color_state][:set],
            'use of -Z (zap) has not enabled in sisurc.yml'
          )
          tell.warn
        end
      end
    end
  end
end
__END__
#+END_SRC

* document header

#+NAME: sisu_document_header
#+BEGIN_SRC emacs-lisp
<<./sisu_version_info_and_doc_header_including_copyright_and_license.org:sisu_doc_header_including_copyright_and_license()>>
#+END_SRC