Blogging with DokuVimKi

If you love Dokuwiki and Vim you also propably know DokuVimKi, but do you use it for blogging? I do, sometime at least, but what me really bugged, was that there is no template, like the web frontend provides. But Vim wouldn't be Vim, if it couldn't be fixed. So here is my solution.

To get it working the way I use DokuVimKi you just need to follow the following steps:

How to install

The shell alias

Put this function into your shell configuration (.zshrc, .bashrc)

function viDokuVimKiBlog() {
    if [ $# -lt 1 ]; then
        echo "You should give your blog article a title!"
        return
    fi
    TITLE="$*"
    DW_PATH=blog:`date +%Y:%m:%d`.`echo ${TITLE} | sed 's# #.#g'`
    vim +DokuVimKi +"DWNew ${DW_PATH}" +"silent! 0r ~/.vim/templates/blog.dokuwiki.tpl" \
    +"%s/%TITLE%/${TITLE}/g"
}
alias viblog='viDokuVimKiBlog'

The template

Create a template diretory:

% mkdir ~/.vim/templates

Create you template called blog.dokuwiki.tpl:

% cat << EOF > ~/.vim/templates/blog.dokuwiki.tpl
====== %TITLE% ======
 
 
 
 
 
 
 
~~NOTOC~~
EOF

How to use

The next time you want to blog you can start the whole environment with

% viblog This is a new entry to my blog

This will start vim and create a new page in the namespace defined by the DW_PATH variable in your shell configuration. You may need to modify it. I use the following namespace to blog:

  blog:%year%:%month%:%day%.%title_of_entry%

Updates

Update #1: I've fixed the viDokuVimKiBlog() function. Within the if-fi-statement was an exit, which causes your shell/terminal to logout/close. The correct function is a simple return.

Update #2: Fixed some stupid typos.

Comments



WPZCS
Posted 2009/09/17 15:45 ·
blog/2009/09/17.blogging.with.dokuvimki.txt · Last modified: 2010/02/02 17:04 (external edit)