diff options
author | B Mathis <brandon@imathis.com> | 2009-10-30 00:31:02 -0500 |
---|---|---|
committer | B Mathis <brandon@imathis.com> | 2009-10-30 00:31:02 -0500 |
commit | 5c736f5eb03d7b51defe27ac027124557c4c7a3b (patch) | |
tree | f2ad356f733a6b359360422209cba95d8197c817 /source/javascripts/twitter_gitter.js | |
parent | 80a70068ed7fda704c769e123c77bb8c78c7d9a3 (diff) | |
download | my_new_personal_website-5c736f5eb03d7b51defe27ac027124557c4c7a3b.tar.xz my_new_personal_website-5c736f5eb03d7b51defe27ac027124557c4c7a3b.zip |
added twitter feed to sidebar, moved to compass-edge gem
Diffstat (limited to 'source/javascripts/twitter_gitter.js')
-rw-r--r-- | source/javascripts/twitter_gitter.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/source/javascripts/twitter_gitter.js b/source/javascripts/twitter_gitter.js new file mode 100644 index 00000000..788883f2 --- /dev/null +++ b/source/javascripts/twitter_gitter.js @@ -0,0 +1,57 @@ +/*
+ Plugin: TwitterGitter
+ Author: David Walsh
+ Website: http://davidwalsh.name
+ Date: 2/21/2009
+*/
+
+var TwitterGitter = new Class({
+
+ //implements
+ Implements: [Options,Events],
+
+ //options
+ options: {
+ count: 2,
+ sinceID: 1,
+ link: true,
+ onRequest: $empty,
+ onComplete: $empty
+ },
+
+ //initialization
+ initialize: function(username,options) {
+ //set options
+ this.setOptions(options);
+ this.info = {};
+ this.username = username;
+ },
+
+ //get it!
+ retrieve: function() {
+ new JsonP('http://twitter.com/statuses/user_timeline/' + this.username + '.json',{
+ data: {
+ count: this.options.count,
+ since_id: this.options.sinceID
+ },
+ onRequest: this.fireEvent('request'),
+ onComplete: function(data) {
+ //linkify?
+ if(this.options.link) {
+ data.each(function(tweet) { tweet.text = this.linkify(tweet.text); },this);
+ }
+ //complete!
+ this.fireEvent('complete',[data,data[0].user]);
+ }.bind(this)
+ }).request();
+ return this;
+ },
+
+ //format
+ linkify: function(text) {
+ //courtesy of Jeremy Parrish (rrish.org)
+ return text.replace(/(https?:\/\/\S+)/gi,'<a href="$1">$1</a>').replace(/(^|\s)@(\w+)/g,'$1<a href="http://twitter.com/$2">@$2</a>').replace(/(^|\s)#(\w+)/g,'$1#<a href="http://search.twitter.com/search?q=%23$2">$2</a>');
+ }
+});
+ + |