-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_example.sh
69 lines (50 loc) · 3.35 KB
/
generate_example.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
# First: in the current directory, clean/remove previous traces of the build directory:
rm -rfv build_openjscad_spa
# Create build directory, and change current working directory to it:
mkdir build_openjscad_spa
cd build_openjscad_spa
# Clone the OpenJSCAD repo, checkout at a known revision used to develop this example, then go back to parent directory (the build directory):
git clone https://github.com/jscad/OpenJSCAD.org OpenJSCAD.org_git
cd OpenJSCAD.org_git
git checkout 231d3c6393e6d84569d8c00cf32dfe83b85d3163
cd ..
# Create directory for the actual example webpage:
mkdir example_webpage
# Copy the right `dist` directory (with OpenJSCAD JavaScript library) in the example directory, and call that directory `openjscad_dist`:
cp -av OpenJSCAD.org_git/packages/web/dist example_webpage/openjscad_dist
# For this example, we actually do not need anything else but `min.css` and `min.js` in the openjscad_dist - so remove all the other files, then copy in `min.css`:
rm -rfv example_webpage/openjscad_dist/[io]*
cp -av OpenJSCAD.org_git/packages/web/min.css example_webpage/openjscad_dist/
# For this example, we also need imgs/{busy.gif,favicon.png}, which the OpenJSCAD JavaScript library refers to.
# Simply copy the entire directory, then delete all other files except for those:
cp -av OpenJSCAD.org_git/packages/web/imgs example_webpage/
rm -rfv example_webpage/imgs/[^bf]*
# Create `css` subdirectory for example_webpage - here just overloading/customizing of existing styles
mkdir example_webpage/css
# Get .css file from repo
wget -q -O example_webpage/css/custom-example.css https://raw.githubusercontent.com/sdaau/openjscad_example_selfhost_spa_webpage/master/_files/css/custom-example.css
# Get other files from repo:
wget -q -O example_webpage/example_webpage.html https://raw.githubusercontent.com/sdaau/openjscad_example_selfhost_spa_webpage/master/_files/example_webpage.html
wget -q -O example_webpage/example_webpage_init.js https://raw.githubusercontent.com/sdaau/openjscad_example_selfhost_spa_webpage/master/_files/example_webpage_init.js
wget -q -O example_webpage/example_scene.jscad https://raw.githubusercontent.com/sdaau/openjscad_example_selfhost_spa_webpage/master/_files/example_scene.jscad
# get the openjscad min.js patch, and then apply it
wget -q -O example_webpage/openjscad_min_js_231d3c6.patch https://raw.githubusercontent.com/sdaau/openjscad_example_selfhost_spa_webpage/master/_files/openjscad_min_js_231d3c6.patch
# change to the directory of the min.js using a subshell (so we do not have to cd back)
(
cd example_webpage/openjscad_dist
# since the patch was generated by `git diff`, it refers to `a/packages/web/dist/min.js`, so we will have to use `-p`/`--strip` of `patch` command, to "Strip the smallest prefix containing num leading slashes from each file name found in the patch file"
patch -p4 <../openjscad_min_js_231d3c6.patch
)
echo
echo "example_webpage is ready at: $(readlink -f example_webpage)
(you can upload that directory to your webserver)
Due to XHR loading of .jscad file, opening example_webpage.html
in browser via file:// protocol (e.g. when you double-click the
.html icon in your OS GUI) will not work.
Therefore, as test, the script here starts a local python3 http.server
in the example_webpage directory; to view, visit:
http://localhost:8000/example_webpage.html
"
cd example_webpage
python3 -m http.server