Permalink
Browse files

enable autolink and possible oEmbed-ification in tweet text

  • Loading branch information...
1 parent 58140c0 commit 786c6bf32469c6c4c9e814435897d47631d45e57 @miyagawa committed Oct 19, 2009
Showing with 3 additions and 3 deletions.
  1. +2 −2 eg/demo.pl
  2. +1 −1 eg/templates/chat.html
View
4 eg/demo.pl
@@ -123,7 +123,7 @@ sub post {
sub format_message {
my($self, $text) = @_;
$text =~ s{ (https?://\S+) | ([&<>"']+) }
- { $1 ? do { my $url = HTML::Entities::encode($1); qq(<a href="$url" class="oembed">$url</a>) } :
+ { $1 ? do { my $url = HTML::Entities::encode($1); qq(<a target="_blank" href="$url">$url</a>) } :
$2 ? HTML::Entities::encode($2) : '' }egx;
$text;
}
@@ -187,7 +187,7 @@ package main;
type => "message", address => 'twitter.com', time => scalar localtime,
name => $tweet->{user}{screen_name},
avatar => $tweet->{user}{profile_image_url},
- text => $tweet->{text},
+ html => ChatPostHandler->format_message($tweet->{text}), # FIXME
ident => "http://twitter.com/$tweet->{user}{screen_name}/status/$tweet->{id}",
});
};
View
2 eg/templates/chat.html
@@ -46,7 +46,7 @@
var message = $('<td/>').addClass('chat-message');
if (e.text) message.text(e.text);
if (e.html) message.html(e.html);
- message.find('a.oembed').oembed();
+ message.find('a').oembed();
var meta = $('<td/>').addClass('meta').text(' (' + e.time + ' from ' + e.address + ')');
$('#messages').prepend($('<tr/>').addClass('message').append(avatar).append(message).append(meta));

0 comments on commit 786c6bf

Please sign in to comment.