ifpress.org - I7 Extensions and JavaScript

So I’m working an some infrastructure spike for ifpress.org and wanted to see if anyone had an opinion on it.

When we create “channels” in an I7 extention, they are identified as four byte keys, like “MAIN” or “LOCN”. For ifpress I’m mapping these things to content types, like “main” or “location-name”. I expect each extension that adds content to implement this mapping within the extension as a JSON object like below:

{
  mappings: [
    { channel: 'MAIN', contentType: 'main' },
    { channel: 'PRPT', contentType: 'prompt' },
    { channel: 'LOCN', contentType: 'location-name' },
    { channel: 'SCOR', contentType: 'score' },
    { channel: 'TIME', contentType: 'time' },
    { channel: 'DEAD', contentType: 'death' },
    { channel: 'ENDG', contentType: 'end-game' },
    { channel: 'TURN', contentType: 'turn' },
    { channel: 'INFO', contentType: 'story-info' },
    { channel: 'NTFY', contentType: 'score-notify' }
  ]
}

The issue is that some content will be more complex and not a simple value. It may be JSON or XML or whatever the extension author decides, but then expects the data to be loaded/processed into the web application appropriately.

I expect the scope or DOM to understand document.ifpress.location-name as the LOCN channel data and document.ifpress.storyinfo.title, document.ifpress.storyinfo.authors, document.ifpress.storyinfo.i7version, etc. as valid DOM values after the extensions are all loaded.

So then after data is returned from the VM, it’s always in document.ifpress.

It would seem that I could enforce a rule for extension authors that they have to add a “when play begins” action that returns on a “LOAD” channel, the mappings of the associated I7 extension. That’s the easy part. But if there’s custom loading code, can I safely inject that from the extension?

So something like:

{
  mappings: [
    { channel: 'MAIN', contentType: 'main' },
    { channel: 'PRPT', contentType: 'prompt' },
    { channel: 'LOCN', contentType: 'location-name' },
    { channel: 'SCOR', contentType: 'score' },
    { channel: 'TIME', contentType: 'time' },
    { channel: 'DEAD', contentType: 'death' },
    { channel: 'ENDG', contentType: 'end-game' },
    { channel: 'TURN', contentType: 'turn' },
    { channel: 'INFO', contentType: 'story-info' },
    { channel: 'NTFY', contentType: 'score-notify' }
  ],
  loader: function() { ... handles loading data into DOM ... }
}

And if the loader is missing or empty, we know we can simply load those channels as direct DOM variables on document.ifpress.

Does this make sense?

David C.
ifpress.org/plover.net/~dave/blog