Posted on Mon - November 28, 2005

NeoWayland dot Net


I use NeoWayland dot Net as sort of a central directory. I use a redirect service to direct people to the actual page which lives on my iDisk.

This script puts an updated page in the right place on my iDisk. It's nothing spectacular, but it does illustrate a couple of things that I think are important. First I like my scripts to be editable so I can change them and tweak them as I like. And that raises the second issue, how do you get around embedding your username and password in an open script?

The solution is actually pretty simple, have the script call an alias instead of the actual iDisk. That way it hands off the security to the OS. The first time the alias is used, your Keychain opens and it will want the username and password. After that it is simple.

Let's go through this step by step. First see if the iDisk is mounted. If not, the computer mounts it. The delay is necessary even on a fast connection. It might need to be increased for dialup.
tell application "Finder"
set iDisk to 0
if disk "neowayland" exists then
set iDisk to 1
else
open file "Users:neo:Sites:neowaylanddotnet:disk of i"
delay
if disk "neowayland" exists then
set iDisk to 1
else
say "i disk not available"
end if
end if

Next, if the iDisk is mounted, it deletes the existing web page file. This is actually the fastest way I have found to delete files on your iDisk.
if iDisk > 0 then
if file "index.html" of folder "Sites" of disk "neowayland" exists then
delete file "index.html" of folder "Sites" of disk "neowayland"
else
say "website is missing"
end if

Then it is a simple copy. The funky URL is one of the internals from the page itself. In this case it brings up the NeoWayland NetWork part of the link directory.
duplicate file "Users:neo:Sites:neowaylanddotnet:index.html" to folder "Sites" of disk "neowayland"
say "nee owayland dot net is ready"
if process "Safari" exists then
tell application "Safari"
open location "http://homepage.mac.com/neowayland/#NWNW"
end tell
end if
else
say "not even. You aren't networked"
end if
end tell

And here is the whole script in one block.
tell application "Finder"
set iDisk to 0
if disk "neowayland" exists then
set iDisk to 1
else
open file "Users:neo:Sites:neowaylanddotnet:disk of i"
delay
if disk "neowayland" exists then
set iDisk to 1
else
say "i disk not available"
end if
end if
if iDisk > 0 then
if file "index.html" of folder "Sites" of disk "neowayland" exists then
delete file "index.html" of folder "Sites" of disk "neowayland"
else
say "website is missing"
end if
duplicate file "Users:neo:Sites:neowaylanddotnet:index.html" to folder "Sites" of disk "neowayland"
say "nee owayland dot net is ready"
if process "Safari" exists then
tell application "Safari"
open location "http://homepage.mac.com/neowayland/#NWNW"
end tell
end if
else
say "not even. You aren't networked"
end if
end tell

www.teknopagan.com
       



teknologi
© 2005 - 2008 All Rights Reserved