Skip to content
Browse files

jQuery Tweets v0.1

  • Loading branch information...
1 parent 5fa9eb0 commit e63b0482a5e2b65dd6585200e6b97ae828de70ef Diego Peralta committed Feb 10, 2010
Showing with 169 additions and 0 deletions.
  1. +62 −0 index.html
  2. +49 −0 js/jquery.tweets.0.1.js
  3. +58 −0 main.css
View
62 index.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>jQuery Tweets v0.1 by Diego Peralta</title>
+ <!-- Meta Tags -->
+ <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
+ <!-- CSS -->
+ <link rel="stylesheet" href="main.css" media="screen,projection" type="text/css" />
+ <!-- JavaScript -->
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js" type="text/javascript"></script>
+ <script src="js/jquery.tweets.0.1.js" type="text/javascript" charset="utf-8"></script>
+ <script type="text/javascript" charset="utf-8">
+ $(document).ready(function() {
+ $('#tweets').tweets({
+ tweets:4,
+ username: "diego_ar"
+ });
+ });
+ </script>
+</head>
+
+<body>
+<div id="main">
+ <h1>jQuery Tweets v0.1 by Diego Peralta</h1>
+ <h2>Tweets of <strong>@diego_ar</strong></h2>
+ <ul id="tweets">
+ </ul>
+ <p><a href="jquery.tweets.0.1.zip" title="Download" class="download">Download (4kb) →</a></p>
+ <h2>Usage:</h2>
+ <pre>
+&lt;script type="text/javascript" charset="utf-8"&gt;
+ $(document).ready(function() {
+ $('#tweets').tweets({
+ tweets:4,
+ username: "diego_ar"
+ });
+ });
+&lt;/script&gt;
+ </pre>
+ <p><small><a href="http://www.twitter.com/diego_ar" title="Follow me on twitter">Follow me on twitter: @diego_ar</a></small></p>
+ <h2>Todo v0.2</h2>
+ <ol>
+ <li>Add Support for Avatar.</li>
+ <li>Add Support for multiple methods.</li>
+ <li>Add Asynchronous load tweets option.</li>
+ </ol>
+ <p>Any ideas or suggestions? <a href="mailto:diego@bahiastudio.net?subject=jQuery Tweets Feedback" title="jQuery Tweets Feedback">Send me an email!</a></p>
+</div>
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+try {
+var pageTracker = _gat._getTracker("UA-5917265-16");
+pageTracker._trackPageview();
+} catch(err) {}</script>
+</body>
+</html>
+
View
49 js/jquery.tweets.0.1.js
@@ -0,0 +1,49 @@
+/*
+* jQuery Tweet v0.1
+* written by Diego Peralta
+*
+* Copyright (c) 2010 Diego Peralta (http://www.bahiastudio.net/)
+* Dual licensed under the MIT (MIT-LICENSE.txt)
+* and GPL (GPL-LICENSE.txt) licenses.
+* Built using jQuery library
+*
+* Options:
+* - before (string): HTML code before the tweet.
+* - after (string): HTML code after the tweet.
+* - tweets (numeric): number of tweets to display.
+*
+* Example:
+*
+* <script type="text/javascript" charset="utf-8">
+* $(document).ready(function() {
+* $('#tweets').tweets({
+* tweets:4,
+* username: "diego_ar"
+* });
+* });
+* </script>
+*
+*/
+(function($){
+ $.fn.tweets = function(options) {
+ $.ajaxSetup({ cache: true });
+ var defaults = {
+ tweets: 5,
+ before: "<li>",
+ after: "</li>"
+ };
+ var options = $.extend(defaults, options);
+ return this.each(function() {
+ var obj = $(this);
+ $.getJSON('http://search.twitter.com/search.json?callback=?&rpp='+options.tweets+'&q=from:'+options.username,
+ function(data) {
+ $.each(data.results, function(i, tweet) {
+ if(tweet.text !== undefined) {
+ $(obj).append(options.before+tweet.text+options.after);
+ }
+ });
+ }
+ );
+ });
+ };
+})(jQuery);
View
58 main.css
@@ -0,0 +1,58 @@
+body {
+ background:#F1F1F1;
+ color:#888888;
+ font-family:"Calibri", Helvetica, Arial, sans-serif;
+ font-size:13px;
+ text-shadow:1px 1px 0 #FFFFFF;
+}
+
+a {
+ color:#e8771a;
+ text-decoration:none;
+}
+
+small a { font-size:14px; }
+
+pre {
+ background:#FAFAFA;
+ border:1px solid #e4e4e4;
+ padding:15px 15px 0;
+ width:380px;
+}
+
+#main {
+ margin:60px auto 0;
+ width:420px;
+}
+
+#tweets {
+ background:#FAFAFA;
+ border:1px solid #e4e4e4;
+ margin:0;
+ padding:0;
+}
+#tweets li {
+ border-bottom:1px dotted #CCC;
+ list-style:none;
+ padding:5px;
+}
+
+#tweets li:last-child {
+ border:0;
+}
+
+.download {
+ background:#ff9f44;
+ border-radius:6px;
+ color:#FFF;
+ font-size:14px;
+ padding:5px 10px;
+ text-shadow:1px 1px #de822c;
+ -moz-border-radius:6px;
+ -webkit-border-radius:6px;
+ -ms-border-radius:6px;
+}
+
+.download:hover {
+ background:#eb6a31;
+}

0 comments on commit e63b048

Please sign in to comment.
Something went wrong with that request. Please try again.