gdritter repos when-computer / de0b055
[...] Getty Ritter 9 years ago
3 changed file(s) with 77 addition(s) and 14 deletion(s). Collapse all Expand all
1 GEN = ./generator/generate
2
3 all: output/index.html output/archive/index.html output/tags/index.html \
4 output/about/index.html $(wildcard output/post/*/index.html)
5
6 output/index.html: posts/*
7 mkdir -p `dirname $@`
8 $(GEN) index posts/`ls -t posts | head -n 1`
9
10 output/archive/index.html: site.scm
11 mkdir -p `dirname $@`
12 $(GEN) archive
13
14 output/tags/index.html: site.scm
15 mkdir -p `dirname $@`
16 $(GEN) tags
17
18 output/post/%/index.html: posts/%.telml
19 mkdir -p `dirname $@`
20 $(GEN) post $<
21
22 output/about/index.html: pages/about.telml
23 mkdir -p `dirname $@`
24 $(GEN) about pages/about.telml
1313 ; [__ () '()]))
1414
1515 ;; template-ey things and style things
16
17 (define (atom-element title url date content)
18 `(entry
19 (title ,title)
20 (link (@ (href ,url)))
21 (id ,url)
22 (updated ,date)
23 (content (@ (type "html"))
24 ,content)))
25
26 (define (atom-feed posts)
27 `(feed (@ (xmlns "htpt://www.w3.org/2005/Atom"))
28 (title "what happens when computer")
29 (link (@ (href "http://what.happens.when.computer/feed/")
30 (rel "self")))
31 (link (@ (href "http://what.happens.when.computer/")))
32 (id "http://what.happens.when.computer/")
33 ,(map (lambda (post) (apply atom-element post)) posts)))
1634
1735 (define stylesheet
1836 '((body
3654 (text-align justify)
3755 (line-height 150%))
3856
39 ((= class menu-index:before) (content "\"/ \""))
40 ((= class menu-archive:before) (content "\"^ \""))
41 ((= class menu-tags:before) (content "\"# \""))
42 ((= class menu-about:before) (content "\"@ \""))
57 ((= class menu-index:before)
58 (font-family "fira, \"Arial\", \"Helvetica\", sans-serif")
59 (content "\"/ \""))
60 ((= class menu-archive:before)
61 (font-family "fira, \"Arial\", \"Helvetica\", sans-serif")
62 (content "\"^ \""))
63 ((= class menu-tags:before)
64 (font-family "fira, \"Arial\", \"Helvetica\", sans-serif")
65 (content "\"# \""))
66 ((= class menu-about:before)
67 (font-family "fira, \"Arial\", \"Helvetica\", sans-serif")
68 (content "\"@ \""))
4369
4470 ((// (= class navlist) li)
4571 (display inline)
112138 (div (@ (class "main")) ,content)
113139 (div (@ (class "footer")) "© 2015 getty ritter"))))
114140
141 (define (archive)
142 (let* ((metadata (read-file "site.scm")))
143 (display (serialize-sxml (page "archive" metadata)))))
144
145 (define (tags)
146 (let* ((metadata (read-file "site.scm")))
147 (display (serialize-sxml (page "tags" "blah")))))
148
115149 ;; actually load and generate the relevant files
116150 (define (main pg file)
117151 (let* ((page-source (translate-file file))
120154 (title (if meta (cadr meta) pg)))
121155 (display (serialize-sxml (page title telml)))))
122156
123 (define (dispatch page file)
124 (cond ((equal? page "index")
157 (define (dispatch pg files)
158 (cond ((equal? pg "index")
125159 (with-output-to-file "output/index.html"
126 (lambda () (main "index" file))))
127 ((equal? page "post")
160 (lambda () (main "index" (car files)))))
161 ((equal? pg "post")
128162 (with-output-to-file "output/post.html"
129 (lambda () (main "post" file))))
130 ((equal? page "tag")
163 (lambda () (main "post" (car files)))))
164 ((equal? pg "archive")
165 (with-output-to-file "output/archive/index.html"
166 (lambda () (archive))))
167 ((equal? pg "tags")
131168 (with-output-to-file "output/tags/index.html"
132 (lambda () (main "tags" file))))
133 ((equal? page "about")
169 (lambda () (tags))))
170 ((equal? pg "about")
134171 (with-output-to-file "output/about/index.html"
135172 (lambda () (main "about" "pages/about.telml"))))))
136173
137174 (define args (command-line-arguments))
138 (format #t "got: ~a\n" args)
139 (apply dispatch args)
175 (cond ((= (length args) 0)
176 (format #t "Usage: generate [page] [files]"))
177 (else (dispatch (car args) (cdr args))))
1 (("dijkstras-comprehensions" ("Dijkstra and Set Comprehensions" "notation")))