Source

shlomi-fish-homepage / bin / gen-docbook-make-helpers.pl

Full commit
shl...@cec68495-… ec9a2b0 






shl...@cec68495-… 419ae56 

shl...@iglu.org.… 20c3344 

shl...@cec68495-… ec9a2b0 


shl...@iglu.org.… f1f20c4 


Shlomi Fish 9b94b26 
shl...@iglu.org.… f1f20c4 
shl...@iglu.org.… 499fc90 
shl...@cec68495-… ec9a2b0 
shl...@iglu.org.… 499fc90 

shl...@cec68495-… ec9a2b0 

shl...@iglu.org.… c4dd324 





shl...@cec68495-… ec9a2b0 




Shlomi Fish 9b94b26 

shl...@cec68495-… ec9a2b0 
shl...@cec68495-… e9891de 
shl...@iglu.org.… 20c3344 
shl...@cec68495-… ec9a2b0 

Shlomi Fish 9b94b26 

shl...@cec68495-… ec9a2b0 


shl...@cec68495-… c738cbc 

shl...@cec68495-… ec9a2b0 

Shlomi Fish 9b94b26 
shl...@cec68495-… ec9a2b0 
Shlomi Fish 9b94b26 

shl...@cec68495-… ec9a2b0 

Shlomi Fish 9b94b26 
shl...@cec68495-… ec9a2b0 
Shlomi Fish 9b94b26 

shl...@cec68495-… ec9a2b0 

Shlomi Fish 9b94b26 
shl...@cec68495-… ec9a2b0 
shl...@cec68495-… e9891de 

shl...@cec68495-… ec9a2b0 

shl...@iglu.org.… a3773c7 






Shlomi Fish 9b94b26 
shl...@cec68495-… ec9a2b0 
shl...@cec68495-… e9891de 

shl...@cec68495-… ec9a2b0 

Shlomi Fish 9b94b26 
shl...@cec68495-… ec9a2b0 
shl...@cec68495-… e9891de 

shl...@cec68495-… ec9a2b0 

Shlomi Fish 9b94b26 
shl...@cec68495-… ec9a2b0 
Shlomi Fish 9b94b26 

shl...@cec68495-… ec9a2b0 

Shlomi Fish 9b94b26 
shl...@cec68495-… ec9a2b0 
Shlomi Fish 9b94b26 

shl...@cec68495-… ec9a2b0 


Shlomi Fish 9b94b26 

shl...@cec68495-… ec9a2b0 


Shlomi Fish 89625d4 




Shlomi Fish 9b94b26 

shl...@cec68495-… fa8437d 


Shlomi Fish 9b94b26 
shl...@cec68495-… e89e673 

shl...@iglu.org.… 9a10971 
Shlomi Fish 9b94b26 
shl...@cec68495-… e89e673 
Shlomi Fish 9b94b26 
shl...@iglu.org.… d7b3945 
shl...@iglu.org.… d8c041b 
Shlomi Fish 9b94b26 
shl...@iglu.org.… d8c041b 
Shlomi Fish 9b94b26 
shl...@iglu.org.… 108a196 

shl...@iglu.org.… 867f48b 
shl...@cec68495-… e9891de 
shl...@cec68495-… c738cbc 
Shlomi Fish 9b94b26 
shl...@cec68495-… c738cbc 
Shlomi Fish 9b94b26 

shl...@cec68495-… ec9a2b0 

shl...@cec68495-… fa8437d 
shl...@iglu.org.… e4e7729 
shl...@iglu.org.… c919bc0 





shl...@iglu.org.… 8f3048f 
Shlomi Fish 9b94b26 
shl...@iglu.org.… 8f3048f 
shl...@iglu.org.… a5125b9 
shl...@iglu.org.… 8f3048f 
shl...@iglu.org.… 035c94b 
shl...@iglu.org.… 8f3048f 

shl...@iglu.org.… 125b2c2 





shl...@iglu.org.… ae64115 





shl...@iglu.org.… ae9b0eb 







shl...@cec68495-… ec9a2b0 

shl...@iglu.org.… de06893 


Shlomi Fish 9b94b26 

shl...@iglu.org.… de06893 







shl...@iglu.org.… 20c3344 









shl...@iglu.org.… 9a10971 




shl...@iglu.org.… 035c94b 




shl...@iglu.org.… 20c3344 

shl...@cec68495-… 98268d0 





shl...@cec68495-… c51fcf6 



shl...@cec68495-… 98268d0 



Shlomi Fish 9b94b26 
shl...@cec68495-… ea430c0 
shl...@cec68495-… 98268d0 




















shl...@cec68495-… c51fcf6 
shl...@cec68495-… 98268d0 
shl...@cec68495-… c51fcf6 
shl...@cec68495-… 98268d0 


shl...@cec68495-… ea430c0 

shl...@cec68495-… ec9a2b0 


shl...@cec68495-… d8cd699 

shl...@cec68495-… 3ea026c 
shl...@cec68495-… 419ae56 
shl...@cec68495-… 3ea026c 
shl...@cec68495-… c3f6edb 



shl...@cec68495-… 77f3d65 
shl...@cec68495-… 419ae56 

shl...@cec68495-… 77f3d65 
shl...@cec68495-… 419ae56 



shl...@cec68495-… 77f3d65 
shl...@cec68495-… 419ae56 


shl...@cec68495-… 77f3d65 



Shlomi Fish 9b94b26 
shl...@cec68495-… c3f6edb 

shl...@iglu.org.… 39bfc16 

Shlomi Fish 9b94b26 
shl...@cec68495-… c3f6edb 
shl...@cec68495-… 77f3d65 

shl...@cec68495-… 419ae56 

shl...@cec68495-… 3ea026c 



shl...@cec68495-… 77f3d65 
shl...@cec68495-… 3ea026c 

Shlomi Fish 9b94b26 
shl...@cec68495-… ec9a2b0 
shl...@iglu.org.… 20c3344 

shl...@cec68495-… ea430c0 
shl...@cec68495-… d8cd699 


shl...@cec68495-… 77f3d65 
shl...@cec68495-… 419ae56 
Shlomi Fish 9b94b26 
shl...@cec68495-… 77f3d65 

Shlomi Fish 9b94b26 
shl...@cec68495-… 77f3d65 







shl...@iglu.org.… 9e560b7 
shl...@cec68495-… 77f3d65 

shl...@iglu.org.… 9e560b7 
shl...@cec68495-… 77f3d65 
shl...@iglu.org.… 9e560b7 
shl...@cec68495-… 1d9d210 







shl...@iglu.org.… 9e560b7 
shl...@cec68495-… 69ba428 

shl...@iglu.org.… 9e560b7 
shl...@cec68495-… 69ba428 
shl...@iglu.org.… 9e560b7 







shl...@cec68495-… 69ba428 
shl...@cec68495-… f93180a 






shl...@iglu.org.… 9e560b7 
shl...@cec68495-… 26f3dd8 

shl...@iglu.org.… 9e560b7 
shl...@cec68495-… 26f3dd8 
shl...@iglu.org.… 9e560b7 
shl...@cec68495-… 26f3dd8 
shl...@iglu.org.… 9e560b7 
shl...@cec68495-… fab6020 

shl...@iglu.org.… 9e560b7 
shl...@cec68495-… fab6020 
shl...@iglu.org.… 9e560b7 
shl...@cec68495-… c3f6edb 
shl...@cec68495-… e86ed66 






shl...@cec68495-… 8c17dc1 






shl...@cec68495-… ad739dd 






shl...@cec68495-… 94a18d7 






shl...@cec68495-… ca3f3c1 






shl...@iglu.org.… 9e560b7 
shl...@iglu.org.… d44a72e 




shl...@iglu.org.… 204bfbf 
shl...@cec68495-… d6805a9 






shl...@iglu.org.… 204bfbf 






shl...@iglu.org.… 9e560b7 
shl...@cec68495-… e11bd01 

shl...@iglu.org.… 9e560b7 
shl...@cec68495-… e11bd01 
shl...@iglu.org.… 9e560b7 
shl...@cec68495-… e11bd01 
shl...@iglu.org.… 168ea4f 






shl...@cec68495-… 2458caa 






shl...@iglu.org.… 9e560b7 
shl...@cec68495-… 588b69f 

shl...@iglu.org.… 9e560b7 
shl...@cec68495-… 588b69f 
shl...@iglu.org.… 9e560b7 













shl...@cec68495-… 588b69f 
shl...@cec68495-… 419ae56 
shl...@cec68495-… ec9a2b0 

shl...@iglu.org.… 20c3344 
shl...@cec68495-… d8cd699 

shl...@cec68495-… ec9a2b0 
  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
#!/usr/bin/perl

use strict;
use warnings;

use Template;

use File::Find::Object::Rule;

use List::MoreUtils qw(any);

my @documents =
(
    {
        id => "case-for-drug-legalisation",
        path => "philosophy/politics/drug-legalisation",
        base => "case-for-drug-legalisation",
    },
    {
        id => "case-for-drug-legalisation-rev2",
        path => "philosophy/politics/drug-legalisation",
        base => "case-for-drug-legalisation-rev2",
        db_ver => 5,
    },
    {
        id => "case-for-drug-legalisation-v3",
        path => "philosophy/politics/drug-legalisation",
        base => "case-for-drug-legalisation-v3",
        db_ver => 5,
    },
    {
        id => "case-for-file-swapping-rev3",
        path => "philosophy/case-for-file-swapping/revision-3",
        base => "case-for-file-swapping-rev3",
    },
    {
        id => "dealing-with-hypomanias",
        path => "philosophy/psychology/hypomanias/",
        base => "dealing-with-hypomanias",
        work_in_progress => 1,
        db_ver => 5,
    },
    {
        id => "end-of-it-slavery",
        path => "philosophy/computers/software-management/end-of-it-slavery",
        base => "end-of-it-slavery",
    },
    {
        id => "foss-and-other-beasts",
        path => "philosophy/foss-other-beasts/revision-2",
        base => "foss-and-other-beasts",
    },

    {
        id => "introductory-language",
        path => "philosophy/computers/education/introductory-language",
        base => "introductory-language",
    },

    {
        id => "isr-pales-conflict-solution",
        path => "philosophy/israel-pales",
        base => "isr-pales-conflict-solution",
    },

    {
        id => "objectivism-and-open-source",
        path => "philosophy/obj-oss",
        base => "objectivism-and-open-source",
    },

    {
        id => "objectivism-and-open-source-r2",
        path => "philosophy/obj-oss/rev2",
        base => "objectivism-and-open-source",
        db_ver => 5,
    },

    {
        id => "rindolf-spec",
        path => "rindolf",
        base => "rindolf-spec",
    },

    {
        id => "the-eternal-jew",
        path => "philosophy/the-eternal-jew",
        base => "the-eternal-jew",
    },

    {
        id => "what-makes-software-high-quality",
        path => "philosophy/computers/high-quality-software",
        base => "what-makes-software-high-quality",
    },

    {
        id => "what-makes-software-high-quality-rev2",
        path => "philosophy/computers/high-quality-software/rev2",
        base => "what-makes-software-high-quality-rev2",
    },
    {
        id => "perfect-it-workplace",
        path => "philosophy/computers/software-management/perfect-workplace",
        base => "perfect-it-workplace",
    },
    {
        id => "park-lisp-informal-spec",
        path => "open-source/projects/Park-Lisp",
        base => "park-lisp-informal-spec",
    },
    {
        id => "Spark-Pre-Birth-of-a-Modern-Lisp",
        path => "open-source/projects/Spark/mission",
        base => "Spark-Pre-Birth-of-a-Modern-Lisp",
    },
    {
        id => "human-hacking-field-guide",
        path =>  "humour/human-hacking",
        base => "human-hacking-field-guide",
        custom_css => 1,
    },
    {
        id => "human-hacking-field-guide-v2-arabic",
        path =>  "humour/human-hacking/arabic-v2",
        base => "human-hacking-field-guide-v2-arabic",
    },
    {
        id => "perfect-it-workplace-v2",
        path =>  "philosophy/computers/software-management/perfect-workplace/v2",
        base => "perfect-it-workplace-v2",
        db_ver => 5,
        work_in_progress => 1,
    },

    {
        id => "foss-licences-wars",
        path => "philosophy/computers/open-source/foss-licences-wars",
        base => "foss-licences-wars",
    },

    {
        id => "foss-licences-wars-rev2",
        path => "philosophy/computers/open-source/foss-licences-wars/rev2/",
        base => "foss-licences-wars-rev2",
        work_in_progress => 1,
        db_ver => 5,
    },
    {
        id => "human-hacking-field-guide-v2",
        path =>  "humour/human-hacking",
        base => "human-hacking-field-guide-v2",
        custom_css => 1,
        del_revhistory => 1,
        db_ver => 5,
    },
    {
        id => "foss-and-other-beasts-v3",
        path => "philosophy/foss-other-beasts/version-3",
        base =>  "foss-and-other-beasts-v3",
        db_ver => 5,
    },
    {
        id => "usability-of-perl-world-for-newcomers",
        path => "philosophy/perl-newcomers/v1",
        base => "usability-of-perl-world-for-newcomers",
        db_ver => 5,
    },
    {
        id => "The-Enemy-English-v7",
        path => "humour/TheEnemy",
        base => "The-Enemy-English-v7",
        custom_css => 1,
        del_revhistory => 1,
        db_ver => 5,
    },
);

=begin foo
    # Removed due to it already being in FICTION_DOCS in Makefile.
    {
        id => "The-Pope-Died-on-Sunday-hebrew",
        path => "humour/Pope/",
        base => "The-Pope-Died-on-Sunday-hebrew",
        work_in_progress => 1,
        db_ver => 5,
    },
=end foo

=cut

foreach my $d (@documents)
{
    if (! exists($d->{db_ver}))
    {
        $d->{db_ver} = 4;
    }
    elsif (! (any { $d->{db_ver} eq $_ } (4,5)))
    {
        die "Illegal db_ver $d->{db_ver}!";
    }

    if (! exists($d->{custom_css}) )
    {
        $d->{custom_css} = 0;
    }

    if (! exists($d->{del_revhistory}) )
    {
        $d->{del_revhistory} = 0;
    }
}

sub process_simple_end_format
{
    my $fmt = shift;

    my %f = %$fmt;

    if (!exists($f{dir}))
    {
        $f{dir} = lc($f{var});
    }

    return \%f;
}

my @end_formats =
(
    (
        map { process_simple_end_format($_) }
        (
        {
            var => "PDF",
            ext => ".pdf",
        },
        {
            var => "XML",
            ext => ".xml",
        },
        {
            var => "RTF",
            ext => ".rtf",
        },
        {
            var => "FO",
            ext => ".fo",
            skip_install => 1,
        },
        {
            var => "INDIVIDUAL_XHTML",
            ext => "",
            dir => "indiv-nodes",
        },
        )
    )
);

my $tt = Template->new({});

open my $make_fh, ">", "lib/make/docbook/sf-homepage-docbooks-generated.mak";
open my $template_fh, "<", "lib/make/docbook/sf-homepage-db-gen.tt";

sub get_quad_pres_files
{
    my $dir = shift;
    my $args = shift || {};

    my $include_cb = $args->{'include_cb'} || sub { return 1; };

    my $dir_src = "$dir/src";

    my @files = File::Find::Object::Rule->name('*.html.wml')->in(
        $dir_src,
    );

    foreach my $f (@files)
    {
        $f =~ s{\A\Q$dir_src\E/}{}ms;
        $f =~ s{\.wml\z}{};
    }

    return
    [
        'src_dir' => $dir,
        'src_files' =>
        [
            sort { $a cmp $b }
            grep { $include_cb->($_) }
            # Filtering out explicitly because it has its own separate
            # dependency.
            grep { $_ ne "index.html" }
            @files
        ],
    ];
}

sub get_p4n_files
{
    my $n = shift;

    return get_quad_pres_files("lib/presentations/qp/perl-for-newbies/$n");
}

$tt->process($template_fh,
    {
        docs_4 => [ grep { $_->{db_ver} != 5 } @documents],
        docs_5 => [ grep { $_->{db_ver} == 5 } @documents],
        fmts => \@end_formats,
        top_header => <<"EOF",
### This file is auto-generated from gen-dobook-make-helpers.pl
EOF
        quadp_presentations =>
        {
            (map
                {
                    (
                        "p4n$_" =>
                        {
                            dest_dir => "lecture/Perl/Newbies/lecture$_",
                            @{get_p4n_files($_)},
                        },
                    )
                }
                (1 .. 5)
            ),
            'autotools' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/Autotools",
                )},
                dest_dir => "lecture/Autotools/slides",
            },
            'catb' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/CatB",
                )},
                dest_dir => "lecture/CatB/slides",
            },
            'gimp_1_2' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/Gimp/1.2",
                )},
                dest_dir => "lecture/Gimp/1/slides",
            },
            'gimp_2_2' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/Gimp/2.2",
                )},
                dest_dir => "lecture/Gimp/1/2.2-slides",
            },
            'haskell_for_perlers' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/haskell-for-perl-programmers",
                )},
                dest_dir => "lecture/Perl/Haskell/slides",
            },
            'joel_test' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/joel-test",
                )},
                dest_dir => "lecture/joel-test/heb-slides",
            },
            'lamp' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/web-publishing-with-LAMP",
                )},
                dest_dir => "lecture/LAMP/slides",
            },
            'freecell_solver_1' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/Freecell-Solver/1",
                )},
                dest_dir => "lecture/Freecell-Solver/slides",
            },
            'freecell_solver_the_next_pres' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/Freecell-Solver/The-Next-Pres",
                )},
                dest_dir => "lecture/Freecell-Solver/The-Next-Pres/slides",
            },
            'freecell_solver_project_intro' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/Freecell-Solver/project-intro",
                )},
                dest_dir => "lecture/Freecell-Solver/project-intro/slides",
            },
            'lm_solve' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/LM-Solve",
                )},
                dest_dir => "lecture/LM-Solve/slides",
            },
            'mdda' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/meta-data-database-access",
                )},
                dest_dir => "lecture/mini/mdda/slides",
            },
            'quad_pres' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/Quad-Pres",
                )},
                dest_dir => "lecture/Quad-Pres/slides",
            },
            'w2l_basic_use' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/welcome-to-linux/Basic_Use-2",
                )},
                dest_dir => "lecture/W2L/Basic_Use/slides",
            },
            'w2l_blitz' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/welcome-to-linux/Blitz",
                )},
                dest_dir => "lecture/W2L/Blitz/slides",
            },
            'w2l_devel' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/welcome-to-linux/Development",
                )},
                dest_dir => "lecture/W2L/Development/slides",
            },
            'w2l_mini_intro' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/welcome-to-linux/Mini-Intro",
                )},
                dest_dir => "lecture/W2L/Mini-Intro/slides",
            },
            'w2l_networking' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/welcome-to-linux/Networking",
                )},
                dest_dir => "lecture/W2L/Network/slides",
            },
            'w2l_technion' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/welcome-to-linux/Technion",
                )},
                dest_dir => "lecture/W2L/Technion/slides",
            },
            'website_meta_lect' =>
            {
                @{get_quad_pres_files(
                    "lib/presentations/qp/Website-Meta-Lecture",
                    {
                        include_cb => sub {
                            my $fn = shift;
                            return ($fn !~ m{\Aexamples/})
                        },
                    },
                )},
                dest_dir => "lecture/WebMetaLecture/slides",
            },
        },
    },
    $make_fh
) or die $tt->error();

close ($template_fh);
close ($make_fh);