support for more pict images; copy static images
This commit is contained in:
parent
0569708c3f
commit
cdc1a9efb7
|
@ -1,6 +1,5 @@
|
|||
# immediate todo
|
||||
|
||||
- handle racket-draw images & just copy regular images
|
||||
- make some CSS
|
||||
- site nav should use titles instead of slugs
|
||||
- user pages
|
||||
|
|
43
render.rkt
43
render.rkt
|
@ -231,12 +231,43 @@
|
|||
[in (build-path src-dir "index.scss")])
|
||||
(~> (compile-index-scss (port->string in)) (write-string out)))
|
||||
|
||||
(define favicon.rkt (build-path src-dir "favicon.png.rkt"))
|
||||
(define-rule (favicon [out (build-path output-dir "favicon.png")]
|
||||
[in favicon.rkt])
|
||||
(define icon-pict (dynamic-require favicon.rkt 'icon-pict))
|
||||
(define img-rules
|
||||
(parameterize ([current-directory src-dir])
|
||||
(for/list ([rkt-file (in-directory #f)]
|
||||
#:when (regexp-match? #px"\\.(png|jpg|jpeg|svg)\\.rkt$" rkt-file))
|
||||
(define out-file (path-replace-extension rkt-file #""))
|
||||
(define filetype
|
||||
(match (path-get-extension out-file)
|
||||
[#".png" 'png]
|
||||
[(or #".jpg" #".jpeg") 'jpeg]
|
||||
[#".svg" 'svg]))
|
||||
(define-rule (render-1-image [out (build-path output-dir out-file)]
|
||||
[in (build-path src-dir rkt-file)])
|
||||
(define icon-pict (dynamic-require (build-path src-dir rkt-file) 'icon-pict))
|
||||
(cond
|
||||
[(eq? 'svg filetype)
|
||||
(define dc (new svg-dc%
|
||||
[width (pict-width icon-pict)]
|
||||
[height (pict-height icon-pict)]
|
||||
[output out]))
|
||||
(send dc start-doc "meow")
|
||||
(send dc start-page)
|
||||
(draw-pict icon-pict dc 0 0)
|
||||
(send dc end-page)
|
||||
(send dc end-doc)]
|
||||
[else
|
||||
(define icon-bitmap (pict->bitmap icon-pict))
|
||||
(send icon-bitmap save-file out 'png))
|
||||
(send icon-bitmap save-file out filetype)]))
|
||||
render-1-image)))
|
||||
|
||||
(define static-rules
|
||||
(parameterize ([current-directory src-dir])
|
||||
(for/list ([static-file (in-directory #f)]
|
||||
#:when (regexp-match? #px"\\.(png|jpg|jpeg|svg)$" static-file))
|
||||
(define-rule (copy-static [out (build-path output-dir static-file)]
|
||||
[in (build-path src-dir static-file)])
|
||||
(copy-port in out))
|
||||
copy-static)))
|
||||
|
||||
(struct rule-spec [src intermediate output xref-name] #:transparent)
|
||||
|
||||
|
@ -303,7 +334,7 @@
|
|||
(ir-doc->page xrefs-repo config)
|
||||
(write-string out)))
|
||||
output-rule))
|
||||
(append intermediate-rules output-rules (list scss favicon hashtag-page)))
|
||||
(append intermediate-rules output-rules img-rules static-rules (list scss hashtag-page)))
|
||||
|
||||
(module+ main
|
||||
(require racket/cmdline)
|
||||
|
|
Loading…
Reference in New Issue