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




If you can't read the letters on the image, download this .wav file to get them read to you.
Posted 2009/09/17 15:45 ·

Discussion

Enter your comment. Wiki syntax is allowed:
If you can't read the letters on the image, download this .wav file to get them read to you.
 
blog/2009/09/17.blogging.with.dokuvimki.txt · Last modified: 2010/02/02 17:04 (external edit)
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0