Module: Webmention

Defined in:
lib/webmention.rb,
lib/webmention/url.rb,
lib/webmention/client.rb,
lib/webmention/parser.rb,
lib/webmention/request.rb,
lib/webmention/version.rb,
lib/webmention/response.rb,
lib/webmention/verification.rb,
lib/webmention/error_response.rb,
lib/webmention/parsers/html_parser.rb,
lib/webmention/parsers/json_parser.rb,
lib/webmention/parsers/plaintext_parser.rb

Defined Under Namespace

Modules: Parsers Classes: Client, ErrorResponse, Parser, Request, Response, Url, Verification

Constant Summary collapse

VERSION =
"8.0.0"

Class Method Summary collapse

Class Method Details

.mentioned_urls(url) ⇒ Array<String>

Retrieve unique URLs mentioned by the provided URL.

Examples:

Webmention.mentioned_urls('https://jgarber.example/posts/100')

Parameters:

  • url (String, HTTP::URI, #to_s)

    An absolute URL.

Returns:

  • (Array<String>)

Raises:

  • (NoMethodError)

    Raised when response is a Webmention::ErrorResponse or response is of an unsupported MIME type.



36
37
38
# File 'lib/webmention.rb', line 36

def self.mentioned_urls(url)
  Client.new(url).mentioned_urls
end

.send_webmention(source, target, vouch: nil) ⇒ Webmention::Response, Webmention::ErrorResponse

Send a webmention from a source URL to a target URL.

Examples:

Send a webmention

source = 'https://jgarber.example/posts/100'
target = 'https://aaronpk.example/notes/1'
Webmention.send_webmention(source, target)

Send a webmention with a vouch URL

source = 'https://jgarber.example/posts/100'
target = 'https://aaronpk.example/notes/1'
Webmention.send_webmention(source, target, vouch: 'https://tantek.example/notes/1')

Parameters:

  • source (String, HTTP::URI, #to_s)

    An absolute URL representing a source document.

  • target (String, HTTP::URI, #to_s)

    An absolute URL representing a target document.

  • vouch (String, HTTP::URI, #to_s) (defaults to: nil)

    An absolute URL representing a document vouching for the source document. See indieweb.org/Vouch for additional details.

Returns:



61
62
63
# File 'lib/webmention.rb', line 61

def self.send_webmention(source, target, vouch: nil)
  Client.new(source, vouch: vouch).send_webmention(target)
end

.send_webmentions(source, *targets, vouch: nil) ⇒ Array<Webmention::Response, Webmention::ErrorResponse>

Send webmentions from a source URL to multiple target URLs.

Examples:

Send multiple webmentions

source = 'https://jgarber.example/posts/100'
targets = ['https://aaronpk.example/notes/1', 'https://adactio.example/notes/1']
Webmention.send_webmentions(source, targets)

Send multiple webmentions with a vouch URL

source = 'https://jgarber.example/posts/100'
targets = ['https://aaronpk.example/notes/1', 'https://adactio.example/notes/1']
Webmention.send_webmentions(source, targets, vouch: 'https://tantek.example/notes/1')

Parameters:

  • source (String, HTTP::URI, #to_s)

    An absolute URL representing a source document.

  • targets (Array<String, HTTP::URI, #to_s>)

    An array of absolute URLs representing multiple target documents.

  • vouch (String, HTTP::URI, #to_s) (defaults to: nil)

    An absolute URL representing a document vouching for the source document. See indieweb.org/Vouch for additional details.

Returns:



86
87
88
# File 'lib/webmention.rb', line 86

def self.send_webmentions(source, *targets, vouch: nil)
  Client.new(source, vouch: vouch).send_webmentions(*targets)
end

.verify_webmention(source, target, vouch: nil) ⇒ Boolean

Verify that a source URL links to a target URL.

Parameters:

  • source (String, HTTP::URI, #to_s)

    An absolute URL representing a source document.

  • target (String, HTTP::URI, #to_s)

    An absolute URL representing a target document.

  • vouch (String, HTTP::URI, #to_s) (defaults to: nil)

    An absolute URL representing a document vouching for the source document. See indieweb.org/Vouch for additional details.

Returns:

  • (Boolean)

Raises:

  • (NoMethodError)

    Raised when response is a Webmention::ErrorResponse or response is of an unsupported MIME type.



97
98
99
# File 'lib/webmention.rb', line 97

def self.verify_webmention(source, target, vouch: nil)
  Client.new(source, vouch: vouch).verify_webmention(target)
end