Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commite59e6426397a3859a34416082f91e036ab7b8671 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-10-17 15:47:15 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-10-17 15:47:15 +0300
Files3cc74046d6f244135f9bc1b15b5c53d1dfdaab1a
csg-e59e6426397a3859a34416082f91e036ab7b8671.tar
csg-e59e6426397a3859a34416082f91e036ab7b8671.tar.gz
csg-e59e6426397a3859a34416082f91e036ab7b8671.zip
Parent6a79e636fc00465221dcd792e494848d89fa7921 (diff)
[README] Updated with information about everything
1 files changed, 88 insertions, 17 deletions
-rw-r--r--README.md105
diff --git a/README.md b/README.md
index 8cf412b..03e5f03 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,103 @@
# csg
csg is the "complicated (static) site generator".
-It's a decently simple static site generator, written in bash, with the capability to be extended via awk scripts.
+It's a somewhat simple static site generator, written in bash, with many "poweruser" features thanks to [awk](TODO).
-The overall design is heavily inspired by [Roman Zolotarev](TODO)'s [ssg](TODO), however the codebase is made from the ground up with the goal of adding more features.
-Mainly:
+The overall design is heavily inspired by [Roman Zolotarev](https://romanzolotarev.com/)'s [ssg](https://romanzolotarev.com/ssg.html), however the codebase is completely different, with the added bonus of:
-- csg supports arbitrary file modifications via awk, which will have access to:
- - git-based "last edited" and "first created" timestamps, which are also cached for fast retrievals
- - word count
+- arbitrary file modifications via awk
+- git-based "created" and "edited" timestamps
- support for (multiple) description and title meta tags
- support for custom title format
-## How it works
+## How to use
-You write your pages in Markdown, you'll also need to have a `_header.html` and `_footer.html` files in the source of your site.
-Every page gets converted to HTML, your awk scripts are ran and then `_header.html` is slapped on the top, `_footer.html` on the bottom.
-All other files are copied to the output repository as-is.
+Your content is inside a "source" folder, while the resulting website files will be put in a "destination" folder.
+Webpages are written in Markdown, which is then transformed into HTML with the proper edits, and finally `_header.html` and `_footer.html` are stitched on top and bottom.
+Everything else is taken as-is.
-## How to use
+Additional features are available with [awk](TODO).
+By default, the title, description and word count are taken from every Markdown file.
+The title and description will be put in place of `[TITLE]` and `[DESCRIPTION]` inside `_header.html`.
+You can also create/use your own awk scripts for further page modification (all three values will also be available inside those scripts).
+
+*Note:* if you don't want the additional features, just use [ssg](https://romanzolotarev.com/ssh.html)
+
+### Writing your own scripts
+
+There are some things you must consider while creating an awk script:
+
+1. It will be ran on the generated HTML pages
+2. It's name **must** start with a capital letter
+ - You can also create so-called "libraries", mainly awk scripts with only function definitions
+ - libraries **must** start with a `#` character in their name, and are included with every script
+3. The current line **mustn't** be printed (unless you want to add a line to the file)
+ - With awk we can modify only certain lines, but the easiest way to get the whole file with the modified lines, is to just print every line.
+ Such a rule is "appended" to the end of your script.
+ - Do modifications to `$0` instead of `print (fancy expression)`
+ - If you don't want to print a line, do `$0 = 0`
+4. Every script **must** begin with a `# regex` line
+ - For optimisation purposes, a script is ran only on the files which match the given regular expression
+ - The regex is on the whole path, so you could make changes (for example) to specific pages or all pages inside folders
+ - The regular expression is fed to `find -regex`, so for exact support view `find`'s documentation
+5. Script variables **mustn't** collide and you **mustn't** use `exit` or `nextfile`
+ - Also for optimisation purposes, scripts with the same regex are combined into one
+6. Inside your scripts you'll have the `title`, `description`, `words`, `created` and `edited` variables available
+ The last two will be dates in the format "%d %B %Y", and are only available if your website uses git.
+
+### Generate website with the script
+
+csg comes with a help message, which contains everything you might want to know for running the script:
+
+```
+Usage: csg [-h | -? | --help]
+ csg <source_dir> <destination_dir> <title_format> [<scripts_dir>]
-This repository comes with a small demo setup, so just run:
+Options:
+ -h, -?, --help Print this help message (also available when given no
+ arguments)
+
+Arguments:
+ <source_dir> Folder which contains source files
+ <destination_dir> Folder in which the generated site will be put
+ <title_format> Format string for page title
+ Accepts any text or HTML, & is replaced with contents
+ title (first h1 header).
+ <scripts_dir> Optional, folder which contains awk script for editing of
+ generated webpages.
+
+Variables (you can predefine):
+ CSG_TIMESTAMP_FILE File path for git-based timestamps (when git exists)
+ Default: "./timestamps.txt"
+ Disable: ""
+ CSG_TMP_DIR Directory to put temporary files
+ Default: "/tmp"
+ CSG_AWK awk executable and flags
+ Default: searches for gawk
+ CSG_MD_TO_HTML Program to convert Markdown to HTML and it'\''s flags
+ Default: searches for lowdown
+
+Dependencies (required):
+ bash, printf, find, cpio
+
+
+csg - complicated (static) site generator
+Created by Syndamia, https://gitlab.com/Syndamia/csg
+```
+
+### Demo
+
+This repository comes with a small demo setup.
+To test it out, run:
```bash
-csg "./demo/awk-edits" "./demo/src" "./demo/website" "& - Demo"
+./csg ./demo/src ./demo/website '& - Demo' ./demo/awk-edits
```
-The first argument is the folder in which you'll have your awk file modification scripts.
-The second is the folder with your website source.
-The third is the output folder.
-The fourth is the title format, where & is a special symbol, which will be replaced with the title of the page (the first h1 header).
+You will find your website, ready to be served, inside `./demo/website`.
+
+## Future features
+
+1. I would love to make it POSIX compatible, however this will require a good amount of work and will introduce inefficiencies, so for now it's left for the future
+2. Right now the whole website is regenerated every time, it's important to add a system for updating only the currently changed pages.
+ I'm not entirely sure how to do that, since we remove the source Markdown after it is converted to HTML, current thinking leads me to a file containing lines of "filepath hash", but we'll see.