forked from AkkomaGang/akkoma
Player: allow styles on CSP, loop videos
This commit is contained in:
parent
aa9af1d639
commit
f4bfc628ca
4 changed files with 9 additions and 9 deletions
|
@ -3,10 +3,10 @@ defmodule Pleroma.Web.Metadata.PlayerView do
|
||||||
import Phoenix.HTML.Tag, only: [content_tag: 3, tag: 2]
|
import Phoenix.HTML.Tag, only: [content_tag: 3, tag: 2]
|
||||||
|
|
||||||
def render("player.html", %{"mediaType" => type, "href" => href}) do
|
def render("player.html", %{"mediaType" => type, "href" => href}) do
|
||||||
tag_type =
|
{tag_type, tag_attrs} =
|
||||||
case type do
|
case type do
|
||||||
"audio" <> _ -> :audio
|
"audio" <> _ -> {:audio, []}
|
||||||
"video" <> _ -> :video
|
"video" <> _ -> {:video, [loop: true]}
|
||||||
end
|
end
|
||||||
|
|
||||||
content_tag(
|
content_tag(
|
||||||
|
@ -15,7 +15,7 @@ def render("player.html", %{"mediaType" => type, "href" => href}) do
|
||||||
tag(:source, src: href, type: type),
|
tag(:source, src: href, type: type),
|
||||||
"Your browser does not support #{type} playback."
|
"Your browser does not support #{type} playback."
|
||||||
],
|
],
|
||||||
controls: true
|
[controls: true] ++ tag_attrs
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -104,8 +104,8 @@ defp build_attachments(id, z = %{data: %{"attachment" => attachments}}) do
|
||||||
[
|
[
|
||||||
{:meta, [property: "twitter:card", content: "player"], []},
|
{:meta, [property: "twitter:card", content: "player"], []},
|
||||||
{:meta, [property: "twitter:player", content: player_url(id)], []},
|
{:meta, [property: "twitter:player", content: player_url(id)], []},
|
||||||
{:meta, [property: "twitter:player:width", content: "1280"], []},
|
{:meta, [property: "twitter:player:width", content: "480"], []},
|
||||||
{:meta, [property: "twitter:player:height", content: "720"], []}
|
{:meta, [property: "twitter:player:height", content: "480"], []}
|
||||||
| acc
|
| acc
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ def notice_player(conn, %{"id" => id}) do
|
||||||
|> put_resp_header("x-frame-options", "ALLOW")
|
|> put_resp_header("x-frame-options", "ALLOW")
|
||||||
|> put_resp_header(
|
|> put_resp_header(
|
||||||
"content-security-policy",
|
"content-security-policy",
|
||||||
"default-src 'none'; img-src 'self' data: https:; media-src 'self' https:;"
|
"default-src 'none';style-src 'self' 'unsafe-inline';img-src 'self' data: https:; media-src 'self' https:;"
|
||||||
)
|
)
|
||||||
|> put_view(Pleroma.Web.Metadata.PlayerView)
|
|> put_view(Pleroma.Web.Metadata.PlayerView)
|
||||||
|> render("player.html", url)
|
|> render("player.html", url)
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
video {
|
video, audio {
|
||||||
width:100%;
|
width:100%;
|
||||||
max-width:600px;
|
max-width:600px;
|
||||||
height:auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue