Created
January 21, 2013 22:04
Revisions
-
coreyweb created this gist
Jan 21, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ <?php // Convert URL's with protocol prefix $tweet = ereg_replace("[a-zA-Z]+://([-]*[.]?[a-zA-Z0-9_/-?&%])*", "<a href=\"\\0\">\\0</a>", $tweet); //Convert URL with just www. $tweet = ereg_replace("(^| |\n)(www([-]*[.]?[a-zA-Z0-9_/-?&%])*)", "\\1<a href=\"http://\\2\">\\2</a>", $tweet); //Convert # hashtags $tweet = ereg_replace("(^| |\n)(\#([-]*[.]?[a-zA-Z0-9_/-?&%])*)", "\\1<a href=\"http://search.twitter.com/search?q=\\2\">\\2</a>", $tweet); $tweet = str_replace("/#", "/", $tweet); //Convert @ replies $tweet = ereg_replace("(^| |\n)(\@([-]*[.]?[a-zA-Z0-9_/-?&%])*)", "\\1@<a href=\"http://www.twitter.com/\\2\">\\2</a>", $tweet); $tweet = str_replace("/@", "/", $tweet); $tweet = str_replace(">@", ">", $tweet); // Make the time prettier $createstamp = $post->get('pubDate'); $relative_time = niceTime(strtotime($createstamp)); ?> <?php echo $tweet ?> <span>posted <a href="<?php echo $tweet_link ?>"><?php echo $relative_time ?></a> </span>