Remove oembed for now, will submit it in another MR. Fix warnings
This commit is contained in:
parent
018516d3f3
commit
b5de7c4c4d
11 changed files with 22 additions and 164 deletions
|
|
@ -1,14 +1,10 @@
|
|||
defmodule Pleroma.Web.Metadata do
|
||||
alias Phoenix.HTML
|
||||
alias Pleroma.{Web, Formatter}
|
||||
alias Pleroma.{User, Activity}
|
||||
alias Pleroma.{Formatter, User}
|
||||
alias Pleroma.Web.MediaProxy
|
||||
|
||||
def build_tags(request_url, params) do
|
||||
Enum.concat([
|
||||
if(meta_enabled?(:opengraph), do: opengraph_tags(params), else: []),
|
||||
if(meta_enabled?(:oembed), do: oembed_links(request_url), else: [])
|
||||
])
|
||||
def build_tags(params) do
|
||||
if(meta_enabled?(:opengraph), do: opengraph_tags(params), else: [])
|
||||
|> Enum.map(&to_tag/1)
|
||||
|> Enum.map(&HTML.safe_to_string/1)
|
||||
|> Enum.join("\n")
|
||||
|
|
@ -24,13 +20,12 @@ defmodule Pleroma.Web.Metadata do
|
|||
with truncated_content = Formatter.truncate(activity.data["object"]["content"]) do
|
||||
[
|
||||
{:meta,
|
||||
[
|
||||
property: "og:title",
|
||||
content: "#{user.name} (@#{user.nickname}@#{pleroma_domain()}) post ##{activity.id}"
|
||||
], []},
|
||||
[
|
||||
property: "og:title",
|
||||
content: "#{user.name} (@#{user.nickname}@#{pleroma_domain()}) post ##{activity.id}"
|
||||
], []},
|
||||
{:meta, [property: "og:url", content: activity.data["id"]], []},
|
||||
{:meta, [property: "og:description", content: truncated_content],
|
||||
[]},
|
||||
{:meta, [property: "og:description", content: truncated_content], []},
|
||||
{:meta, [property: "og:image", content: user_avatar_url(user)], []},
|
||||
{:meta, [property: "og:image:width", content: 120], []},
|
||||
{:meta, [property: "og:image:height", content: 120], []},
|
||||
|
|
@ -44,10 +39,10 @@ defmodule Pleroma.Web.Metadata do
|
|||
with truncated_bio = Formatter.truncate(user.bio) do
|
||||
[
|
||||
{:meta,
|
||||
[
|
||||
property: "og:title",
|
||||
content: "#{user.name} (@#{user.nickname}@#{pleroma_domain()}) profile"
|
||||
], []},
|
||||
[
|
||||
property: "og:title",
|
||||
content: "#{user.name} (@#{user.nickname}@#{pleroma_domain()}) profile"
|
||||
], []},
|
||||
{:meta, [property: "og:url", content: User.profile_url(user)], []},
|
||||
{:meta, [property: "og:description", content: truncated_bio], []},
|
||||
{:meta, [property: "og:image", content: user_avatar_url(user)], []},
|
||||
|
|
@ -58,13 +53,6 @@ defmodule Pleroma.Web.Metadata do
|
|||
end
|
||||
end
|
||||
|
||||
defp oembed_links(url) do
|
||||
Enum.map(["xml", "json"], fn format ->
|
||||
href = HTML.raw(oembed_path(url, format))
|
||||
{ :link, [ type: ["application/#{format}+oembed"], href: href, rel: 'alternate'], [] }
|
||||
end)
|
||||
end
|
||||
|
||||
def to_tag(data) do
|
||||
with {name, attrs, _content = []} <- data do
|
||||
HTML.Tag.tag(name, attrs)
|
||||
|
|
@ -77,11 +65,6 @@ defmodule Pleroma.Web.Metadata do
|
|||
end
|
||||
end
|
||||
|
||||
defp oembed_path(url, format) do
|
||||
query = URI.encode_query(%{url: url, format: format})
|
||||
"#{Web.base_url()}/oembed?#{query}"
|
||||
end
|
||||
|
||||
defp user_avatar_url(user) do
|
||||
User.avatar_url(user) |> MediaProxy.url()
|
||||
end
|
||||
|
|
@ -89,4 +72,4 @@ defmodule Pleroma.Web.Metadata do
|
|||
def pleroma_domain do
|
||||
Pleroma.Config.get([:instance, :domain], "UNKNOWN_DOMAIN")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue