| filsa.net: Frontier Scripting [ Script Archive | Ideas & Issues | Polyglot | Software | Projects ] |
|
|
Binary Objects in Your WebsiteFrontier needs to learn how to render binary objectsFri, Jul 17, 1998 at 0:48:14 PMIn the past few days there's been lots of discussion about how to handle media objects that are not images, inside of a website. Here's my take on this. Why render binary objects?
Two paths There are two ways to go One way is to duplicate the imageRef and #images structure, but make it more general, so that it will handle any kind of object. This could be done with a huge 'mediaRef' macro. While that approach has advantages, it requires people to change to the 'Frontier-way'. I believe another approach comes closer to how many people already handle their websites. That's what I'd like to investigate here. This second way involves modifying the renderer. Modifying the Renderer Changing the renderer to handle binary objects was relatively easy. I wrote new routines for importing binaries, with smart namespace protections (movie.html and movie.mov don't overwrite each other). And I modified html.commands.releaserenderedPage to check the type of the object--if it is a binary object, it goes to a new script, renderBinaryObject.
Allow smart importing of binaries Binaries should be allowed to be imported anywhere in a website. During importing, the binaryType gets set to the binary object's file suffix. For example, the binary object manual.pdf would have the binarytype of 'pdf '. If there is a namespace conflict during the import, the new binary object has an underbar plus the binarytype attached to its name. For example, if we imported an item called manual.swf, and it conflicted with another object named 'manual', it would be renamed to 'manual_swf', with it's binary type set to 'swf '. Rendering the binary object When an object is rendered, the first thing we check is the type. If it is a binary type it gets sent to releaseBinaryObject. Although I haven't implemented it, at this point the binary object should be registered in the glossary (or perhaps a special glossary?) so that it can be referenced relatively. The actual releaseBinaryObject script determines the file suffix for the object based on it's binaryType. (It would be excellent to have a new type of binaryObject that would allow one to set a MIMEtype.) In my script this is done via a case statement, but ideally there would be a lookup table. A pagetable is created so that we can calculate URL's and find out where to write the object to. The filename is calculated, allowing for overlapping namespace (which we handled in the import), and then the file gets written out. Source for Release Binary Object. An example I had to deal with mixed media (mostly Java, Javascript, and Flash files) when working on the AsiaSociety.org site. Here's what part of the original site looked like:
and then what it looked like after custom importing into Frontier:
Finally, after rendering with the new binary script:
Comments to phil@filsa.net or the community list! |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This is Phil's Frontier Scripting Site. San Francisco, CA |
| filsa.net: Frontier Scripting [ Script Archive | Ideas & Issues | Polyglot | Software | Projects ] |