10.4: Automatically upload published-to-folder iWeb sites

Aug 21, '06 07:30:05AM

Contributed by: pglock

My 10-year-old daughter is putting together her own simple website. The authoring tools and process need to be as simple as possible, and she's happy with the whole iLife package so iWeb seems to be the way to go. I have spare space on a linux webserver, so I don't want to use .Mac. As a result, I've been ftp'ing her files up to the server using Transmit.

I'm trying to avoid being 24x7 tech support, so I was looking for ways to automate the iWeb 'Publish to a Folder' export followed by the FTP transfer. I've used a combination of Automator (Transmit supports Automator actions) and AppleScript as a folder action to:

  1. Watch the username/Sites folder for added files
  2. Wait 20 seconds after files are changed to trigger the action
  3. Mirror the Sites folder via Transmit with the web server
  4. Delete the contents of the Sites folder after upload
Why delete the Sites content? Well, folder actions are only triggered on addition of new content at the root level, so they won't trigger on file changes or any changes to subfolders. Also, iWeb publishes the whole site each time, so the timestamps are all wrong for folder sync to work.

The AppleScript attached as the folder action is:

on adding folder items to this_folder after receiving added_items
  tell application "Path:to:Autmoator:action"
    open added_items
  end tell
  try
    tell application "Finder"
      try
        delete (every item of folder "Sites" of ¬
         folder "username" of folder "Users" of startup disk)
      end try
    end tell
  end try
end adding folder items to
The Automator action contains the FTP login, so I won't post it here, but I'll make a screenshot available on my own site. It's only a two-step workflow:
  1. Automator Library, Pause Action -- 20 seconds
  2. Transmit Library, Synchronize Files Action -- Sync Direction upload, Sync Method mirror.
This may be too specific as a general hint, but then again, it may help someone.

Comments (12)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20060817122512500