ruboty-url 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/ruboty/url/actions/title.rb +11 -11
- data/lib/ruboty/url/version.rb +1 -1
- data/test/ruboty/url/actions/title_test.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81cd33b72d31b926cc1ed0dbb100bf97f33366a9
|
4
|
+
data.tar.gz: 5220f5fca994bbf462f566731ac7f90a9ba16513
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb9cbb4ecca2aeb2a6e3735e427f38cb42c17ff986824231a75393eb21666b0d51ab9da263dc17f1ccdc4f0f7566c08d4007b2e01a6b2bbb3a1848c0402de65e
|
7
|
+
data.tar.gz: fa0e987e074823ff585ce87d3022b618a24cd5daedd7d337268fc0b9dbf496b8ad1c891a5ef4b1a1b89d66db7e856bc694462725bc1a96e73c036789651e991e
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ And then execute:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
<img width="
|
23
|
+
<img width="773" alt="screenshot_ruboty-url" src="https://user-images.githubusercontent.com/105469/37564163-a3ef0bba-2ad3-11e8-886e-58f4c8d73957.png">
|
24
24
|
|
25
25
|
This plugin responds with messages including specified URL (such as private URL), and shows HTML title.
|
26
26
|
|
@@ -8,7 +8,7 @@ module Ruboty
|
|
8
8
|
def call
|
9
9
|
url = message[0]
|
10
10
|
attachment = {
|
11
|
-
color: '#
|
11
|
+
color: '#E2E2E2',
|
12
12
|
title_link: url,
|
13
13
|
}
|
14
14
|
open(url) do |f|
|
@@ -16,16 +16,16 @@ module Ruboty
|
|
16
16
|
attachment[:title] = html.xpath('/html/head/title').text
|
17
17
|
|
18
18
|
# optional infos
|
19
|
-
og_title = html.xpath('/html/head/meta[@property="og:title"]/@content').
|
20
|
-
attachment[:title] = og_title if og_title.present?
|
21
|
-
og_site_name = html.xpath('/html/head/meta[@property="og:site_name"]/@content').
|
22
|
-
attachment[:author_name] = og_site_name if og_site_name.present?
|
23
|
-
favicon_url = html.xpath('/html/head/link[@rel="icon"]/@href').
|
24
|
-
attachment[:author_icon] = favicon_url if favicon_url.present?
|
25
|
-
og_description = html.xpath('/html/head/meta[@property="og:description"]/@content').
|
26
|
-
attachment[:text] = og_description if og_description.present?
|
27
|
-
og_image = html.xpath('/html/head/meta[@property="og:image"]/@content').
|
28
|
-
attachment[:thumb_url] = og_image if og_image.present?
|
19
|
+
og_title = html.xpath('/html/head/meta[@property="og:title"]/@content').first
|
20
|
+
attachment[:title] = og_title.text if og_title.present?
|
21
|
+
og_site_name = html.xpath('/html/head/meta[@property="og:site_name"]/@content').first
|
22
|
+
attachment[:author_name] = og_site_name.text if og_site_name.present?
|
23
|
+
favicon_url = html.xpath('/html/head/link[@rel="icon"]/@href').first
|
24
|
+
attachment[:author_icon] = favicon_url.text if favicon_url.present?
|
25
|
+
og_description = html.xpath('/html/head/meta[@property="og:description"]/@content').first
|
26
|
+
attachment[:text] = og_description.text if og_description.present?
|
27
|
+
og_image = html.xpath('/html/head/meta[@property="og:image"]/@content').first
|
28
|
+
attachment[:thumb_url] = og_image.text if og_image.present?
|
29
29
|
end
|
30
30
|
message.reply(nil, attachments: [attachment]) if attachment[:title].present?
|
31
31
|
end
|
data/lib/ruboty/url/version.rb
CHANGED
@@ -18,7 +18,7 @@ describe Ruboty::Url::Actions::Title do
|
|
18
18
|
OpenURI.stubs(:open_uri).yields(StringIO.new("<html><head><title>#{title}</title></head></html>"))
|
19
19
|
# mock
|
20
20
|
attachments = [{
|
21
|
-
color: '#
|
21
|
+
color: '#E2E2E2',
|
22
22
|
title_link: url,
|
23
23
|
title: title,
|
24
24
|
}]
|
@@ -35,10 +35,10 @@ describe Ruboty::Url::Actions::Title do
|
|
35
35
|
it 'should get optional infos' do
|
36
36
|
# stub
|
37
37
|
mock_message.stubs(:[]).with(0).returns(url)
|
38
|
-
OpenURI.stubs(:open_uri).yields(StringIO.new("<html><head><meta property=\"og:image\" content=\"#{og_image}\" /><meta property=\"og:site_name\" content=\"#{og_site_name}\" /><meta property=\"og:type\" content=\"object\" /><meta property=\"og:title\" content=\"#{og_title}\" /><meta property=\"og:url\" content=\"https://github.com/zeero/ruboty-url\" /><meta property=\"og:description\" content=\"#{og_description}\" /><title>#{title}</title><link rel=\"icon\" type=\"image/x-icon\" class=\"js-site-favicon\" href=\"#{favicon_url}\"></head></html>"))
|
38
|
+
OpenURI.stubs(:open_uri).yields(StringIO.new("<html><head><meta property=\"og:image\" content=\"#{og_image}\" /><meta property=\"og:site_name\" content=\"#{og_site_name}\" /><meta property=\"og:type\" content=\"object\" /><meta property=\"og:title\" content=\"#{og_title}\" /><meta property=\"og:url\" content=\"https://github.com/zeero/ruboty-url\" /><meta property=\"og:description\" content=\"#{og_description}\" /><title>#{title}</title><link rel=\"icon\" type=\"image/x-icon\" class=\"js-site-favicon\" href=\"#{favicon_url}\"><link rel=\"icon\" type=\"image/x-icon\" class=\"js-site-favicon\" href=\"#{favicon_url}/dummy\"></head></html>"))
|
39
39
|
# mock
|
40
40
|
attachments = [{
|
41
|
-
color: '#
|
41
|
+
color: '#E2E2E2',
|
42
42
|
title_link: url,
|
43
43
|
title: og_title,
|
44
44
|
author_name: og_site_name,
|