Skip to content

Commit

Permalink
Upgrade to Webmention client 7.0.0
Browse files Browse the repository at this point in the history
The Webmention and IndieWeb libraries have gone through some API churn,
and these changes are intended to accommodate that churn.

This should resolve issue #138.
  • Loading branch information
fancypantalons committed Nov 28, 2022
1 parent 55cf627 commit 28a07fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion jekyll-webmention_io.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ EOF
s.add_runtime_dependency "string_inflection", "~> 0.1"
s.add_runtime_dependency "htmlbeautifier", "~> 1.1"
s.add_runtime_dependency "uglifier", "~> 4.1"
s.add_runtime_dependency "webmention", "~> 0.1.6"
s.add_runtime_dependency "webmention", "~> 7.0"

s.add_development_dependency "bundler", "~> 2.2"
s.add_development_dependency "cucumber", "~> 3.1"
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/commands/webmention.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def self.process(_args = [], options = {})
next unless endpoint

# get the response
response = WebmentionIO.webmention(source, escaped, endpoint)
response = WebmentionIO.webmention(source, target)
next unless response

# capture JSON responses in case site wants to do anything with them
Expand Down
14 changes: 8 additions & 6 deletions lib/jekyll/webmention_io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
require "uri"
require "openssl"
require "string_inflection"
require "indieweb/endpoints"
require "webmention"

module Jekyll
Expand Down Expand Up @@ -209,7 +210,7 @@ def self.get_date_from_string(text)
def self.get_webmention_endpoint(uri)
# log "info", "Looking for webmention endpoint at #{uri}"
begin
endpoint = Webmention::Client.supports_webmention?(uri)
endpoint = IndieWeb::Endpoints.get(uri)[:webmention]
unless endpoint
log("info", "Could not find a webmention endpoint at #{uri}")
uri_is_not_ok(uri)
Expand All @@ -222,16 +223,17 @@ def self.get_webmention_endpoint(uri)
endpoint
end

def self.webmention(source, target, endpoint)
def self.webmention(source, target)
log "info", "Sending webmention of #{target} in #{source}"
# return `curl -s -i -d \"source=#{source}&target=#{target}\" -o /dev/null #{endpoint}`
mention = Webmention::Client.send_mention(endpoint, source, target, true)
case mention.response
response = Webmention.send_webmention(source, target)

case response
when Net::HTTPOK, Net::HTTPCreated, Net::HTTPAccepted
log "info", "Webmention successful!"
mention.response.body
response.body
else
log "info", mention.inspect
log "info", response.inspect
log "info", "Webmention failed, but will remain queued for next time"
false
end
Expand Down

0 comments on commit 28a07fa

Please sign in to comment.