summaryrefslogtreecommitdiff
path: root/support/lug/lug
blob: bd1e2c49507a8e289366e65aaf16d2a370edbdc8 (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
#!/bin/bash

version=2.02
myname=$(basename $0)

<<'DOC'
= lug - create and edit TeX Local User Group web pages

= Synopsis
lug [options] [lug-code]	

lug can be used to maintain the TeX Local User Group web pages, currently
located at www.ntg.nl/lug.
Without options, reads key=value pairs, possibly embedded in the body of a
mail as sent by a web form like U{www.ntg.nl/lug/nl.html}{here}.
You can feed the complete email (after saving it) to lug, or you can paste
its content to standard input.

For testing, you may want to make a copy and run it from there:

   $ cp -a /var/www/html/lug /var/www/html/lugtest
   $ cd /var/www/html/lugtest
   $ ./lug --help
   $ (more lug calls)

Finally look at the results in http://www.ntg.nl/lugtest

Options:
-h,--help	Print this help and exit
-H,--Help	Print full documentation via less and exit
-V,--version	Print version and exit
-f,--full	Re-create all files
-e,--extras=STR	Re-create STR, where STR can be:
		labels.pdf
		lugs.pdf
		lugs.html
		index.html
		links.inc
-s,--sync[=STR]	Synchronize the lug page at |www.ntg.nl/STR| with the current directory
		The default for |STR| is |lug| 
-c,--clean	Remove all files that can be re-created

= Description
lug can be used to to (re-)create the web pages of the LUG database.
This script must be executed in its own directory. After the script has
been executed, this directory will contain the web site for the Electronic
LUG Database, currently: U{www.ntg.nl/lug}{www.ntg.nl/lug}.

Before execution, the directory must contain at least"
- the script (as said)
- a subdirectory containing one text file for each LUG
The HTML files depend 4 files in the parent directory: 
|ntg.css|, |1blok1e.inc|, |1blok2e.inc|, and |1blok4e.inc|.

The |lugs.rb| script must be moved to the |cgi-bin| directory.

When people send new data by using the forms of the site, they do so by 
submitting the form, which causes an email with raw data to be sent to
the administrator(s). 

An administrator should verify the password reported in the email and then
cd to this directory, or to a copy of it on his own computer, and he should
then run:

	$ ./lug

lug waits for data, which it can be given by cut (from the email) and paste
(to standard input). By ending the input with |^D|, lug corrects the data in
the directory `lugs'

It is of course also possible to save the contents of the email into a file 
and then run:

	$ ./lug <file

The administrator can make small correction to one country by giving the
necessary input on the command line. For example, to change the email address
of the treasurer of The Netherlands he can run:

	$ ./lug
	code=nl
	femail=wybo@dekkerdocumenten.nl
	^D

Synchronize the website (|www.ntg.nl/lug|) with the current directory:

	./lug --sync

Or, for testing purposes, synchronize |www.ntg.nl/lugtest|:

	./lug --sync=lugtest

or, shorter:

	./lug -slugtest

Remove everything that can be regenerated:

	lug --clean

Regenerate everything: 

	lug --full

= Author and copyright
Author	Wybo Dekker
Email	U{wybo@dekkerdocumenten.nl}{wybo@dekkerdocumenten.nl}
License	Released under the U{www.gnu.org/copyleft/gpl.html}{GNU General Public License}
DOC

    die() { echo -e "$myname: $Err$@$Nor" 1>&2; exit 1; }
   Warn() { echo -e "$myname: $War$@$Nor" 1>&2; }
   warn() { $verbose && Warn $@; }
   help() { sed -n '/^= Synopsis/,/^= /p' $0|sed '1s/.*/Usage:/;/^= /d'; exit; }
helpall() { sed -n '/^<<.DOC.$/,/^DOC$/p' $0|sed -n '1d;$d;p'|less; exit; }
version() { echo $version; exit; }
install() { which instscript>&/dev/null && instscript -zp $myname
            cd ..
            zip -Drqq lug/lug-$version.zip lug/{images,lugs,lugs.rb}
            exit
          }

Nor='\e[0m'    # reset color	]
Err='\e[31;1m' # light red	]
War='\e[35;1m' # light magenta	]


<<'DOC' #------ function setkeys ----------------------------------------------- 
= setkeys
parameters:	1: country code
description:	Set the |keys| hash to the values taken from the file |lugs/$1|.
globals  set:	 keys
globals used:	-
returns:	0
DOC
#-------------------------------------------------------------------------------
setkeys() { # code semicolonreplacement ampersandreplacement
   local k v
   while IFS=$'\t' read -r k v; do 
      [[ $k = '' || $k =~ ^# ]] && continue
      [[ $k =~ addr$ ]] && v=${v//;/$2}
      keys["$k"]="${v//&/$3}"
   done <lugs/$1
}

<<'DOC' #------ function clean -------------------------------------------------
= clean
parameters:	-
description:	Remove files created but not needed for the web site or for 
		lug functioning.
globals  set:	-
globals used:	-
returns:	0
DOC
#-------------------------------------------------------------------------------
clean() {
   rm -f utf82html.c Makefile
}

<<'DOC' #------ function Clean -------------------------------------------------
= Clean
parameters:	-
description:	Remove all files that can be re-created.
globals  set:	-
globals used:	-
returns:	0
DOC
#-------------------------------------------------------------------------------
Clean() {
   clean
   rm -f *.html labels.* lugs.{html,pdf,tex} \
	links.inc utf82html
}

<<'DOC' #------ function makeMakefile ------------------------------------------
= makeMakefile
parameters:	-
description:	Create the file |Makefile|
globals  set:	-
globals used:	 db 
returns:	0
DOC
#-------------------------------------------------------------------------------
makeMakefile() {
   local i
   cat<<EOF |sed 's/\t//' > Makefile
	BASEFILES = $(for i in ${db[@]}; do echo -n lugs/$i' '; done)

	.SUFFIXES: .tex .pdf

	.tex.pdf:
		PDFLATEX='xelatex -recorder -interaction=batchmode' texi2dvi -p -q \$< 2>/tmp/\$\$ || cat /tmp/\$\$
		PDFLATEX='xelatex -interaction=batchmode' texi2dvi -p -q --mostly-clean \$< 2>/tmp/\$\$ || cat /tmp/\$\$
	all:	$(echo -n ${db[@]} |sed 's/ /.html /g').html \
		utf82html index.html lugs.html \
		links.inc \
		lugs.pdf labels.pdf
	$(for i in ${db[@]}; do echo "$i.html: lugs/$i utf82html; ./lug $i"; done)
	labels.pdf: \$(BASEFILES)
		./lug --extras=labels.pdf

	lugs.pdf: \$(BASEFILES)
		./lug --extras=lugs.pdf

	lugs.html: \$(BASEFILES)
		./lug --extras=lugs.html

	index.html: \$(BASEFILES)
		./lug --extras=index.html

	links.inc: \$(BASEFILES)
		./lug --extras=links.inc

	clean:
		rm -rf *.html labels.* lugs.* links.inc utf82html Makefile

	utf82html: utf82html.c
		cc -o utf82html utf82html.c

EOF
}

<<'DOC' #------ function makeutf82html.c --------------------------------------
= makeutf82html.c
parameters:	-
description:	Create the file |utf82html.c|;
		it will be compiled /via/ |Makefile|
globals  set:	-
globals used:	-
returns:	0
DOC
#-------------------------------------------------------------------------------
makeutf82html.c() {
   cat <<-'EOF' >utf82html.c
	// utf82html.c: convert UTF-8 byte sequences to numeric html entities
	// Written in 2004 by Peter Samuelson <peter@p12n.org>
	// Copyright abandoned by the author

	#include <stdio.h>
	#include <string.h>
	#include <ctype.h>

	void from_utf8 (FILE *in, FILE *out)
	{
		char buf[4096 + 17];
		size_t len = 0;

		while (!feof(in)) {
			size_t usable, i;

			len += fread(buf+len, 1, 4096, in);
			buf[len] = 0;
			if (feof(in) || len < 16)
				usable = len;
			else
				usable = len - 16;

			for (i=0; i<usable; i++) {
				int t;
				unsigned ch, len;

				/* properties of UTF-8 chars */
				static struct { unsigned minval; int len; char b0, b0mask; }
				uprop[] = {
					{ 1<<7,  2, 0xc0, 0xe0 },
					{ 1<<11, 3, 0xe0, 0xf0 },
					{ 1<<16, 4, 0xf0, 0xf8 },
					{ 1<<21, 5, 0xf8, 0xfc },
					{ 1<<26, 6, 0xfc, 0xfe },
					{ 0, }
				};

				if (!(buf[i] & 0x80)) {
					putc(buf[i], out);
					continue;
				}
				for (t = 0; uprop[t].minval; t++)
					if ((buf[i] & uprop[t].b0mask) == uprop[t].b0)
						break;
				if (!uprop[t].minval)
					goto invalid;

				ch = buf[i] & ~uprop[t].b0mask;
				for (len = uprop[t].len - 1; len; len--,i++) {
					if ((buf[i+1] & 0xc0) != 0x80)
						goto invalid;

					ch = (ch << 6) | (buf[i+1] & 0x3f);
				}
				if (ch < uprop[t].minval)
					goto invalid;

				fprintf(out, (ch > 255) ? "&#x%04x;" : "&#x%02x;", ch);
				continue;

			invalid:
				fprintf(stderr, "illegal UTF-8 sequence\n");
				fprintf(out, "&#xfffd;"); /* "REPLACEMENT CHARACTER" */
			}
			if (i < len)
				memcpy(buf, buf+i, len-i);
			len -= i;
		}
	}

	int main (int argc, char *argv[])
	{
		if (argc == 1) {
			from_utf8(stdin, stdout);
			return 0;
		}
		while (argc > 1) {
			FILE *fp = fopen(argv[1], "r");
			if (fp)
				from_utf8(fp, stdout);
			else
				perror("fopen");

			fclose(fp);
			argc--; argv++;
		}
		return 0;
	}
	EOF
}

<<'DOC' #------ function makelinks.inc -----------------------------------------
= makelinks.inc
parameters:	-
description:	Create the file |links.inc|
globals  set:	-
globals used:	-
returns:	0
DOC
#-------------------------------------------------------------------------------
makelinks.inc() {
   local i
   for i in lugs/*; do 
      i=${i#lugs/}
      echo "<a href=\"$i.html\">$i</a>"
   done
   echo '<a href="index.html">home</a>'
} >links.inc

<<'DOC' #------ function makexx.html -------------------------------------------
= makexx.html
parameters:	1: country code
description:	Create the file |lugs/$1|
globals  set:	(/via/ setkeys): |keys|
globals used:	 db keys adminemail
returns:	
DOC
#-------------------------------------------------------------------------------
makexx.html() {
   [[ -n ${db[$1]} ]] || die "Unknown country code $1"
   setkeys $1 "\n" '&amp;'
   local www
   [[ -n ${keys[www]} ]] && www='<a href="http://'${keys[www]}'">(Here is this lug'"'"'s website)</a>'
   cat <<-EOF |./utf82html >$1.html
	<!--#include virtual="../1blok1e.inc" -->
	<title>${keys[full]}</title>
	<!--#include virtual="../1blok2e.inc" -->
	<h1>TeX user groups around the world</h1>
	<h2>${keys[full]}</h2>
	<ul>
	  <li>Changes won't be instant, but are mailed to the maintainer</li>
	  <li>Use either TeX notation or accented characters for accents.</li>
	  <li>Enter phone numbers starting with +, then the country code et cetera,<br>
	  no whitespace, hyphens or other punctuation.</li>
	</ul>
	<form id="lugform" name="reaction" method="post" action="/cgi-bin/lugs.rb">
	  <input size="23" type="hidden" value="${keys[code]}" name="code">
	  Links to other User Group correction forms:<p>
	  <!--#include virtual="links.inc" --><p>
	  <table id="luginfo" border="0" cellspacing="3" summary="form">
	    <tr class="mainhead">
	      <th colspan="4" align="center">${keys[code]} - ${keys[country]} $www</th>
	    </tr>
	    <tr>
	      <td align="right">full name</td>
	      <td>
	      <textarea cols="21" rows="2" name="full">
	${keys[full]}
	</textarea></td>
	      <td align="right">periodical</td>
	      <td>
	      <textarea cols="21" rows="2" name="publ">
	${keys[publ]}
	</textarea></td>
	    </tr>
	    <tr>
	      <td align="right">short name</td>
	      <td><input size="23" value="${keys[short]}" name="short"></td>
	      <td align="right">editor</td>
	      <td><input size="23" value="${keys[editor]}" name="editor"></td>
	    </tr>
	    <tr>
	      <td align="right"><a href="http://www.lingoes.net/en/translator/langcode.htm">language(s)</a></td>
	      <td><input size="23" value="${keys[lang]}" name="lang"></td>
	      <td align="right">editor email</td>
	      <td><input size="23" value="${keys[eemail]}" name="eemail"></td>
	    </tr>
	    <tr>
	      <td align="right">members</td>
	      <td><input size="23" value="${keys[members]}" name="members"></td>
	    </tr>
	    <tr>
	      <td align="right">email</td>
	      <td><input size="23" value="${keys[email]}" name="email"></td>
	      <td align="right">bank</td>
	      <td><input size="23" value="${keys[bank]}" name="bank"></td>
	    </tr>
	    <tr>
	      <td align="right">web site</td>
	      <td><input size="23" value="${keys[www]}" name="www"></td>
	      <td align="right">bank account</td>
	      <td><input size="23" value="${keys[bacc]}" name="bacc"></td>
	    </tr>
	    <tr>
	      <td align="right">mailing list</td>
	      <td><input size="23" value="${keys[list]}" name="list"></td>
	      <td align="right">swift code</td>
	      <td><input size="23" value="${keys[bcode]}" name="bcode"></td>
	    </tr>
	    <tr>
	      <td align="right">subscribe at</td>
	      <td><input size="23" value="${keys[subscr]}" name="subscr"></td>
	      <td align="right">routing no/BIC</td>
	      <td><input size="23" value="${keys[brout]}" name="brout"></td>
	    </tr>
	    <tr>
	      <td align="right">address</td>
	      <td>
	      <textarea cols="21" rows="6" name="addr">
	$(echo -e ${keys[addr]})
	</textarea></td>
	      <td align="right">bank address</td>
	      <td>
	      <textarea cols="21" rows="6" name="baddr">
	$(echo -e ${keys[baddr]})
	</textarea></td>
	    </tr>
	    <tr class="mainhead">
	      <th colspan="4" align="center">contact addresses</th>
	    </tr>
	    <tr>
	      <td>&nbsp;</td>
	      <th>policy matters</th>
	      <th>general matters</th>
	      <th>finance / member admin</th>
	    </tr>
	    <tr>
	      <td align="right">position</td>
	      <td><input size="23" value="${keys[ppos]}" name="ppos"></td>
	      <td><input size="23" value="${keys[gpos]}" name="gpos"></td>
	      <td><input size="23" value="${keys[fpos]}" name="fpos"></td>
	    </tr>
	    <tr>
	      <td align="right">name</td>
	      <td><input size="23" value="${keys[pname]}" name="pname"></td>
	      <td><input size="23" value="${keys[gname]}" name="gname"></td>
	      <td><input size="23" value="${keys[fname]}" name="fname"></td>
	    </tr>
	    <tr>
	      <td align="right">address</td>
	      <td>
	      <textarea cols="21" rows="6" name="paddr">
	$(echo -e ${keys[paddr]})
	</textarea></td>
	      <td>
	      <textarea cols="21" rows="6" name="gaddr">
	$(echo -e ${keys[gaddr]})
	</textarea></td>
	      <td>
	      <textarea cols="21" rows="6" name="faddr">
	$(echo -e ${keys[faddr]})
	</textarea></td>
	    </tr>
	    <tr>
	      <td align="right">email</td>
	      <td><input size="23" value="${keys[pemail]}" name="pemail"></td>
	      <td><input size="23" value="${keys[gemail]}" name="gemail"></td>
	      <td><input size="23" value="${keys[femail]}" name="femail"></td>
	    </tr>
	    <tr>
	      <td align="right">phone</td>
	      <td><input size="23" value="${keys[pphone]}" name="pphone"></td>
	      <td><input size="23" value="${keys[gphone]}" name="gphone"></td>
	      <td><input size="23" value="${keys[fphone]}" name="fphone"></td>
	    </tr>
	    <tr>
	      <td align="right">fax</td>
	      <td><input size="23" value="${keys[pfax]}" name="pfax"></td>
	      <td><input size="23" value="${keys[gfax]}" name="gfax"></td>
	      <td><input size="23" value="${keys[ffax]}" name="ffax"></td>
	    </tr>
	    <tr>
	      <td></td>
	      <th align="left"><a href="lugs/${keys[code]}">download data</a></th>
	    </tr>
	    <tr class="mainhead">
	      <th colspan="4" align="center">submission of corrected data; enter your email address and password first!</th>
	    </tr>
	    <!--
	    <tr><td></td><td align="center" colspan="2" ><font color="red"><b>Currently no changes can be submitted</font></b></td><td></td></tr>
	    <tr><td></td><td align="center" colspan="2" ><font color="red"><b>due to technical problems</font></b></td><td></td></tr>
	    <tr><td></td><td align="center" colspan="2" ><font color="red"><b>Please try again later.</font></b></td><td></td></tr>
	    -->
	    <tr>
	      <td></td>
	      <td align="right">password</td>
	      <td><input size="23" name="password"></td>
	      <td><font size="1">obtain from wybo@dekkerdocumenten.nl</font></td>
	    </tr>
	    <tr>
	      <td></td>
	      <td align="right">your email address</td>
	      <td><input size="23" name="submitemail"></td>
	      <td><font size="1">needed in case we have questions</font></td>
	    </tr>
	    <tr>
	      <td></td>
	      <td></td>
	      <td align="left"><input type="submit" value="submit corrected data"></td>
	    </tr>
	  </table><p>
	  Links to other User Group correction forms:<p>
	  <!--#include virtual="links.inc" -->
	</form>
	<!--#include virtual="../1blok4e.inc" -->
	<!--#config timefmt="%Y-%m-%d %H:%M" -->
	<!--#echo var="LAST_MODIFIED" -->
	by <a href="mailto:$adminemail">$adminemail</a>
	</p> </div> </body> </html>
	EOF
}

<<'DOC' #------ function makeindex.html ----------------------------------------
= makeindex.html
parameters:	-
description:	Create the file |index.html|
globals  set:	-
globals used:	 db fullname adminemail
returns:	0
DOC
#-------------------------------------------------------------------------------
makeindex.html() {
   local content=$(for i in ${db[@]}; do echo "<tr><td>$i</td><td><a href=\"$i.html\">${fullname[$i]}</a></td></tr>"; done)
   cat <<-EOF |./utf82html >index.html
	<!--#include virtual="../1blok1e.inc" -->
	<title>Nederlandstalige TeX Gebruikersgroep</title>
	<!--#include virtual="../1blok2e.inc" -->
	<h1>TeX user groups around the world</h1>
	<table border="0" cellspacing="0" cellpadding="10">
	<tr valign="top"><td width="67%">
	This page presents electronic information about TeX User Groups around 
	the world, with an automated mechanism for updating this information and 
	a download facility with which the primary database can be extracted.
	<p>
	The data for each user group is generated in a separate table. To access it,
	simply click on the name of the country.
	<p> 
	A user group representative (the secretary, usually) can send a corrected version of his
	group data by editing the data on-line and then hitting the Send
	button. This will mail the changed data to the maintainer of this page.
	<p><b>New</b> user groups can request an entry by sending an
	email to wybodekker@dekkerdocumenten.nl
	<ul>
	<li>Please enter ASCII characters (decimal 32-126) only
	<li>use TeX for accents
	<li>Enter phone numbers starting with +, then the country code
	et cetera, no whitespace, hyphens or other punctuation.
	</ul>
	Anybody can obtain user group information by downloading the data from
	the green cell in a table. 
	This will generate a key=value line for  each cell in the table, starting with
	a key for that cell, followed by the contents of the cell.
	<p>
	<table border="1" cellspacing="0" cellpadding="10">
	<tr class="mainhead"><th colspan="3">
	How to obtain information about all lugs at once:
	</th>
	</tr>
	<tr><td>Obtain a LaTeX file presenting all lug information
	for publication in two-column format:
	</td>
	<td><a href="lugs.tex">LaTeX source</a>
	</td>
	<td><table>
	<tr><td><a href="lugs.pdf">PDF</a></td></tr>
	<tr><td><a href="lugs.html">HTML</a></td></tr>
	</table>
	</td>
	</tr>
	<tr><td>Obtain a LaTeX file containing labels with addresses
	of all lugs, where you can send your publication:
	</td>
	<td><a href="labels.tex">LaTeX source</a>
	</td>
	<td><a href="labels.pdf">PDF</a>
	</td>
	</tr>
	</table>
	</td>
	<td><table>
	$content
	</table></td></tr></table>
	<!--#include virtual="../1blok4e.inc" -->
	<!--#config timefmt="%Y-%m-%d %H:%M" -->
	<!--#echo var="LAST_MODIFIED" -->
	by <a href="mailto:$adminemail">$adminemail</a>
	</p></div></body></html>
	EOF
}

<<'DOC' #------ function makelugs.html -----------------------------------------
= makelugs.html
parameters:	-
description:	Create the file |lugs.html|
globals  set:	(/via/ setkeys) |keys|
globals used:	 db keys fullname
returns:	0
DOC
#-------------------------------------------------------------------------------
makelugs.html() {
   local linkline=$(for l in ${db[@]}; do echo "<a href=\"#$l\">$l</a>"; done)
   local i l lug www
   {  cat <<-EOF
	<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
	<html>
	<head>
	  <script language="Javascript" type="text/javascript">
	    <!--
	      if (top.location != location) top.location.href = location.href;
	    -->
	  </script>
	  <title>All TeX User Groups</title>
	  <style type="text/css">
	    <!--
	      body {
	        margin-top: 8pt;
	        margin-left: 8pt;
	        color: #777;
	        background: white;
	        font-family: Cambria, sans-serif;
	        font-size:110%;
	      }
	      H1, H2, H3, H4 { color: navy; }
	      a:link      { color: navy; }
	      a:visited   { color: green; }
	      a:active    { color: red; }
	      td.label {
	        text-align: right;
	      }
	      td.addr {
	        text-align: right;
	        vertical-align:top;
	      }
	      .nounderline A {text-decoration:none; font-weight:bold}
	      th.kop {
	        background-color:#aaa;
	        color:black;
	        vertical-align:middle;
	        text-align:left;
	        font-size:150%;
	        line-height:200%;
	      }
	      th.sub {
	        color:navy;
	        text-align:left;
	        font-size:120%;
	      }
	    -->
	  </style>
	</head>
	<body>
	<h1>TeX user groups around the world</h1>
	The TeX Users Group (contact info below) serves as the local user
	group (LUG) of TeX users in North America and any other area or
	language not appearing in the following list. TUG is always
	interested in fostering the formation of local TeX users groups;
	please contact the TUG board (board at tug.org) for assistance,
	such as forwarding information about others who might be
	interested, publicity, arranging joint memberships and so on.
	<p>
	See also:
	<ul>
	<li>The TeX calendar (
	      <a href="http://texcalendar.dante.de/month.php">month view</a>,
	      <a href="http://texcalendar.dante.de/year.php">year view</a>
	    ) for user group activities.
	<li>The <a href="http://www.tug.org/calendar.html">TUG Calendar</a> for general TeX and other typographic activities.
	<li>The list of <a href="http://www.tug.org/pubs.html">user group publications and journals</a>.
	<li>This same information in <a href="lugs.pdf">PDF</a> and in <a href="lugs.tex">LaTeX</a>.
	</ul>
	<p>
	This information comes from the
	<a href="http://www.ntg.nl/lug/index.html">Electronic LUG Database</a>:
	you can correct or add information there.<br>The following links
	bring you straight to the individual user group correction forms:<p>
	<strong>
	EOF
      for i in ${db[@]}; do 
         echo "    <a href=\"http://www.ntg.nl/lug/$i.html\">$i</a>"
      done
      cat <<-EOF
	</strong>
	<p>
	Below, a similar line of links just above
	every LUG header can be used to wander between the LUG info records in this document.<hr>
	<table summary="lugs">
	EOF
      for lug in ${db[@]}; do 
         setkeys $lug '<br>' '&amp;'
         www=${keys[www]}
         [[ -n $www ]] && www="<a href=\"http://$www\">$www</a>"
         cat <<-EOF
		<tr><td colspan="2"><br>$linkline</td></tr>

		<tr><th class="kop" colspan="2">&nbsp;<img src="./images/$lug.png"/>&nbsp;<a name="$lug">$lug - ${fullname[$lug]}</a></th></tr>
		<tr><td class="label">short name:     </td><td>${keys[short]}</td></tr>
		<tr><td class="label">full name:      </td><td>${keys[full]}</td></tr>
		<tr><td class="label">language:       </td><td>${keys[lang]}</td></tr>
		<tr><td class="label">members:        </td><td>${keys[members]}</td></tr>
		<tr><td class="label">email:          </td><td>${keys[email]}</td></tr>
		<tr><td class="label">web site:       </td><td>$www</td></tr>
		<tr><td class="label">discussion list:</td><td>${keys[list]}</td></tr>
		<tr><td class="label">subscribe at:   </td><td>${keys[subscr]}</td></tr>
		<tr><td class="addr" >address:</td><td>${keys[addr]}</td></tr>
		
		<tr><th class="sub" colspan="2">Periodical</th></tr>
		<tr><td class="label">title:          </td><td>${keys[publ]}</td></tr>
		<tr><td class="label">editor:         </td><td>${keys[editor]}</td></tr>
		<tr><td class="label">editor email:   </td><td>${keys[eemail]}</td></tr>
		
		<tr><th class="sub" colspan="2">Banking</th></tr>
		<tr><td class="label">name:           </td><td>${keys[bank]}</td></tr>
		<tr><td class="label">account:        </td><td>${keys[bacc]}</td></tr>
		<tr><td class="label">(swift) code:   </td><td>${keys[bcode]}</td></tr>
		<tr><td class="label">routing no.:    </td><td>${keys[brout]}</td></tr>
		<tr><td class="addr" >address:</td><td>${keys[baddr]}</td></tr>
		
		<tr><th class="sub" colspan="2">${keys[ppos]:-President}</th></tr>
		<tr><td class="label">name:           </td><td>${keys[pname]}</td></tr>
		<tr><td class="addr" >address:</td><td>${keys[paddr]}</td></tr>
		<tr><td class="label">email:          </td><td>${keys[pemail]}</td></tr>
		<tr><td class="label">phone:          </td><td>${keys[pphone]}</td></tr>
		<tr><td class="label">fax:            </td><td>${keys[pfax]}</td></tr>
		
		<tr><th class="sub" colspan="2">${keys[gpos]:-Secretary}</th></tr>
		<tr><td class="label">name:           </td><td>${keys[gname]}</td></tr>
		<tr><td class="addr" >address:</td><td>${keys[gaddr]}</td></tr>
		<tr><td class="label">email:          </td><td>${keys[gemail]}</td></tr>
		<tr><td class="label">phone:          </td><td>${keys[gphone]}</td></tr>
		<tr><td class="label">fax:            </td><td>${keys[gfax]}</td></tr>
		
		<tr><th class="sub" colspan="2">${keys[fpos]:-Treasurer}</th></tr>
		<tr><td class="label">name:           </td><td>${keys[fname]}</td></tr>
		<tr><td class="addr" >address:</td><td>${keys[faddr]}</td></tr>
		<tr><td class="label">email:          </td><td>${keys[femail]}</td></tr>
		<tr><td class="label">phone:          </td><td>${keys[fphone]}</td></tr>
		<tr><td class="label">fax:            </td><td>${keys[ffax]}</td></tr>
	EOF
      done
      echo "</table></body></html>" 
   } |	sed '/^$/d;/<\/td><td><\/td><\/tr>$/d' |
	tac | # reverse and go looking for <h3> headers with no content
	while read -r l; do
	   if [[ $l =~ :\ *\</td\> ]]; then		# content line?
	      keep=true					# yes, keep <h3> header
	   elif [[ $l =~ class=\"sub\" ]]; then		# sub header?
	      $keep || continue				# keep it if keep was set true, skip otherwise
	      keep=false				# not a content line, so set keep false
	   else
	      keep=false				# not a content line, so set keep false
	   fi
	   echo "$l"
	done |
	tac |
	utf82html >lugs.html
}

<<'DOC' #------ function makelugs.pdf ------------------------------------------
= makelugs.pdf
parameters:	-
description:	Create the files |lug.tex| and |lugs.pdf|
globals  set:	(/via/ setkeys) |keys|
globals used:	 keys db fullname
returns:	0
DOC
#-------------------------------------------------------------------------------
makelugs.pdf() {
   local l lug
   { cat <<-'EOF'
	%!xelatex
	\documentclass[10pt]{article}
	\usepackage[a4paper,margin=25mm]{geometry}
	\usepackage{textcomp}
	\usepackage{fontspec}
	\usepackage{url}
	\usepackage[usestackEOL]{stackengine}
	\setcounter{secnumdepth}{0}
	\renewcommand{\-}{\discretionary{}{}{}}
	\newenvironment{mylist}{%
	  \begin{list}{}{%
	    \itemsep.5ex\parsep0pt\leftmargin25mm\labelwidth25mm
	    \renewcommand{\makelabel}[1]{\hfill\emph{##1:}}
	  }}{\end{list}
	}
	\def\head#1#2{\vfill\item[\bfseries\large\upshape #1] {\Large\bfseries\upshape
	#2}\nopagebreak}
	\def\subhead#1{\\{\bfseries\upshape #1:}}
	\begin{document}\fontspec{FreeSans}
	EOF
   for lug in ${db[@]}; do 
      setkeys $lug '\\' '\&'
      cat <<-EOF
	\begin{mylist}
	\head{$lug}{${fullname[$lug]}}
	\item[short name]     ${keys[short]}
	\item[full name]      ${keys[full]}
	\item[language]       ${keys[lang]}
	\item[members]        ${keys[members]}
	\item[email]          ${keys[email]:+$(echo "\\url{${keys[email]}}")}
	\item[web site]       ${keys[www]:+$(echo "\\url{${keys[www]}}")}
	\item[discussion list]${keys[list]}
	\item[subscribe at]   ${keys[subscr]}
	\item[address] ${keys[addr]:+$(echo "\\Longunderstack[l]{${keys[addr]//;/\\\\}\\strut}")}

	\subhead{Periodical}
	\item[title]          ${keys[publ]}
	\item[editor]         ${keys[editor]}
	\item[editor email]   ${keys[eemail]:+$(echo "\\url{${keys[eemail]}}")}

	\subhead{Banking}
	\item[name]           ${keys[bank]}
	\item[account]        ${keys[bacc]}
	\item[(swift) code]   ${keys[bcode]}
	\item[routing no.]    ${keys[brout]}
	\item[address] ${keys[baddr]:+$(echo "\\Longunderstack[l]{${keys[baddr]//;/\\\\}\\strut}")}

	\subhead{${keys[ppos]:-President}}
	\item[name]           ${keys[pname]}
	\item[address] ${keys[paddr]:+$(echo "\\Longunderstack[l]{${keys[paddr]//;/\\\\}\\strut}")}
	\item[email]          ${keys[pemail]:+$(echo "\\url{${keys[pemail]}}")}
	\item[phone]          ${keys[pphone]}
	\item[fax]            ${keys[pfax]}

	\subhead{${keys[gpos]:-Secretary}}
	\item[name]           ${keys[gname]}
	\item[address] ${keys[gaddr]:+$(echo "\\Longunderstack[l]{${keys[gaddr]//;/\\\\}\\strut}")}
	\item[email]          ${keys[gemail]:+$(echo "\\url{${keys[gemail]}}")}
	\item[phone]          ${keys[gphone]}
	\item[fax]            ${keys[gfax]}

	\subhead{${keys[fpos]:-Treasurer}}
	\item[name]           ${keys[fname]}
	\item[address] ${keys[faddr]:+$(echo "\\Longunderstack[l]{${keys[faddr]//;/\\\\}\\strut}")}
	\item[email]          ${keys[femail]:+$(echo "\\url{${keys[femail]}}")}
	\item[phone]          ${keys[fphone]}
	\item[fax]            ${keys[ffax]}

	\end{mylist}
	EOF
      done
      echo '\end{document}'
   } |
   sed '/^\\item\[.*\] *$/d;/^$/d' |
   tac | # reverse and go looking for \subhead headers with no content
   while read -r l; do
      if [[ $l =~ ^\\item ]]; then	# content line?
         keep=true			# yes, keep <h3> header
      elif [[ $l =~ ^\\subhead ]]; then	# \subhead header?
         $keep || continue		# keep it if keep was set true, skip otherwise
         keep=false			# not a content line, so set keep false
      else
         keep=false			# not a content line, so set keep false
      fi
      echo "$l"
   done |
   tac >lugs.tex
   mk --noprint --noview lugs.tex &&
      mk -c lugs.tex ||
      die "Problems compiling lugs.tex"
}

<<'DOC' #------ function makelabels.pdf ----------------------------------------
= makelabels.pdf
parameters:	-
description:	Create the file |labels.tex| and |labels.pdf|
globals  set:	(/via/ setkeys) |keys|
globals used:	 keys db
returns:	0
DOC
#-------------------------------------------------------------------------------
makelabels.pdf() {
   local a i lug 
   { cat <<-'EOF'
	%!xelatex
	\documentclass{article}
	\usepackage{labels,fontspec}
	\LabelRows=8\LabelCols=3
	\TopBorder=0mm\BottomBorder=0mm
	\LeftBorder=7mm\RightBorder=7mm
	\begin{document}\fontspec{FreeSans}\begin{labels}
	EOF
     for lug in ${db[@]}; do 
        setkeys $lug "\n" '\&'
        a=
        for i in addr gaddr paddr faddr; do 
           if [[ -n ${keys[$i]} ]]; then 
              a=${keys[$i]}
              break
           fi
        done 
        [[ -n $a ]] || continue
        echo -e "${keys[short]:-${keys[full]}}\n$a\n"
     done
     echo '\end{labels}\end{document}' 
   } >labels.tex
   mk --noprint --noview labels.tex &&
      mk -c labels.tex ||
      die "Problems compiling labels.tex"
}

<<'DOC' #----------- fullname -----------------------------
= fullname (hash)
Links the country codes to the full name of countries.
Also used to test the validity of country codes.
DOC
#----------------------------------------------------------
declare -A fullname=(
   [ad]='Andorra'                  [ky]='Cayman Islands'
   [ae]='United Arab Emirates'     [kz]='Kazakhstan'
   [af]='Afghanistan'              [la]='Laos'
   [ag]='Antigua and Barbuda'      [lb]='Lebanon'
   [ai]='Anguilla'                 [li]='Liechtenstein'
   [al]='Albania'                  [lk]='Sri Lanka'
   [am]='Armenia'                  [lr]='Liberia'
   [an]='Netherlands Antilles'     [ls]='Lesotho'
   [ao]='Angola'                   [lt]='Lithuania'
   [ar]='Argentina'                [lu]='Luxembourg'
   [as]='American Samoa'           [lv]='Latvia'
   [at]='Austria'                  [ly]='Libya'
   [au]='Australia'                [ma]='Morocco'
   [aw]='Aruba'                    [mc]='Monaco'
   [az]='Azerbaijan'               [md]='Moldova'
   [ba]='Bosnia and Herzegovina'   [mg]='Madagascar'
   [bb]='Barbados'                 [mh]='Marshall Islands'
   [bd]='Bangladesh'               [mk]='Macedonia'
   [be]='Belgium'                  [ml]='Mali'
   [bf]='Burkina Faso'             [mm]='Myanmar'
   [bg]='Bulgaria'                 [mn]='Mongolia'
   [bh]='Bahrain'                  [mo]='Macau'
   [bi]='Burundi'                  [mp]='Northern Marianas Islands'
   [bj]='Benin'                    [mq]='Martinique'
   [bm]='Bermuda'                  [mr]='Mauritania'
   [bn]='Brunei'                   [ms]='Montserrat'
   [bo]='Bolivia'                  [mt]='Malta'
   [br]='Brazil'                   [mu]='Mauritius'
   [bs]='Bahamas'                  [mv]='Maldives'
   [bt]='Bhutan'                   [mw]='Malawi'
   [bw]='Botswana'                 [mx]='Mexico'
   [by]='Belarus'                  [my]='Malaysia'
   [bz]='Belize'                   [mz]='Mozambique'
   [ca]='Canada'                   [na]='Namibia'
   [cf]='Central African Republic' [nc]='New Caledonia'
   [cg]='Congo'                    [ne]='Niger'
   [ch]='Switzerland'              [nf]='Norfolk Island'
   [ci]='Ivory Coast'              [ng]='Nigeria'
   [ck]='Cook Islands'             [ni]='Nicaragua'
   [cl]='Chile'                    [nl]='Netherlands'
   [cm]='Cameroon'                 [no]='Norway'
   [cn]='China'                    [nr]='Nauru'
   [co]='Colombia'                 [nu]='Niue'
   [cr]='Costa Rica'               [nz]='New Zealand'
   [cu]='Cuba'                     [om]='Oman'
   [cv]='Cape Verde Islands'       [pa]='Panama'
   [cy]='Cyprus'                   [pe]='Peru'
   [cz]='Czech Republic'           [pf]='French Polynesia'
   [de]='Germany'                  [pg]='Papua New Guinea'
   [dj]='Djibouti'                 [ph]='Philippines'
   [dk]='Denmark'                  [pk]='Pakistan'
   [dm]='Dominica'                 [pl]='Poland'
   [do]='Dominican Republic'       [pm]='St Pierre and Miquelon'
   [dz]='Algeria'                  [pr]='Puerto Rico'
   [ec]='Ecuador'                  [pt]='Portugal'
   [ee]='Estonia'                  [pw]='Palau'
   [eg]='Egypt'                    [py]='Paraguay'
   [eh]='Western Samoa'            [qa]='Qatar'
   [er]='Eritrea'                  [re]='Reunion'
   [es]='Spain'                    [ro]='Romania'
   [esc]='Spain (Catalan)'         [ru]='Russia'
   [et]='Ethiopia'                 [rw]='Rwanda'
   [fi]='Finland'                  [sa]='Saudi Arabia'
   [fj]='Fiji Islands'             [sb]='Solomon Islands'
   [fk]='Falkland Islands'         [sc]='Seychelles Islands'
   [fm]='Micronesia'               [sd]='Sudan'
   [fo]='Faroe Islands'            [se]='Sweden'
   [fr]='France'                   [sg]='Singapore'
   [ga]='Gabon'                    [si]='Slovenia'
   [gb]='United Kingdom'           [sk]='Slovak Republic'
   [gd]='Grenada'                  [sl]='Sierra Leone'
   [ge]='Georgia'                  [sm]='San Marino'
   [gf]='French Guiana'            [sn]='Senegal'
   [gh]='Ghana'                    [so]='Somalia'
   [gi]='Gibraltar'                [sr]='Suriname'
   [gl]='Greenland'                [sv]='El Salvador'
   [gm]='Gambia'                   [sy]='Syria'
   [gn]='Guinea'                   [sz]='Swaziland'
   [gp]='Guadeloupe'               [tc]='Turks and Caicos Islands'
   [gq]='Equatorial Guinea'        [td]='Chad'
   [gr]='Greece'                   [tg]='Togo'
   [gt]='Guatemala'                [th]='Thailand'
   [gu]='Guam'                     [tj]='Tajikistan'
   [gw]='Guinea-Bissau'            [tk]='Tokelau'
   [gy]='Guyana'                   [tm]='Turkmenistan'
   [hk]='Hong Kong'                [tn]='Tunisia'
   [hn]='Honduras'                 [to]='Tonga Islands'
   [hr]='Croatia'                  [tp]='East Timor'
   [ht]='Haiti'                    [tr]='Turkey'
   [hu]='Hungary'                  [tt]='Trinidad and Tobago'
   [id]='Indonesia'                [tv]='Tuvalu'
   [ie]='Ireland'                  [tw]='Taiwan'
   [il]='Israel'                   [tz]='Tanzania'
   [in]='India'                    [ua]='Ukraine'
   [iq]='Iraq'                     [ug]='Uganda'
   [ir]='Iran'                     [us]='TeX User Group (International)'
   [is]='Iceland'                  [uy]='Uruguay'
   [it]='Italy'                    [uz]='Uzbekistan'
   [jm]='Jamaica'                  [ve]='Venezuela'
   [jo]='Jordan'                   [vg]='Virgin Islands (GB)'
   [jp]='Japan'                    [vi]='Virgin Islands (US)'
   [ke]='Kenya'                    [vn]='Vietnam'
   [kg]='Kyrgyzstan'               [vu]='Vanuatu'
   [kh]='Cambodia'                 [wf]='Wallis and Futuna Islands'
   [ki]='Kiribati'                 [ye]='Yemen'
   [km]='Comoros'                  [yt]='Mayotte Island'
   [kn]='St Kitts and Nevis'       [yu]='Yugoslavia'
   [kp]='Korea (North)'            [za]='South Africa'
   [kr]='Korea (South)'            [zm]='Zambia'
   [kw]='Kuwait'                   [zw]='Zimbabwe'
)

<<'DOC' #----------- keys, inp ----------------------------
= keys, inp (hashes)
Depending on which lug is handled, |keys| will contain the
key and values defined in the files in |lugs/|. 
In an edit operation, |inp| will be filled with similar
keys and values that will replace those in keys.
DOC
#----------------------------------------------------------
declare -A keys inp

<<'DOC' #------------- db ---------------------------------
= db (string)
Contains the space-separated country codes for which data
are available in the |lugs/| directory.
DOC
#----------------------------------------------------------
db=$(test -d lugs && cd lugs && ls | tr "\n" " ")

<<'DOC' #------------- admin ------------------------------
= admin (string)
Contains the user name of the lug administrator at www.ntg.nl
DOC
#----------------------------------------------------------
admin=wybo

<<'DOC' #------------- adminemail -------------------------
= adminemail (string)
Contains the email address that should receive corrections
from the web site.
DOC
#----------------------------------------------------------
adminemail=wybo@dekkerdocumenten.nl

# =============== Program starts here =============
source=$(readlink $0 || echo ./lug)
cd ${source%/lug}
test -d lugs -a -e lug || 
  die "The lug script is part of a directory containing all LUG data;\n" \
      "    You must run (an exact copy of) it in that directory,\n" \
      "    or you must make a link to the lug script in your PATH"
diff ./lug $0 >/dev/null || die "You are running a copy of the lug script that differs from its source"

if ! options=$(getopt \
   -n $myname \
   -o hHVIcfe:s:: \
   -l help,Help,version,clean,full,extras:,sync:: \
   -- "$@"
); then exit 1; fi
eval set -- "$options"
while [ $# -gt 0 ]; do
   case $1 in
   (-h|--help)    help;;
   (-H|--Help)    helpall;;
   (-V|--version) version;;
   (-I)           install;;
   (-c|--clean)	  Clean
		  exit;;
   (-f|--full)    Clean
		  makeutf82html.c
		  makeMakefile
		  make --quiet
		  clean
		  exit;;
   (-e|--extras)  eval "make$2"
		  exit;;
   (-s|--sync)    i=${2:-lug}
		  n=$(ls -R|wc -l)
		  test $n -lt 70 && die "Only $n files here, can't sync"
		  echo syncing with www.ntg.nl/$i
		  rsync -ia --delete --exclude='.hg*' ./ $admin@www.ntg.nl:html/$i/
		  exit;;
   (--)           shift;  break;;
   (*)			  break;;
   esac
done

if [ -n "$1" ]; then 
   for i in "$@"; do
      makexx.html $i
   done
   exit 
fi

in=false
echo waiting for input...
while IFS='' read line; do
   [[ -z $line ]] && continue 		# skip empty lines
   if [[ $line =~ ^code= ]]; then	# we get here only with manual input 
      in=true				# of a few lines; those must start with code=
      inp[code]=${line#*=}
   fi
   [[ $line == 'password=kjwb' ]] && { in=true; continue; }
   $in || continue 			# look only after "password=kjwb"
   [[ $line =~ =$ ]] && continue
   if [[ $line =~ = ]]; then
      IFS='=' read k v <<<$line
      inp[$k]="$v"
   else 
      inp[$k]+=";$line"
   fi
done
code=${inp[code]}
[[ -n $code ]] || die "No code was specified"
[[ $(echo ${db[@]}) =~ $code ]] || die "Unrecognized code: $code"

setkeys $code ';' '&' # make copy of old data in keys
for i in ${!inp[@]}; do keys[$i]=${inp[$i]}; done # overwrite with new data

cat <<-EOF >new
	# General:
	code	${keys[code]}
	short	${keys[short]}
	full	${keys[full]}
	lang	${keys[lang]}
	members	${keys[members]}
	email	${keys[email]}
	www	${keys[www]}
	list	${keys[list]}
	subscr	${keys[subscr]}
	addr	${keys[addr]}

	# Periodical:
	publ	${keys[publ]}
	editor	${keys[editor]}
	eemail	${keys[eemail]}

	# Banking:
	bank	${keys[bank]}
	bacc	${keys[bacc]}
	bcode	${keys[bcode]}
	brout	${keys[brout]}
	baddr	${keys[baddr]}

	# Policy matters:
	ppos	${keys[ppos]}
	pname	${keys[pname]}
	paddr	${keys[paddr]}
	pemail	${keys[pemail]}
	pphone	${keys[pphone]}
	pfax	${keys[pfax]}

	# General matters:
	gpos	${keys[gpos]}
	gname	${keys[gname]}
	gaddr	${keys[gaddr]}
	gemail	${keys[gemail]}
	gphone	${keys[gphone]}
	gfax	${keys[gfax]}

	# Finance matters:
	fpos	${keys[fpos]}
	fname	${keys[fname]}
	faddr	${keys[faddr]}
	femail	${keys[femail]}
	fphone	${keys[fphone]}
	ffax	${keys[ffax]}
	EOF
diff -y --left-column --report-identical-files lugs/$code new && die "No changes"
while true; do
   echo -n "Save [Yn]? "
   read r 
   case $r in 
   ([yY]|'')	mv -f new lugs/$code && Warn Saved || die "Could not save"
		exit
		;;
   (n|N) 	die "Not saved, result left in file new"
		;;
   esac 
done