16
.gitea/workflows/lint.yml
Normal file
16
.gitea/workflows/lint.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
name: Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, master ]
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
shellcheck:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install Shellcheck
|
||||||
|
run: sudo apt-get update && sudo apt-get install -y shellcheck
|
||||||
|
- name: Run Shellcheck
|
||||||
|
run: shellcheck kewt.sh markdown.sh tools/build-standalone.sh || true
|
||||||
24
.gitea/workflows/release.yml
Normal file
24
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
name: Release Standalone Builder
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build standalone executable
|
||||||
|
run: |
|
||||||
|
chmod +x tools/build-standalone.sh
|
||||||
|
./tools/build-standalone.sh
|
||||||
|
|
||||||
|
- name: Upload Release Asset
|
||||||
|
uses: https://gitea.com/actions/release-action@main
|
||||||
|
with:
|
||||||
|
files: |-
|
||||||
|
kewt
|
||||||
|
api_key: '${{secrets.GITEA_TOKEN}}'
|
||||||
16
.github/workflows/lint.yml
vendored
Normal file
16
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
name: Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, master ]
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
shellcheck:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install Shellcheck
|
||||||
|
run: sudo apt-get update && sudo apt-get install -y shellcheck
|
||||||
|
- name: Run Shellcheck
|
||||||
|
run: shellcheck kewt.sh markdown.sh tools/build-standalone.sh || true
|
||||||
22
.github/workflows/release.yml
vendored
Normal file
22
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: Release Standalone Builder
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build standalone executable
|
||||||
|
run: |
|
||||||
|
chmod +x tools/build-standalone.sh
|
||||||
|
./tools/build-standalone.sh
|
||||||
|
|
||||||
|
- name: Upload Release Asset
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: kewt
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
out/
|
out/
|
||||||
|
kewt
|
||||||
18
kewt.sh
18
kewt.sh
@@ -20,7 +20,7 @@ Options:
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
script_dir=$(CDPATH="" cd -- "$(dirname -- "$0")" && pwd)
|
||||||
awk_dir="$script_dir/awk"
|
awk_dir="$script_dir/awk"
|
||||||
|
|
||||||
ensure_root_defaults() {
|
ensure_root_defaults() {
|
||||||
@@ -93,10 +93,7 @@ create_new_site() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_nav() {
|
|
||||||
dinfo=$(find "$1" \( -name ".*" ! -name "." ! -name ".." -prune \) -o -print | sort | awk -v src="$1" -f "$awk_dir/collect_dir_info.awk")
|
|
||||||
find "$1" \( -name ".*" ! -name "." ! -name ".." -prune \) -o -name "*.md" -print | sort | awk -v src="$1" -v single_file_index="$single_file_index" -v flatten="$flatten" -v order="$order" -v dinfo="$dinfo" -f "$awk_dir/generate_sidebar.awk"
|
|
||||||
}
|
|
||||||
|
|
||||||
src=""
|
src=""
|
||||||
out=""
|
out=""
|
||||||
@@ -133,9 +130,9 @@ while [ $# -gt 0 ]; do
|
|||||||
*)
|
*)
|
||||||
positional_count=$((positional_count + 1))
|
positional_count=$((positional_count + 1))
|
||||||
if [ "$positional_count" -eq 1 ]; then
|
if [ "$positional_count" -eq 1 ]; then
|
||||||
[ -z "$src" ] && src="$1" || die "Source already set (use either positional or --from)."
|
if [ -z "$src" ]; then src="$1"; else die "Source already set (use either positional or --from)."; fi
|
||||||
elif [ "$positional_count" -eq 2 ]; then
|
elif [ "$positional_count" -eq 2 ]; then
|
||||||
[ -z "$out" ] && out="$1" || die "Output already set (use either positional or --to)."
|
if [ -z "$out" ]; then out="$1"; else die "Output already set (use either positional or --to)."; fi
|
||||||
else
|
else
|
||||||
die "Too many positional arguments."
|
die "Too many positional arguments."
|
||||||
fi
|
fi
|
||||||
@@ -333,6 +330,7 @@ nav_links_html() {
|
|||||||
old_ifs=$IFS
|
old_ifs=$IFS
|
||||||
set -f
|
set -f
|
||||||
IFS=','
|
IFS=','
|
||||||
|
# shellcheck disable=SC2086
|
||||||
set -- $nav_links
|
set -- $nav_links
|
||||||
IFS=$old_ifs
|
IFS=$old_ifs
|
||||||
set +f
|
set +f
|
||||||
@@ -418,7 +416,7 @@ render_markdown() {
|
|||||||
closest_style_src=$(find_closest "styles.css" "$(dirname "$file")")
|
closest_style_src=$(find_closest "styles.css" "$(dirname "$file")")
|
||||||
[ -z "$closest_style_src" ] && closest_style_src=$(find_closest "style.css" "$(dirname "$file")")
|
[ -z "$closest_style_src" ] && closest_style_src=$(find_closest "style.css" "$(dirname "$file")")
|
||||||
if [ -n "$closest_style_src" ]; then
|
if [ -n "$closest_style_src" ]; then
|
||||||
style_rel_to_src="${closest_style_src#$src/}"
|
style_rel_to_src="${closest_style_src#"$src"/}"
|
||||||
case "$closest_style_src" in
|
case "$closest_style_src" in
|
||||||
"$src/styles.css") style_rel_to_src="styles.css" ;;
|
"$src/styles.css") style_rel_to_src="styles.css" ;;
|
||||||
"$src/style.css") style_rel_to_src="style.css" ;;
|
"$src/style.css") style_rel_to_src="style.css" ;;
|
||||||
@@ -466,7 +464,7 @@ render_markdown() {
|
|||||||
echo "Building site from '$src' to '$out'..."
|
echo "Building site from '$src' to '$out'..."
|
||||||
|
|
||||||
eval "find \"$src\" \( $IGNORE_ARGS \) -prune -o -type d -print" | sort | while read -r dir; do
|
eval "find \"$src\" \( $IGNORE_ARGS \) -prune -o -type d -print" | sort | while read -r dir; do
|
||||||
rel_dir="${dir#$src}"
|
rel_dir="${dir#"$src"}"
|
||||||
rel_dir="${rel_dir#/}"
|
rel_dir="${rel_dir#/}"
|
||||||
[ -z "$rel_dir" ] && rel_dir="."
|
[ -z "$rel_dir" ] && rel_dir="."
|
||||||
out_dir="$out/$rel_dir"
|
out_dir="$out/$rel_dir"
|
||||||
@@ -518,7 +516,7 @@ if [ ! -f "$out/styles.css" ] && [ -f "$script_dir/styles/$style.css" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
eval "find \"$src\" \( $IGNORE_ARGS \) -prune -o -type f -print" | sort | while IFS= read -r file; do
|
eval "find \"$src\" \( $IGNORE_ARGS \) -prune -o -type f -print" | sort | while IFS= read -r file; do
|
||||||
rel_path="${file#$src}"
|
rel_path="${file#"$src"}"
|
||||||
rel_path="${rel_path#/}"
|
rel_path="${rel_path#/}"
|
||||||
dir_rel=$(dirname "$rel_path")
|
dir_rel=$(dirname "$rel_path")
|
||||||
out_dir="$out/$dir_rel"
|
out_dir="$out/$dir_rel"
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
script_dir=$(CDPATH="" cd -- "$(dirname -- "$0")" && pwd)
|
||||||
awk_dir="$script_dir/awk"
|
awk_dir="$script_dir/awk"
|
||||||
|
|
||||||
sed_inplace() {
|
sed_inplace() {
|
||||||
script="$1"
|
script="$1"
|
||||||
file="$2"
|
file="$2"
|
||||||
tmp="${file}.tmp.$$"
|
tmp="${file}.tmp.$$"
|
||||||
sed "$script" "$file" > "$tmp" && mv "$tmp" "$file" || {
|
if sed "$script" "$file" > "$tmp" && mv "$tmp" "$file"; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
rm -f "$tmp"
|
rm -f "$tmp"
|
||||||
return 1
|
return 1
|
||||||
}
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_file="/tmp/markdown.$$.md"
|
temp_file="/tmp/markdown.$$.md"
|
||||||
|
|||||||
32
tools/build-standalone.sh
Normal file
32
tools/build-standalone.sh
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
|
||||||
|
if [ ! -f "$REPO_ROOT/kewt.sh" ]; then
|
||||||
|
echo "kewt.sh not found. Run from the repository root or tools/."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
OUT_FILE="$REPO_ROOT/kewt"
|
||||||
|
|
||||||
|
cat << 'EOF' > "$OUT_FILE"
|
||||||
|
#!/bin/sh
|
||||||
|
tmpdir=$(mktemp -d "/tmp/kewt.XXXXXX")
|
||||||
|
trap 'rm -rf "$tmpdir"' EXIT HUP INT TERM
|
||||||
|
|
||||||
|
# Extract payload
|
||||||
|
sed '1,/^#==PAYLOAD==$/d' "$0" | tar -xz -C "$tmpdir"
|
||||||
|
|
||||||
|
# Pass control to the extracted script
|
||||||
|
exec "$tmpdir/kewt.sh" "$@"
|
||||||
|
|
||||||
|
#==PAYLOAD==
|
||||||
|
EOF
|
||||||
|
|
||||||
|
tar -cz -C "$REPO_ROOT" kewt.sh markdown.sh awk styles >> "$OUT_FILE"
|
||||||
|
|
||||||
|
chmod +x "$OUT_FILE"
|
||||||
|
|
||||||
|
echo "Generated standalone executable at $OUT_FILE"
|
||||||
Reference in New Issue
Block a user