Let’s display scheduled Jekyll blog posts using DokuWiki on your own personal wiki.

Create a system user that can access git repositories and wiki pages.

$ sudo useradd -s /usr/sbin/nologin -G "git,www-data" -r wiki-git-bridge

Create external namespace for DokuWiki installed in /opt/wiki/ directory.

$ sudo mkdir /opt/wiki/data/pages/external

Change the owner and group from root to www-data.

$ sudo chown www-data:www-data /opt/wiki/data/pages/external

Add write access for the assigned group.

$ sudo chmod g+w /opt/wiki/data/pages/external

Create /opt/sbin/wiki_blog_posts.sh shell script to generate a list of scheduled blog posts for /opt/repositories/blog.git Jekyll git repository and store it using /opt/wiki/data/pages/external/git_blog_scheduled.txt wiki page file.

#!/bin/bash
# display scheduled Jekyll blog posts using dokuwiki syntax

# git repository
git_repository="/opt/repositories/blog.git/"

# output directory and filename
output_dir="/opt/wiki/data/pages/external"
output_file="git_blog_scheduled.txt"
output="${output_dir}/${output_file}"

# header title
header_title="Scheduled blog posts"

# limit the number of posts to check only a third for increased performance
n_posts=$(git --git-dir="${git_repository}" ls-tree HEAD _posts --name-only -r | wc -l)
n_posts_to_check=$(( n_posts / 3 ))

echo "==== ${header_title} ====" | tee $output >/dev/null
posts=$(git --git-dir="${git_repository}" ls-tree HEAD _posts --name-only -r | sort | tail -${n_posts_to_check})
for post in $posts; do
  date=$(echo $post | sed "s/\_posts\/\([0-9]*\).\([0-9]*\).\([0-9]*\).*/\1-\2-\3/")
  date_s=$(date -d ${date} +%s)
  now_s=$(date -d now +%s)
  date_diff=$(( (date_s - now_s) / 86400 ))
  if [ "$date_diff" -ge "0" ]; then
    title=$(git --git-dir="${git_repository}" show HEAD:${post} | grep ^title: |  awk -F ": " '{print $2}')
    echo "  * **$date** \\\\  //$title//" | tee -a $output >/dev/null
  fi
done

Verify that the created shell script is running without any problems.

$ sudo -u wiki-git-bridge  /opt/sbin/wiki_blog_posts.sh

Create cron job to schedule script execution.

$ cat << EOF | sudo tee /etc/cron.d/wiki_blog_posts
MAILTO=root
# Generate recent repository changes page
25 */3 * * * wiki-git-bridge [ -x /opt/sbin/wiki_blog_posts.sh ] && /opt/sbin/wiki_blog_posts.sh
EOF

tmux

Use include plugin to embed the generated page.

{{page>external:git_blog_scheduled&inline&nofooter&noeditbutton}}