Created
August 30, 2011 17:30
-
-
Save chanwit/1181433 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <title>Bat Tracer, a simple Twitter search client in Batman.js</title> | |
| <script src="/batman/es5-shim.js" type="text/javascript"></script> | |
| <script src="/batman/coffee-script.js" type="text/javascript"></script> | |
| <script src="/batman/batman.js" type="text/javascript"></script> | |
| <script src="/batman/batman.solo.js" type="text/javascript"></script> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> | |
| <link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap-1.1.0.min.css"> | |
| </head> | |
| <body> | |
| <div class="container" style="margin-top: 40px"> | |
| <h1>Bat Tracer <small>a simple Twitter search client in Batman.js</small></h1> | |
| <p>See the code on <a href="https://github.com/ktusznio/Bat-Tracer">GitHub</a>.</p> | |
| <form data-event-submit="controllers.app.submitSearch"> | |
| <fieldset> | |
| <div class="input"> | |
| <input class="xlarge" type="text" placeholder="Enter fugitive name..." data-bind="Tracer.query"/> | |
| </div> | |
| </fieldset> | |
| </form> | |
| <p data-bind="Tracer.Tweet.all.length | prepend 'Found ' | append ' tweets.'" data-showif="Tracer.hasSearched"></p> | |
| <div class="row" data-foreach-tweet="Tracer.Tweet.all"> | |
| <div class="span1 columns"> | |
| <img data-bind-src="tweet.profile_image_url" /> | |
| </div> | |
| <div class="span8 columns"> | |
| <blockquote> | |
| <p data-bind="tweet.text"></p> | |
| <small><a data-bind="tweet.from_user | prepend '@'" data-bind-href="tweet.from_user | prepend 'http://twitter.com/#!'"></a></small> | |
| </blockquote> | |
| </div> | |
| </div> | |
| </div> | |
| <script type="text/coffeescript"> | |
| class Tracer extends Batman.App | |
| @global yes | |
| @root 'app#index' | |
| query: '' | |
| class Tracer.Tweet extends Batman.Model | |
| @persist Batman.LocalStorage | |
| class Tracer.AppController extends Batman.Controller | |
| index: -> false | |
| submitSearch: => | |
| Tracer.set 'hasSearched', yes | |
| Tracer.Tweet.all.forEach (t) -> t.destroy() | |
| $.ajax 'http://search.twitter.com/search.json?q=' + encodeURI(Tracer.query), | |
| dataType: 'jsonp' | |
| success: (data) -> | |
| for obj in data.results | |
| tweet = new Tracer.Tweet obj | |
| tweet.save (error, record) -> | |
| throw error if error | |
| false | |
| Tracer.run() | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment