onebox 1.8.95 → 1.8.96
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onebox/engine/twitter_status_onebox.rb +58 -17
- data/lib/onebox/version.rb +1 -1
- data/templates/twitterstatus.mustache +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f16554d39128fb96f768eb076e102f93a3a3a5b25225470babdc73b595cc039
|
4
|
+
data.tar.gz: e940f9efc136221d4343871fe9ed7032879866358d9c06cba4224d0a6b9d1e9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2331514eb4a99ccb813fd8f61522d326d42209a7bb184b24cc8484fa85b7894b8fcfb78806a5a6bbe9012a645c141f5bec30c34d9a900c8d0616671df2bd994
|
7
|
+
data.tar.gz: 484b176b361a4afb29d334a8491a9e3dcc51686594c96b23162a2c634b58d357d3e851bf8ecaf952aa847ac86546b34938057eabbf8bfaf9ee6fe20bcb3b6a7a
|
@@ -23,7 +23,7 @@ module Onebox
|
|
23
23
|
twitter_data[m_property.to_sym] = m_content
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
twitter_data
|
27
27
|
end
|
28
28
|
|
29
29
|
def match
|
@@ -31,7 +31,7 @@ module Onebox
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def twitter_data
|
34
|
-
@twitter_data
|
34
|
+
@twitter_data ||= get_twitter_data
|
35
35
|
end
|
36
36
|
|
37
37
|
def client
|
@@ -51,9 +51,7 @@ module Onebox
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def access(*keys)
|
54
|
-
|
55
|
-
memo[key] || memo[key.to_s]
|
56
|
-
end
|
54
|
+
raw.dig *keys
|
57
55
|
end
|
58
56
|
|
59
57
|
def tweet
|
@@ -66,13 +64,12 @@ module Onebox
|
|
66
64
|
|
67
65
|
def timestamp
|
68
66
|
if twitter_api_credentials_present?
|
69
|
-
|
70
|
-
date = DateTime.strptime(created_at, "%a %b %d %H:%M:%S %z %Y")
|
67
|
+
date = DateTime.strptime(access(:created_at), "%a %b %d %H:%M:%S %z %Y")
|
71
68
|
user_offset = access(:user, :utc_offset).to_i
|
72
69
|
offset = (user_offset >= 0 ? "+" : "-") + Time.at(user_offset.abs).gmtime.strftime("%H%M")
|
73
70
|
date.new_offset(offset).strftime("%-l:%M %p - %-d %b %Y")
|
74
71
|
else
|
75
|
-
|
72
|
+
attr_at_css(".tweet-timestamp", 'title')
|
76
73
|
end
|
77
74
|
end
|
78
75
|
|
@@ -80,7 +77,7 @@ module Onebox
|
|
80
77
|
if twitter_api_credentials_present?
|
81
78
|
"#{access(:user, :name)} (#{access(:user, :screen_name)})"
|
82
79
|
else
|
83
|
-
"#{
|
80
|
+
"#{attr_at_css('.tweet.permalink-tweet', 'data-name')} (#{attr_at_css('.tweet.permalink-tweet', 'data-screen-name')})"
|
84
81
|
end
|
85
82
|
end
|
86
83
|
|
@@ -94,30 +91,74 @@ module Onebox
|
|
94
91
|
|
95
92
|
def likes
|
96
93
|
if twitter_api_credentials_present?
|
97
|
-
|
98
|
-
return count > 0 ? client.prettify_number(count) : nil
|
94
|
+
prettify_number(access(:favorite_count).to_i)
|
99
95
|
else
|
100
|
-
|
96
|
+
attr_at_css(".request-favorited-popup", 'data-compact-localized-count')
|
101
97
|
end
|
102
98
|
end
|
103
99
|
|
104
100
|
def retweets
|
105
101
|
if twitter_api_credentials_present?
|
106
|
-
|
107
|
-
return count > 0 ? client.prettify_number(count) : nil
|
102
|
+
prettify_number(access(:retweet_count).to_i)
|
108
103
|
else
|
109
|
-
|
104
|
+
attr_at_css(".request-retweeted-popup", 'data-compact-localized-count')
|
110
105
|
end
|
111
106
|
end
|
112
107
|
|
108
|
+
def quoted_full_name
|
109
|
+
if twitter_api_credentials_present?
|
110
|
+
access(:quoted_status, :user, :name)
|
111
|
+
else
|
112
|
+
raw.css('.QuoteTweet-fullname')[0]&.text
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def quoted_screen_name
|
117
|
+
if twitter_api_credentials_present?
|
118
|
+
access(:quoted_status, :user, :screen_name)
|
119
|
+
else
|
120
|
+
attr_at_css(".QuoteTweet-innerContainer", "data-screen-name")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def quoted_tweet
|
125
|
+
if twitter_api_credentials_present?
|
126
|
+
access(:quoted_status, :full_text)
|
127
|
+
else
|
128
|
+
raw.css('.QuoteTweet-text')[0]&.text
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def quoted_link
|
133
|
+
if twitter_api_credentials_present?
|
134
|
+
"https://twitter.com/#{quoted_screen_name}/status/#{access(:quoted_status, :id)}"
|
135
|
+
else
|
136
|
+
"https://twitter.com#{attr_at_css(".QuoteTweet-innerContainer", "href")}"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def prettify_number(count)
|
141
|
+
count > 0 ? client.prettify_number(count) : nil
|
142
|
+
end
|
143
|
+
|
144
|
+
def attr_at_css(css_property, attribute_name)
|
145
|
+
raw.at_css(css_property)&.attr(attribute_name)
|
146
|
+
end
|
147
|
+
|
113
148
|
def data
|
114
|
-
|
149
|
+
@data ||= {
|
150
|
+
link: link,
|
115
151
|
tweet: tweet,
|
116
152
|
timestamp: timestamp,
|
117
153
|
title: title,
|
118
154
|
avatar: avatar,
|
119
155
|
likes: likes,
|
120
|
-
retweets: retweets
|
156
|
+
retweets: retweets,
|
157
|
+
quoted_tweet: quoted_tweet,
|
158
|
+
quoted_full_name: quoted_full_name,
|
159
|
+
quoted_screen_name: quoted_screen_name,
|
160
|
+
quoted_link: quoted_link
|
161
|
+
}
|
121
162
|
end
|
122
163
|
end
|
123
164
|
end
|
data/lib/onebox/version.rb
CHANGED
@@ -5,7 +5,19 @@
|
|
5
5
|
</a>
|
6
6
|
</h4>
|
7
7
|
|
8
|
-
<div class="tweet">
|
8
|
+
<div class="tweet">
|
9
|
+
{{{tweet}}}
|
10
|
+
{{#quoted_tweet}}
|
11
|
+
<a class="quoted-link" href="{{quoted_link}}">
|
12
|
+
<div class="quoted">
|
13
|
+
<p class="quoted-title">{{quoted_full_name}} <span>@{{quoted_screen_name}}</span></p>
|
14
|
+
<div>
|
15
|
+
{{quoted_tweet}}
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
</a>
|
19
|
+
{{/quoted_tweet}}
|
20
|
+
</div>
|
9
21
|
|
10
22
|
<div class='date'>
|
11
23
|
<a href="{{link}}" target="_blank">{{timestamp}}</a>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.96
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joanna Zeta
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-07-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|