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


Click here to return to the 'An AppleScript to publish Address Book as HTML' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to publish Address Book as HTML
Authored by: Lou Kash on May 20, '05 07:28:57AM
Thanks for the script.
A couple of comments:

  • The download link is still broken, it will download an "obscure" HTML file in Safari. You may want to zip the .scpt file before you post it to your web site.
  • I have also tried the other solutions suggested in the comments above. In fact, your script was the only one that really worked for me. The other solutions didn't output any useful results.
  • My Address Book has about 250 entries, many of them use either German umlauts or Central European (Czech) characters. If your script is used unmodified, the HTML files are wrongly encoded when viewed in a browser. Since the meta tag is missing, it's possible to change the encoding manually in web browser; in Safari I got the desired result by changing the encoding to "Central European (Mac OS)".
  • I have then modified your script to include the charset meta tag into each output file. For me the following tag works fine:
    <meta http-equiv="content-type" content="text/html; charset=x-mac-ce">

    The relevant parts of your script now look like this:
    tell application "Address Book"
    	set indexFile to my blankFile("index.html")
    	my out("<html><head>", indexFile)
    	my out("<title>Address Book</title>", indexFile)
    	my out("<meta http-equiv=\"content-type\" content=\"text/html; charset=x-mac-ce\">", indexFile)
    	my out("</head><body>", indexFile)
    	my out("<h1>Address Book</h1>", indexFile)
    	my out("Click on a name below for address book information:<br><ul>", indexFile)
    
    and
    		set thisPage to my blankFile(x & ".html")
    		my out("<html><head>", thisPage)
    		my out("<title>" & theName & "</title>", thisPage)
    		my out("<meta http-equiv=\"content-type\" content=\"text/html; charset=x-mac-ce\">", thisPage)
    		my out("</head><body>", thisPage)
    		my out("<center><table cellpadding=3>", thisPage)
    		my out("<tr><td colspan=2>", thisPage)
    
    Of course, depending on characters you might use in your address book, the charset may vary.

    The best solution for a browser view is, however, to encode all non-ASCII characters to HTML entities. This works well if I open an HTML output file in a text editor and use the UnicodeChecker's service "Unicode to HTML entities preserving ASCII".
    Unfortunatelly I'm not that skilled with AppleScript to figure out quickly how to automate that process using UnicodeChecker, but I can see in its AppleScript dictionary that it should be possible.

    [ Reply to This | # ]