How to Automate Pasting a Widget in iWeb

I've got the automator action that adds code for Google Analytics to all your iWeb pages. I'd like to do something something similar for HTML widget so that it would add code for ads and Amazon widgets. I thought I could open up the Google Analytics action and see how they do it, but XCode doesn't want to do that. Does anybody have any suggestions on how to get started doing this?

Thanks for any help, you can give.

2 GHz Intel Core 2 Duo, Mac OS X (10.5.6)

Posted on Jul 12, 2009 12:19 PM

Reply
5 replies

Jul 12, 2009 5:41 PM in response to Leo Raymaekers

What I'd like to do is take two snippets of code, one for a coffee ad, and the other for one of Amazon's widgets, and have an action paste the widget for coffee in a standard position (somewhere in the left margin), and the Amazon widget at the bottom, either in the footer, or just above it.

I've got one or two hundred pages, and I don't want to do it by hand.

Thanks for any help you can give.

Jul 13, 2009 9:03 AM in response to Thomas Hart1

Hello Thomas,

As far as I know there is no option/tool to do that inside iWeb.
(Ex : find & replace works only in 1 page)

There are some third-party applications that work alongside iWeb.
Ex with iWebBuddy you can enter code to be added to the header and/or the footer per Site.

For your situation, check out [TextWrangler|http://www.barebones.com/products/TextWrangler>.
It's great freeware. One of it's features is "mass" find&replace = you can apply find&replace to all files in a given folder/subfolders.

You do this on the published HTML files on your iDisk (or in the local folder if you publish to a Folder).

Adding code to the bottom is easy : you do a find for the HTML tag </body> and replace it with your_code </body> (so your code will be added above the </body> tag).

Adding code at a specific place in the body can also be easy IF at that place there is a unique string of code in all the pages that you can use for the Search.

If that is not the case, then in iWeb you'll have to enter (by hand) some unique find-code yourself.
Ex, at the location where you want the coffee add : create a textbox and type something like AAAAA.
(something that is unique in all pages), after publishing, you'll enter this AAAAA in the search field of TekstWrangler.

Now, the problem with editing the HTML files is that iWeb overwrites them when they are republished. (a page that was changed in iWeb)
So you'll have to do the whole process all over again.

Here comes the real power of TextWrangler : it fully supports Apple's AppleScript.
When you open TextWrangler, start with "record script", do your thing and when ready, save script.

Next time you need to add the coffe code to new or replublished pages : Run the script and have a coffee yourself 🙂

On my Blog about adding [Favicons|http://www.site49.eu/Leo/Tips4Mac/Entries/2009/2/15_Favicons.html|Add favicons to iWeb websites] you can find some screen shots on how this mass find&replace works in TextWrangler.

Kind regards,
Leo

Jul 15, 2009 9:23 AM in response to Leo Raymaekers

Leo,

I did a little experimenting, and what iWeb does when you add an HTML snippet for an Amazon widget, or my coffee ad, is generate a bunch of HTML code that handles positioning, and other stuff. The Automator action that adds the code for Google Analytics, simply adds text at the bottom. So I can't use a TextWrangler to simply add the code snippet, otherwise all the extra code won't generate, and I can't adapt the Google Analytics action to add the widgets throughout the site.

Thanks for the suggestion though.

Tom Hart

Jul 15, 2009 1:37 PM in response to Thomas Hart1

Hello Tom,

Yes, indeed the HTML snippet generates location specific code.
You would need to include this in the TextWrangler replace code.
A work around is the use of the textbox with AAAAA. I leave the textbox to specify the location and only replace the AAAAA with the code.

I already used TextWrangel to add Google Analytics code, Favicon code,... so it became my preferred tool for post- publish editing.

Kind regards,
Leo

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to Automate Pasting a Widget in iWeb

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.