tweetwall 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -23,9 +23,19 @@ The print_tweets method returns an HTML division of Tweets.
23
23
  Simply call the print_tweets method like so:
24
24
  Tweetwall.print_tweets("oceancucumber")
25
25
 
26
+ You'll get the full tweet_wall HTML division
27
+
26
28
  Optionally, you can specify the number of tweets:
27
29
  Tweetwall.print_tweets("oceancucumber", 10)
28
30
 
31
+ There is also a function that you can call that will only print
32
+ the Tweet content. This is useful if you want to do an AJAX
33
+ refresh on the tweet_wall division without refreshing the entire
34
+ page:
35
+ Tweetwall.print_tweet_content("oceancucumber", 10)
36
+
37
+ The number of tweets is again optional.
38
+
29
39
  ## Contributing
30
40
 
31
41
  1. Fork it
data/lib/tweetwall.rb CHANGED
@@ -2,21 +2,32 @@ require "tweetwall/version"
2
2
  require "twitter"
3
3
 
4
4
  module Tweetwall
5
+
6
+ # This method prints the entire DIV of the tweet_wall in your html
5
7
  def self.print_tweets(twitter_user, number_of_tweets=5)
6
- tweet_html = String.new
7
- tweet_wall_html = String.new
8
- twitter_image = String.new
9
- twitter_feed = Array.new
10
- words = String.new
8
+ begin
9
+ '<div id="tweet_wall">' + self.print_tweet_content(twitter_user, number_of_tweets) + '</div>'
10
+ rescue
11
+ ""
12
+ end
13
+ end
11
14
 
15
+ # This method prints out just the tweet content. Usefull if you want to do an AJAX refresh
16
+ # of your Tweets without reloading the whole page
17
+ def self.print_tweet_content(twitter_user, number_of_tweets=5)
12
18
  begin
19
+ # working with an array that starts at 0
20
+ number_of_tweets = number_of_tweets - 1
21
+
13
22
  # Get the tweets from the feed
14
23
  twitter_feed = Twitter.user_timeline(twitter_user)[0..number_of_tweets]
15
24
 
16
25
  # Get the twitter user's profile picture
17
26
  twitter_image = Twitter.user(twitter_user).profile_image_url
18
27
 
19
- tweet_wall_html = tweet_wall_html + '<div id="tweet_wall">'
28
+ # This variable needs to be declared because of the scop of the each\do block
29
+ tweet_content = String.new
30
+
20
31
  twitter_feed.each do |tweet|
21
32
  # Process the tweet
22
33
  tweet_html = tweet.text
@@ -25,7 +36,7 @@ module Tweetwall
25
36
  words.each do |word|
26
37
  # if there's a hyperlink, make it clickable
27
38
  if word.start_with?("http://") or word.start_with?("https://")
28
- tweet_html = tweet_html.gsub(word, '<a href="' + word + '" target="_blank">' + word + '</a>')
39
+ tweet_html = tweet_html.gsub(word, '<a href="' + word + '" target="_blank">' + word + '</a>')
29
40
  end
30
41
 
31
42
  # if someone has been mentioned, make that clickable
@@ -34,22 +45,16 @@ module Tweetwall
34
45
  end
35
46
  end
36
47
 
37
- tweet_wall_html = tweet_wall_html + '<div class="tweet_line">'
38
- tweet_wall_html = tweet_wall_html + '<a href="http://www.twitter.com/#!/' + twitter_user + '" target="_blank"><img src="' + twitter_image + '" alt="" class="tweet_image" /></a> '
39
- tweet_wall_html = tweet_wall_html + '<span class="tweet_text">' + tweet_html + '</span><br />'
40
- tweet_wall_html = tweet_wall_html + '</div>'
48
+ tweet_content = tweet_content + '<div class="tweet_line">'
49
+ tweet_content = tweet_content + '<a href="http://www.twitter.com/#!/' + twitter_user + '" target="_blank"><img src="' + twitter_image + '" alt="" class="tweet_image" /></a> '
50
+ tweet_content = tweet_content + '<span class="tweet_text">' + tweet_html + '</span><br />'
51
+ tweet_content = tweet_content + '</div>'
41
52
  end
42
- tweet_wall_html = tweet_wall_html + '</div>'
43
53
 
44
- tweet_wall_html
54
+ tweet_content
45
55
  rescue
46
- "Unable to fetch tweets."
47
- ensure
48
- twitter_feed = nil
49
- twitter_image = nil
50
- tweet_wall_html = nil
51
- tweet_html = nil
52
- words = nil
56
+ "Tweets not available"
53
57
  end
54
58
  end
59
+
55
60
  end
@@ -1,3 +1,3 @@
1
1
  module Tweetwall
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tweetwall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-10 00:00:00.000000000Z
12
+ date: 2012-06-16 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: This Gem makes it very easy to add a wall of Tweets from a Twitter User
15
15
  in your web application.