Jump to content


Photo

TinyURL Service


  • Please log in to reply
23 replies to this topic

#1 Sparks

Sparks

    Atlantis Author

  • Root Admin
  • PipPipPip
  • 1,791 posts
  • Gender:Female
  • Location:Seattle, WA
  • Interests:Cocoa, Obj-C, iPhone, horses, writing

Posted 03 April 2007 - 06:03 PM

NOTE: version 0.3 of this service is out. Notes here.

Okay, I put together a quicky little TinyURL system service. If installed, it adds a 'Shrink URL' option to the Mac OS X services menu. Select a URL in any editable field -- Mail.app, Atlantis' input window, whatever -- and go to the application menu, select Services, select Shrink URL. There'll be a momentary pause, and then the highlighted URL will be replaced with a TinyURL equivalent.

Useful for sending long URLs to someone over a game channel or page, or in an e-mail, or whatever. Uses the same TinyURL engine I wrote for the next Atlantis release (0.9.7.7); in 0.9.7.7, if you highlight a URL in the input window and right-click it, it will give you a 'Shrink URL' option. I figured I might as well wrap it into a simple little service and toss an installer out there, since I wanted to use this in Mail.app.

http://www.riverdark...isc/TinyURL.zip

Feel free to share it around; I may clean it up or add different shrinking engines (RubyURL et al) down the road. It should work on OS X 10.3.9 and higher on both PowerPC and Intel, though I will grant I have not tested it particularly extensively to be certain of that. Hence why it reports a version number of 0.1. wink.gif
Rachel "Sparks" Blackman
Riverdark Studios

#2 Sparks

Sparks

    Atlantis Author

  • Root Admin
  • PipPipPip
  • 1,791 posts
  • Gender:Female
  • Location:Seattle, WA
  • Interests:Cocoa, Obj-C, iPhone, horses, writing

Posted 03 April 2007 - 06:48 PM

Tossed the source for that little tool up at http://www.riverdark...TinyURL-src.zip -- consider it public domain for anyone who finds the guts useful. smile.gif
Rachel "Sparks" Blackman
Riverdark Studios

#3 bjbkk

bjbkk

    Member

  • Members
  • PipPip
  • 17 posts

Posted 04 April 2007 - 08:13 AM

Thanks, Sparks! Beats the heck out of my /tinyurl idea for Atlantis!

#4 CdtDelta

CdtDelta

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 04 April 2007 - 08:46 AM

I'm trying to understand how this utility is supposed to work outside of Atlantis. Is it limited to specific applications? I've highlighted URL's in both Firefox and Mail.app, and the service is always greyed out.
Is there an example of how this is supposed to work you could give? It's a great idea and I'd love to be able to use it.

Thanks,
CdtDelta

#5 bjbkk

bjbkk

    Member

  • Members
  • PipPip
  • 17 posts

Posted 04 April 2007 - 08:50 AM

I think it has something to do with incomplete urls. I highlighted "doman.com" and the option was greyed out, but I highlighted a full link in an email message and the service was available.

#6 Riashain

Riashain

    Advanced Member

  • Members
  • PipPipPip
  • 398 posts

Posted 04 April 2007 - 09:57 AM

Does it handle non www. or http:// addresses in Atlantis?

Most apps I've played with only recognize url's if they have http://, or at the least, the www.

#7 Sparks

Sparks

    Atlantis Author

  • Root Admin
  • PipPipPip
  • 1,791 posts
  • Gender:Female
  • Location:Seattle, WA
  • Interests:Cocoa, Obj-C, iPhone, horses, writing

Posted 04 April 2007 - 10:11 AM

It recognizes whatever can successfully be turned into a proper NSURL. Since it is a service that has output, it /will/ only work in editable text-fields, like any other output-generating service; any place OS X cannot get and paste a clipboard of string data, it will be greyed out.

Firefox, I'm not certain it will work with since they use their own non-OS X text engine and OS X has no way of knowing that yes, it can get some string data and paste it back, as Firefox text-fields aren't OS X responders at all. *goes to double check...* No, it -- and any other output-based service -- do not work in Firefox, I'm afraid. They do work in Camino, however, which plays nice with OS X accessibility and eventing.

It does work fine in Mail.app for me; Mail.app was the reason I wrote the service.

I grant I have not particularly tested this on Panther. Are you on Panther?
Rachel "Sparks" Blackman
Riverdark Studios

#8 Sparks

Sparks

    Atlantis Author

  • Root Admin
  • PipPipPip
  • 1,791 posts
  • Gender:Female
  • Location:Seattle, WA
  • Interests:Cocoa, Obj-C, iPhone, horses, writing

Posted 04 April 2007 - 10:43 AM

QUOTE (Riashain @ Apr 4 2007, 09:57 AM) <{POST_SNAPBACK}>
Does it handle non www. or http:// addresses in Atlantis?

Most apps I've played with only recognize url's if they have http://, or at the least, the www.


The Atlantis 'Shrink URL' option in 0.9.7.7 only works if NSURL can recognize it as a URL. It does, apparently, support websites with the 'http://' left off -- I just tested -- but that's a function more of NSURL than anything else.
Rachel "Sparks" Blackman
Riverdark Studios

#9 Riashain

Riashain

    Advanced Member

  • Members
  • PipPipPip
  • 398 posts

Posted 04 April 2007 - 10:51 AM

QUOTE (Sparks @ Apr 4 2007, 02:43 PM) <{POST_SNAPBACK}>
The Atlantis 'Shrink URL' option in 0.9.7.7 only works if NSURL can recognize it as a URL. It does, apparently, support websites with the 'http://' left off -- I just tested -- but that's a function more of NSURL than anything else.


I was just trying to theorize (without testing, because I'm smart like that) whether there would be a similar issue in Atlantis. Obviously you would've tested something like that already though, so ignore me biggrin.gif

#10 CdtDelta

CdtDelta

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 04 April 2007 - 12:08 PM

QUOTE (Sparks @ Apr 4 2007, 01:11 PM) <{POST_SNAPBACK}>
It does work fine in Mail.app for me; Mail.app was the reason I wrote the service.

I grant I have not particularly tested this on Panther. Are you on Panther?


No I'm on Tiger (10.4.9). So in Mail.app, you just highlight a URL (ex. http://www.somewhere.net) and then you can use the service? That's what I tried in Mail.app and it was still greyed out.

#11 Sparks

Sparks

    Atlantis Author

  • Root Admin
  • PipPipPip
  • 1,791 posts
  • Gender:Female
  • Location:Seattle, WA
  • Interests:Cocoa, Obj-C, iPhone, horses, writing

Posted 04 April 2007 - 02:31 PM

Yes. Weird... humor me, try it in TextEdit or something?

I wonder why Mail isn't working for you. Do you have any other services installed that /do/ show up in Mail? For instance, I can use the 'Search with Google' and 'Search with Spotlight' and so on services in Mail just fine.
Rachel "Sparks" Blackman
Riverdark Studios

#12 bjbkk

bjbkk

    Member

  • Members
  • PipPip
  • 17 posts

Posted 04 April 2007 - 02:33 PM

now, if I could only find a way to bind this to a hotkey....!

(ask and ye shall receive: http://www.manytrick...ervicescrubber/ )

#13 CdtDelta

CdtDelta

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 04 April 2007 - 03:17 PM

QUOTE (Sparks @ Apr 4 2007, 05:31 PM) <{POST_SNAPBACK}>
Yes. Weird... humor me, try it in TextEdit or something?

I wonder why Mail isn't working for you. Do you have any other services installed that /do/ show up in Mail? For instance, I can use the 'Search with Google' and 'Search with Spotlight' and so on services in Mail just fine.


Well, I actually tried it in Yojimbo with a bookmark I had in there, and it worked.

So let me ask this (back to the Mail.app thing), just to make sure I'm doing this right. Someone sends me an email, it has a URL in the body of the email. If I highlight that URL, I should be able to use the service yes or no?

#14 Sparks

Sparks

    Atlantis Author

  • Root Admin
  • PipPipPip
  • 1,791 posts
  • Gender:Female
  • Location:Seattle, WA
  • Interests:Cocoa, Obj-C, iPhone, horses, writing

Posted 04 April 2007 - 04:14 PM

Ah! Okay. No, because you cannot edit a mail you were /sent/; a received message is read-only, and the service needs a way to return the URL (which it does by replacing the URL in whatever the origin is). That's the standard way text-replacement services under Mac OS X work. smile.gif

It's for when you send a mail, you can take a URL and drop it in, paste a URL, whatever... and then highlight the URL in your outgoing message, and it turns it into a TinyURL. You could also use it directly in the browser address bar... highlight the URL, fire the service, copy the result and paste it into a mail message or an IM message or whatever. smile.gif
Rachel "Sparks" Blackman
Riverdark Studios

#15 gudrun45

gudrun45

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 05 April 2007 - 08:55 AM

I now have a tinyurl folder with seven items on my desktop. How do I install?

#16 Sparks

Sparks

    Atlantis Author

  • Root Admin
  • PipPipPip
  • 1,791 posts
  • Gender:Female
  • Location:Seattle, WA
  • Interests:Cocoa, Obj-C, iPhone, horses, writing

Posted 05 April 2007 - 09:02 AM

Er, you unzip it and you should have a 'TinyURL.pkg' bundle. You click the bundle, and it fires off Apple's generic Installer.app, as with any OS X .pkg. smile.gif

If you unzipped it with a non-Mac-OS-X-aware ZIP program, it may have unpacked the bundle directory as files.
Rachel "Sparks" Blackman
Riverdark Studios

#17 Macskeeball

Macskeeball

    Newbie

  • Members
  • Pip
  • 3 posts
  • Interests:Mac OS X and Linux<br />Web sites and podcasts<br />Cell phones and iPods<br />Photoshop and design<br />Home networking and security

Posted 05 April 2007 - 12:21 PM

I registered just to post this.

I like your service very much, especially because I can use Services with Quicksilver. I can definitely see myself using this. However, there are two problems with your installation implementation that I noticed due to a recent post by John Gruber on his "Daring Fireball" blog.

There are two standard ways for installing Mac software: drag-and-drop and Apple's Installer.app. The former is preferred, while the latter is used in the event that the software requires the use of multiple files stored in various places of the hard disk. Your software consists of a single bundle, and therefore you should really be using drag-and-drop installation, with instructions provided through a folder background image or a Read Me.

The second problem is that your installer places the software inside /System/Library. Generally speaking, third party party software has no business modifying the System folder in anyway (notable exceptions include kernel extensions, etc.). This isn't Mac OS Classic. The System folder is supposed to remain pure; items such as services really have no business in there. Third party software that modifies the system folder causes issues when users do an Archive & Install of the OS (which migrates everything over but /System).

In short, please use drag-and-drop. It keeps both installation and uninstallation simple, and gives the user the option to install for all users (/Library) or just their own account (~/Library). If for some reason you absolutely insist on using an installer, install in /Library/Services. Do not touch the System folder.

#18 Sparks

Sparks

    Atlantis Author

  • Root Admin
  • PipPipPip
  • 1,791 posts
  • Gender:Female
  • Location:Seattle, WA
  • Interests:Cocoa, Obj-C, iPhone, horses, writing

Posted 05 April 2007 - 12:32 PM

I originally had just the bundle around, and after the 8th 'but how do I install it' query in e-mail, I killed the readme/.service ZIP and tossed together an installer. I will admit I just used the 'service' template I found for Iceberg to whip up the installer... and to my chagrin, I didn't actually check whether the template put it in /Library or /System/Library. I just loaded template, filled out forms, dropped bundle in, and packaged. Oops.

(Plus, I thought as long as I'd make an installer to save myself time, I'd be clever and try to make the installer refresh the service list. I went and wrote a quicky little 'RefreshServices' command-line tool and included it as a script in the installer... only to find out after the fact that the 'refresh service list' function Apple offers in the system libraries is a no-op stub, which doesn't actually refresh the services at all. Doh. So I just packaged it without the script.)
Rachel "Sparks" Blackman
Riverdark Studios

#19 Macskeeball

Macskeeball

    Newbie

  • Members
  • Pip
  • 3 posts
  • Interests:Mac OS X and Linux<br />Web sites and podcasts<br />Cell phones and iPods<br />Photoshop and design<br />Home networking and security

Posted 05 April 2007 - 12:43 PM

Hey, you did the right thing by going the drag and drop route initially. I had wrongly assumed that the installer method was your first choice. Kudos for that.

Another method to consider is keeping the file there but providing an AppleScript named Installer. Some software, such as Adium, includes a symbolic link (similar to an alias, but Unix like and sharable) to the Applications folder along with directions set as the .dmg's background image.

#20 Sparks

Sparks

    Atlantis Author

  • Root Admin
  • PipPipPip
  • 1,791 posts
  • Gender:Female
  • Location:Seattle, WA
  • Interests:Cocoa, Obj-C, iPhone, horses, writing

Posted 05 April 2007 - 12:57 PM

Yeah, I have a background-image DMG with instructions on drag-and-drop for Atlantis (the app I actually spend time on). smile.gif

This, I will admit, was a 5 minute 'oh, look, I have this code for an Atlantis input-window feature that might make a good service.' Made service, tossed .zip on a mailing list, and then promptly got back 8 '...how do I install this?' So I went the super quick 'eh, we'll make a package' route to make the questions go away.

Probably the *right* reaction would've been to go make a DMG with a symlink and instructions, but it was quicker to grab the template and make a package instead of going and trying to muddle my way through doing DMG background art! wink.gif
Rachel "Sparks" Blackman
Riverdark Studios




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users