From d7a6747d12a570c6408e1d2f7685508f98a4cfa5 Mon Sep 17 00:00:00 2001 From: p4bl0 Date: Sun, 25 Jul 2010 00:39:13 +0200 Subject: include directive now works \o/ --- post-commit.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'post-commit.sh') diff --git a/post-commit.sh b/post-commit.sh index 64a94d9..ccfc5be 100644 --- a/post-commit.sh +++ b/post-commit.sh @@ -110,14 +110,34 @@ replace_str() { # REMEMBER: 2nd arg should be a tempfile! replace_file() { - sed "// { - r $2 - d }" + sed "s//\n\0\n/g" | \ + sed "// { + r $2 + d }" rm "$2" } replace_includes() { - cat + buf=`tempfile -p "fugitive"` + buf2=`tempfile -p "fugitive"` + cat > "$buf" + includes=`cat "$buf" | \ + sed "s//\n\0\n/g" | \ + grep -E "<\?fugitive\s+include:.+\s*\?>" | \ + sed "s/^$//"` + for i in $includes; do + esc=`echo -n $i | sed 's/\//\\\\\//g'` + inc="$templates_dir/$i" + cat "$buf" | \ + sed "// { + r $inc + d }" > "$buf2" + tmpbuf="$buf" + buf="$buf2" + buf2="$tmpbuf" + done + cat "$buf" + rm "$buf" "$buf2" } replace_commit_info() { @@ -177,6 +197,27 @@ replace_article_info() { replace_str "article_next_title" "$article_next_title" } +replace_empty_article_info() { + replace_str "article_file" "" | \ + replace_str "article_title" "" | \ + replace_str "article_cdatetime" "" | \ + replace_str "article_cdate" "" | \ + replace_str "article_ctime" "" | \ + replace_str "article_ctimestamp" "" | \ + replace_str "article_mdatetime" "" | \ + replace_str "article_mdate" "" | \ + replace_str "article_mtime" "" | \ + replace_str "article_mtimestamp" "" | \ + replace_str "article_cauthor" "" | \ + replace_str "article_cauthor_email" "" | \ + replace_str "article_mauthor" "" | \ + replace_str "article_mauthor_email" "" | \ + replace_str "article_previous_file" "" | \ + replace_str "article_previous_title" "" | \ + replace_str "article_next_file" "" | \ + replace_str "article_next_title" "" +} + replace_foreach_article() { foreach_body=`tempfile -p "feb"` tmpfile=`tempfile -p "tfil"` @@ -278,6 +319,7 @@ if [ $modification -gt 0 ]; then cat "$templates_dir/archives.html" | \ replace_includes | \ replace_foreach_article | \ + replace_empty_article_info | \ replace_commit_info | \ sed "/^\s*$/d" > "$public_dir/archives.html" echo "done." -- cgit v1.2.3