Difference between revisions of "Livelets"
m |
m |
||
Line 15: | Line 15: | ||
= Internal Tag Hook = | = Internal Tag Hook = | ||
− | There's no HTML content because the parser-function | + | There's no HTML content because the parser-function doesn't actually do any transclusion, the info that arrives here is the artcile name and parameters. This hook returns the JavaScript container which makes a separate request for the content when it runs in the browser. The request uses the ''live'' action and passes the parameters used in the original parser-function transclude statement. |
= Live Action = | = Live Action = |
Revision as of 21:49, 29 March 2007
The idea of this extension is to allow live articles to be transcluded which update automatically on change in a non-polling, fully event-driven way. It will use the parser-functions syntax to make it very similar in usage to normal templates.
LiveTemplates.php
- Ensure the PERL socket server is running
- Add the parser function and internal hook
- Add the "live" action
- Add the AfterSaveComplete hook
- Insert the SWF into the page somewhere invisible but active
- Add the JS headscripts
Parser Function
Converts the syntax to tag-hook along with the parameters
Internal Tag Hook
There's no HTML content because the parser-function doesn't actually do any transclusion, the info that arrives here is the artcile name and parameters. This hook returns the JavaScript container which makes a separate request for the content when it runs in the browser. The request uses the live action and passes the parameters used in the original parser-function transclude statement.
Live Action
This does the actual Generating of the HTML for a live container. It would probably change the content AfterDatabaseFetch to a normal transclude with the parameters. It must also ensure that none of the HTML head, scripts, body or any skin components are sent, only the HTML of the rendered template itself.
AfterSaveComplete Hook
For now all clients with live templates could be notified on any article change. later we may want to maintain a tree of articles and their current subscribers (which must include articles changing inside transclusion structures of live templates).
JavaScript Functions
The JS can send HTTP requests itself with the XMLHTTPRequest object, but must rely on the SWF to call some kind of onData event handler function.
SWF Movie
Even the SWF XMLSocket is crippled in three main ways:
- It can only recieve incoming data from servers in the same domain the SWF was served from
- It can only use port number >1023
- Most importantly - it is not a true listener, it can only listen on streams it has already established with the server. A server cannot spontaneously request a new connection from the SWF socket.
This third item is very important, because it means that a permenantly running server must be present, so we may need to include a simple server daemon using the code from server.pl, unless PHP can somehow be used to do it....?
PERL Server
Although PHP has socket capability it seems that many users would not have the functionality easily available as it often requires PHP to be recompiled with the --enable-sockets switch. Also, the PHP server script would need to be set up to run as a daemon, and many PHP installs do not support command-line PHP by default. So it seems to me that a PERL server would be simplest to implement, especially since we already have working socket code in PERL, it's available by default on virtually all Linux's, and is easy to install on Win32 as well.
Rather than installing the daemon into init.d or as a service, the PHP script could check whether an instance is running and execute it if not so that the installation would then be no different than for most extensions, of putting the files into the extensions directory and ensuring they have the right permissions.
Examples & Usage Ideas
- Forms: Allowing forms to be submitted which can be posted to the server without reloading the page. Any items which may change are made into live templates.
- Caching: Normal templates which are used across many articles like those which include category links would be far more efficient when wrapped inside a live template.
- Collaboration: The edit form could be modified to post the form without reloading the page, and to have a live preview of the content which would make article editing much more chat-like.
- Channels: having live content opens up the whole channel aspect...