diff --git a/doku.php b/doku.php new file mode 100755 index 0000000..ccdbef1 --- /dev/null +++ b/doku.php @@ -0,0 +1,33 @@ +#!/usr/bin/php + +# +# You should probably adjust path to DOKU_INC. + +if ('cli' != php_sapi_name()) die(); + +define('DOKU_INC', '/usr/share/dokuwiki/'); +require_once DOKU_INC.'inc/init.php'; +require_once DOKU_INC.'inc/common.php'; +require_once DOKU_INC.'inc/cliopts.php'; + +switch ($argv[1]) { +case 'cleanID': + echo cleanID($argv[2]); + break; +case 'wikiFn': + echo wikiFn($argv[2]); + break; +case 'mediaFn': + echo mediaFn($argv[2]); + break; +case 'getNS': + echo getNS($argv[2]); + break; +default: + die("Unknown knob: {$argv[1]}"); +} diff --git a/doku.py b/doku.py new file mode 100644 index 0000000..c547ff6 --- /dev/null +++ b/doku.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Setup VIM: ex: noet ts=2 sw=2 : +# Bridge for Python code to invoke DokuWiki functions. +# +# Author: Elan Ruusamäe + +import sys +import subprocess + +class DokuWiki: + def __init__(self): + self.callcache = {} + + def __call(self, call, id): + key = "%s-%s" % (call, id) + if not self.callcache.has_key(key): + cmd = ['./doku.php', call, id] + print cmd + res = subprocess.Popen(cmd, stdin = None, stdout = subprocess.PIPE, stderr = sys.stderr, close_fds = True).communicate() + self.callcache[key] = res[0] + return self.callcache[key] + + def wikiFn(self, id): + return self.__call('wikiFn', id) + + def mediaFn(self, id): + return self.__call('mediaFn', id) + + def getNS(self, id): + return self.__call('getNS', id)