-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen.dt
executable file
·71 lines (50 loc) · 1.49 KB
/
gen.dt
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
#!/usr/bin/env dt
[ "}}" split deq [code literal]:
code eval
literal push "" join
] \fill-part def!
[ "{{" split deq
\fill-part map enq
"" join
] \fill def!
### Site template ###
"site.html.template" readf \site-template:
[ [title main]: site-template fill ] \gen-page def!
### Main pages ###
ls
[ ".html.part" ends-with? ] filter
[ \partial:
partial ".html.part" split first
"." split pop downcase \page:
"." join "-" split unwords \title:
title partial readf gen-page
page "html" push "." join writef
] each
### Blog ###
"blog" cd
# TODO: dirname/basename should be in dt
[ "/" split last ] \basename def
[ "." split pop drop "." join ] \drop-ext def
[ "so.dang.cool ::" push rev unwords ] \as-title def
### Blog posts ###
"posts" cd ls ".." cd
[ ".html.part" ends-with? ] filter
[ \filename:
"posts" filename push "/" join \source:
filename drop-ext drop-ext \filepath:
filepath "-" split \deq 3 times unwords \post-title:
\enq 2 times "-" join \date:
### Render the post ###
[ post-title date ] \do map " :: " join
source readf fill gen-page
"mkdir -p" filepath push unwords exec drop
filepath "index.html" push "/" join writef
### Return the list item for index ###
[ " <li><a href='" filepath "'>" date " :: " post-title "</a></li>" ] \do map
"" join
] map
sort rev unlines \posts:
### Blog index ###
"boonie pepper blog" as-title
[ "<ul>" posts "</ul>" ] [do " " push rev "" join] map unlines
gen-page "index.html" writef