(* Written by © Mark Hunte - 2006 Instructions can be found here: http://www.macosxhints.com/article.php?story=20060126122633213 *) property New_dilog : "Enter Name for Project" property New_dilo : "Enter Name for Project" property AppSupp_folder : path to application support from user domain set APpSuppFolderPosix to "~/Library/Application\\ Support/" set Domain_ to "iWeb" set folderlist to {} property Projects_folder : "iWeb_Projects" property the_doc_folder : path to documents folder from user domain as string property Domain_folder : "" property Stop_stop : true property dump_sym : true property thedom : "" property domPath : "" property Domain_ : "" property APpSuppFolderPosix : "" property appName : "" property starter : true try tell application "System Events" if exists (process "iWeb") then tell application "iWeb" set starter to true set appName to "iWeb" display dialog "" buttons {"Swap iWeb Project", "New Project", "Cancel"} default button 3 set the button_press to the button returned of the result end tell else tell application "Finder" set starter to false set appName to "Finder" display dialog "" buttons {"Swap iWeb Project", "New Project", "Cancel"} default button 3 set the button_press to the button returned of the result end tell end if end tell if the button_press is "Swap iWeb Project" and Stop_stop is true then my _quit_iWeb() set appName to "Finder" my change_proj() my _Start_iweb() else if the button_press is "New Project" and Stop_stop is true then my New(folderlist) my _quit_iWeb() set appName to "Finder" my change_proj_replace() my _Start_iweb() else end if on error error_message set New_dilog to "Enter Name for Project" end try on New(folderlist) tell application "Finder" set the_doc_folder to path to documents folder from user domain as string set Domain_folder to folder Projects_folder of folder the_doc_folder as alias end tell tell application appName display dialog New_dilog default answer "New_Project" buttons {"Ok", "Cancel"} default button 1 copy the result as list to {text_returned, button_pressed} set domPath to text_returned end tell if button_pressed is "Cancel" then set dump_sym to false end if if dump_sym is true then tell application "Finder" if not (exists folder text_returned of Domain_folder) then make new folder at Domain_folder with properties {name:text_returned} make new folder at folder text_returned of Domain_folder with properties {name:"iWeb"} set New_dilog to "Enter Name for Project" else if (exists folder text_returned of Domain_folder) then set New_dilog to "It Looks like you already have a folder called : " & return & return & ¬ text_returned & return & " Please try again or Cancel" & return & ¬ "Enter Name for Project" my New(folderlist) end if end if end tell else if dump_sym is false then end if end New on _Start_iweb() if starter is true then tell application "iWeb" activate end tell end if end _Start_iweb on _quit_iWeb() tell application "System Events" if exists (process "iWeb") then tell application "iWeb" to quit end if end tell end _quit_iWeb on change_proj() tell application "Finder" set biglist to {} set Projects_folder to "iWeb_Projects" set APpSuppFolderPosix to "~/Library/Application\\ Support/" --(get POSIX path of chosen) set Domain_folder to folder Projects_folder of folder the_doc_folder as string set Domain_ to "iWeb" set thecounter to 0 repeat count of (every item of folder Domain_folder whose (class is folder)) times set thecounter to thecounter + 1 copy displayed name of (item thecounter of folder Domain_folder whose (class is folder)) to end of biglist end repeat end tell tell application appName activate set domPath to choose from list biglist with prompt "Choose iWeb Project" OK button name "Choose" without multiple selections allowed and empty selection allowed end tell if domPath is not false then set domPath to domPath as string my check_symlink() my MoveSymlink(AppSupp_folder) set Domain_folder to (get POSIX path of Domain_folder) if dump_sym is true then set thedom to do shell script " echo " & Domain_folder & domPath & "/" & Domain_ & "/" & "" & "| sed 's/\\ /\\\\ /g'" do shell script "ln -s \\" & thedom & "/" & " " & APpSuppFolderPosix & "/" & Domain_ & "" set starter to true end if end if end change_proj on change_proj_replace() my check_symlink() my MoveSymlink(AppSupp_folder) set Domain_folder to (get POSIX path of Domain_folder) set thedom to do shell script " echo " & Domain_folder & domPath & "/" & Domain_ & "/" & "" & "| sed 's/\\ /\\\\ /g'" do shell script "ln -s \\" & thedom & "/" & " " & APpSuppFolderPosix & "/" & Domain_ & "" set starter to true end change_proj_replace on check_symlink() tell application "Finder" if exists folder Domain_ of folder AppSupp_folder then tell application "System Events" to tell application appName activate display dialog "The Current iWeb Folder is not a symlink" buttons {"Move & Name Project", "Send to Trash", "Cancel"} default button 3 set the button_press to the button returned of the result if button_press is "Cancel" then set Stop_stop to false else if button_press is "Move & Name Project" then my MoveNonSymlink() else if button_press is "Send to Trash" then tell application "Finder" move folder "iWeb" of AppSupp_folder to trash end tell end if end tell end if end tell end check_symlink on MoveNonSymlink() tell application "Finder" to set Domain_folder to folder Projects_folder of folder the_doc_folder as alias tell application "System Events" to tell application appName activate display dialog New_dilo default answer "Name " buttons {"Ok", "Cancel"} default button 1 copy the result as list to {text_return, button_pressed} end tell if button_pressed is "Cancel" then set Stop_stop to false else tell application "System Events" to tell application appName if not (exists folder text_return of Domain_folder) then tell application "Finder" make new folder at Domain_folder with properties {name:text_return} move folder "iWeb" of AppSupp_folder to folder text_return of Domain_folder end tell else if (exists folder text_return of Domain_folder) then set New_dilo to "It Looks like you already have a folder called : " & return & return & ¬ text_return & return & " Please try again or Cancel" & return & ¬ "Enter Name for Project" my MoveNonSymlink() end if end tell end if end MoveNonSymlink on MoveSymlink(AppSupp_folder) if dump_sym is true then tell application "Finder" if exists file "iWeb" of AppSupp_folder then move file "iWeb" of AppSupp_folder to trash end if end tell end if end MoveSymlink