View Source Libmention.Outgoing (libmention v0.1.4)

See Sending Webmentions for the full spec.

Functions for finding links in an html document, discovering webmention support, and sending webmentions from a source_url to a target_url.

Link to this section Summary

Functions

Fetchs the URL and checks for an HTTP Link header with a rel value of webmention.

Find available links in an html document.

Sends a webmention to endpoint.

Link to this section Functions

Link to this function

discover(target_url, opts \\ [])

View Source
@spec discover(
  String.t(),
  keyword()
) :: String.t() | nil

Fetchs the URL and checks for an HTTP Link header with a rel value of webmention.

Initially make an HTTP HEAD request to check for the Link header before making a GET request.

When making a GET request, if the content type of the document is HTML, looks for an HTML <link> and <a> element with a rel value of webmention. If more than one of these is present, the first HTTP Link header takes precedence, followed by the first <link> or <a> element in document order.

Returns the Webmention link found at the target url.

options

Options

  • user_agent - defaults to libmention-Webmention-Discovery
@spec parse(html() | Floki.html_tree()) :: links()

Find available links in an html document.

This is typically used to find links in your post or other html document that may need Webmentions sent.

Link to this function

send(endpoint, source_url, target_url, opts \\ [])

View Source
@spec send(String.t(), String.t(), String.t(), keyword()) ::
  :ok | {:ok, String.t()} | {:error, String.t()}

Sends a webmention to endpoint.

source_url is the URL of the html page containing a link target_url is the URL of the page being linked to

If the endpoint supports sending back a location for monitoring the queued request, an {:ok, url} will be returned, otherwise just an :ok will be returned.

options

Options