On Browser Protocols...
On Browser Protocols...
- Subject: On Browser Protocols...
- From: Peter Bunn <email@hidden>
- Date: Fri, 24 Jan 2003 13:50:06 -0600
On Browser Protocols...
In my last post here, I extolled the virtues of my oft-mentioned project
'Missing Link'. Over the past few months (read: years), I've tried hard
to make Missing Link portable and readily usable, but in recent efforts
to promote the scheme (read: scam), it appears I've failed quite
convincingly.
Missing Link had grown top heavy with features intended to entice
AppleScript-innocent users. The added niceties only introduced
additional portability problems.
I've lost patience trying to make ML tidy, universal and run-only... and
found I couldn't abide the promotion process anyway... so I offer some of
the 'nuggets' here in open code.
In simplest form, the idea is this:
Using a unique browser protocol or helper, one can open, run or launch
almost any item in the Finder from a local HTML link such as -
A HREF="Protocol:Macintosh HD/Folder 1/Folder 2/File"
See Example 1 below.
The same script can be used to pass not only file paths, but additional
parameters or commands from link to script in the form -
A HREF="Protocol:Disk Name/Folder/the file-run-20030119"
Example 2 is a droplet that provides a quick and dirty way of writing a
simple link for almost anything on disk... for test purposes, if nothing
more. Hyphen-delimited comments added to the Finder's standard 'Get
Info' window are passed to the link as parameters.
In order to work properly, Example 1 requires that the script be saved as
stay open ("Never show startup screen"), given a unique creator type and
entered as a protocol (or helper app) in either the Internet control
panel or, in OS X, Explorer's preferences.
At least two other list/BBS members have been jumping up and down quietly
about the potential of browser protocols for some time. Despite my
failure to exploit the idea, I remain convinced of their utility.
Crafted correctly, they work cross-OS and cross-browser. Quite likely,
using VB, RealBasic or Revolution, they can be made cross-platform as
well.
And why bother? You tell me.
Once again, comments, corrections, test reports and even flames are - all
- most welcome. Some additional detail is provided at Missing Link's web
site (though little else has changed there as of this writing)...
http://www.mhtc.net/~bunnz/scriptlink.html
I will likely post these scripts and the 'added features' of Missing Link
there in open code soon. Over time, I would like to make the site a
repository for information regarding browser protocols and their use.
Suggestions and submissions are also welcome.
At this point, I hope that someone, somewhere might gain some use or
amusement from Missing Link. I have... at least in the 'discovery'
phase... but it gets a little lonely when no one else can make it work.
Stipulation and Disclaimer: If you use these scripts, you must try to
have fun with them and/or make constructive use of them, and/or inform
others of their availability. Failure to do so constitutes breach of
contract. If they work, don't hesitate to credit me. If they don't, it
ain't my fault.
Regards,
Peter B.
-----
"Free ! / Free ! / A Trip To Mars / For Nine Hundred / Empty Jars /
Burma-Shave"
"You can't spend what you ain't got... you can't lose what you ain't
never had." - Willy Dixon
--------------------
Example 1
on open location the_URL
try
set _Priors_ to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set the_amended_URL to text item 2 of the_URL as text
set AppleScript's text item delimiters to "-"
set param_count to count of text items of the_amended_URL
try
set _Parameters_ to {text items 2 through param_count} of
the_amended_URL as text
on error
set _Parameters_ to ""
end try
set file_URL to text item 1 of the_amended_URL as text
set AppleScript's text item delimiters to "/"
set linked_string to every text item of file_URL
set AppleScript's text item delimiters to ":"
set file_location to linked_string as string
if file_location contains " " then
set AppleScript's text item delimiters to " "
set amended_string to every text item of file_location
set AppleScript's text item delimiters to " "
set file_location to amended_string as string
end if
set AppleScript's text item delimiters to _Priors_
set _result_ to file_location & return & _Parameters_ & return
display dialog _result_
tell application "Finder"
activate
set the_file to ((the desktop) as text) & "the_file"
try
open for access file the_file with write permission
write _result_ to file the_file starting at eof
close access file the_file
on error
close access file the_file
end try
open file the_file
end tell
tell me to quit
on error
tell me to quit
end try
end open location
---------------------------------------------
Example 2
on open the_selection
try
tell application "Finder"
activate
repeat with This_Item in the_selection
if the kind of This_Item contains "alias" then
set This_Item to original item of This_Item
end if
set the_address to This_Item as string
set the_LinkName to the name of This_Item
try
set the_comment to the comment of This_Item
on error
set the_comment to ""
end try
set _Priors_ to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set the_list_string to every text item of the_address
set AppleScript's text item delimiters to "/"
set the_new_string to the_list_string as string
set AppleScript's text item delimiters to _Priors_
set the_HTML to "
<BR>
<A HREF=\"" & "Protocol:" & the_new_string & the_comment & "\">" &
the_LinkName & "</A>"
set the_link_file to ((the desktop) as text) & "Index.html"
try
open for access file the_link_file with write permission
write (the_HTML) to file the_link_file starting at eof
close access file the_link_file
on error
close access file the_link_file
end try
end repeat
end tell
on error
end try
end open
------------------------------------------------
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.