Permalink
Browse files

allow user to supply a max number of tweets

  • Loading branch information...
1 parent e1e4d50 commit e7b253ce5e655c53d8a9b6907ce7a5e6d876f79d msp committed Dec 22, 2009
Showing with 37 additions and 13 deletions.
  1. +15 −11 lib/twitter_tags.rb
  2. +22 −2 spec/lib/twitter_tags_spec.rb
View
@@ -31,14 +31,16 @@ module TwitterTags
Usage:
Displays the tweets from the current user's timeline:
<r:twitter>
- <r:tweets:each>
- <div class="tweet">
- <p class="text">
- <r:tweet:text />
- <br/> <r:tweet:created_ago /> ago from <r:tweet:source />
- </p>
- </div>
- </r:tweets:each>
+ <r:tweets max="10">
+ <r:each>
+ <div class="tweet">
+ <p class="text">
+ <r:tweet:text />
+ <br/> <r:tweet:created_ago /> ago from <r:tweet:source />
+ </p>
+ </div>
+ </r:each>
+ </r:tweets>
</r:twitter
<br/>
@@ -58,10 +60,12 @@ module TwitterTags
end
desc %{
- Retrieve a users recent tweets
+ Retrieve a users recent tweets, optional max, default 10. Usage:
+ <pre><code><r:twitter:tweets [max="10"] /></code></pre>
}
- tag 'twitter:tweets' do |tag|
- tag.locals.tweets = tag.locals.client.user_timeline #TODO define number of tweets
+ tag 'twitter:tweets' do |tag|
+ tag.locals.max = tag.attr['max'].blank? ? 9 : tag.attr['max'].to_i - 1
+ tag.locals.tweets = tag.locals.client.user_timeline[0..(tag.locals.max)]
tag.expand
end
Oops, something went wrong.

0 comments on commit e7b253c

Please sign in to comment.