tweetwall 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +8 -2
- data/lib/tweetwall/version.rb +1 -1
- data/lib/tweetwall.rb +37 -11
- metadata +1 -1
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Tweetwall
|
2
2
|
|
3
|
-
|
3
|
+
This Gem makes it very wasy to add a Tweet Wall of Twitter feeds for a particular Twitter user
|
4
|
+
on your web application.
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -18,7 +19,12 @@ Or install it yourself as:
|
|
18
19
|
|
19
20
|
## Usage
|
20
21
|
|
21
|
-
|
22
|
+
The print_tweets method returns an HTML division of Tweets.
|
23
|
+
Simply call the print_tweets method like so:
|
24
|
+
Tweetwall.print_tweets("oceancucumber")
|
25
|
+
|
26
|
+
Optionally, you can specify they number of tweets:
|
27
|
+
Tweetwall.print_tweets("oceancucumber", 10)
|
22
28
|
|
23
29
|
## Contributing
|
24
30
|
|
data/lib/tweetwall/version.rb
CHANGED
data/lib/tweetwall.rb
CHANGED
@@ -3,19 +3,45 @@ require "twitter"
|
|
3
3
|
|
4
4
|
module Tweetwall
|
5
5
|
def self.print_tweets(twitter_user, number_of_tweets=5)
|
6
|
-
|
7
|
-
|
8
|
-
twitter_image =
|
6
|
+
tweet_html = String.new
|
7
|
+
tweet_wall_html = String.new
|
8
|
+
twitter_image = String.new
|
9
|
+
twitter_feed = Array.new
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
begin
|
12
|
+
# Get the tweets from the feed
|
13
|
+
twitter_feed = Twitter.user_timeline(twitter_user)[0..number_of_tweets]
|
14
|
+
|
15
|
+
# Get the twitter user's profile picture
|
16
|
+
twitter_image = Twitter.user(twitter_user).profile_image_url
|
17
|
+
|
18
|
+
tweet_wall_html = tweet_wall_html + '<div id="tweet_wall">'
|
19
|
+
twitter_feed.each do |tweet|
|
20
|
+
tweet_html = tweet.text
|
21
|
+
|
22
|
+
# if there's a hyperlink, make it clickable
|
23
|
+
words = tweet_html.split(" ")
|
24
|
+
words.each do |word|
|
25
|
+
if word.start_with?("http://") or word.start_with?("https://")
|
26
|
+
tweet_html = tweet_html.gsub(word, '<a href="' + word + '" target="_blank">' + word + '</a>')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
tweet_wall_html = tweet_wall_html + '<div class="tweet_line">'
|
31
|
+
tweet_wall_html = tweet_wall_html + '<img src="' + twitter_image + '" alt="" class="tweet_image" /> '
|
32
|
+
tweet_wall_html = tweet_wall_html + '<span class="tweet_text">' + tweet_html + '</span><br />'
|
33
|
+
tweet_wall_html = tweet_wall_html + '</div>'
|
34
|
+
end
|
15
35
|
tweet_wall_html = tweet_wall_html + '</div>'
|
16
|
-
end
|
17
|
-
tweet_wall_html = tweet_wall_html + '</div>'
|
18
36
|
|
19
|
-
|
37
|
+
tweet_wall_html
|
38
|
+
rescue
|
39
|
+
"Unable to fetch tweets."
|
40
|
+
ensure
|
41
|
+
twitter_feed = nil
|
42
|
+
twitter_image = nil
|
43
|
+
tweet_wall_html = nil
|
44
|
+
tweet_html = nil
|
45
|
+
end
|
20
46
|
end
|
21
47
|
end
|