|
261 | 261 | result))
|
262 | 262 |
|
263 | 263 | (def readtop (filename)
|
264 |
| - ; (index* foo.tem) == (prev.tem this.tem next.tem) |
| 264 | + ; (index* foo.tem) == (title prev.tem this.tem next.tem) |
| 265 | + (= index* (table)) |
| 266 | + (let temlinks (gettemlinks filename) |
265 | 267 | ; pagelist* == ("page1.tem" "page2.tem" ...)
|
266 |
| - (= index* (table)) |
267 |
| - (let temlinks (gettemlinks filename) |
268 |
| - (= pagelist* (map [_ 1] temlinks)) |
269 |
| - (each (title link) temlinks |
270 |
| - (= (index* link) title)) ; (index* foo.tem) = title |
271 |
| - (each trip (triples (+ '(nil) pagelist* '(nil))) |
272 |
| - (= (index* (trip 1)) (cons (index* (trip 1)) trip)) |
273 |
| - ))) |
| 268 | + (= pagelist* (map [_ 1] temlinks)) |
| 269 | + (each (title link) temlinks |
| 270 | + (= (index* link) title)) |
| 271 | + (each trip (triples (+ '(nil) pagelist* '(nil))) |
| 272 | + (if trip |
| 273 | + (= (index* trip.1) (cons (index* trip.1) trip))) |
| 274 | + ))) |
274 | 275 |
|
275 | 276 | (def htmllink (href text) (prn "<a href=\"" href "\">" text "</a>"))
|
276 | 277 |
|
277 | 278 | ; Convert foo.tem to foo.html
|
278 | 279 | (def htmlname(x) (subst ".html" ".tem" x))
|
279 | 280 |
|
280 | 281 | (def getlinks (tem)
|
281 |
| - (let info (index* tem) |
282 |
| - (if info |
283 |
| - (with (text (info 0) prev (info 1) this (info 2) next (info 3)) |
284 |
| - (tostring (pr "<div class=\"links\">") |
285 |
| - (when prev |
286 |
| - (pr "Previous: ") |
287 |
| - (htmllink (htmlname prev) ((index* prev) 0))) |
288 |
| - (pr "Up: ") |
289 |
| - (htmllink "index.html" "Contents") |
290 |
| - (when next |
291 |
| - (pr "Next: ") |
292 |
| - (htmllink (htmlname next) ((index* next) 0))) |
293 |
| - (pr "</div>") |
294 |
| - ) |
295 |
| - )))) |
296 |
| - |
297 |
| -(= index* nil) |
| 282 | + (aif index*.tem |
| 283 | + (let (_ prev this next) it |
| 284 | + (tostring |
| 285 | + (tag (div class "links") |
| 286 | + (when prev |
| 287 | + (pr "Previous: ") |
| 288 | + (htmllink (htmlname prev) ((index* prev) 0))) |
| 289 | + (pr "Up: ") |
| 290 | + (htmllink "index.html" "Contents") |
| 291 | + (when next |
| 292 | + (pr "Next: ") |
| 293 | + (htmllink (htmlname next) ((index* next) 0)))))))) |
298 | 294 |
|
299 | 295 | ; Generate html from a template
|
300 | 296 | (def run (filename)
|
301 |
| - (= current-file* filename) |
302 |
| - (= out-file-name* (+ "html/" (subst "" ".tem" filename) ".html")) |
303 |
| - (= page* "") |
304 |
| - (= out-file* (outfile out-file-name*)) |
305 |
| - (when (no index*) |
306 |
| - (prn "Reading top.tem") |
307 |
| - (readtop "top.tem")) |
308 |
| - (= links* (getlinks filename)) |
309 |
| - (doit (sread (infile filename) 'eof)) |
310 |
| - out-file-name* |
311 |
| -) |
| 297 | + (= current-file* filename) |
| 298 | + (= out-file-name* (+ "html/" (subst "" ".tem" filename) ".html")) |
| 299 | + (= page* "") |
| 300 | + (= out-file* (outfile out-file-name*)) |
| 301 | + (= links* (getlinks filename)) |
| 302 | + (doit (sread (infile filename) 'eof)) |
| 303 | + out-file-name*) |
312 | 304 |
|
313 | 305 | ; Run through all the templates listed in the top file.
|
314 | 306 | (def runall ((o topname "docs/index.html"))
|
315 |
| - (= all-links* '()) |
316 |
| - (readtop topname) |
317 |
| - (= update-links* t) |
318 |
| - (on filename pagelist* |
319 |
| - (prn "Doing file " filename) |
320 |
| - (run filename)) |
321 |
| - (= update-links* nil) |
322 |
| - ) |
| 307 | + (= all-links* '()) |
| 308 | + (readtop topname) |
| 309 | + (= update-links* t) |
| 310 | + (on filename pagelist* |
| 311 | + (prn "Doing file " filename) |
| 312 | + (run filename)) |
| 313 | + (= update-links* nil)) |
323 | 314 |
|
324 | 315 | (def tem () (load "template.arc"))
|
325 | 316 |
|
|
0 commit comments