move templates from rakyll/statik to go:embed

There is no need for the rakyll/statik package starting with Go 1.16,
which provides us with tools for embedding files
without third-party libraries.
This commit is contained in:
Dmitry Verkhoturov
2022-07-29 19:07:49 +02:00
parent 76f5ce32ca
commit 86d059bf99
21 changed files with 39 additions and 137 deletions
+1 -1
View File
@@ -190,7 +190,7 @@ After you set `SMTP_` variables, you can allow email authentication by setting t
## HTML templates for emails and error messages
Remark42 uses golang templates for email templating. Templates are located in `backend/templates` and embedded into binary by statik
Remark42 uses golang templates for email templating. Templates are located in `backend/app/templates/static` and embedded into binary by `go:embed` [directive](https://pkg.go.dev/embed).
Now we have the following templates:
+1 -3
View File
@@ -30,7 +30,7 @@ Run tests in your IDE, and re-run `make rundev` each time you want to see how yo
You have to [install](https://golang.org/doc/install) the latest stable `go` toolchain to run the backend locally.
In order to have working Remark42 installation you need once to copy frontend static files to `./backend/web` directory from `master` docker image, and also copy files from `./templates` to the `./backend` as they are expected to be where application starts:
In order to have working Remark42 installation you need once to copy frontend static files to `./backend/web` directory from `master` docker image, as it is expected to be where application compiles:
```shell
# frontend files
@@ -38,8 +38,6 @@ docker pull umputun/remark42:master
docker create -ti --name remark42files umputun/remark42:master sh
docker cp remark42files:/srv/web/ ./backend/
docker rm -f remark42files
# template files
cp ./backend/templates/* ./backend
# fix frontend files to point to the right URL
## Mac version
find -E ./backend/web -regex '.*\.(html|js|mjs)$' -print -exec sed -i '' "s|{% REMARK_URL %}|http://127.0.0.1:8080|g" {} \;