Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e331b5d9a | |||
| 9f5d1089a2 | |||
| 9ccba8fd4e | |||
| 95679abd85 | |||
| 8b1e793510 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
out/
|
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
|
- Inline html support
|
||||||
- MFM `$font` and `\<plain>` tags
|
- MFM `$font` and `\<plain>` tags
|
||||||
- Admonition support (that's what the blocks like the warning block below are called)
|
- 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 `\![]`
|
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:
|
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
|
```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
|
chmod +x kewt
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -38,12 +40,15 @@ On Arch Linux, _kewt_ is available on the AUR:
|
|||||||
```sh
|
```sh
|
||||||
./kewt.sh --help
|
./kewt.sh --help
|
||||||
./kewt.sh --new [title]
|
./kewt.sh --new [title]
|
||||||
|
./kewt.sh --post
|
||||||
./kewt.sh --from <src> --to <out>
|
./kewt.sh --from <src> --to <out>
|
||||||
./kewt.sh [src] [out]
|
./kewt.sh [src] [out]
|
||||||
```
|
```
|
||||||
|
|
||||||
`--new [title]` creates a new site directory with a copied `site.conf` and a default `index.md`.
|
`--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
|
## site.conf
|
||||||
|
|
||||||
```conf
|
```conf
|
||||||
@@ -57,7 +62,7 @@ home_name = "Home"
|
|||||||
show_home_in_nav = true
|
show_home_in_nav = true
|
||||||
nav_links = ""
|
nav_links = ""
|
||||||
nav_extra = ""
|
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 = ""
|
logo = ""
|
||||||
display_logo = false
|
display_logo = false
|
||||||
display_title = true
|
display_title = true
|
||||||
@@ -66,6 +71,10 @@ favicon = ""
|
|||||||
generate_page_title = true
|
generate_page_title = true
|
||||||
error_page = "not_found.html"
|
error_page = "not_found.html"
|
||||||
versioning = false
|
versioning = false
|
||||||
|
base_url = ""
|
||||||
|
generate_feed = false
|
||||||
|
feed_file = "rss.xml"
|
||||||
|
posts_dir = ""
|
||||||
```
|
```
|
||||||
|
|
||||||
- `title` site title
|
- `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)
|
- `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)
|
- `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)
|
- `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
|
## Ignores
|
||||||
|
|
||||||
|
|||||||
41
kewt.sh
41
kewt.sh
@@ -13,6 +13,7 @@ Usage: $invoked_as [--from <src>] [--to <out>]
|
|||||||
$invoked_as --new [title]
|
$invoked_as --new [title]
|
||||||
$invoked_as --update [dir]
|
$invoked_as --update [dir]
|
||||||
$invoked_as --post
|
$invoked_as --post
|
||||||
|
$invoked_as --version
|
||||||
$invoked_as --help
|
$invoked_as --help
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
@@ -20,6 +21,7 @@ Options:
|
|||||||
--new [title] Create a new site directory (default: site)
|
--new [title] Create a new site directory (default: site)
|
||||||
--update [dir] Update site.conf and template.html with latest defaults (defaults to current directory)
|
--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
|
--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)
|
--from <src> Source directory (default: site)
|
||||||
--to <out> Output directory (default: out)
|
--to <out> Output directory (default: out)
|
||||||
EOF
|
EOF
|
||||||
@@ -44,7 +46,7 @@ home_name = "Home"
|
|||||||
show_home_in_nav = true
|
show_home_in_nav = true
|
||||||
nav_links = ""
|
nav_links = ""
|
||||||
nav_extra = ""
|
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 = ""
|
logo = ""
|
||||||
display_logo = false
|
display_logo = false
|
||||||
display_title = true
|
display_title = true
|
||||||
@@ -156,7 +158,7 @@ home_name = "Home"
|
|||||||
show_home_in_nav = true
|
show_home_in_nav = true
|
||||||
nav_links = ""
|
nav_links = ""
|
||||||
nav_extra = ""
|
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 = ""
|
logo = ""
|
||||||
display_logo = false
|
display_logo = false
|
||||||
display_title = true
|
display_title = true
|
||||||
@@ -259,6 +261,10 @@ while [ $# -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
--version|-v)
|
||||||
|
echo "kewt version git"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
--post)
|
--post)
|
||||||
post_mode="true"
|
post_mode="true"
|
||||||
;;
|
;;
|
||||||
@@ -301,7 +307,13 @@ done
|
|||||||
|
|
||||||
ensure_root_defaults
|
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"
|
[ -z "$out" ] && out="out"
|
||||||
|
|
||||||
src="${src%/}"
|
src="${src%/}"
|
||||||
@@ -456,8 +468,14 @@ load_config() {
|
|||||||
key=$(printf '%s' "$key" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
|
key=$(printf '%s' "$key" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
|
||||||
val=$(printf '%s' "$val" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
|
val=$(printf '%s' "$val" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
|
||||||
case "$val" in
|
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
|
esac
|
||||||
|
|
||||||
case "$key" in
|
case "$key" in
|
||||||
@@ -707,7 +725,11 @@ eval "find \"$src\" \( $IGNORE_ARGS \) -prune -o -type d -print" | sort | while
|
|||||||
[ "$dir_indexes" != "true" ] && continue
|
[ "$dir_indexes" != "true" ] && continue
|
||||||
|
|
||||||
if [ ! -f "$dir/index.md" ]; then
|
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)
|
md_count=$(find "$dir" ! -name "$(basename "$dir")" -prune -name "*.md" | wc -l)
|
||||||
if [ "$md_count" -eq 1 ]; then
|
if [ "$md_count" -eq 1 ]; then
|
||||||
md_file=$(find "$dir" ! -name "$(basename "$dir")" -prune -name "*.md")
|
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
|
is_preserved=1
|
||||||
fi
|
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=$(find "$(dirname "$file")" ! -name "$(basename "$(dirname "$file")")" -prune -name "*.md" | wc -l)
|
||||||
[ "$md_count" -eq 1 ] && continue
|
[ "$md_count" -eq 1 ] && continue
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ It's meant to be a static site generator, like _[kew](https://github.com/uint23/
|
|||||||
- Inline html support
|
- Inline html support
|
||||||
- MFM `$font` and `\<plain>` tags
|
- MFM `$font` and `\<plain>` tags
|
||||||
- Admonition support (that's what the blocks like the warning block below are called)
|
- 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 `\![]`
|
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:
|
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
|
```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
|
chmod +x kewt
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -38,12 +40,15 @@ On Arch Linux, _kewt_ is available on the AUR:
|
|||||||
```sh
|
```sh
|
||||||
./kewt.sh --help
|
./kewt.sh --help
|
||||||
./kewt.sh --new [title]
|
./kewt.sh --new [title]
|
||||||
|
./kewt.sh --post
|
||||||
./kewt.sh --from <src> --to <out>
|
./kewt.sh --from <src> --to <out>
|
||||||
./kewt.sh [src] [out]
|
./kewt.sh [src] [out]
|
||||||
```
|
```
|
||||||
|
|
||||||
`--new [title]` creates a new site directory with a copied `site.conf` and a default `index.md`.
|
`--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
|
## site.conf
|
||||||
|
|
||||||
```conf
|
```conf
|
||||||
@@ -57,7 +62,7 @@ home_name = "Home"
|
|||||||
show_home_in_nav = true
|
show_home_in_nav = true
|
||||||
nav_links = ""
|
nav_links = ""
|
||||||
nav_extra = ""
|
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 = ""
|
logo = ""
|
||||||
display_logo = false
|
display_logo = false
|
||||||
display_title = true
|
display_title = true
|
||||||
@@ -66,6 +71,10 @@ favicon = ""
|
|||||||
generate_page_title = true
|
generate_page_title = true
|
||||||
error_page = "not_found.html"
|
error_page = "not_found.html"
|
||||||
versioning = false
|
versioning = false
|
||||||
|
base_url = ""
|
||||||
|
generate_feed = false
|
||||||
|
feed_file = "rss.xml"
|
||||||
|
posts_dir = ""
|
||||||
```
|
```
|
||||||
|
|
||||||
- `title` site title
|
- `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)
|
- `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)
|
- `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)
|
- `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
|
## 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)
|
- 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...
|
>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
|
dir_indexes = true
|
||||||
single_file_index = true
|
single_file_index = true
|
||||||
flatten = false
|
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 = ""
|
logo = ""
|
||||||
display_logo = false
|
display_logo = false
|
||||||
display_title = true
|
display_title = true
|
||||||
|
|||||||
@@ -26,7 +26,13 @@ exit $?
|
|||||||
#==PAYLOAD==
|
#==PAYLOAD==
|
||||||
EOF
|
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"
|
chmod +x "$OUT_FILE"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user