• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: URL wrapping [was: Re: Change Character]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: URL wrapping [was: Re: Change Character]


  • Subject: Re: URL wrapping [was: Re: Change Character]
  • From: Barry Wainwright <email@hidden>
  • Date: Mon, 06 Jun 2005 09:24:00 +0100
  • Thread-topic: URL wrapping [was: Re: Change Character]

On 6/6/05 02:27, "Gary (Lists)" <email@hidden> wrote:

> "David Marshall" wrote:
>
>>> Section related to 'Scope':
>>
>> http://tinyurl.com/9k4e9
>
> Well.  There you go.  Is that some kind of "sign up" deal?  (I tend to not
> "sign up" for anything except the Free Beer Give Away and the "Open a 5,000$
> Certificate of Deposit, Get a Free* Toaster".)
>
> Kidding aside, I'll check it out.   And thanks, David.
> --
> Gary


No, it's not a sign-up deal. And, this being the ApplescriptUsers list,
here's a script that will truncate the URL for you automagically (at least,
if you're using MS Entourage. Other users will be able to adopt the relevant
bits, I'm sure)...


-- Make TinyURL v1.0.1 (12th May 2004)
-- Barry Wainwright <mailto:email@hidden>
-- A script to make a TinyURL from selected text in a draft window
-- see http://tinyurl.com for details

-- Version History
-- v1.0.0  (27th April 2004) - First Release
-- v1.0.1 (12th May 2004) - Fixed a bug where selecting a URL
--            enclosed in braces caused an error in the resulting tinyURL.
-- v1.1 (11th February 2005) - used curl to get the tinyURL instead of URL
Access Scripting


property versionNumber : "1.1.0"

tell application "Microsoft Entourage"
    if class of window 1 is draft window or class of window 1 is draft news
window then
        set theurl to selection
    else
        display dialog "Message window not open - please select a URL in an
editable window and run the script again" buttons {"Stop"} default button 1
with icon 0
        return -99
    end if
end tell

if theurl is "" then
    display dialog "No text selected text - please select a URL and run the
script again" buttons {"Stop"} default button 1 with icon 0
    return -98
else if not (theurl starts with "<http://"; or theurl starts with "http://";)
then
    display dialog "Not a valid URL - the selected text must begin with
\"http://\""; buttons {"Stop"} default button 1 with icon 0
    return -97
end if

if theurl starts with "<" then set theurl to text 2 thru -1 of theurl
if theurl ends with ">" then set theurl to text 1 thru -2 of theurl

set tinyURL to text 8 thru -2 of (do shell script "curl -s
http://tinyurl.com/create.php?url="; & (quoted form of theurl) & " | awk
'/tinyurl value/ { print $NF }'")


tell application "Microsoft Entourage" to set selection to "<" & tinyURL &
">"

on errorroutine(theTarget)
    display dialog "TinyURL.com returned an unexpected result.
This could be because they have changed their website. Make sure you have a
proper URL selected and try again. If it keeps happening, please let me know
about it." buttons {"Tell Barry", "I'll Try Again"} default button 2
    if button returned of the result is "Tell Barry" then
        display dialog "Have you checked for updates to the script" buttons
{"Yes", "No"} default button 2 with icon note
        if button returned of the result is "No" then
            display dialog "Please check for an update before mailing me
directly!" buttons {"I'll Check"} default button 1
            return
        end if
        tell application "Microsoft Entourage" to make new draft window with
properties {subject:"TinyURL Script Problem", content:"I got a problem
making a TinyURL from the selected text '" & theTarget & "'" & return &
return & "Script Version: " & my versionNumber, to recipients:"Barry
Wainwright <email@hidden>", signature type:none}
    end if
end errorroutine


--
Barry



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: URL wrapping [was: Re: Change Character] (From: "Gary (Lists)" <email@hidden>)

  • Prev by Date: Fwd: Regex with Satimage
  • Next by Date: Re: Internet Connect, AirPort, and Tiger
  • Previous by thread: Re: URL wrapping [was: Re: Change Character]
  • Next by thread: Tiger: determining if a script is being run as an application
  • Index(es):
    • Date
    • Thread