Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (33 sloc) 1.18 KB
<html>
<head>
<title>Tweet streaming on Heroku</title>
<script src="http://js.pusherapp.com/1.8/pusher.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>
<script>
$(window).ready(function() {
Pusher.log = function(message) {
if (window.console && window.console.log) window.console.log(message);
};
var pusher = new Pusher('<%= pusher_api_key %>');
var channel = pusher.subscribe('tweets');
channel.bind('tweet', function(tweet) {
var template = $('#tweet-template').html()
.replace('{{PROFILE_IMAGE}}', tweet.user.profile_image_url)
.replace('{{TEXT}}', tweet.text);
$('#tweets').prepend(template);
});
});
</script>
<script id="tweet-template" type="text/html">
<li class="tweet">
<img width="48" height="48" src="{{PROFILE_IMAGE}}"/>
{{TEXT}}
</li>
</script>
</head>
<body>
<h1>Tweets about <%=ENV["TWITTER_KEYWORD"]%></h1>
<ul id="tweets"></ul>
</body>
</html>