-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.erb
37 lines (33 loc) · 1.17 KB
/
index.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<html>
<head>
<title>Pusher Example</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>