summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile12
-rw-r--r--backend/Makefile5
-rw-r--r--docs/admin_handbook.html9
-rw-r--r--frontend/Makefile11
-rw-r--r--frontend/README.md17
-rw-r--r--frontend/eslint.config.js (renamed from static/eslint.config.js)0
-rw-r--r--frontend/student.js (renamed from static/student.js)0
-rw-r--r--frontend/style.css (renamed from static/style.css)0
-rwxr-xr-xscripts/eslint.sh2
-rw-r--r--tmpl/Makefile15
11 files changed, 66 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index c67eb42..02ad029 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,2 @@
-cca
cca.scfg
+dist
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9f122cd
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,12 @@
+.PHONY: default backend frontend
+
+default: backend tmpl frontend
+
+backend:
+ make -C backend
+
+tmpl:
+ make -C tmpl
+
+frontend:
+ make -C frontend
diff --git a/backend/Makefile b/backend/Makefile
index 08566d8..22c6e5f 100644
--- a/backend/Makefile
+++ b/backend/Makefile
@@ -1,2 +1,3 @@
-cca: *.go
- go build -o cca
+../dist/cca: *.go
+ mkdir -p ../dist
+ go build -o ../dist/cca
diff --git a/docs/admin_handbook.html b/docs/admin_handbook.html
index 14af917..4d3e1db 100644
--- a/docs/admin_handbook.html
+++ b/docs/admin_handbook.html
@@ -27,12 +27,15 @@
</ul>
<h2>Building</h2>
<p>
- There is a <code>Makefile</code> in the <code>backend</code> directory that builds the backend. This is all the compilation necessary at the moment; in the future, the frontend code such as the CSS and JavaScript may be minified too.
+ You need a standard Go toolchain to build the backend. You need <a href="https://github.com/tdewolff/minify">minify</a> to build the minified frontend; read the README in the frontend directory for details; if you don&rsquo;t want to minify, you could just copy the files over.
</p>
+ <pre>cd ./backend/
+make
+cd ../frontend/
+make</pre>
<p>
- You may also wish to strip the binary&rsquo;s debug symbols to shrink the file size:
+ Your compiled files will appear in <code>dist/</code>.
</p>
- <pre>make && strip cca</pre>
<h2>Configuration</h2>
<p>
The <code>static</code> and <code>tmpl</code> directories must be available to the running program, in addition to a configuration file <code>cca.scfg</code>.
diff --git a/frontend/Makefile b/frontend/Makefile
new file mode 100644
index 0000000..d863e84
--- /dev/null
+++ b/frontend/Makefile
@@ -0,0 +1,11 @@
+.PHONY: frontend
+
+frontend: ../dist/static/student.js ../dist/static/style.css
+
+../dist/static/student.js:
+ mkdir -p ../dist/static
+ minify student.js -o ../dist/static/student.js
+
+../dist/static/style.css:
+ mkdir -p ../dist/static
+ minify style.css -o ../dist/static/style.css
diff --git a/frontend/README.md b/frontend/README.md
new file mode 100644
index 0000000..d586f3a
--- /dev/null
+++ b/frontend/README.md
@@ -0,0 +1,17 @@
+# Frontend
+
+We do not use a JavaScript package manager because we don't use any JavaScript
+libraries at all.
+
+## JavaScript linting
+
+eslint may be installed separately via pgx if linting is desired.
+
+## Building
+
+Building is actually just minification.
+
+```sh
+go install github.com/tdewolff/minify/v2/cmd/minify@latest
+make
+```
diff --git a/static/eslint.config.js b/frontend/eslint.config.js
index 0245ab8..0245ab8 100644
--- a/static/eslint.config.js
+++ b/frontend/eslint.config.js
diff --git a/static/student.js b/frontend/student.js
index 9d220ef..9d220ef 100644
--- a/static/student.js
+++ b/frontend/student.js
diff --git a/static/style.css b/frontend/style.css
index 15c3add..15c3add 100644
--- a/static/style.css
+++ b/frontend/style.css
diff --git a/scripts/eslint.sh b/scripts/eslint.sh
index fe21ffe..9144c06 100755
--- a/scripts/eslint.sh
+++ b/scripts/eslint.sh
@@ -2,6 +2,6 @@
set -e
-cd static
+cd frontend
NPM_CONFIG_REGISTRY=https://registry.npmmirror.com npx eslint . "$@"
diff --git a/tmpl/Makefile b/tmpl/Makefile
new file mode 100644
index 0000000..61f3713
--- /dev/null
+++ b/tmpl/Makefile
@@ -0,0 +1,15 @@
+.PHONY: default ../dist/tmpl/student.html ../dist/tmpl/staff.html ../dist/tmpl/login.html
+
+default: ../dist/tmpl/student.html ../dist/tmpl/staff.html ../dist/tmpl/login.html
+
+../dist/tmpl/student.html: student.html
+ mkdir -p ../dist/tmpl
+ cp student.html ../dist/tmpl/student.html
+
+../dist/tmpl/staff.html: staff.html
+ mkdir -p ../dist/tmpl
+ cp staff.html ../dist/tmpl/staff.html
+
+../dist/tmpl/login.html: login.html
+ mkdir -p ../dist/tmpl
+ cp login.html ../dist/tmpl/login.html