One cute hack for MacOS X (... or nice internet protocol helper hacks...)
Andre Garzia
soapdog at mac.com
Tue Jan 3 00:21:21 EST 2006
Hi Folks,
this email is about a little nice hack I made today. Here I present
the steps for making URLs like:
x-dreamcard://www.mysweetserver/mySweetStack.rev
Open inside Revolution app, even when inserted inside HTML files
rendered by Safari or the like. So this is about Registering a new
protocol and protocol helper application in MacOS X. When you type a
URL in MacOS X, for example:
http://www.runrev.com
The system first try to recognize the HTTP protocol, if it does, then
it looks for an app that can handle this kind of protocol, in my case
Safari, then it passes an AppleEvent GURLGURL with the URL for the
application. So we can create a new protocol called x-dreamcard and
associate it with Revolution, this way, when the user access a URL
that uses x-dreamcard as the protocol, Revolution will receive the
GURLGURL AppleEvent with the URL. I named the protocol x-dreamcard
here for some reasons, first it's advised by many groups of very
important IETF members that all protocols that are not approved by
IETF (this experimental) be prefixed with an X and a dash. I also was
trying to open the URL in the Dreamcard Player but since the player
and Rev shares the same creator codes, my system finds that Rev is
the default application for REVO creator code.
We can associate creator codes with protocols using something called
LaunchServices (new MacOS X thingy), or you can use some tool like
MoreInternet (http://www.monkeyfood.com/software/moreinternet/). So
the steps are:
(1) Download moreInternet.
(2) Use it to add x-dreamcard protocol and associate it with Rev.
This takes care of the Operating System part, now onto Rev.
Revolution does not deal with GURL AppleEvents by default so what we
do is write a little plugin that is loaded as backscript on startup,
this script traps all AppleEvents looking for a GURL, if it receives
it, the it loads the file, the script I use is below:
on appleEvent pClass,pID,pSender
if pClass is "GURL" and pID is "GURL" then
request appleEvent data -- get the content of the AppleEvent
replace "x-dreamcard" with "http" in it
go stack URL it
end if
pass appleEvent
end appleevent
We need to replace the x-dreamcard protocol in the AppleEvent data
because this protocol don't actually exists, it's just a little tag
to tell the system: "Hey load this stuff on Revolution!"
What can you do with things such as this? Well, you can create
educational resources as HTML and create little demo stacks, when the
user clicks on the demo stack links inside the HTML, the app will
load on demand inside Revolution (or Dreamcard player, whichever is
available, you could even create your own loader using splash
techniques), which would be a very easy student user experience.
I created this to see if I could, it involves lots of customizations,
quick ones, but some effort, maybe someone might do clever things
with it, I just wanted to share.
Cheers
andre
More information about the use-livecode
mailing list