new todo item
[ikiwiki] / doc / todo / support_for_plugins_written_in_other_languages.mdwn
1 ikiwiki should support writing plugins in other languages
2
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
7 that, never again.)
8
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.
12
13 Here's how it would basically look, not showing the actual XML RPC used to
14 pass values.
15
16         -> init
17         <- 1
18         <- hook type => preprocess, id => foo
19         -> 1
20         <- done 1
21         -> 1
22
23         -> callback type => preprocess id => foo, page => bar
24         <- 1
25         <- getconfig url
26         -> "http://example.com", ...
27         <- debug "foo"
28         -> 1
29         <- done "my return value"
30         -> 1
31
32 From ikiwiki's POV:
33
34 * ikiwiki always initiates each conversation with a command
35 * After sending a command, ikiwiki reads commands, dispatches them, and 
36   returns the results, in a loop.
37 * The loop continues until the plugin calls the "done" command, with a value
38   that is the return value for the command that initiated the conversation.
39
40 From the plugin's POV:
41
42 * It's probably sitting in an XML::RPC loop.
43 * Get a command from ikiwiki.
44 * Call the appropriate callback.
45 * The callback can use XML::RPC to communicate with ikiwiki to get things
46   like config values; and to call ikiwiki functions.
47 * When the callback returns, use XML::RPC to send a "done" command to ikiwiki.