1 ikiwiki should support writing plugins in other languages
3 While it should be possible to call ikiwiki from C, doing the callbacks in C is
4 probably hard. And accessing perl at all from C is ugly. It also doesn't
5 make it very easy to write plugins in an interpreted language, since that
6 would mean linking perl and eg, python in one binary. (Been there, done
9 Instead, I'm considering using XML RPC to let ikiwiki communicate with a
10 child process that it can spawn. The child could then be any program,
11 written in any language. It could talk XML RPC via stdio. (This assumes
12 that most languages allow easily serialising XML::RPC calls and responses
13 to a file descriptor. Some XML RPC implementations may be hardcoded to use
16 Here's how it would basically look, not showing the actual XML RPC used to
21 <- hook type => preprocess, id => foo
26 -> callback type => preprocess, id => foo, page => bar
29 -> "http://example.com", ...
32 <- done "my return value"
37 * ikiwiki always initiates each conversation with a command
38 * After sending a command, ikiwiki reads commands, dispatches them, and
39 returns the results, in a loop.
40 * The loop continues until the plugin calls the "done" command, with a value
41 that is the return value for the command that initiated the conversation.
43 From the plugin's POV:
45 * It's probably sitting in an XML::RPC loop.
46 * Get a command from ikiwiki.
47 * Disaptch the command to the appropriate function. The main commands seem
48 to be "import" and "callback"; callback can call any function that the
49 plugin has registered a hook for. Others commands might include
50 "rcs_*" for RCS plugins..
51 * The function can use XML::RPC to communicate with ikiwiki to get things
52 like config values; and to call ikiwiki functions.
53 * When the callback returns, use XML::RPC to send a "done" command to ikiwiki.
55 Simple enough, really. ikiwiki would need to add accessor functions for
56 all important variables, such as "getconfig" and "setconfig". It would
57 probably be easiest for ikiwiki to dispatch a command by just evaling
60 Plugin programs could be dropped into /usr/share/ikiwiki/plugins/, and
61 load_plugin() would just open2 the plugin program and call import.