Poking about
This commit is contained in:
parent
c66afcce2c
commit
f36662652d
14
index.tmpl
14
index.tmpl
|
@ -3,6 +3,20 @@
|
|||
<head>
|
||||
<title>TweepyDeck.com</title>
|
||||
</head>
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="${prefix}/scripts/timeline.js"></script>
|
||||
<script type="text/javascript" src="${prefix}/scripts/bootstrap.js"></script>
|
||||
<link type="text/css" rel="stylesheet" href="${prefix}/styles/tweepydeck.css"/>
|
||||
<body>
|
||||
<a href="http://github.com/rtyler/TweepyDeck">
|
||||
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" />
|
||||
</a>
|
||||
<center>
|
||||
<strong>TweepyDeck</strong>
|
||||
<br/>
|
||||
</center>
|
||||
<div id="deck">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -17,7 +17,13 @@ class DevServer(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||
|
||||
def render_file(self, path):
|
||||
with open(path, 'r') as fd:
|
||||
return fd.read(), 'text/plain'
|
||||
mtype = 'text/plain'
|
||||
if path.endswith('.js'):
|
||||
mtype = 'text/javascript'
|
||||
elif path.endswith('.css'):
|
||||
mtype = 'text/css'
|
||||
|
||||
return fd.read(), mtype
|
||||
|
||||
def do_GET(self, *args, **kwargs):
|
||||
data = None
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
self._search = new Timeline('#git');
|
||||
self._search.start();
|
||||
});
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Timeline objects
|
||||
*/
|
||||
|
||||
|
||||
var Timeline = (function() {
|
||||
var t = function(term) {
|
||||
this.term = term.replace('#', '%23');
|
||||
};
|
||||
|
||||
t.prototype.markupTweet = function(text) {
|
||||
var newtext = '';
|
||||
$.each(text.split(' '), function(i, piece) {
|
||||
if (piece.charAt(0) == '@') {
|
||||
newtext += '<a class="mention" href="http://twitter.com/' + piece.replace('@', '') + '">';
|
||||
newtext += piece;
|
||||
newtext += '</a>';
|
||||
}
|
||||
else if (piece.charAt(0) == '#') {
|
||||
newtext += '<a class="hashtag" href="http://search.twitter.com/search?q=' + piece + '">';
|
||||
newtext += piece;
|
||||
newtext += '</a>';
|
||||
}
|
||||
else {
|
||||
newtext += piece;
|
||||
}
|
||||
newtext += ' ';
|
||||
});
|
||||
return newtext;
|
||||
};
|
||||
|
||||
t.prototype.renderItem = function(data) {
|
||||
var item = '<div class="timeline row" id="' + data['id'] + '">';
|
||||
item += '<div class="timeline avatar">';
|
||||
item += '<img width="50" height="50" src="' + data['profile_image_url'] + '"/>';
|
||||
item += '<br/>';
|
||||
item += '<strong>' + data['from_user'] + '</strong>';
|
||||
item += '</div>';
|
||||
item += '<div class="timeline tweet">' + this.markupTweet(data['text']) + '</div>';
|
||||
item += '</div>';
|
||||
$('#' + this.getDivId()).append(item);
|
||||
};
|
||||
|
||||
t.prototype.getDivId = function() {
|
||||
return 'timeline_';
|
||||
};
|
||||
|
||||
t.prototype.start = function() {
|
||||
var timeline = this;
|
||||
$('#deck').append('<div class="timeline" id="' + this.getDivId() + '"></div>');
|
||||
|
||||
$.getJSON(
|
||||
'http://search.twitter.com/search.json?rpp=10&callback=?&q=' + this.term,
|
||||
function(data) {
|
||||
$.each(data['results'], function(i, item) {
|
||||
timeline.renderItem(item);
|
||||
});
|
||||
$('body').append('<script id="aptureScript" type="text/javascript" src="http://www.apture.com/js/apture.js?siteToken=yYBMQRz" charset="utf-8"></script>');
|
||||
});
|
||||
};
|
||||
|
||||
return t;
|
||||
})();
|
Binary file not shown.
|
@ -0,0 +1,30 @@
|
|||
.timeline {
|
||||
width: 350px;
|
||||
##border: 1px solid #cecece;
|
||||
padding: 3px;
|
||||
}
|
||||
.timeline .row {
|
||||
padding-bottom: 2px;
|
||||
border-bottom: 1px solid #cecece;
|
||||
clear: both;
|
||||
}
|
||||
.timeline .avatar {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
float: left;
|
||||
text-align: center;
|
||||
}
|
||||
.timeline .tweet {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.hashtag a {
|
||||
font-weight: bold;
|
||||
color: orange;
|
||||
}
|
||||
.mention a {
|
||||
font-weight: bold;
|
||||
color: cyan;
|
||||
}
|
Loading…
Reference in New Issue