/
gen-config.pl
127 lines (109 loc) · 3.43 KB
/
gen-config.pl
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
use strict; use warnings; use warnings FATAL => 'uninitialized';
use utf8;
use Function::Parameters qw(:strict);
our ($mydir,$gitrepository); # 'import' from main
use PXML::XHTML ":all";
use Clone 'clone';
use FP::Lazy;
# htmlgen is run with CWD set to website/
my $logocfg= require "./logo.pl";
my $css_path0= "FP.css";
my $version_numrevisions = lazy {
my $describe= $gitrepository->describe ();
my ($version,$maybe_numrevisions,$maybe_shorthash)=
$describe=~ /^(.*?)(?:-(\d+)-g(.*))?\z/s
or die "huh describe '$describe'";
[$version, $maybe_numrevisions]
};
my $year= (localtime)[5]+1900;
my $email= "copying\@christianjaeger.ch"; # ? or ch@?
+{
map_code_body=> fun ($str, $uplist, $path0) {
my ($version, $maybe_numrevisions)= @{force $version_numrevisions};
my $version_underscores= $version;
$version_underscores=~ tr/./_/;
my $commits=
$maybe_numrevisions ?
($maybe_numrevisions==1 ? "$maybe_numrevisions commit"
: "$maybe_numrevisions commits")
: "zero commits";
$str=~ s|\$FP_VERSION\b|$version|sg;
$str=~ s|\$FP_VERSION_UNDERSCORES\b|$version_underscores|sg;
$str=~ s|\$FP_COMMITS_DIFFERENCE\b|$commits|sg;
$str
},
#copy_paths=> [], optional, for path0s from the main source root
copy_paths_separate=>
# source_root => path0s
+{"."=> [
"FP-logo.png",
$css_path0,
]},
path0_handlers=>
+{
},
title=> fun ($filetitle) {
($filetitle eq "Readme" ?
"Functional programming on Perl"
: $filetitle,
" - functional-perl.org")
},
head=> fun ($path0) {
# HTML to add to the <head> section
LINK ({rel=> "stylesheet",
href=> path_diff ($path0, $css_path0),
type=> "text/css"})
},
header=> fun ($path0) {
# HTML above navigation
# XX hack: clone it so that serialization doesn't kill parts of
# it (by way of `weaken`ing)
clone $logocfg->($path0)->{logo}
},
nav=>
nav(entry("README.md",
entry("docs/intro.md"),
entry("docs/howto.md"),
entry("docs/design.md"),
entry("examples/README.md")),
entry("functional_XML/README.md",
entry("functional_XML/TODO.md")),
entry("htmlgen/README.md",
entry("htmlgen/TODO.md")),
entry("docs/ideas.md"),
entry("docs/TODO.md"),
entry("docs/names.md"),
entry("docs/HACKING.md"),
entry("COPYING.md",
entry("licenses/artistic_license_2.0.md")),
entry("docs/links.md"),
entry("docs/contact.md",
entry("docs/mailing_list.md"))),
belownav=> fun ($path0) {
# HTML between navigation and page content.
# path0 is the source (.md) file.
DIV({class=> "editandhist"},
A({href=> "https://github.com/pflanze/functional-perl/commits/master/$path0"},
"history"),
" | ",
A({href=> "https://github.com/pflanze/functional-perl/edit/master/$path0"},
"edit"))
},
footer=> fun ($path0) {
my $yearstart= 2014;
my $years= $year == $yearstart ? $year : "$yearstart-$year";
DIV({class=>"footer_legalese"},
# our part
"© $years ",
A ({href=> "mailto:$email"}, "Christian Jaeger"),
". ",
# camel logo
"The Perl camel image is a trademark of ",
A({href=> "http://www.oreilly.com"}, "O'Reilly Media, Inc."),
" Used with permission."
)
},
warn_hint=> 1, # warn if the website hint (header) is missing in a
# .md file
downcaps=> 1, # whether to downcase all-caps filenames like README -> Readme
}