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


Click here to return to the 'Automatically send a TinyURL from Safari via Mail.app' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically send a TinyURL from Safari via Mail.app
Authored by: jaysoffian on Feb 11, '05 09:16:42AM

Two things:

  1. You can use http://tinyurl.com/api-create.php?url= as your URL and you get back just the tinyurl, so you can simplify your script quite a bit.

  2. This seemed like a good excuse to learn some more Cocoa, so I wrote a TinyURL Service. You can download it here:

    http://www.soffian.org/downloads/TinyURLService.service.zip

    Download it and place TinyURLService.service under ~/Library/Services and then logout/login. You can then select a URL in an editable text field and select Services -> TinyURL (command-shift-2) and it will get replaced with a tinyurl. Also, if you select a tinyurl, it will get replaced with the long form.

    Source code is available for the curious.

j.



[ Reply to This | # ]
Automatically send a TinyURL from Safari via Mail.app
Authored by: jaysoffian on Feb 11, '05 03:01:22PM
And here's a simplfied version:

-- get the url
tell application "Safari"
	set bigURL to the URL of document 1
	set theTitle to the name of document 1
end tell

-- build the command for curl...quoting the url
set curlCMD to ¬
	"curl --stderr /dev/null \"http://tinyurl.com/api-create.php?url=" & bigURL & "\""

-- run the script and get the result
set tinyURL to do shell script curlCMD

-- pass the value to Mail and put it in the body
tell application "Mail"
	activate
	set this_message to make new outgoing message with properties ¬
		{visible:true, subject:theTitle, content:(return & theTitle & ":" & return & tinyURL & return & return)}
end tell


[ Reply to This | # ]