From ada384207b2b49ce410ea19b45c97868625d6d8d Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Fri, 19 Apr 2019 07:50:21 +0000 Subject: [PATCH] typo fix docs for RelMe provider --- CHANGELOG.md | 1 + README.md | 2 +- config/config.exs | 4 +++- docs/config.md | 3 ++- lib/pleroma/web/metadata/rel_me.ex | 13 +++++++++++++ test/web/metadata/rel_me_test.exs | 18 ++++++++++++++++++ 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 lib/pleroma/web/metadata/rel_me.ex create mode 100644 test/web/metadata/rel_me_test.exs diff --git a/CHANGELOG.md b/CHANGELOG.md index 21ad83a01..c90ff61cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Mastodon API: `/api/v1/notifications/destroy_multiple` (glitch-soc extension) - Mastodon API: [Reports](https://docs.joinmastodon.org/api/rest/reports/) - ActivityPub C2S: OAuth endpoints +- Metadata RelMe provider ### Changed - **Breaking:** Configuration: move from Pleroma.Mailer to Pleroma.Emails.Mailer diff --git a/README.md b/README.md index c45190fc3..987f973ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Pleroma -**Note**: This readme as well as complete documentation is also availible at +**Note**: This readme as well as complete documentation is also available at ## About Pleroma diff --git a/config/config.exs b/config/config.exs index 595e3505c..1114dc84d 100644 --- a/config/config.exs +++ b/config/config.exs @@ -337,7 +337,9 @@ ip: {0, 0, 0, 0}, port: 9999 -config :pleroma, Pleroma.Web.Metadata, providers: [], unfurl_nsfw: false +config :pleroma, Pleroma.Web.Metadata, + providers: [Pleroma.Web.Metadata.Providers.RelMe], + unfurl_nsfw: false config :pleroma, :suggestions, enabled: false, diff --git a/docs/config.md b/docs/config.md index d618c5dde..5a97033b2 100644 --- a/docs/config.md +++ b/docs/config.md @@ -343,9 +343,10 @@ This config contains two queues: `federator_incoming` and `federator_outgoing`. * `max_retries`: The maximum number of times a federation job is retried ## Pleroma.Web.Metadata -* `providers`: a list of metadata providers to enable. Providers availible: +* `providers`: a list of metadata providers to enable. Providers available: * Pleroma.Web.Metadata.Providers.OpenGraph * Pleroma.Web.Metadata.Providers.TwitterCard + * Pleroma.Web.Metadata.Providers.RelMe - add links from user bio with rel=me into the `
` as `` * `unfurl_nsfw`: If set to `true` nsfw attachments will be shown in previews ## :rich_media diff --git a/lib/pleroma/web/metadata/rel_me.ex b/lib/pleroma/web/metadata/rel_me.ex new file mode 100644 index 000000000..03af899c4 --- /dev/null +++ b/lib/pleroma/web/metadata/rel_me.ex @@ -0,0 +1,13 @@ +defmodule Pleroma.Web.Metadata.Providers.RelMe do + alias Pleroma.Web.Metadata.Providers.Provider + @behaviour Provider + + @impl Provider + def build_tags(%{user: user}) do + (Floki.attribute(user.bio, "link[rel~=me]", "href") ++ + Floki.attribute(user.bio, "a[rel~=me]", "href")) + |> Enum.map(fn link -> + {:link, [rel: "me", href: link], []} + end) + end +end diff --git a/test/web/metadata/rel_me_test.exs b/test/web/metadata/rel_me_test.exs new file mode 100644 index 000000000..f66bf7834 --- /dev/null +++ b/test/web/metadata/rel_me_test.exs @@ -0,0 +1,18 @@ +defmodule Pleroma.Web.Metadata.Providers.RelMeTest do + use Pleroma.DataCase + import Pleroma.Factory + alias Pleroma.Web.Metadata.Providers.RelMe + + test "it renders all links with rel='me' from user bio" do + bio = + ~s(https://some-link.com https://another-link.com + "], []}, + {:link, [rel: "me", href: "https://another-link.com"], []} + ] + end +end