Add copying of all files under "common/resources" as resources.
Note that they're all copied "flatly" into the toplevel web directory. There is no problem with overwriting, since if a resource file is rendered twice the renderer will throw an error. There shouldn't be too many chances for such clashes since each kind of resource has a unique suffix, but if this happens it's easy to change `copydir/flat' to copy files using their paths, or something similar (like copying "x/y.z" to "x-y.z"). In that case references to these resources should change too. Also move the logo and favicon files to that directory instead of copying them individually.
This commit is contained in:
parent
dd1996eefd
commit
70078746fa
|
@ -21,6 +21,15 @@
|
||||||
;; the default target argument duplicate the behavior in "utils.rkt"
|
;; the default target argument duplicate the behavior in "utils.rkt"
|
||||||
(define (copyfile file [target (basename file)])
|
(define (copyfile file [target (basename file)])
|
||||||
(list target (copyfile-resource (in-here file) (web-path dir target))))
|
(list target (copyfile-resource (in-here file) (web-path dir target))))
|
||||||
|
(define (copydir/flat dir* [target (basename dir*)])
|
||||||
|
(let loop ([dir* (in-here dir*)])
|
||||||
|
(append-map
|
||||||
|
(λ(p) (define path (build-path dir* p))
|
||||||
|
(cond [(file-exists? path)
|
||||||
|
(define str (path->string p))
|
||||||
|
`([,str ,(copyfile-resource path (web-path dir str))])]
|
||||||
|
[(directory-exists? path) (loop path)]))
|
||||||
|
(directory-list dir*))))
|
||||||
(define (writefile file . contents)
|
(define (writefile file . contents)
|
||||||
(list file (resource (web-path dir file)
|
(list file (resource (web-path dir file)
|
||||||
(file-writer output (list contents "\n")))))
|
(file-writer output (list contents "\n")))))
|
||||||
|
@ -28,9 +37,11 @@
|
||||||
(list file
|
(list file
|
||||||
(apply page (string->symbol (regexp-replace #rx"[.]html$" file ""))
|
(apply page (string->symbol (regexp-replace #rx"[.]html$" file ""))
|
||||||
contents)))
|
contents)))
|
||||||
`(,(copyfile "logo.png")
|
`(,(writefile "plt.css" racket-style)
|
||||||
,(copyfile "plticon.ico")
|
;; resource files are everything in this directory, copied to the toplevel
|
||||||
,(writefile "plt.css" racket-style)
|
;; web directory (if there's ever a name clash, the rendering will throw an
|
||||||
|
;; error, and this can be changed accordingly)
|
||||||
|
,@(copydir/flat "resources")
|
||||||
;; the following resources are not used directly, so their names are
|
;; the following resources are not used directly, so their names are
|
||||||
;; irrelevant
|
;; irrelevant
|
||||||
@,writefile["google5b2dc47c0b1b15cb.html"]{
|
@,writefile["google5b2dc47c0b1b15cb.html"]{
|
||||||
|
@ -43,7 +54,7 @@
|
||||||
[t (and t (list "User-agent: *\n" t))])
|
[t (and t (list "User-agent: *\n" t))])
|
||||||
(if t (writefile "robots.txt" t) '(#f #f)))
|
(if t (writefile "robots.txt" t) '(#f #f)))
|
||||||
;; There are still some clients that look for a favicon.ico file
|
;; There are still some clients that look for a favicon.ico file
|
||||||
,(copyfile "plticon.ico" "favicon.ico")
|
,(copyfile "resources/plticon.ico" "favicon.ico")
|
||||||
@,pagefile["page-not-found.html"]{
|
@,pagefile["page-not-found.html"]{
|
||||||
@h1[style: "text-align: center; margin: 3em 0 1em 0;"]{
|
@h1[style: "text-align: center; margin: 3em 0 1em 0;"]{
|
||||||
Page not found}
|
Page not found}
|
||||||
|
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 318 B |
Loading…
Reference in New Issue
Block a user