I saw http://www.makeashorterlink.com/ and thought it was a pretty useful idea for posting/mailing really long links. I whipped up a small script to do the same thing sans advertising.
#!/usr/local/bin/perl -w =head1 uri.cgi Create short URL re-directs, similar to www.makeashorterlink.com =head1 Usage When passed a valid redirect uri it sends the user to the appropriate link. When passed an http uri it creates a new redirect uri or returns existing one. uri.cgi?1062698960 uri.cgi?http://www.sfu.ca/~ajdelore/ =cut use strict; use CGI qw (header redirect url); my $path_to_data = "./.uri_data"; my $uri = $ENV{QUERY_STRING} or &bad_query_string; if ($uri =~ qr(^\d+$) || $uri =~ qr(^http://)) { open (URI_DATA,"+>> $path_to_data"); my %uri_data; while (<URI_DATA>) { chomp; my ($key,$value) = split; $uri_data{$key} = $value; } if ($uri_data{$uri}) { print redirect($uri_data{$uri}); } elsif ($uri =~ qr(^http://)) { my %data_uri; foreach (keys %uri_data) { $data_uri{$uri_data{$_}} = $_; } my $key = ($data_uri{$uri} || time); print URI_DATA "$key $uri\n"; print header (-type=>'text/plain'); print "The link is ", url, "?$key" } else { &bad_query_string } close URI_DATA; } else { &bad_query_string } sub bad_query_string { print header (-type=>'text/plain'); print "Bad query string supplied.\n"; exit; }
I also created a javascript (ick, I know) bookmarklet to quickly create links. Granted, it doesn't actually work for me except on the 6-7 sites where I allow javascript, but nonetheless...
javascript:void(location='http://path/to/uri.cgi?'+location)</ajdelore>
In reply to Shorter links for email/posts by ajdelore
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |