A Webmention module for Elixir.
This package is available in Hex
-
Add webmentions to your list of dependencies in
mix.exs
:def deps do [{:webmentions, "~> 2.0.0"}] end
Just call Webmentions.send_webmentions("http://example.org/")
where
the URL is the URL of the source document:
Webmentions.send_webmentions("http://example.org/", opts \\ [])
Options include:
root_selector
: css class filtering the block where to look for links (default:.h-entry
)reject_nofollow
: doesn't send webmention to links withrel="nofollow"
attribute (default:true
)
This will give you either
{:ok, [%Webmentions.Response{}]}
where the list contains a list of response structures for each endpoint we sent a webmention to or
{:error, reason}
If you already know the list of URL mentions, you can skip parsing the source URL and send webmentions to all destinations URL (if they support it):
destinations = ["http://example.org/", "http://other.org/"]
Webmentions.send_webmentions_for_links("https://source.org", destinations)
It will behave as Webmentions.send_webmentions/2
does.
We need Floki for HTML parsing and Tesla for HTTP communication.