hscloud/tools/gostatic
Serge Bazanski 97b5cd7b58 go: re-do the entire thing
This is a mega-change, but attempting to split this up further is
probably not worth the effort.

Summary:

1. Bump up bazel, rules_go, and others.
2. Switch to new go target naming (bye bye go_default_library)
3. Move go deps to go.mod/go.sum, use make gazelle generate from that
4. Bump up Python deps a bit

And also whatever was required to actually get things to work - loads of
small useless changes.

Tested to work on NixOS and Ubuntu 20.04:

   $ bazel build //...
   $ bazel test //...

Change-Id: I8364bdaa1406b9ae4d0385a6b607f3e7989f98a9
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1583
Reviewed-by: q3k <q3k@hackerspace.pl>
2023-09-22 21:50:19 +00:00
..
example go: re-do the entire thing 2023-09-22 21:50:19 +00:00
tarify go: re-do the entire thing 2023-09-22 21:50:19 +00:00
BUILD go: re-do the entire thing 2023-09-22 21:50:19 +00:00
gomod-import-force.go go: re-do the entire thing 2023-09-22 21:50:19 +00:00
README.md tools/gostatic: init 2020-10-26 12:08:33 +01:00
rules.bzl tools/gostatic: init 2020-10-26 12:08:33 +01:00

gostatic site generator

This implements support for gostatic, a static site generator, inside hscloud.

Creating a gostatic site

To get started, copy over the skeleton from //tools/gostatic/example into a new directory.

mkdir -p personal/foo
cp -rv tools/gostatic/example personal/foo/mysite

You can also build your own gostatic_tarball from scratch if you are familiar enough with gostatic.

You can then then build a tarball of your site by running:

bazel build //personal/foo/mysite

Your site will be built and tarred up into bazel-bin/personal/foo/mysite/mysite.tar. You can then use this to populate a container in docker_rules.

TODO(q3k): add a target that starts up a simple web server for testing the rendered site.

Configuring a gostatic site

Configuration is done via the gostatic_tarball rule. This mostly generates an upstream gostatic configuration file - please refer to that file for more information.

Field Description Example
templates List of template sources/targets. This is used to populate the TEMPLATES config option. [ ":site.tmpl" ]
source_dir BUILDfile-relative source directory containing site sources. This is used to populate the SOURCE config option. All files given in srcs must be contained within this directory. "src"
srcs List of template sources/targets. This is what will be available to gostatic during compilation. [ "src/blog/first.md" ]
extra_config Rest of the gostatic config, ie. rules.

Running gostatic-the-tool

If you want to run plain gostatic for some odd reason, it's available under:

bazel run //tools/gostatic

TODO(q3k): allow running this against a gostatic_tarball's config.