Created
June 5, 2009 11:27
-
-
Save domwom/124240 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Twita@talinkahashifyer | |
| * http://www.dustindiaz.com | |
| * http://www.dustindiaz.com/basement/ify.html | |
| * | |
| * Copyright (c) 2009 Dustin Diaz | |
| * licensed under public BSD | |
| */ | |
| var ify = function() { | |
| return { | |
| "link": function(t) { | |
| return t.replace(/(^|\s+)(https*\:\/\/\S+[^\.\s+])/g, function(m, m1, link) { | |
| return ((m1 != '') ? ' ' : '') + '<a href=' + link + '>' + ((link.length > 25) ? link.substr(0, 24) + '...' : link) + '</a>'; | |
| }); | |
| }, | |
| "at": function(t) { | |
| return t.replace(/(^|\s+)\@([a-zA-Z0-9_]{1,15})/g, function(m, m1, m2) { | |
| return ((m1 != '') ? ' ' : '') + '@<a href="http://twitter.com/' + m2 + '">' + m2 + '</a>'; | |
| }); | |
| }, | |
| "hash": function(t) { | |
| return t.replace(/(^|\s+)\#([a-zA-Z0-9_]+)/g, function(m, m1, m2) { | |
| return ((m1 != '') ? ' ' : '') + '#<a href="http://search.twitter.com/search?q=%23' + m2 + '">' + m2 + '</a>'; | |
| }); | |
| }, | |
| "clean": function(tweet) { | |
| return this.hash(this.at(this.link(tweet))); | |
| } | |
| }; | |
| }(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment