twitterfeed 0.1.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/app/assets/images/bird.jpg +0 -0
- data/app/assets/stylesheets/twitterfeed.css +8 -3
- data/app/views/twitterfeed/_twitterfeed_box.html.haml +4 -2
- data/lib/twitterfeed.rb +3 -3
- data/lib/twitterfeed/version.rb +1 -1
- data/lib/twitterfeed/view_helpers.rb +18 -8
- metadata +3 -2
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -27,7 +27,7 @@ Place helper line anywhere in your project with an array of twitter handles or h
|
|
27
27
|
|
28
28
|
Options:
|
29
29
|
|
30
|
-
<%= twitterfeed(["#ruby", "#rails"], :align => "left", :max => 10) %>
|
30
|
+
<%= twitterfeed(["#ruby", "#rails"], :align => "left", :max => 10, :title => "Cool Ruby Tweets") %>
|
31
31
|
|
32
32
|
Enjoy!
|
33
33
|
|
Binary file
|
@@ -16,15 +16,20 @@
|
|
16
16
|
|
17
17
|
#twitterfeed_header {
|
18
18
|
margin-bottom: 5px;
|
19
|
-
|
19
|
+
font-family: arial;
|
20
|
+
font-size: 15px;
|
21
|
+
font-style: italic;}
|
22
|
+
|
23
|
+
#twitterfeed_header img{
|
24
|
+
margin-left: 10px;
|
25
|
+
}
|
20
26
|
|
21
27
|
#twitterfeed_content {
|
22
28
|
height: 300px;
|
23
29
|
overflow: scroll;
|
24
30
|
overflow-x:hidden;
|
25
31
|
border: 1px solid black;
|
26
|
-
|
27
|
-
-moz-border-radius: 5px;
|
32
|
+
border-radius: 5px;
|
28
33
|
}
|
29
34
|
|
30
35
|
#twitterfeed_tweet {
|
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
#twitterfeed{:class => align}
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
- if title
|
6
|
+
#twitterfeed_header
|
7
|
+
= title
|
8
|
+
= image_tag("bird.jpg")
|
7
9
|
#twitterfeed_content
|
8
10
|
- tweet_array.each do |tweet|
|
9
11
|
#twitterfeed_tweet{:class => cycle('even','odd')}
|
data/lib/twitterfeed.rb
CHANGED
@@ -8,11 +8,11 @@ module Twitterfeed
|
|
8
8
|
total_tweets = []
|
9
9
|
name_array.first(150).each do |name|
|
10
10
|
if name[0] == "#"
|
11
|
-
Twitter.search(name, :rpp => 20).results.each do |tweet|
|
11
|
+
Twitter.search("#{name} -rt", :rpp => 20).results.each do |tweet|
|
12
12
|
total_tweets << tweet
|
13
13
|
end
|
14
14
|
else
|
15
|
-
Twitter.user_timeline(name, :include_rts => true).each do |tweet|
|
15
|
+
Twitter.user_timeline(name, :include_rts => true, :exclude_replies => true, :count => 100).first(20).each do |tweet|
|
16
16
|
total_tweets << tweet
|
17
17
|
end
|
18
18
|
end
|
@@ -34,7 +34,7 @@ module Twitterfeed
|
|
34
34
|
def self.set_defaults(options)
|
35
35
|
#sets values for twitterfeed window options, with some validations
|
36
36
|
|
37
|
-
defaults = {:align => 'right', :max => 20}
|
37
|
+
defaults = {:align => 'right', :max => 20, :title => nil}
|
38
38
|
defaults.merge!(options)
|
39
39
|
|
40
40
|
if (defaults[:align] != ("left" || "right"))
|
data/lib/twitterfeed/version.rb
CHANGED
@@ -2,6 +2,7 @@ require 'twitter'
|
|
2
2
|
|
3
3
|
module Twitterfeed
|
4
4
|
module ViewHelpers
|
5
|
+
|
5
6
|
def twitterfeed(name_array, options = {})
|
6
7
|
|
7
8
|
defaults = Twitterfeed.set_defaults(options)
|
@@ -19,7 +20,8 @@ module Twitterfeed
|
|
19
20
|
twitterfeed_data = YAML.load(File.open("twitterfeed.yml"))
|
20
21
|
#removing update time from array
|
21
22
|
twitterfeed_data.slice!(0)
|
22
|
-
render :partial => "twitterfeed/twitterfeed_box",
|
23
|
+
render :partial => "twitterfeed/twitterfeed_box",
|
24
|
+
:locals => { :tweet_array => twitterfeed_data, :align => defaults[:align], :title => defaults[:title]}
|
23
25
|
|
24
26
|
end
|
25
27
|
|
@@ -44,23 +46,31 @@ module Twitterfeed
|
|
44
46
|
@links = tweet.scan(/https?:\/\/\S+/)
|
45
47
|
|
46
48
|
@ats.each do |a|
|
47
|
-
|
49
|
+
at = sanitize_link(a)
|
50
|
+
tweet.gsub!(/#{at}/, "<a href='http://twitter.com/#{at[1..(at.length - 1)]}' target='_blank'>#{at}</a>")
|
48
51
|
end
|
49
52
|
|
50
53
|
@tags.each do |t|
|
51
|
-
t
|
52
|
-
|
53
|
-
tweet.gsub!(/#{t}/, "<a href='http://twitter.com/search/%23#{t[1..(t.length - 1)]}' target='_blank'>#{t}</a>")
|
54
|
+
tag = sanitize_link(t)
|
55
|
+
tweet.gsub!(/#{tag}(\Z|[\s.,()!?\"\'*])/, "<a href='http://twitter.com/search/%23#{tag[1..(tag.length - 1)]}' target='_blank'>#{tag}</a> ")
|
54
56
|
end
|
55
57
|
|
56
58
|
@links.each do |l|
|
57
|
-
l
|
58
|
-
|
59
|
-
tweet.gsub!(/#{l}/, "<a href='#{l}' target='_blank'>#{l}</a>")
|
59
|
+
link = sanitize_link(l)
|
60
|
+
tweet.gsub!(/#{link}/, "<a href='#{link}' target='_blank'>#{link}</a>")
|
60
61
|
end
|
61
62
|
|
62
63
|
tweet.html_safe
|
63
64
|
end
|
65
|
+
|
66
|
+
def sanitize_link(item)
|
67
|
+
#this enables crap like (#ruby) and "http://yahoo.com" to link properly in tweets
|
68
|
+
while item.last =~ /[.,()!?\"\'*]/
|
69
|
+
item.chop!
|
70
|
+
end
|
71
|
+
item
|
72
|
+
end
|
73
|
+
|
64
74
|
end
|
65
75
|
end
|
66
76
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: twitterfeed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mark Capodagli
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-09-02 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: twitter
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- LICENSE
|
39
39
|
- README.md
|
40
40
|
- Rakefile
|
41
|
+
- app/assets/images/bird.jpg
|
41
42
|
- app/assets/images/twitterfeed-logo.gif
|
42
43
|
- app/assets/stylesheets/twitterfeed.css
|
43
44
|
- app/views/twitterfeed/_twitterfeed_box.html.haml
|