Lua Reference
WebTrash is written to execute primarily trusted Lua scripts. That means nearly all functionality from the Lua standard library is available, and the extensions provided by WebTrash perform no sandboxing. As such, you should use it only to execute scripts you have written yourself, or scripts that you've scruitinized. Currently, WebTrash includes Lua 5.4.7, and will follow the most recent Lua release with slight delays.
Prefixes
For convenience, WebTrash supports two global configuration variables.
SourcePrefix = "/source/path"
DestinationPrefix = "/destination/path"
Most of the custom functions provided by WebTrash take in two arguments, the source path, and the destination path. These paths are always relative to the above variables unless explicitly specified otherwise. By default, these are set to a dot, which means the paths should behave exactly as if they weren't there (perhaps with the exception of some obscure situations).
Requires
WebTrash supports all the default Lua package loaders, but provides an extra one that takes
SourcePrefix
into account. This custom loader is intended for extension scripts, and is more
simplistic compared to the default loaders. It doesn't recognize dots as directory separators, and
it doesn't automatically append the .lua
file extension. However, it does enable using
Lua scripts conveniently from inside the website source directory.
-- Tries all default Lua package paths, and if these all fail, tries loading
-- the equivalent of SourcePrefix.."/".."AuxiliaryScript.lua"
require("AuxiliaryScript.lua")
Generic utilities
WebTrash provides various filesystem-level utilities for simple copying of files, directories, and removing existing items.
Utils.Copy("Source/File", "Destination/File")
Copies the file at the source path to the destination path.
Utils.CopyDir("Source/Directory", "Destination/Directory")
Recursively copies the specified source directory to the destination directory.
Utils.RemoveDestination("Destination")
By design, the copying functions above do not overwrite existing files/directories. In case this behavior is undesirable, this function can be called before the copy functions to ensure that all existing files get replaced every time.
Markdown
WebTrash provides a single function to convert Markdown files into valid HTML documents.
Markdown.Render("Source/File.md", "Destination/File.html")
This function also supports a special header at the beginning of the file to provide customization to the final HTML that the tool generates. For example, this is the header at the top of the file used to generate this page.
=====
SiteTitle : WebTrash
SiteLink : https://3011.io/Documentation/WebTrash/
Title : WebTrash - Lua Reference
Description : Documentation the Lua API exposed in WebTrash.
Styles : /Assets/Styles/Basic.css
Styles : /Assets/Styles/Highlight.js/BlackMetalBurzum.css
Script : /Assets/Scripts/Highlight.js
RawScript : hljs.highlightAll();
Favicon : /Assets/Images/Icon.png
Navigation : Introduction -> /Documentation/WebTrash/
Navigation : Lua Reference -> /Documentation/WebTrash/LuaReference/
Navigation : Main Website -> /
=====
TODO: What does each of these mean?
Kanimaji, Megane & Tablegen
These serve as fairly thin wrappers over functionality implemented in kanjivg-tools.
TODO: Explain how the settings objects are initialized/configured, and how tablegen pages can be customized.