Smallest-Federated-Wiki
Smallest-Federated-Wiki copied to clipboard
"hooks" in SFW?
In #348 Ward kindly pointed me to a script I can use to generate a "global" recent changes page. The docs suggest to invoke the "script at your convenience or add a line to cron".
To me the most convenient way would be to be able to hook into the SFW somehow. In this particular case, I'd like to run the script whenever any page is modified. Presumably I could just dig into the code and find the place where that happens and add a system call. But perhaps there is some other more elegant extensions mechanism?
We are inching towards elegance.
We've shown that we can establish independent socket connections between client and server, over the same port even. The logwatch plugin does this by connecting to a single-purpose hook in the server and receiving page view events as they happen. See source.. Thanks to @hallahan for this.
You will see a few lines above the logwatch hook where we mention the goal of replacing them with a more general plugin approach. Thanks to @nrn for help here. The ideal would be an even more strongly event-driven server with fit for purpose plugins that could broadcast appropriately aggregated and filtered streams to clients.
My own work reaches out past the server to the management of long-running data processing processes under close supervision of the client. This is in support of lab.fed.wiki.org where customized c code parsers are generated on the fly and they stream back parse statistics as they run.
How about the case of relatively simpler server-side plugins/hooks?
Um, you put some javascript in a file and it runs it? I'm not sure what you're asking for?
Caveat: programming-wise I am coming from an Emacs and Drupal background -- two places where hooks rule (as explained at those links... and especially for Drupal). If the right way to extend RoR/SFW is not via hooks, that's OK with me - the question is just a matter of feeling my way around a bit (as someone with no RoR experience).
Ah, we are talking about the same thing. There is one server-side hook: server.js
. If you put that in a plugin then it will be loaded and the function startServer(app)
will be called. App is an object containing the Express application server. This is a wide interface with a large attack surface. We'll narrow that as we learn more about how this hook can be useful.