Blogging
Da ich so viele Anfragen bekomme habe, wie ich denn meine Blogposts erstelle (haha, als ob), teile ich mal mein Prozedere.
Ich mache alles per Terminal + Vim + Jekyll + Git und habe es “TVJGing” getauft.
An sich tut es nichts anderes als zu überprüfen ob etwas im _drafts
Verzeichnis ist, das vielleicht nach _posts zu kopieren, commits zu pushen und
_site auf den Server zu pushen.
Code
#!/bin/bash
dir="$HOME/blog"
server_name="<NAME>"
server_dir="<FOLDER>"
push=""
if [ "$PWD" != "$dir" ]; then
    cd "$dir" || exit
fi
###
# Check if we have uncommit stuff
###
if [ "$(git status --porcelain)" ]; then
    echo "Uncommited stuff, exiting."
    exit
fi
###
# Check if we have unpushed stuff
###
if [ "$(git log --pretty=oneline origin/master..master)" ]; then
    echo "--------------------"
    echo "Unpushed commits"
    echo "--------------------"
    git log --pretty="format:%p %s" origin/master..master
    echo ""
    echo -n "Push them? [y/n] "
    read -r push
fi
###
# Check if we have drafts left we forgot to publish
###
if [ "$(ls -A _drafts)" ]
then
    got_drafts=true
else
    got_drafts=false
fi
###
# Fix picture permissions
###
find images/ -type f -exec chmod 644 {} \;
if "$got_drafts"; then
    echo "--------------------"
    echo "Found drafts"
    echo "--------------------"
    for x in _drafts/*
    do
        echo -n "Want to publish $(basename "$x")? [y/n]: "
        read -r choice
        if [ "$choice" == "y" ]; then
            echo "--------------------"
            echo "Publishing posts"
            echo "--------------------"
            mv "$x" _posts
            git add -A .
            git commit -m "Publishing $x"
        fi
    done
fi
if [ "$push" == "y" ]; then
    echo "--------------------"
    echo "Pushing to repo"
    echo "--------------------"
    git push origin master
fi
echo "--------------------"
echo "Building site"
echo "--------------------"
jekyll build
echo "--------------------"
echo "Syncing blog"
echo "--------------------"
rsync --human-readable -a --info=progress2 --partial \
    _site/ "$server_name:$server_dir"