Poking about

This commit is contained in:
R. Tyler Ballance 2009-12-01 22:44:11 -08:00
parent c66afcce2c
commit f36662652d
8 changed files with 121 additions and 1 deletions

View File

@ -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>

View File

@ -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

BIN
scripts/.bootstrap.js.swp Normal file

Binary file not shown.

BIN
scripts/.timeline.js.swp Normal file

Binary file not shown.

7
scripts/bootstrap.js vendored Normal file
View File

@ -0,0 +1,7 @@
/*
*/
$(document).ready(function() {
self._search = new Timeline('#git');
self._search.start();
});

63
scripts/timeline.js Normal file
View File

@ -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;
})();

BIN
styles/.tweepydeck.css.swp Normal file

Binary file not shown.

30
styles/tweepydeck.css Normal file
View File

@ -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;
}