diff --git a/kewt.sh b/kewt.sh index 5612e46..6f3b818 100755 --- a/kewt.sh +++ b/kewt.sh @@ -13,6 +13,7 @@ Usage: $invoked_as [--from ] [--to ] $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 Source directory (default: site) --to Output directory (default: out) EOF @@ -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%/}" @@ -713,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") diff --git a/tools/build-standalone.sh b/tools/build-standalone.sh index a3403b1..b5ebf31 100755 --- a/tools/build-standalone.sh +++ b/tools/build-standalone.sh @@ -26,7 +26,13 @@ exit $? #==PAYLOAD== EOF -tar -cz -C "$REPO_ROOT" kewt.sh markdown.sh awk styles >> "$OUT_FILE" +VERSION=$(git describe --tags --always --dirty 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"