Add nsfw banner to attachments

This commit is contained in:
Sol Fisher Romanoff 2022-10-25 14:02:07 +03:00
parent ba9b93bba8
commit 825b4ffd92
No known key found for this signature in database
GPG key ID: 9D3F2B64F2341B62
3 changed files with 25 additions and 1 deletions

View file

@ -1,4 +1,9 @@
<a class="attachment" href="<%= @url %>">
<%= if @nsfw do %>
<div class="nsfw-banner" alt="<%= @name %>" title="<%= @name %>">
<div><%= gettext("Hover to show content") %></div>
</div>
<% end %>
<%= case @mediaType do %>
<% "audio" -> %>
<audio class="u-audio" src="<%= @url %>" controls="controls"></audio>

View file

@ -54,7 +54,7 @@
<div class="attachments">
<%= for %{"name" => name, "url" => [url | _]} <- @attachment do %>
<%= render("_attachment.html", %{name: name, url: url["href"],
mediaType: fetch_media_type(url)}) %>
mediaType: fetch_media_type(url), nsfw: @sensitive}) %>
<% end %>
</div>
<% end %>

View file

@ -442,6 +442,7 @@ .attachment {
display: flex;
flex-grow: 1;
justify-content: center;
position: relative;
min-width: 0;
}
@ -464,3 +465,21 @@ .fa-icon {
.status-actions .fa-icon {
height: 1.1em;
}
.nsfw-banner {
position: absolute;
height: 100%;
display: flex;
align-items: center;
}
.nsfw-banner div {
width: 100%;
text-align: center;
}
.nsfw-banner:not(:hover) {
background-color: var(--background);
}
.nsfw-banner:hover div {
display: none;
}