Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e331b5d9a | |||
| 9f5d1089a2 | |||
| 9ccba8fd4e | |||
| 95679abd85 | |||
| 8b1e793510 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,2 +1,4 @@
|
||||
out/
|
||||
kewt
|
||||
kewt
|
||||
site.conf
|
||||
template.html
|
||||
|
||||
17
README.md
17
README.md
@@ -16,6 +16,8 @@ It's meant to be a static site generator, like _[kew](https://github.com/uint23/
|
||||
- Inline html support
|
||||
- MFM `$font` and `\<plain>` tags
|
||||
- Admonition support (that's what the blocks like the warning block below are called)
|
||||
- RSS/Feed generation and Sitemap support
|
||||
- Post creation via `--post`
|
||||
|
||||
If you want to **force** a file to be inlined, use `\!![]` instead of `\![]`
|
||||
|
||||
@@ -24,7 +26,7 @@ If you want to **force** a file to be inlined, use `\!![]` instead of `\![]`
|
||||
You can clone the repository to use `kewt.sh` directly, or you can download the standalone executable, which bundles all dependencies into a single file:
|
||||
|
||||
```sh
|
||||
curl -L -o kewt https://git.krzak.org/N0VA/kewt/releases/latest/download/kewt
|
||||
curl -L -o kewt https://git.krzak.org/N0VA/kewt/releases/download/latest/kewt
|
||||
chmod +x kewt
|
||||
```
|
||||
|
||||
@@ -38,12 +40,15 @@ On Arch Linux, _kewt_ is available on the AUR:
|
||||
```sh
|
||||
./kewt.sh --help
|
||||
./kewt.sh --new [title]
|
||||
./kewt.sh --post
|
||||
./kewt.sh --from <src> --to <out>
|
||||
./kewt.sh [src] [out]
|
||||
```
|
||||
|
||||
`--new [title]` creates a new site directory with a copied `site.conf` and a default `index.md`.
|
||||
|
||||
`--post` creates a new empty markdown file in the configured `posts_dir` with the current date and time as the name.
|
||||
|
||||
## site.conf
|
||||
|
||||
```conf
|
||||
@@ -57,7 +62,7 @@ home_name = "Home"
|
||||
show_home_in_nav = true
|
||||
nav_links = ""
|
||||
nav_extra = ""
|
||||
footer = "made with <a href="https://kewt.krzak.org">kewt</a>"
|
||||
footer = "made with <a href=\"https://kewt.krzak.org\">kewt</a>"
|
||||
logo = ""
|
||||
display_logo = false
|
||||
display_title = true
|
||||
@@ -66,6 +71,10 @@ favicon = ""
|
||||
generate_page_title = true
|
||||
error_page = "not_found.html"
|
||||
versioning = false
|
||||
base_url = ""
|
||||
generate_feed = false
|
||||
feed_file = "rss.xml"
|
||||
posts_dir = ""
|
||||
```
|
||||
|
||||
- `title` site title
|
||||
@@ -87,6 +96,10 @@ versioning = false
|
||||
- `generate_page_title` automatically generate title text from the first markdown heading or filename (default: true)
|
||||
- `error_page` filename for the generated 404 error page (default: "not_found.html", empty to disable)
|
||||
- `versioning` append a version query parameter (`?v=timestamp`) to css asset urls to bypass cache (default: false)
|
||||
- `base_url` absolute URL of the site, used for sitemap and RSS feed generation
|
||||
- `generate_feed` enable RSS feed generation (requires `base_url`)
|
||||
- `feed_file` filename for the generated RSS feed (default: "rss.xml")
|
||||
- `posts_dir` directory name containing posts (e.g., "posts"). Enables reverse-chronological sorting, title headings in indexes, and automatic backlinks.
|
||||
|
||||
## Ignores
|
||||
|
||||
|
||||
41
kewt.sh
41
kewt.sh
@@ -13,6 +13,7 @@ Usage: $invoked_as [--from <src>] [--to <out>]
|
||||
$invoked_as --new [title]
|
||||
$invoked_as --update [dir]
|
||||
$invoked_as --post
|
||||
$invoked_as --version
|
||||
$invoked_as --help
|
||||
|
||||
Options:
|
||||
@@ -20,6 +21,7 @@ Options:
|
||||
--new [title] Create a new site directory (default: site)
|
||||
--update [dir] Update site.conf and template.html with latest defaults (defaults to current directory)
|
||||
--post Create a new empty post file in the configured posts_dir with current date and time as name
|
||||
--version Show version information.
|
||||
--from <src> Source directory (default: site)
|
||||
--to <out> Output directory (default: out)
|
||||
EOF
|
||||
@@ -44,7 +46,7 @@ home_name = "Home"
|
||||
show_home_in_nav = true
|
||||
nav_links = ""
|
||||
nav_extra = ""
|
||||
footer = "made with <a href="https://kewt.krzak.org">kewt</a>"
|
||||
footer = "made with <a href=\"https://kewt.krzak.org\">kewt</a>"
|
||||
logo = ""
|
||||
display_logo = false
|
||||
display_title = true
|
||||
@@ -156,7 +158,7 @@ home_name = "Home"
|
||||
show_home_in_nav = true
|
||||
nav_links = ""
|
||||
nav_extra = ""
|
||||
footer = "made with <a href="https://kewt.krzak.org">kewt</a>"
|
||||
footer = "made with <a href=\"https://kewt.krzak.org\">kewt</a>"
|
||||
logo = ""
|
||||
display_logo = false
|
||||
display_title = true
|
||||
@@ -259,6 +261,10 @@ while [ $# -gt 0 ]; do
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--version|-v)
|
||||
echo "kewt version git"
|
||||
exit 0
|
||||
;;
|
||||
--post)
|
||||
post_mode="true"
|
||||
;;
|
||||
@@ -301,7 +307,13 @@ done
|
||||
|
||||
ensure_root_defaults
|
||||
|
||||
[ -z "$src" ] && src="site"
|
||||
if [ -z "$src" ]; then
|
||||
if [ "$post_mode" = "true" ] && [ -f "./site.conf" ]; then
|
||||
src="."
|
||||
else
|
||||
src="site"
|
||||
fi
|
||||
fi
|
||||
[ -z "$out" ] && out="out"
|
||||
|
||||
src="${src%/}"
|
||||
@@ -456,8 +468,14 @@ load_config() {
|
||||
key=$(printf '%s' "$key" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
|
||||
val=$(printf '%s' "$val" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
|
||||
case "$val" in
|
||||
\"*\") val=${val#\"}; val=${val%\"} ;;
|
||||
\'*\') val=${val#\'}; val=${val%\'} ;;
|
||||
\"*\")
|
||||
val=${val#\"}; val=${val%\"}
|
||||
val=$(printf '%s' "$val" | sed 's/\\"/\"/g; s/\\\\/\\/g')
|
||||
;;
|
||||
\'*\')
|
||||
val=${val#\'}; val=${val%\'}
|
||||
val=$(printf '%s' "$val" | sed "s/\\\\'/'/g; s/\\\\/\\/g")
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$key" in
|
||||
@@ -707,7 +725,11 @@ eval "find \"$src\" \( $IGNORE_ARGS \) -prune -o -type d -print" | sort | while
|
||||
[ "$dir_indexes" != "true" ] && continue
|
||||
|
||||
if [ ! -f "$dir/index.md" ]; then
|
||||
if [ "$single_file_index" = "true" ]; then
|
||||
is_posts_dir="false"
|
||||
if [ -n "$posts_dir" ] && { [ "$rel_dir" = "$posts_dir" ] || [ "./$rel_dir" = "$posts_dir" ]; }; then
|
||||
is_posts_dir="true"
|
||||
fi
|
||||
if [ "$single_file_index" = "true" ] && [ "$is_posts_dir" = "false" ]; then
|
||||
md_count=$(find "$dir" ! -name "$(basename "$dir")" -prune -name "*.md" | wc -l)
|
||||
if [ "$md_count" -eq 1 ]; then
|
||||
md_file=$(find "$dir" ! -name "$(basename "$dir")" -prune -name "*.md")
|
||||
@@ -794,7 +816,12 @@ eval "find \"$src\" \( $IGNORE_ARGS \) -prune -o -type f -print" | sort | while
|
||||
is_preserved=1
|
||||
fi
|
||||
|
||||
if [ "$single_file_index" = "true" ] && [ "${file%.md}" != "$file" ] && [ "$is_preserved" -eq 0 ] && [ ! -f "$(dirname "$file")/index.md" ]; then
|
||||
is_posts_dir_2="false"
|
||||
if [ -n "$posts_dir" ] && { [ "$dir_rel" = "$posts_dir" ] || [ "./$dir_rel" = "$posts_dir" ]; }; then
|
||||
is_posts_dir_2="true"
|
||||
fi
|
||||
|
||||
if [ "$single_file_index" = "true" ] && [ "${file%.md}" != "$file" ] && [ "$is_preserved" -eq 0 ] && [ ! -f "$(dirname "$file")/index.md" ] && [ "$is_posts_dir_2" = "false" ]; then
|
||||
md_count=$(find "$(dirname "$file")" ! -name "$(basename "$(dirname "$file")")" -prune -name "*.md" | wc -l)
|
||||
[ "$md_count" -eq 1 ] && continue
|
||||
fi
|
||||
|
||||
@@ -16,6 +16,8 @@ It's meant to be a static site generator, like _[kew](https://github.com/uint23/
|
||||
- Inline html support
|
||||
- MFM `$font` and `\<plain>` tags
|
||||
- Admonition support (that's what the blocks like the warning block below are called)
|
||||
- RSS/Feed generation and Sitemap support
|
||||
- Post creation via `--post`
|
||||
|
||||
If you want to **force** a file to be inlined, use `\!![]` instead of `\![]`
|
||||
|
||||
@@ -24,7 +26,7 @@ If you want to **force** a file to be inlined, use `\!![]` instead of `\![]`
|
||||
You can clone the repository to use `kewt.sh` directly, or you can download the standalone executable, which bundles all dependencies into a single file:
|
||||
|
||||
```sh
|
||||
curl -L -o kewt https://git.krzak.org/N0VA/kewt/releases/latest/download/kewt
|
||||
curl -L -o kewt https://git.krzak.org/N0VA/kewt/releases/download/latest/kewt
|
||||
chmod +x kewt
|
||||
```
|
||||
|
||||
@@ -38,12 +40,15 @@ On Arch Linux, _kewt_ is available on the AUR:
|
||||
```sh
|
||||
./kewt.sh --help
|
||||
./kewt.sh --new [title]
|
||||
./kewt.sh --post
|
||||
./kewt.sh --from <src> --to <out>
|
||||
./kewt.sh [src] [out]
|
||||
```
|
||||
|
||||
`--new [title]` creates a new site directory with a copied `site.conf` and a default `index.md`.
|
||||
|
||||
`--post` creates a new empty markdown file in the configured `posts_dir` with the current date and time as the name.
|
||||
|
||||
## site.conf
|
||||
|
||||
```conf
|
||||
@@ -57,7 +62,7 @@ home_name = "Home"
|
||||
show_home_in_nav = true
|
||||
nav_links = ""
|
||||
nav_extra = ""
|
||||
footer = "made with <a href="https://kewt.krzak.org">kewt</a>"
|
||||
footer = "made with <a href=\"https://kewt.krzak.org\">kewt</a>"
|
||||
logo = ""
|
||||
display_logo = false
|
||||
display_title = true
|
||||
@@ -66,6 +71,10 @@ favicon = ""
|
||||
generate_page_title = true
|
||||
error_page = "not_found.html"
|
||||
versioning = false
|
||||
base_url = ""
|
||||
generate_feed = false
|
||||
feed_file = "rss.xml"
|
||||
posts_dir = ""
|
||||
```
|
||||
|
||||
- `title` site title
|
||||
@@ -87,6 +96,10 @@ versioning = false
|
||||
- `generate_page_title` automatically generate title text from the first markdown heading or filename (default: true)
|
||||
- `error_page` filename for the generated 404 error page (default: "not_found.html", empty to disable)
|
||||
- `versioning` append a version query parameter (`?v=timestamp`) to css asset urls to bypass cache (default: false)
|
||||
- `base_url` absolute URL of the site, used for sitemap and RSS feed generation
|
||||
- `generate_feed` enable RSS feed generation (requires `base_url`)
|
||||
- `feed_file` filename for the generated RSS feed (default: "rss.xml")
|
||||
- `posts_dir` directory name containing posts (e.g., "posts"). Enables reverse-chronological sorting, title headings in indexes, and automatic backlinks.
|
||||
|
||||
## Ignores
|
||||
|
||||
@@ -108,5 +121,5 @@ versioning = false
|
||||
|
||||
- Default css style and html template based on _[kew](https://github.com/uint23/kew)_ by [uint23](https://github.com/uint23)
|
||||
|
||||
>![WARNING]
|
||||
>[!WARNING]
|
||||
>Most of this was coded at night, while sleepy and a bit sick, and after walking for about 4 hours around a forest, so...
|
||||
|
||||
@@ -3,7 +3,7 @@ style = "kewt"
|
||||
dir_indexes = true
|
||||
single_file_index = true
|
||||
flatten = false
|
||||
footer = "<a href="https://kewt.krzak.org"><img src="/button.gif" /></a>"
|
||||
footer = "<a href=\"https://kewt.krzak.org\"><img src=\"/button.gif\" /></a>"
|
||||
logo = ""
|
||||
display_logo = false
|
||||
display_title = true
|
||||
|
||||
@@ -26,7 +26,13 @@ exit $?
|
||||
#==PAYLOAD==
|
||||
EOF
|
||||
|
||||
tar -cz -C "$REPO_ROOT" kewt.sh markdown.sh awk styles >> "$OUT_FILE"
|
||||
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "standalone")
|
||||
tmpbuild=$(mktemp -d)
|
||||
cp -r "$REPO_ROOT/kewt.sh" "$REPO_ROOT/markdown.sh" "$REPO_ROOT/awk" "$REPO_ROOT/styles" "$tmpbuild/"
|
||||
sed -e "s/kewt version git/kewt version $VERSION/" "$tmpbuild/kewt.sh" > "$tmpbuild/kewt.sh.tmp" && mv "$tmpbuild/kewt.sh.tmp" "$tmpbuild/kewt.sh"
|
||||
chmod +x "$tmpbuild/kewt.sh" "$tmpbuild/markdown.sh"
|
||||
tar -cz -C "$tmpbuild" kewt.sh markdown.sh awk styles >> "$OUT_FILE"
|
||||
rm -rf "$tmpbuild"
|
||||
|
||||
chmod +x "$OUT_FILE"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user