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