Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Automatically upload published-to-folder iWeb sites Apps
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.
    •    
  • Currently 1.75 / 5
  You rated: 2 / 5 (4 votes cast)
 
[27,613 views]  

10.4: Automatically upload published-to-folder iWeb sites | 12 comments | Create New Account
Click here to return to the '10.4: Automatically upload published-to-folder iWeb sites' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Automatically upload published-to-folder iWeb sites
Authored by: DJMac317 on Aug 21, '06 09:10:05AM

This hint works pretty well, until you have multiple iWeb sites in the same file. For instance, I have one that is for my software, one that is for my family pics and one for my podcasts. After this script adds the one site to the folder, the upload begins and doesn't wait for the others to finish being published.

What I did is take the deletion of items from the Finder part of the script and added an applescript action to the end of the workflow in Automator that then deletes the files after the upload has completed.

The other part of not waiting for all the sites to be added to the folder before the upload, I solved that by just upping the pause workflow action to 400 seconds, giving iWeb enough time to publish all the sites.

Also instead of making the script shown in this hint the folder action, I was able to save the workflow as a folder action and connect it directly to the folder within Automator.

Great hint, saving a lot of time, thanks.



[ Reply to This | # ]
10.4: Automatically upload published-to-folder iWeb sites
Authored by: adrianm on Aug 21, '06 10:31:49AM

Prob worth making a very large flashing comment that it will wipe out your Sites folder when you run it. That may not be what the user wants.



[ Reply to This | # ]
10.4: Automatically upload published-to-folder iWeb sites
Authored by: tocoolcjs on Aug 21, '06 10:44:02AM

I must say: this is fine for simple websites. But if you plan on making a podcast or vidcast, this could end up being very slow. Unfortunately, iWeb always replaces old files when saving to folder. Thus one can't use a simple date created check. I think I once set up a script that loaded the ftp server via the finder, and then only uploaded files that were new or that "diff" (unix) said were different.



[ Reply to This | # ]
10.4: Automatically upload published-to-folder iWeb sites
Authored by: jtratcliff on Aug 21, '06 01:12:20PM
Why not just use a rsync to synchronize the Mac's Sites folderwith the linux box?

No need to delete anything since rsync only syncs stuff that has changed. Plus you get the bonus of being able to do it via ssh, so your passwords are not sent in the clear. And if you set up public/private keys, you won't need a password at all...

Here's a rough outline of the steps to take... the ssh details can be found in any ssh tutorial, and the rsync man page is fairly useful too:

  1. on the Linux box, make sure sshd is running and that the /etc/sshd_config file has "PubkeyAuthentication yes" in it (I think it is, by default)
  2. on the mac run, ssh-keygen as the user who will be transfering files, for instance...

    % ssh-keygen -b 1024 -t dsa

    to create a 1024 bit DSA public/private key pair

  3. copy the public key ( ~/.ssh/id_dsa.pub) from the mac into the ~/.ssh/authorized_keys file on the linux box
  4. make sure it works by ssh-ing or sftp-ing from the mac to the linux box
  5. once it works, test out mac -> linux rsync-ing of files, e.g.:

    rsync -e ssh -az ~/Sites/ UserID@linuxbox.domain:/path/to/webspace/.

  6. one you get that working as you like, wrap it in a cron job, applescript, automator action, or whatever you like....

    [ Reply to This | # ]
10.4: Automatically upload published-to-folder iWeb sites
Authored by: pglock on Aug 22, '06 06:17:09AM

This prompts me to add: Transmit also has the ability to only upload changed files, choose 'Synchronize' rather than 'Mirror' in the Automator action. The downside of this is that any pages or content you remove in iWeb will remain on the web server.

P.S. Even though the 'Site' folder is wiped each time, the iWeb documents remain in your documents folder so you don't lose them as one comment seemed to suggest.

---
Too lazy to think of an original signoff...



[ Reply to This | # ]
10.4: Automatically upload published-to-folder iWeb sites
Authored by: jtratcliff on Aug 22, '06 01:14:39PM

I don't know about Transmit but rsync has a "--delete" option that will remove anything at the destination that doesn't exist on the host...

% rsync -az --delete -e ssh Source User@destination/path/to/desired/location



[ Reply to This | # ]
10.4: Automatically upload published-to-folder iWeb sites
Authored by: jakecigar on Aug 21, '06 01:19:48PM

Great suggestion... took a bit of programming!

I simply use the rsync command, it works for multiple sites, partial sites, only doing the changed files, and it can use SFTP for secure transfers, and it requires no additional software.

I bet that's what our friends at apple use for .mac



[ Reply to This | # ]
10.4: Automatically upload published-to-folder iWeb sites
Authored by: pglock on Sep 25, '06 04:12:08AM

An update: I've played around a bit since writing this hint. I tried the rsync suggestions, especially as it is one of my favourite command line tools for automation of backup (via launchd using lingon ) but:

  • I don't have the option of installing certs on a number of the hosted servers that my family and friends use for their public websites
  • As I'm back to userid/password for authentication, it means keeping track of user credentials in one more place (rather than just keeping the Transmit 'favourite' up to date)
  • I worked out a more efficient way of triggering the folder action (read on for more...)
  • I've modified the process so that iWeb places a dummy file in the root of the site folder to be mirrored, then this file is deleted after the Transmit process completes. That way it's no longer necessary to delete the entire contents of the site folder and recreate each time iWeb publishes.

    There's a full write up on my personal website

    ---
    Too lazy to think of an original signoff...

    [ Reply to This | # ]

    10.4: Automatically upload published-to-folder iWeb sites
    Authored by: yubbie2 on Aug 21, '06 08:03:25PM

    NOTE: Typo spelling "AUTOMATOR" on the 2nd line of the code. Beware copy & pasters! :-)



    [ Reply to This | # ]
    10.4: Automatically upload published-to-folder iWeb sites
    Authored by: fredrikw on Oct 05, '06 03:01:00PM
    I have made a small program to help my brother to update his site from iWeb. You give it a local folder and a remote one (on an ftp-server) and when you choose "Upload" it checks the checksum of all local files and compares those to a database. Changed files gets uploaded. The first time you run the program it will upload everything though. If you would like to try it, you can find it at http://www.wallner.nu/fredrik/software/w2w/

    /Fredrik

    [ Reply to This | # ]
    10.4: Automatically upload published-to-folder iWeb sites
    Authored by: fredrikw on Oct 07, '06 08:52:53PM

    Apparently, I had forgotten to add a download link on the web page. It's now corrected...



    [ Reply to This | # ]
    10.4: Automatically upload published-to-folder iWeb sites
    Authored by: fredrikw on Nov 03, '06 12:50:33PM
    I have now updated w2w to solve an issue with large directory structures. If the last version didn't work for you, please take a look at this one.

    /Fredrik

    [ Reply to This | # ]