Difference between revisions of "Livelets"
(SWF's XMLSocket is not a true listener either) |
m (Caretaker: headings) |
||
Line 3: | Line 3: | ||
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. | 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 = | |
*Add the parser function and internal hook | *Add the parser function and internal hook | ||
*Add the "live" action | *Add the "live" action | ||
Line 10: | Line 10: | ||
*Add the JS headscripts | *Add the JS headscripts | ||
− | + | = Parser Function = | |
Converts the syntax to tag-hook along with the parameters | Converts the syntax to tag-hook along with the parameters | ||
− | + | = Internal Tag Hook = | |
There's no HTML content because the parser-function does 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. | There's no HTML content because the parser-function does 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. | 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). | 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. | 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: | 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 recieve incoming data from servers in the same domain the SWF was served from | ||
Line 32: | Line 32: | ||
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....? | 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....? | ||
− | + | = 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. | *'''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. | *'''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. | *'''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... | *'''Channels:''' having live content opens up the whole channel aspect... |
Revision as of 18:21, 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
- 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 does 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....?
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...