WebTrash
WebTrash is a very simple custom command line tool for generating static websites, such as this one. It doesn't do anything fancy, all it does is copy files, convert Markdown to HTML, add animation CSS to kanjivg SVGs, and generate table pages. It uses Lua scripts as the driver of the site generation.
The tool isn't public for now, primarily because I don't think it's ready for any sort of external use. There are still many rough edges, and things to tweak.
Example
Here is an example of a small script to generate a static website.
SourcePrefix = "3011.io"
DestinationPrefix = "/var/www/3011.io"
-- Copy assets
Utils.RemoveDestination("Assets") -- We want to refresh the assets every time
Utils.Copy("Assets/Fonts/Domine.ttf", "Assets/Fonts/Domine.ttf")
Utils.Copy("Assets/Images/Icon.png", "Assets/Images/Icon.png")
Utils.Copy("Assets/Styles/Basic.css", "Assets/Styles/Basic.css")
-- Top level
Markdown.Render("Index.md", "index.html")
Markdown.Render("Posts.md", "Posts/index.html")
-- Documentation
Markdown.Render("Documentation/WebTrash/Index.md", "Documentation/WebTrash/index.html")
-- Posts
Markdown.Render("Posts/Reading.md", "Posts/Reading/index.html")
Markdown.Render("Posts/Graphics.md", "Posts/Graphics/index.html")
In fact, this example is a subset of the script used to generate this site.
Note! The SourcePrefix
and DestinationPrefix
affect all of the paths specified in
the functions below. I'm not very happy with this design, it will likely change in the future.
Bulding
Any fairly recent compiler should be able to build the project fairly easily. However, as with any C++ project, there are some caveats:
- You will need at least GCC 13, but only GCC 14 has heen properly tested.
- Clang 19 (and likely a few versions below) will build the project, but only with libstdc++ or
MSVC STL, libc++ is still missing some features. (Most notably
std::views::enumerate
tracked here) - The MSVC compiler itself is untested, but the code powering this isn't exactly exotic, and should build with a few tiny patched at worst.
The build process itself should be as simple as running the following commands.
git clone $GIT_REPO_SOURCE WebTrash
cmake -S WebTrash -B Build -D CMAKE_BUILD_TYPE=Release -D CMAKE_EXE_LINKER_FLAGS="-static"
cmake --build Build --config Release --target WebTrash
The -static
linker flag is completely optional, and will not be necessary unless you need to
run this executable in an environment with older or incompatible C and C++ standard libraries
(such as Debian 12 or older). All dependencies are pinned, and pulled in via FetchContent.
This means you should need only working C and C++ toolchains, Make/Ninja, and CMake.
Dependencies
The project depends on a few libraries, these should be pulled in by CMake via FetchContent when configuring the project. Please note that they are configured to pull directly from my mirrors of these repositories.
- cmark-gfm (2-clause BSD licence, MIT licence)
- ctre (Apache 2.0 licence)
- pugixml (MIT license)
- lua (MIT licence)
- sol2 (MIT licence)
- Garbage (No licence for now)
- kanjivg-tools (No licence for now)
In this list, Garbage and kanjivg-tools are libraries I've written. These do not have an associated licence yet, they will be licences appropriately when applicable.