filsa.net: Frontier Scripting [ Script Archive | Ideas & Issues | Polyglot | Software | Projects ]

Binary Objects in Your Website

Frontier needs to learn how to render binary objects

Fri, Jul 17, 1998 at 0:48:14 PM

In 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?

  1. It's convenient to keep everything in the root. The day of keeping everything outside your root is, in my opinion, over. Cheap storage and faster networks are making this possible.

  2. On the web, there's no delineation between filetypes. Users don't see the difference between a text html file or a flash file or a pdf. For the most part (barring plug-in problems, it's all one experience for the user. And so it should be for the designer/site administrator as well.

  3. I want Frontier to keep track of those files, not me. Tracking downloads by hand is no fun. If I'm keeping downloadable files on my site, I want them in my root as well, so Frontier can write them out automagically when needed.

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.

  1. Allow smart importing of binaries.
  2. Render Binary Object.

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!

Ideas & Issues
Site Outline

I&I Home
1998
  05
  Improving Javascript Support
  Featuring suites.jsl: A pageheader script for the <SCRIPT> tag.
  06
  Character Entities
  Make working with HTML character entities easy.
  Copy Address
  FileWriters Questions
  Ideas for discussion
  Navigating the ODB
  Making it easier to get around in Frontier
  Suite Info
  If you write suites, tell your users about yourself!
  07
  Binary Objects in Your Website
  Frontier needs to learn how to render binary objects
  Creating META tags
  How can I put <meta> tags into my Frontier web pages?
  Filemaker and Frontier
  Where can I find resources for scripting Filemaker with Frontier?
  Frontier Mailing Lists
  More signal, less noise
  08
  Comments on Fat Pages
  Good fatpage, bad fatpage
  Quiet Advances
  Userland continues to crank out new features, bug fixes.
  Render Table Memory Issues
  An easy fix to a problem with rendering huge websites
  12
  Rendering out to more than one server
  Filewriters should be able to see the adrPageTable

   
Back to I&I Home   >>  

Back to
the top

This is Phil's Frontier Scripting Site. San Francisco, CA
Copyright © 1996-98, Phil Suh. All Rights Reserved.
http://www.filsa.net/frontier/ii/1998/07/websiteBinaries.html
This page last built on 6/28/99; 11:08:01 PM

filsa.net: Frontier Scripting [ Script Archive | Ideas & Issues | Polyglot | Software | Projects ]