Hi all, With all the talk of rubyurl.com over the past couple of days, I thought I''d have my own go at implementing the same kind of site. And, well, it''s done! I don''t really expect anyone to use it, but one thing that might come in useful is the web service that it exposes. If you are interested on more details on how to consume it, visit : http://www.carldr.com/blog/article/9/make-your-urls-shorter Again, thanks to Leon Breedt for the help sorting out the problems I was having earlier. Now, onto getting syntax.carldr.com (optionally) storing code and then using this service to generate nice looking URLs. Regards, Carl.
On Tue, 2005-03-15 at 23:28 +0000, carl wrote:> Hi all, > > With all the talk of rubyurl.com over the past couple of days, I thought I''d > have my own go at implementing the same kind of site. And, well, it''s done! > I don''t really expect anyone to use it, but one thing that might come in > useful is the web service that it exposes. If you are interested on more > details on how to consume it, visit : > > http://www.carldr.com/blog/article/9/make-your-urls-shorter > > Again, thanks to Leon Breedt for the help sorting out the problems I was > having earlier. > > Now, onto getting syntax.carldr.com (optionally) storing code and then using > this service to generate nice looking URLs. > > Regards, > Carl.Cool, I was hoping to work on a web service for http://rubyurl.com/ in the next few days. Perhaps I''ll use your example as a basis for it. Today, I added the ability to keep it from making duplicates..and there are currently 275 unique URLs in the system in just under 2 days. :-) Expect a bunch of people who want to try to break it...or to cause infinite loops until the client stops. For example: I just created: http://tiny.carldr.com/15 knowing that 15 was the next one.. which is why I went for a random alpha-numeric method. -Robby -- /*************************************** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | robby-/Lcn8Y7Ot69QmPsQ1CNsNQ@public.gmane.org * 503.351.4730 | blog.planetargon.com * PHP, Ruby, and PostgreSQL Development * http://www.robbyonrails.com/ ****************************************/
* Robby Russell (robby-/Lcn8Y7Ot69QmPsQ1CNsNQ@public.gmane.org) wrote:> Cool, I was hoping to work on a web service for http://rubyurl.com/ in > the next few days. Perhaps I''ll use your example as a basis for it.You''ll notice for qurl I generate a <link> to make it trivial to write a simple RESTish interface to it without loading huge SOAP/XMLRPC libraries. <link rel="bookmark" title="Original URL" href="http://www.newzbin.com/"> <link rel="bookmark" title="Generated qURL" href="http://qurl.net/1"> Clients can just make a POST with values url and action=''Create qURL'', and read ther response from the <link> tags. I''ve also tried alternative formats using the Accept header, e.g: Accept: text/plain, */*;q=0.0 Which simply returned the new URL as plaintext. These work well in the context of tiny perl scripts for IRC clients :)> Today, I added the ability to keep it from making duplicates..and there > are currently 275 unique URLs in the system in just under 2 days. :-)You should really sort out your error handling. I get "Application Error" on large URL''s; I take it you''re using a VARCHAR(255) or so? I''m surprised it''s not simply clipping the string. If you switch to TEXT, keep in mind that you can''t have a unique index on it in MySQL; I got around this by generating a SHA1 of it and indexing on that. Here''s a nice long URL for you to test with: http://qurl.net/a8 Now, who''s gonna be the first person to create a hugeurl service with Rails? ;)> Expect a bunch of people who want to try to break it...or to cause > infinite loops until the client stops. For example: > > I just created: > http://tiny.carldr.com/15 > > knowing that 15 was the next one.. which is why I went for a random > alpha-numeric method.Two solutions: don''t redirect if the target URL matches a local one, or validates_format_of :url, :with => /^(?!http:\/\/tiny\.carldr\.com)/ in the model. A bit of referer checking might not go amiss either, but obviously that''s not something to rely on. Of course, not redirecting automatically by default is good too; this helps avoid more complex loops (think: having rubyurl redirect to carldr to qurl and back again). -- Thomas ''Freaky'' Hurst http://hur.st/