webmention 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/webmention.rb CHANGED
@@ -5,5 +5,5 @@ require 'open-uri'
5
5
  require 'set'
6
6
  require 'uri'
7
7
 
8
- require 'webmention/version'
9
- require 'webmention/client'
8
+ require './lib/webmention/version'
9
+ require './lib/webmention/client'
@@ -27,7 +27,7 @@ module Webmention
27
27
  raise ArgumentError.new "url is nil."
28
28
  end
29
29
 
30
- Nokogiri::HTML(open(self.url)).css('a').each do |link|
30
+ Nokogiri::HTML(open(self.url)).css('.h-entry a').each do |link|
31
31
  link = link.attribute('href').to_s
32
32
  if Webmention::Client.valid_http_url? link
33
33
  @links.add link
@@ -69,16 +69,20 @@ module Webmention
69
69
  :target => target,
70
70
  }
71
71
 
72
- uri = URI.parse(endpoint)
73
- http = Net::HTTP.new(uri.host, uri.port)
72
+ begin
73
+ uri = URI.parse(endpoint)
74
+ http = Net::HTTP.new(uri.host, uri.port)
74
75
 
75
- request = Net::HTTP::Post.new(uri.request_uri)
76
- request.set_form_data(data)
77
- request['Content-Type'] = "application/x-www-form-urlencoded"
78
- request['Accept'] = 'application/json'
79
- response = http.request(request)
76
+ request = Net::HTTP::Post.new(uri.request_uri)
77
+ request.set_form_data(data)
78
+ request['Content-Type'] = "application/x-www-form-urlencoded"
79
+ request['Accept'] = 'application/json'
80
+ response = http.request(request)
80
81
 
81
- return response.code.to_i == 200
82
+ return response.code.to_i == 200
83
+ rescue
84
+ return false
85
+ end
82
86
  end
83
87
 
84
88
  # Public: Fetch a url and check if it supports webmention
@@ -1,3 +1,3 @@
1
1
  module Webmention
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -75,7 +75,7 @@ class SampleData
75
75
  <head>
76
76
  <title>Sample Post</title>
77
77
  </head>
78
- <body>
78
+ <body class="h-entry">
79
79
  <p><a href="http://target.example.com/post/4">Link to Target 4</a></p>
80
80
  <p><a href="http://target.example.com/post/5">Link to Target 5</a></p>
81
81
  </body>
data/webmention.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'webmention/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'webmention'
7
7
  s.version = Webmention::VERSION
8
- s.date = '2013-09-14'
8
+ s.date = '2014-05-25'
9
9
  s.homepage = 'https://github.com/indieweb/mention-client-ruby'
10
10
  s.summary = 'A gem for sending webmention (and pingback) notifications'
11
11
  s.authors = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmention
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-09-14 00:00:00.000000000 Z
13
+ date: 2014-05-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json