Generate web page

This commit is contained in:
Sebastiaan de Schaetzen 2023-02-17 16:28:28 +01:00
parent 57447f79b4
commit e6dd71ad22
5 changed files with 37 additions and 5 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
*.stl *.stl
*.3mf *.3mf
*.gcode *.gcode
*.png
public/

View File

@ -1,13 +1,32 @@
DESTDIR = public
PARAMETERS := $(shell cat Lego.json | grep -v '"parameterSets": ""' | jq -r '.parameterSets | keys[]') PARAMETERS := $(shell cat Lego.json | grep -v '"parameterSets": ""' | jq -r '.parameterSets | keys[]')
STL = $(PARAMETERS:%=%.stl) STL = $(PARAMETERS:%=$(DESTDIR)/%.stl)
PNG = $(PARAMETERS:%=$(DESTDIR)/%.png)
INDEX = $(DESTDIR)/index.html
SCAD = Lego.scad SCAD = Lego.scad
CONFIG = Lego.json CONFIG = Lego.json
all: $(STL) .PHONY: all
all: models thumbnails
.PHONY: clean
clean: clean:
rm -f $(STL) rm -f $(STL) $(PNG) $(INDEX)
$(STL): $(SCAD) $(CONFIG) Makefile .PHONY: models
openscad -o $@ -p $(CONFIG) -P $(@:%.stl=%) $(SCAD) models: $(STL)
.PHONY: thumbnails
thumbnails: $(PNG)
.PHONY: webpage
webpage: thumbnails $(INDEX)
$(STL) $(PNG): $(SCAD) $(CONFIG) Makefile
mkdir -p $(@D)
openscad -o $@ -p $(CONFIG) -P $(basename $(@F)) $(SCAD)
$(INDEX): header.html entry.html footer.html Makefile
cat header.html > $@
$(foreach P,$(PARAMETERS),cat entry.html | sed 's/%/$P/g' >> $@;)
cat footer.html >> $@

4
entry.html Normal file
View File

@ -0,0 +1,4 @@
<a href="%.stl">
<h1>%</h1>
<img src="%.png" />
</a>

2
footer.html Normal file
View File

@ -0,0 +1,2 @@
</body>
</html>

5
header.html Normal file
View File

@ -0,0 +1,5 @@
<html>
<head>
<title>LEGO STLs</title>
</head>
<body>