[Emacs] Add github pages publishing hooks

This commit is contained in:
Ivan Malison 2016-10-19 17:57:03 -07:00
parent a87da9360d
commit d4ad629514
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8
4 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$THIS_DIR/../util.sh"
if readme_was_updated; then
update_index
commit_index_changes
fi

View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
TOP_LEVEL="$(git rev-parse --show-toplevel)"
HOOK_DIR="$TOP_LEVEL/.git/hooks"
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE_DIR="$THIS_DIR/git-hooks"
for hook in "$SOURCE_DIR"/*; do
filename=$(basename "$hook")
source="$SOURCE_DIR/$filename"
dest="$HOOK_DIR/$filename"
# If the hook already exists, is executable, and is not a symlink
if [ -e "$dest" ]; then
mv "$dest" "$dest.local"
fi
echo "linking $source to $dest"
ln -s "$source" "$dest"
chmod 755 "$dest"
done

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$THIS_DIR/util.sh"
update_index

20
dotfiles/emacs.d/bin/util.sh Executable file
View File

@ -0,0 +1,20 @@
# -*- mode: sh -*-
EMACS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
TOP_LEVEL="$(git rev-parse --show-toplevel)"
README="$EMACS_DIR/README.org"
REPOSITORY_NAME="$(realpath --relative-to="$TOP_LEVEL" "$README")"
readme_was_updated() {
git diff HEAD~1 --name-only | grep --quiet "$REPOSITORY_NAME"
}
update_index () {
emacsclient -e "(with-current-buffer (find-file-noselect \"$README\")
(org-html-export-to-html))"
cp -f "$EMACS_DIR/README.html" "$TOP_LEVEL/index.html"
}
commit_index_changes () {
git add "$TOP_LEVEL/index.html"
git commit -m "[Emacs] Update github pages index file"
}