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/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

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 an ErrorResponse or response is of an unsupported MIME type.



34
35
36
# File 'lib/webmention.rb', line 34

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

.send_webmention(source, target, vouch: nil) ⇒ Response, 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:



59
60
61
# File 'lib/webmention.rb', line 59

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

.send_webmentions(source, *targets, vouch: nil) ⇒ Array<Response, 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:



84
85
86
# File 'lib/webmention.rb', line 84

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 an ErrorResponse or response is of an unsupported MIME type.



95
96
97
# File 'lib/webmention.rb', line 95

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