Thursday, July 12, 2007

Transclusion? Is that a real word?

People have been asking for Transclusion in their project pages for some time (bug 179537 and bug 157707). The idea of keeping wiki pages up to date versus maintaining static pages is very attractive, hence the explosion of wikis all over the 'net. It seems like a simple problem to solve: just get the page from the wiki, chop it up server-side and put it in the output HTML. That's one solution. There are a lot of ways pages could be included from one source into the other--but they're all complicated by a number of issues:
  1. wiki.eclipse.org and www.eclipse.org exist on the same physical servers
  2. wiki.eclipse.org and www.eclipse.org are not the same as far as a browser is concerned
  3. wiki content needs to pass through MediaWiki's parser in order to get turned into HTML
Here's why those matter:
  1. Because the pages exist on the same physical servers, web requests from one page to the other can end up in deadlocks and similar actions in the past have nearly brought us down as Apache threads get tied up one by one waiting on each other.
  2. A simple Javascript script solution is complicated by not being able to manipulate the DOM of objects from the wiki inside of pages on www.
  3. Loading wiki pages directly from the database into the project page would bypass the wiki's parser and be useless. Alas MediaWiki's parser is not easily accessed on its own.
So it sounds like an insurmountable problem. Well there are possibilities. I spent a bit of time today and put together a solution which accomplishes some of what people want from Transclusion at Eclipse.org. It's an all client-side solution that works in Javascript (tested in Firefox and IE6 only at the moment) using an IFrame to load the content. A PHP script lives in the wiki's web root at wiki.eclipse.org and does some magic on wiki pages to display only the parsed raw content. Inside the project's IFrame a stripped wiki page is displayed. In my opinion it's a pretty good solution except for the problem of correctly sizing the IFrame. You can't do it in Javascript because the security model prevents manipulation of the DOM inside the IFrame, which means you can't see how big the IFrame needs to be.

In any case, if you want to see what I've worked up check out the demo page at:
http://www.eclipse.org/phoenix/howto_transclude.php

This isn't a final solution as I wait for feedback on bug 157707 but it's a potential solution.

Labels: ,

1 Comments:

Anonymous Chris Aniszczyk (zx) said...

cool, I do agree that 'Transclusion' sounds stupid :D

2:13 PM  

Post a Comment

<< Home