diff options
-rwxr-xr-x | build.sh | 21 | ||||
-rw-r--r-- | install.sh | 30 | ||||
-rw-r--r-- | post-commit.sh | 4 | ||||
-rw-r--r-- | post-receive.sh | 3 |
4 files changed, 43 insertions, 15 deletions
diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..50d45ee --- /dev/null +++ b/build.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +include_file() { + tmp=`tempfile -p "figitive"` + cat "$2" | gzip | base64 > "$tmp" + cat "$1" | sed "/#INCLUDE:$2#/ { + r $tmp + d }" + rm "$tmp" +} + +cp install.sh tmp1 +i=1 +for f in archives.html article.html fugitive.css post-commit.sh post-receive.sh; do + j=$((1 - i)) + include_file tmp$i $f > tmp$j + i=$j +done +cp tmp$j fugitive +chmod +x fugitive +rm tmp0 tmp1 @@ -10,6 +10,19 @@ fugitive_write_template() { replace_var_by_string year "`date +%Y`" } +fugitive_install_hooks() { + echo -n "Installing fugitive hooks scripts... " + (base64 -d | gunzip) > .git/hooks/post-commit <<EOF +#INCLUDE:post-commit.sh# +EOF + chmod +x .git/hooks/post-commit + (base64 -d | gunzip) > .git/hooks/post-receive <<EOF +#INCLUDE:post-receive.sh# +EOF + chmod +x .git/hooks/post-receive + echo "done." +} + fugitive_install() { DIR="." if [ "$1" != "" ]; then DIR="$1"; fi @@ -19,7 +32,7 @@ fugitive_install() { git init >/dev/null echo "done." echo -n "Creating default directory tree... " - mkdir -p fugitive/{drafts,articles,templates} + mkdir -p fugitive/drafts fugitive/articles fugitive/templates echo "done." echo -n "Adding default directory paths to git config... " git config --add --path fugitive.templates-dir "fugitive/templates" @@ -35,20 +48,11 @@ EOF EOF echo "done." echo -n "Writing default css file... " - (base64 -d | gunzip) > fugitice.css <<EOF + (base64 -d | gunzip) > fugitive.css <<EOF #INCLUDE:fugitive.css# EOF echo "done." - echo -n "Installing fugitive hooks scripts... " - (base64 -d | gunzip) > .git/hooks/post-commit <<EOF -#INCLUDE:post-commit.sh# -EOF - chmod +x .git/hooks/post-receive - (base64 -d | gunzip) > .git/hooks/post-receive <<EOF -#INCLUDE:post-receive.sh# -EOF - chmod +x .git/hooks/post-receive - echo "done." + fugitive_install_hooks echo -n "Importing files into git repository... " git add fugitive/templates/* fugitive.css >/dev/null git commit -m "fugitive inital import" >/dev/null @@ -56,7 +60,7 @@ EOF echo -n "Preventing git to track temp files... " echo "*~" > .git/info/exclude echo "done." - cd - + cd - >/dev/null echo "Installation complete, please see the README file for an howto." } diff --git a/post-commit.sh b/post-commit.sh index c028f85..06f9a95 100644 --- a/post-commit.sh +++ b/post-commit.sh @@ -32,7 +32,6 @@ commit_slug=`git log -1 --format="%f"` commit_body() { tmp=`tempfile -p "fugitive"` git log -1 --format="%b" > "$tmp" - (sleep 5 && rm -f "$tmp") & # this message will self-destruct in 5s echo "$tmp" } @@ -45,17 +44,18 @@ article_title() { article_content() { tmp=`tempfile -p "fugitive"` tail -n+2 "$1" > "$tmp" - (sleep 5 && rm -f "$tmp") & # this message will self-destruct in 5s echo "$tmp" } replace_var_by_string() { sed "s/<?fugitive\s\+$1\s*?>/$2/" } +# REMEMBER: 2nd arg should be a tempfile! replace_var_by_file() { sed "/<?fugitive\s\+$1\s*?>/ { r $2 d }" + rm "$2" } replace_commit_info() { replace_var_by_string "commit_Hash" "$commit_Hash" | \ diff --git a/post-receive.sh b/post-receive.sh index e69de29..ba901c5 100644 --- a/post-receive.sh +++ b/post-receive.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "hi!" |