13 | 13 |
; [__ () '()]))
|
14 | 14 |
|
15 | 15 |
;; 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)))
|
16 | 34 |
|
17 | 35 |
(define stylesheet
|
18 | 36 |
'((body
|
|
36 | 54 |
(text-align justify)
|
37 | 55 |
(line-height 150%))
|
38 | 56 |
|
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 "\"@ \""))
|
43 | 69 |
|
44 | 70 |
((// (= class navlist) li)
|
45 | 71 |
(display inline)
|
|
112 | 138 |
(div (@ (class "main")) ,content)
|
113 | 139 |
(div (@ (class "footer")) "© 2015 getty ritter"))))
|
114 | 140 |
|
| 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 |
|
115 | 149 |
;; actually load and generate the relevant files
|
116 | 150 |
(define (main pg file)
|
117 | 151 |
(let* ((page-source (translate-file file))
|
|
120 | 154 |
(title (if meta (cadr meta) pg)))
|
121 | 155 |
(display (serialize-sxml (page title telml)))))
|
122 | 156 |
|
123 | |
(define (dispatch page file)
|
124 | |
(cond ((equal? page "index")
|
| 157 |
(define (dispatch pg files)
|
| 158 |
(cond ((equal? pg "index")
|
125 | 159 |
(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")
|
128 | 162 |
(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")
|
131 | 168 |
(with-output-to-file "output/tags/index.html"
|
132 | |
(lambda () (main "tags" file))))
|
133 | |
((equal? page "about")
|
| 169 |
(lambda () (tags))))
|
| 170 |
((equal? pg "about")
|
134 | 171 |
(with-output-to-file "output/about/index.html"
|
135 | 172 |
(lambda () (main "about" "pages/about.telml"))))))
|
136 | 173 |
|
137 | 174 |
(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))))
|