Browse Source

build time in filenames

pull/2/head
Ivan Polyakov 3 years ago
parent
commit
e8893aae88
  1. 10
      Makefile
  2. 2
      config.mk
  3. 17
      src/templates/clean.scm

10
Makefile

@ -22,24 +22,26 @@ SRCPAGES := $(shell find $(SRCDIR)/pages/* -name '*.scm') @@ -22,24 +22,26 @@ SRCPAGES := $(shell find $(SRCDIR)/pages/* -name '*.scm')
SRCSTYLES := $(shell find $(SRCDIR)/styles/* -name '*.scm')
SRCJS := $(shell find $(SRCDIR)/scripts/* -name '*.js')
BUILDTIME=$(shell date "+%s")
all: $(OUTDIR) $(STATICDIR) pages styles js
pages: $(SRCPAGES)
for page in $(SRCPAGES) ; do \
$(SCHEME) $(SCHEMEFLAGS) $$page \
$(SCHEME) $(SCHEMEFLAGS) -e "(define build-time $(BUILDTIME))" -s $$page \
| sed -f scripts/minify-html.sed \
> $$(echo $$page | sed 's/.*\/pages/dist/' | sed 's/scm/xhtml/') \
; done
styles: $(SRCSTYLES)
for style in $(SRCSTYLES) ; do \
$(SCHEME) $(SCHEMEFLAGS) $$style \
> $$(echo $$style | sed 's/.*\/styles/dist/' | sed 's/scm/css/') \
$(SCHEME) $(SCHEMEFLAGS) -e "(define build-time $(BUILDTIME))" -s $$style \
> $$(echo $$style | sed 's/.*\/styles/dist/' | sed 's/scm/$(BUILDTIME).css/') \
; done
js: $(SRCJS)
for script in $(SRCJS) ; do \
cp $$script $$(echo $$script | sed 's/.*\/scripts/dist/') \
cp $$script $$(echo $$script | sed 's/.*\/scripts/dist/' | sed 's/js/$(BUILDTIME).js/') \
; done
$(OUTDIR):

2
config.mk

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
SCHEME=csi
SCHEMEFLAGS=-s
SCHEMEFLAGS=
SRCDIR=src
STATICDIR=public

17
src/templates/clean.scm

@ -16,6 +16,13 @@ @@ -16,6 +16,13 @@
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(import scss)
(import (chicken string))
(define (path-with-build-time path suffix)
(string-translate* path
`((,suffix . ,(string-intersperse
`("." ,(number->string build-time) ,suffix)
"")))))
(define (clean-tpl
page-title
@ -40,7 +47,8 @@ @@ -40,7 +47,8 @@
`(meta ,(append '(@) args))) page-meta)
,(map (lambda (l)
`(link (@ (rel "stylesheet") (href ,l))))
`(link (@ (rel "stylesheet")
(href ,(path-with-build-time l ".css")))))
page-styles)
(title ,page-title)
@ -51,4 +59,9 @@ @@ -51,4 +59,9 @@
(body
,page-content
,(map (lambda (l) `(script (@ (src ,l) (type "text/javascript")) " ")) page-scripts))))
,(map
(lambda (l)
`(script (@ (src ,(path-with-build-time l ".js"))
(type "text/javascript"))
" "))
page-scripts))))

Loading…
Cancel
Save