IndieWeb.Webmention (IndieWeb v0.0.49) View Source

General facilities around Webmentions.

This module provides methods around handling receiving and sending Webmentions.

Link to this section Summary

Functions

Finds the Webmention endpoint of the provided URI.

Parses properties of an incoming Webmention.

Generates a source URL for the provided resource.

Determines the resource from the provided target URI.

Sends a Webmention to the provided URI.

Defines the adpater to use to resolve URI and source content.

Link to this section Functions

Link to this function

direct_send!(endpoint, target_url, source, opts \\ %{})

View Source

Specs

direct_send!(binary(), binary(), binary(), keyword()) ::
  {:ok, IndieWeb.Webmention.SendResponse.t()} | {:error, atom(), keyword()}

Explicitly sends a Webmention.

Sends a Webmention to the provided endpoint for target from source.

Link to this function

discover_endpoint(page_url)

View Source

Specs

discover_endpoint(binary()) ::
  {:ok, binary()} | {:error, [{:reason, :no_endpoint_found}]}

Finds the Webmention endpoint of the provided URI.

This employs the Webmention endpoint discovery algorithm to find the proper endpoint to send Webmentions for the URI in question.

TODO: Add User-Agent information (by allowing to pass in header options) TODO: This hits every endpoint with a HEAD when it's called - need to cache the value. NOTE: This makes an assumption that the endpoint is self-hosted by default. NOTE: This assumes that a site can only have one Webmention endpoint.

Specs

receive(map()) ::
  {:ok, IndieWeb.Webmention.ReceiveResponse.t()}
  | {:error, :webmention_receive_failure, [{:reason, any()}]}

Parses properties of an incoming Webmention.

This aims to resolve the target of an incoming Webmention and determine if there's a valid action to take from it.

Link to this function

resolve_source_url(source)

View Source

Specs

resolve_source_url(binary()) ::
  {:ok, URI.t()} | {:error, :no_source} | {:error, :no_adapter}

Generates a source URL for the provided resource.

Link to this function

resolve_target_from_url(target_url)

View Source

Specs

resolve_target_from_url(binary()) ::
  {:ok, any()} | {:error, :no_target} | {:error, :no_adapter}

Determines the resource from the provided target URI.

Link to this function

send(target_url, source, opts \\ %{})

View Source

Specs

send(binary(), binary(), map()) ::
  {:ok, IndieWeb.Webmention.SendResponse.t()}
  | {:error, :webmention_send_failure, [{:reason, any()}]}

Sends a Webmention to the provided URI.

This determines the endpoint to send Webmentions to (using discover_endpoint/1) and sends the request using the HTTP client provided.

Specs

url_adapter() :: IndieWeb.Webmention.URIAdapter.t()

Defines the adpater to use to resolve URI and source content.