Friday, December 29, 2006

OSX browser war -ongoing update on what I like/dislike about the primary browsers I use..

Sad enough the default Safari browser has shortcomings so this post is my ongoing update on which browser I use and what I dis/like with them.

Currently my active browsers are Safari and Camino.



Safari

PROs
  • Built-in RSS reader. Yeah yeah - I know there are gazillion readers out there but I frankly have not found the right one yet. Its just "easier" to have this integrated and the bookmark show unread entries..dont have to start other app. Also like simple (for dummies) search, change days viewed, change amount of lines to display,etc


CONs:
  • RSS feed - I'd really like this to be plain XML docs in file system so I can take my RSS feeds with me if/when I switch to other apps. Over time RSS feeds have become part of my knowledgebase..
  • Too many webpages do not work well - seem that the Safari renedring engine has its quirks. Sites w trouble: Some of my financial sites (not disclosing details here - duh!), Zillow.com, more to be listed....
  • Blogger.com post editing doesnt work - no kind-of-wysiwyg interface





Camino
PROs:
  • Seem to be much faster than Safari in rendering.
  • Most sites work well - gecko engine seem to be broadly recognized.




CONs:
  • Copying part of a webpage (HTML) into an email (Mail.app) or doc (winword) lose almost all formatting. Here Safari works much better - Font sizes, links, bullets,etc are copied as in the webpage

Thursday, December 28, 2006

How to manage/change file extension and application lauch mapping

You will like run into scenario where you really wanted to have a different application launch when double clikcling a file in your Finder (or PathFinder). Windoze switchers addicts are used to have the Explorer tool where you can manage extention-2-application mapping.

OS X has a fancy system (see Launch Services) but the UI for managing this is very basic ( via Finder->GetInfo)

Luckily there are solutions out there - I have used the RCDefaultApp for a while and so far its been working well for me. As usual judge for yourself if it works for you.

For example - I used this to make sure showwave flash files that I received in email would open with my prefered browser at this time Camino.

Tuesday, December 12, 2006

Adding GoogleMaps lookup/directions to AddressBook

For those of us how want to use googlemaps instead of mapquest and/or want a 1-click "get me from home to address" do the following:

1) Go to http://farha.com/GMAP/ and download the two files at the bottom of that entry. rename the files fromk .txt to .scpt and copy into ~/Library/Address Book Plug-Ins/ (~ is your home folder for example niels)

2) If the above link does work then copy/paste the following into a textfile and save as per above


a) Map:
=============================
- Hacked from two scripts from MacOSXHints.com
-- http://www.macosxhints.com/article.php?story=20050208234638329

-- The code is a combination of the two scripts on that site,
-- plus the urlencode routine from the site below
-- I added a lot of comments to help me understand how this script works and how to make an Address Book plugin

-- First script: http://www.macosxhints.com/dlfiles/google_map_scpt.txt
-- Update script: http://homepage.mac.com/unixjunkie/.cv/unixjunkie/Public/Google%20Map%20Of.dmg.zip-link.zip
-- by UnixJunkie (http://www.unixjunkie.net/)

-- Second script: http://www.macosxhints.com/dlfiles/google_map_scpt2.txt
-- by miked378

-- Set the property for the Google Maps URL
property googleMaps : "http://maps.google.com/maps?q="

-- Set up Address Book
using terms from application "Address Book"

-- Tell Address Book to display this script when a ctrl-click is done on an address
on action property
return "address"
end action property

-- Tell Address Book to display the text below as the menu option
on action title for aPerson with anAddress
return "Get a Google Map for " & name of aPerson
end action title

-- Tell Address Book to enable this action
on should enable action for aPerson with anAddress
return true
end should enable action

-- Tell Address Book what to do when the script is selected
on perform action for aPerson with anAddress
showMap(street of anAddress, zip of anAddress, city of anAddress, state of anAddress, country code of anAddress)
end perform action

end using terms from

-- This is where the magic happens
on showMap(street, zip, city, state)

set addressURL to ""

if zip is missing value then
set addressURL to stripReturn(street) & ", " & city & ", " & state
else
set addressURL to stripReturn(street) & ", " & zip
end if

set addressURL to urlencode(addressURL)

try
-- tell application "Firefox"
-- OpenURL googleMaps & addressURL
tell application "Safari"
open location googleMaps & addressURL
activate
end tell

on error error_message
display dialog error_message buttons {"OK"} default button 1
end try

end showMap

-- Strip returns and everything after them
on stripReturn(itemName)

set returnChar to (ASCII character 10)

if itemName contains returnChar then
set AppleScript's text item delimiters to returnChar
set itemName to itemName's text items
set itemName to (the first item of itemName as string)
end if

set itemName to (itemName as string)

end stripReturn

-- urlencode is from:
-- http://harvey.nu/applescript_url_encode_routine.html
-- This safely encodes text so it can be used in a URL
on urlencode(theText)
set theTextEnc to ""
repeat with eachChar in characters of theText
set useChar to eachChar
set eachCharNum to ASCII number of eachChar
if eachCharNum = 32 then
set useChar to "+"
else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then
set firstDig to round (eachCharNum / 16) rounding down
set secondDig to eachCharNum mod 16
if firstDig > 9 then
set aNum to firstDig + 55
set firstDig to ASCII character aNum
end if
if secondDig > 9 then
set aNum to secondDig + 55
set secondDig to ASCII character aNum
end if
set numHex to ("%" & (firstDig as string) & (secondDig as string)) as string
set useChar to numHex
end if
set theTextEnc to theTextEnc & useChar as string
end repeat
return theTextEnc
end urlencode

b)Directions:
=================
-- Hacked from two scripts from MacOSXHints.com
-- http://www.macosxhints.com/article.php?story=20050208234638329

-- The code is a combination of the two scripts on that site,
-- plus the urlencode routine from the site below
-- I added a lot of comments to help me understand how this script works and how to make an Address Book plugin

-- First script: http://www.macosxhints.com/dlfiles/google_map_scpt.txt
-- Update script: http://homepage.mac.com/unixjunkie/.cv/unixjunkie/Public/Google%20Map%20Of.dmg.zip-link.zip
-- by UnixJunkie (http://www.unixjunkie.net/)

-- Second script: http://www.macosxhints.com/dlfiles/google_map_scpt2.txt
-- by miked378

-- Set the property for the Google Maps URL
property googleMaps : "http://maps.google.com/maps?q="

-- Set up Address Book
using terms from application "Address Book"

-- Tell Address Book to display this script when a ctrl-click is done on an address
on action property
return "address"
end action property

-- Tell Address Book to display the text below as the menu option
on action title for aPerson with anAddress
return "Get Google directions to " & name of aPerson
end action title

-- Tell Address Book to enable this action
on should enable action for aPerson with anAddress
return true
end should enable action

-- Tell Address Book what to do when the script is selected
on perform action for aPerson with anAddress
set myAddress to first address of my card
showMapDirections(street of myAddress, zip of myAddress, city of myAddress, state of myAddress, country code of myAddress, street of anAddress, zip of anAddress, city of anAddress, state of anAddress, country code of anAddress)
end perform action

end using terms from

-- This is where the magic happens
on showMapDirections(mystreet, myzip, mycity, mystate, mycc, tostreet, tozip, tocity, tostate, tocc)

set addressURL to ""

if myzip is missing value then
set addressURL to stripReturn(mystreet) & ", " & mycity & ", " & mystate
else
set addressURL to stripReturn(mystreet) & ", " & myzip
end if

set addressURL to addressURL & " to "

if tozip is missing value then
set addressURL to addressURL & stripReturn(tostreet) & ", " & tocity & ", " & tostate
else
set addressURL to addressURL & stripReturn(tostreet) & ", " & tozip
end if

set addressURL to urlencode(addressURL)

try
--tell application "Firefox"
-- OpenURL googleMaps & addressURL
tell application "Safari"
open location googleMaps & addressURL
activate
end tell

on error error_message
display dialog error_message buttons {"OK"} default button 1
end try

end showMapDirections

-- Strip returns and everything after them
on stripReturn(itemName)

set returnChar to (ASCII character 10)

if itemName contains returnChar then
set AppleScript's text item delimiters to returnChar
set itemName to itemName's text items
set itemName to (the first item of itemName as string)
end if

set itemName to (itemName as string)

end stripReturn

-- urlencode is from:
-- http://harvey.nu/applescript_url_encode_routine.html
-- This safely encodes text so it can be used in a URL
on urlencode(theText)
set theTextEnc to ""
repeat with eachChar in characters of theText
set useChar to eachChar
set eachCharNum to ASCII number of eachChar
if eachCharNum = 32 then
set useChar to "+"
else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then
set firstDig to round (eachCharNum / 16) rounding down
set secondDig to eachCharNum mod 16
if firstDig > 9 then
set aNum to firstDig + 55
set firstDig to ASCII character aNum
end if
if secondDig > 9 then
set aNum to secondDig + 55
set secondDig to ASCII character aNum
end if
set numHex to ("%" & (firstDig as string) & (secondDig as string)) as string
set useChar to numHex
end if
set theTextEnc to theTextEnc & useChar as string
end repeat
return theTextEnc
end urlencode