forked from AkkomaGang/akkoma
static-fe overhaul (#236)
makes static-fe look more like pleroma-fe, with the stylesheets matching pleroma-dark and pleroma-light based on `prefers-color-scheme`. - [x] navbar - [x] about sidebar - [x] background image - [x] statuses - [x] "reply to" or "edited" tags - [x] accounts - [x] show more / show less - [x] posts / with replies / media / followers / following - [x] followers/following would require user card snippets - [x] admin/bot indicators - [x] attachments - [x] nsfw attachments - [x] fontawesome icons - [x] clean up and sort css - [x] add pleroma-light - [x] replace hardcoded strings also i forgot - [x] repeated headers how it looks + sneak peek at statuses: ![](https://akkoma.dev/attachments/c0d3a025-6987-4630-8eb9-5f4db6858359) Co-authored-by: Sol Fisher Romanoff <sol@solfisher.com> Reviewed-on: AkkomaGang/akkoma#236 Co-authored-by: sfr <sol@solfisher.com> Co-committed-by: sfr <sol@solfisher.com>
This commit is contained in:
parent
09326ffa56
commit
7c4b415929
21 changed files with 525 additions and 126 deletions
5
.gitattributes
vendored
5
.gitattributes
vendored
|
@ -1,10 +1,11 @@
|
|||
*.ex diff=elixir
|
||||
*.exs diff=elixir
|
||||
|
||||
priv/static/instance/static.css diff=css
|
||||
|
||||
# Most of js/css files included in the repo are minified bundles,
|
||||
# and we don't want to search/diff those as text files.
|
||||
*.js binary
|
||||
*.js.map binary
|
||||
*.css binary
|
||||
|
||||
priv/static/instance/static.css diff=css
|
||||
priv/static/static-fe/static-fe.css diff=css
|
||||
|
|
|
@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- NormalizeMarkup MRF is now on by default
|
||||
- Follow/Block/Mute imports now spin off into *n* tasks to avoid the oban timeout
|
||||
- Transient activities recieved from remote servers are no longer persisted in the database
|
||||
- Overhauled static-fe view for logged-out users
|
||||
|
||||
## Upgrade Notes
|
||||
- If you have an old instance, you will probably want to run `mix pleroma.database prune_task` in the foreground to catch it up with the history of your instance.
|
||||
|
|
|
@ -728,6 +728,12 @@ defmodule Pleroma.Web.Router do
|
|||
get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
|
||||
end
|
||||
|
||||
scope "/", Pleroma.Web.StaticFE do
|
||||
# Profile pages for static-fe
|
||||
get("/users/:nickname/with_replies", StaticFEController, :show)
|
||||
get("/users/:nickname/media", StaticFEController, :show)
|
||||
end
|
||||
|
||||
scope "/", Pleroma.Web do
|
||||
pipe_through(:accepts_html)
|
||||
get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
|
||||
|
@ -771,10 +777,16 @@ defmodule Pleroma.Web.Router do
|
|||
post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
|
||||
post("/api/ap/upload_media", ActivityPubController, :upload_media)
|
||||
|
||||
get("/users/:nickname/collections/featured", ActivityPubController, :pinned)
|
||||
end
|
||||
|
||||
scope "/", Pleroma.Web.ActivityPub do
|
||||
# Note: html format is supported only if static FE is enabled
|
||||
pipe_through([:accepts_html_json, :static_fe, :activitypub_client])
|
||||
|
||||
# The following two are S2S as well, see `ActivityPub.fetch_follow_information_for_user/1`:
|
||||
get("/users/:nickname/followers", ActivityPubController, :followers)
|
||||
get("/users/:nickname/following", ActivityPubController, :following)
|
||||
get("/users/:nickname/collections/featured", ActivityPubController, :pinned)
|
||||
end
|
||||
|
||||
scope "/", Pleroma.Web.ActivityPub do
|
||||
|
|
|
@ -45,7 +45,7 @@ def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do
|
|||
end
|
||||
end
|
||||
|
||||
def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do
|
||||
def show(%{assigns: %{username_or_id: username_or_id, tab: tab}} = conn, params) do
|
||||
with {_, %User{local: true} = user} <-
|
||||
{:fetch_user, User.get_cached_by_nickname_or_id(username_or_id)},
|
||||
{_, :visible} <- {:visibility, User.visible_for(user, _reading_user = nil)} do
|
||||
|
@ -55,12 +55,37 @@ def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do
|
|||
params
|
||||
|> Map.take(@page_keys)
|
||||
|> Map.new(fn {k, v} -> {String.to_existing_atom(k), v} end)
|
||||
|> Map.put(:limit, 20)
|
||||
|
||||
params =
|
||||
case tab do
|
||||
"posts" ->
|
||||
Map.put(params, :exclude_replies, true)
|
||||
|
||||
"media" ->
|
||||
Map.put(params, :only_media, true)
|
||||
|
||||
_ ->
|
||||
params
|
||||
end
|
||||
|
||||
timeline =
|
||||
case tab do
|
||||
tab when tab in ["posts", "with_replies", "media"] ->
|
||||
user
|
||||
|> ActivityPub.fetch_user_activities(_reading_user = nil, params)
|
||||
|> Enum.map(&represent/1)
|
||||
|
||||
"following" when not user.hide_follows ->
|
||||
User.get_friends(user)
|
||||
|
||||
"followers" when not user.hide_followers ->
|
||||
User.get_followers(user)
|
||||
|
||||
_ ->
|
||||
[]
|
||||
end
|
||||
|
||||
prev_page_id =
|
||||
(params["min_id"] || params["max_id"]) &&
|
||||
List.first(timeline) && List.first(timeline).id
|
||||
|
@ -75,6 +100,11 @@ def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do
|
|||
meta: meta
|
||||
})
|
||||
else
|
||||
{_, %User{} = user} ->
|
||||
conn
|
||||
|> put_status(:found)
|
||||
|> redirect(external: user.uri || user.ap_id)
|
||||
|
||||
_ ->
|
||||
not_found(conn, "User not found.")
|
||||
end
|
||||
|
@ -150,6 +180,23 @@ defp represent(%Activity{object: %Object{data: data}} = activity, selected) do
|
|||
nil
|
||||
end
|
||||
|
||||
reply_to_user =
|
||||
if data["inReplyTo"] do
|
||||
activity
|
||||
|> Activity.get_in_reply_to_activity()
|
||||
|> Map.get(:actor)
|
||||
|> User.get_cached_by_ap_id()
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
total_votes =
|
||||
if data["oneOf"] do
|
||||
Enum.sum(for option <- data["oneOf"], do: option["replies"]["totalItems"])
|
||||
else
|
||||
0
|
||||
end
|
||||
|
||||
%{
|
||||
user: User.sanitize_html(user),
|
||||
title: get_title(activity.object),
|
||||
|
@ -160,7 +207,13 @@ defp represent(%Activity{object: %Object{data: data}} = activity, selected) do
|
|||
sensitive: data["sensitive"],
|
||||
selected: selected,
|
||||
counts: get_counts(activity),
|
||||
id: activity.id
|
||||
id: activity.id,
|
||||
visibility: Visibility.get_visibility(activity.object),
|
||||
reply_to: data["inReplyTo"],
|
||||
reply_to_user: reply_to_user,
|
||||
edited_at: data["updated"],
|
||||
poll: data["oneOf"],
|
||||
total_votes: total_votes
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -177,7 +230,16 @@ defp assign_id(%{path_info: [_nickname, "status", notice_id]} = conn, _opts),
|
|||
do: assign(conn, :notice_id, notice_id)
|
||||
|
||||
defp assign_id(%{path_info: ["users", user_id]} = conn, _opts),
|
||||
do: assign(conn, :username_or_id, user_id)
|
||||
do:
|
||||
conn
|
||||
|> assign(:username_or_id, user_id)
|
||||
|> assign(:tab, "posts")
|
||||
|
||||
defp assign_id(%{path_info: ["users", user_id, tab]} = conn, _opts),
|
||||
do:
|
||||
conn
|
||||
|> assign(:username_or_id, user_id)
|
||||
|> assign(:tab, tab)
|
||||
|
||||
defp assign_id(%{path_info: ["objects", object_id]} = conn, _opts),
|
||||
do: assign(conn, :object_id, object_id)
|
||||
|
|
|
@ -8,7 +8,6 @@ defmodule Pleroma.Web.StaticFE.StaticFEView do
|
|||
alias Calendar.Strftime
|
||||
alias Pleroma.Emoji.Formatter
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.Endpoint
|
||||
alias Pleroma.Web.Gettext
|
||||
alias Pleroma.Web.MediaProxy
|
||||
alias Pleroma.Web.Metadata.Utils
|
||||
|
@ -22,17 +21,38 @@ def fetch_media_type(%{"mediaType" => mediaType}) do
|
|||
Utils.fetch_media_type(@media_types, mediaType)
|
||||
end
|
||||
|
||||
def time_ago(date) do
|
||||
{:ok, date, _} = DateTime.from_iso8601(date)
|
||||
now = DateTime.utc_now()
|
||||
|
||||
Timex.from_now(date, now)
|
||||
end
|
||||
|
||||
def format_date(date) do
|
||||
{:ok, date, _} = DateTime.from_iso8601(date)
|
||||
Strftime.strftime!(date, "%Y/%m/%d %l:%M:%S %p UTC")
|
||||
end
|
||||
|
||||
def instance_name, do: Pleroma.Config.get([:instance, :name], "Pleroma")
|
||||
def instance_name, do: Pleroma.Config.get([:instance, :name], "Akkoma")
|
||||
|
||||
def open_content? do
|
||||
Pleroma.Config.get(
|
||||
[:frontend_configurations, :collapse_message_with_subjects],
|
||||
true
|
||||
false
|
||||
)
|
||||
end
|
||||
|
||||
def get_attachment_name(%{"name" => name}), do: name
|
||||
|
||||
def get_attachment_name(_), do: ""
|
||||
|
||||
def poll_percentage(count, total_votes) do
|
||||
case count do
|
||||
0 ->
|
||||
"0%"
|
||||
|
||||
_ ->
|
||||
Integer.to_string(trunc(count / total_votes * 100)) <> "%"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,10 +6,39 @@
|
|||
<title><%= Pleroma.Config.get([:instance, :name]) %></title>
|
||||
<%= Phoenix.HTML.raw(assigns[:meta] || "") %>
|
||||
<link rel="stylesheet" href="/static-fe/static-fe.css">
|
||||
<link rel="icon" type="image/png" href="/favicon.png">
|
||||
</head>
|
||||
<body>
|
||||
<div class="background-image"></div>
|
||||
<nav>
|
||||
<div class="inner-nav">
|
||||
<a class="site-brand" href="/">
|
||||
<img class="favicon" src="/favicon.png" />
|
||||
<span><%= Pleroma.Config.get([:instance, :name]) %></span>
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container">
|
||||
<div class="underlay"></div>
|
||||
<div class="column main">
|
||||
<%= @inner_content %>
|
||||
</div>
|
||||
<div class="column sidebar">
|
||||
<div class="about panel">
|
||||
<div class="panel-heading">
|
||||
<%= gettext("About %{instance}", instance: Pleroma.Config.get([:instance, :name])) %>
|
||||
</div>
|
||||
<div class="about-content">
|
||||
<%= raw render_html("/static/terms-of-service.html") %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--background-image: url("<%= Pleroma.Config.get([:instance, :background_image]) %>");
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
<%= case @mediaType do %>
|
||||
<% "audio" -> %>
|
||||
<audio class="u-audio" src="<%= @url %>" controls="controls"></audio>
|
||||
<% "video" -> %>
|
||||
<video class="u-video" src="<%= @url %>" controls="controls"></video>
|
||||
<% _ -> %>
|
||||
<img class="u-photo" src="<%= @url %>" alt="<%= @name %>" title="<%= @name %>">
|
||||
<% end %>
|
||||
<a class="attachment" href="<%= @url %>" alt=<%= @name %>" title="<%= @name %>">
|
||||
<%= if @nsfw do %>
|
||||
<div class="nsfw-banner">
|
||||
<div><%= gettext("Hover to show content") %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= case @mediaType do %>
|
||||
<% "audio" -> %>
|
||||
<audio class="u-audio" src="<%= @url %>" controls="controls"></audio>
|
||||
<% "video" -> %>
|
||||
<video class="u-video" src="<%= @url %>" controls="controls"></video>
|
||||
<% _ -> %>
|
||||
<img class="u-photo" src="<%= @url %>">
|
||||
<% end %>
|
||||
</a>
|
||||
|
|
|
@ -1,41 +1,109 @@
|
|||
<div class="activity h-entry" <%= if @selected do %> id="selected" <% end %>>
|
||||
<p class="pull-right">
|
||||
<a class="activity-link u-url u-uid" href="<%= @link %>">
|
||||
<time class="dt-published" datetime="<%= @published %>">
|
||||
<%= format_date(@published) %>
|
||||
<div class="status-container" <%= if @selected do %> id="selected" <% end %>>
|
||||
<div class="left-side">
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>" rel="author noopener">
|
||||
<div class="avatar">
|
||||
<img
|
||||
class="u-photo" width="48" height="48"
|
||||
src="<%= User.avatar_url(@user) |> MediaProxy.url %>"
|
||||
title="<%= @user.nickname %>" alt="<%= @user.nickname %>"
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="right-side">
|
||||
<div class="status-heading">
|
||||
<div class="heading-name-row">
|
||||
<div class="heading-left">
|
||||
<h4 class="username">
|
||||
<%= raw Formatter.emojify(@user.name, @user.emoji) %>
|
||||
</h4>
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>" class="account-name">
|
||||
<%= @user.nickname %>
|
||||
</a>
|
||||
</div>
|
||||
<div class="heading-right">
|
||||
<a class="timeago" href="<%= @link %>">
|
||||
<time
|
||||
class="dt-published" datetime="<%= @published %>"
|
||||
title="<%= format_date(@published) %>"
|
||||
>
|
||||
<%= time_ago(@published) %>
|
||||
</time>
|
||||
</a>
|
||||
</p>
|
||||
<%= render("_user_card.html", %{user: @user}) %>
|
||||
<div class="activity-content">
|
||||
<%= if @title != "" do %>
|
||||
<%= if @visibility == "public" do %>
|
||||
<img class="fa-icon" src="/static-fe/svg/globe-solid.svg">
|
||||
<% else %>
|
||||
<%= if @visibility == "unlisted" do %>
|
||||
<img class="fa-icon" src="/static-fe/svg/lock-open-solid.svg">
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<%= if @reply_to do %>
|
||||
<div class="heading-reply-row">
|
||||
<a class="reply-to-link" href="<%= @reply_to %>">
|
||||
<img class="fa-icon" src="/static-fe/svg/reply-solid.svg">
|
||||
<%= gettext("Reply to") %>
|
||||
</a>
|
||||
<span class="h-card">
|
||||
<a href="<%= (@reply_to_user.uri || @reply_to_user.ap_id) %>" class="u-url mention">
|
||||
@<%= @reply_to_user.nickname %>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= if @edited_at do %>
|
||||
<div class="heading-edited-row">
|
||||
<%= gettext("Edited %{timeago}", timeago: time_ago(@edited_at)) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="status-content">
|
||||
<%= if @title && @title != "" do %>
|
||||
<span class="status-summary"><%= raw @title %></span>
|
||||
<details <%= if open_content?() do %>open<% end %>>
|
||||
<summary class="p-name"><%= raw @title %></summary>
|
||||
<div class="e-content"><%= raw @content %></div>
|
||||
</details>
|
||||
<% else %>
|
||||
<div class="e-content"><%= raw @content %></div>
|
||||
<summary><%= gettext("Show content") %></summary>
|
||||
<% end %>
|
||||
<%= for %{"name" => name, "url" => [url | _]} <- @attachment do %>
|
||||
<%= if @sensitive do %>
|
||||
<details class="nsfw">
|
||||
<summary><%= Gettext.gettext("sensitive media") %></summary>
|
||||
<div class="status-body">
|
||||
<%= raw @content %>
|
||||
<%= if @poll && length(@poll) > 0 do %>
|
||||
<div class="poll">
|
||||
<%= for %{"name" => option, "replies" => %{"totalItems" => count}} <- @poll do %>
|
||||
<div class="poll-option" title="<%= count %>/<%= @total_votes %>">
|
||||
<span class="percentage"><%= poll_percentage(count, @total_votes) %></span>
|
||||
<span><%= raw option %></span>
|
||||
<div class="fill" style="width: <%= poll_percentage(count, @total_votes) %>"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= if length(@attachment) > 0 do %>
|
||||
<div class="attachments">
|
||||
<%= for attachment = %{"url" => [url | _]} <- @attachment do %>
|
||||
<%= render("_attachment.html", %{name: get_attachment_name(attachment),
|
||||
url: url["href"], mediaType: fetch_media_type(url), nsfw: @sensitive}) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= if @title && @title != "" do %>
|
||||
</details>
|
||||
<% end %>
|
||||
</div>
|
||||
<!-- <div class="emoji-reactions"></div> -->
|
||||
<div class="status-actions">
|
||||
<div>
|
||||
<%= render("_attachment.html", %{name: name, url: url["href"],
|
||||
mediaType: fetch_media_type(url)}) %>
|
||||
<img class="fa-icon" src="/static-fe/svg/reply-solid.svg">
|
||||
<span class="action-count"><%= @counts.replies %></span>
|
||||
</div>
|
||||
<div>
|
||||
<img class="fa-icon" src="/static-fe/svg/retweet-solid.svg">
|
||||
<span class="action-count"><%= @counts.announces %></span>
|
||||
</div>
|
||||
<div>
|
||||
<img class="fa-icon" src="/static-fe/svg/star-regular.svg">
|
||||
<span class="action-count"><%= @counts.likes %></span>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
<% else %>
|
||||
<%= render("_attachment.html", %{name: name, url: url["href"],
|
||||
mediaType: fetch_media_type(url)}) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= if @selected do %>
|
||||
<dl class="counts">
|
||||
<dt><%= Gettext.gettext("replies") %></dt><dd><%= @counts.replies %></dd>
|
||||
<dt><%= Gettext.gettext("announces") %></dt><dd><%= @counts.announces %></dd>
|
||||
<dt><%= Gettext.gettext("likes") %></dt><dd><%= @counts.likes %></dd>
|
||||
</dl>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -1,11 +1,21 @@
|
|||
<div class="p-author h-card">
|
||||
<a class="u-url" rel="author noopener" href="<%= (@user.uri || @user.ap_id) %>">
|
||||
<div class="user-card">
|
||||
<div class="left-side">
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>" rel="author noopener">
|
||||
<div class="avatar">
|
||||
<img class="u-photo" src="<%= User.avatar_url(@user) |> MediaProxy.url %>" width="48" height="48" alt="">
|
||||
<img
|
||||
class="u-photo" width="48" height="48"
|
||||
src="<%= User.avatar_url(@user) |> MediaProxy.url %>"
|
||||
title="<%= @user.nickname %>" alt="<%= @user.nickname %>"
|
||||
/>
|
||||
</div>
|
||||
<span class="display-name">
|
||||
<bdi class="p-name"><%= raw Formatter.emojify(@user.name, @user.emoji) %></bdi>
|
||||
<span class="nickname"><%= @user.nickname %></span>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="right-side">
|
||||
<div class="username">
|
||||
<%= raw Formatter.emojify(@user.name, @user.emoji) %>
|
||||
</div>
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>" class="account-name">
|
||||
@<%= @user.nickname %>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
<header>
|
||||
<h1><%= link instance_name(), to: "/" %></h1>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="conversation">
|
||||
<div class="panel conversation">
|
||||
<div class="panel-heading">
|
||||
<%= gettext("Conversation") %>
|
||||
</div>
|
||||
<%= for activity <- @activities do %>
|
||||
<%= render("_notice.html", activity) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<header>
|
||||
<h1><%= gettext("Oops") %></h1>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<p><%= @message %></p>
|
||||
</main>
|
||||
<div class="panel">
|
||||
<div class="panel-heading">
|
||||
<%= gettext("Error") %>
|
||||
</div>
|
||||
<div class="status-container">
|
||||
<%= @message %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,31 +1,148 @@
|
|||
<header>
|
||||
<h1><%= link instance_name(), to: "/" %></h1>
|
||||
|
||||
<h3>
|
||||
<form class="pull-right collapse" method="POST" action="<%= Helpers.util_path(@conn, :remote_subscribe) %>">
|
||||
<div class="panel profile">
|
||||
<div class="user-header">
|
||||
<div class="user-banner"></div>
|
||||
<div class="user-info">
|
||||
<div class="container">
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>" rel="author noopener">
|
||||
<div class="avatar">
|
||||
<img
|
||||
class="u-photo" width="48" height="48"
|
||||
src="<%= User.avatar_url(@user) |> MediaProxy.url %>"
|
||||
title="<%= @user.nickname %>" alt="<%= @user.nickname %>"
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
<div class="user-summary">
|
||||
<div class="top-line">
|
||||
<span class="username">
|
||||
<%= raw Formatter.emojify(@user.name, @user.emoji) %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="bottom-line">
|
||||
<%= link "@#{@user.nickname}", to: (@user.uri || @user.ap_id), class: "account-name" %>
|
||||
<%= if @user.is_admin && @user.show_role do %>
|
||||
<span class="user-role"><%= gettext("Admin") %></span>
|
||||
<% end %>
|
||||
<%= if @user.is_moderator && @user.show_role do %>
|
||||
<span class="user-role"><%= gettext("Moderator") %></span>
|
||||
<% end %>
|
||||
<%= if @user.actor_type == "Service" do %>
|
||||
<span class="user-role"><%= gettext("Bot") %></span>
|
||||
<% end %>
|
||||
<%= if @user.is_locked do %>
|
||||
<img class="fa-icon" src="/static-fe/svg/lock-solid.svg">
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="remote-follow">
|
||||
<form method="POST" action="<%= Helpers.util_path(@conn, :remote_subscribe) %>">
|
||||
<input type="hidden" name="nickname" value="<%= @user.nickname %>">
|
||||
<input type="hidden" name="profile" value="">
|
||||
<button type="submit" class="collapse"><%= Gettext.dpgettext("static_pages", "static fe profile page remote follow button", "Remote follow") %></button>
|
||||
<button type="submit" class="button-default"><%= Gettext.dpgettext("static_pages", "static fe profile page remote follow button", "Remote follow") %></button>
|
||||
</form>
|
||||
<%= raw Formatter.emojify(@user.name, @user.emoji) %> |
|
||||
<%= link "@#{@user.nickname}@#{Endpoint.host()}", to: (@user.uri || @user.ap_id) %>
|
||||
</h3>
|
||||
<p><%= raw @user.bio %></p>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
</div>
|
||||
</div>
|
||||
<div class="user-counts">
|
||||
<div class="user-count">
|
||||
<h5><%= gettext("Posts") %></h5>
|
||||
<span><%= @user.note_count %></span>
|
||||
</div>
|
||||
<div class="user-count">
|
||||
<h5><%= gettext("Following") %></h5>
|
||||
<span><%= if @user.hide_follows_count do gettext("Hidden") else @user.following_count end %></span>
|
||||
</div>
|
||||
<div class="user-count">
|
||||
<h5><%= gettext("Followers") %></h5>
|
||||
<span><%= if @user.hide_followers_count do gettext("Hidden") else @user.follower_count end %></span>
|
||||
</div>
|
||||
</div>
|
||||
<span class="user-bio"><%= raw Formatter.emojify(@user.bio, @user.emoji) %></span>
|
||||
</div>
|
||||
<div class="user-profile-fields">
|
||||
<%= for field <- @user.fields do %>
|
||||
<div class="user-profile-field">
|
||||
<dt title="<%= field["name"] %>"><%= raw Formatter.emojify(field["name"], @user.emoji) %></dt>
|
||||
<dd title="<%= field["value"] %>"><%= raw Formatter.emojify(field["value"], @user.emoji) %></dd>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="tab-switcher">
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>">
|
||||
<button class="button-default tab <%= if @tab == "posts" do %>active<% end %>">
|
||||
<%= gettext("Posts") %>
|
||||
</button>
|
||||
</a>
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>/with_replies">
|
||||
<button class="button-default tab <%= if @tab == "with_replies" do %>active<% end %>">
|
||||
<%= gettext("With Replies") %>
|
||||
</button>
|
||||
</a>
|
||||
<%= unless @user.hide_follows do %>
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>/following">
|
||||
<button class="button-default tab <%= if @tab == "following" do %>active<% end %>">
|
||||
<%= gettext("Following") %>
|
||||
</button>
|
||||
</a>
|
||||
<% end %>
|
||||
<%= unless @user.hide_followers do %>
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>/followers">
|
||||
<button class="button-default tab <%= if @tab == "followers" do %>active<% end %>">
|
||||
<%= gettext("Followers") %>
|
||||
</button>
|
||||
</a>
|
||||
<% end %>
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>/media">
|
||||
<button class="button-default tab <%= if @tab == "media" do %>active<% end %>">
|
||||
<%= gettext("Media") %>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
<%= if @prev_page_id do %>
|
||||
<%= link gettext("Show newer"), to: "?min_id=" <> @prev_page_id, class: "load-posts" %>
|
||||
<% end %>
|
||||
<div class="activity-stream">
|
||||
<%= if @tab in ["posts", "with_replies", "media"] do %>
|
||||
<%= for activity <- @timeline do %>
|
||||
<%= if(activity.user.id != @user.id) do %>
|
||||
<div class="repeat-header">
|
||||
<div class="left-side">
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>" rel="author noopener">
|
||||
<div class="avatar">
|
||||
<img
|
||||
class="u-photo" width="48" height="48"
|
||||
src="<%= User.avatar_url(@user) |> MediaProxy.url %>"
|
||||
title="<%= @user.nickname %>" alt="<%= @user.nickname %>"
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="right-side">
|
||||
<span class="username">
|
||||
<a href="<%= (@user.uri || @user.ap_id) %>" class="account-name">
|
||||
<%= raw Formatter.emojify(@user.name, @user.emoji) %>
|
||||
</a>
|
||||
</span>
|
||||
<img class="fa-icon" src="/static-fe/svg/retweet-solid.svg">
|
||||
<%= gettext("repeated") %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= render("_notice.html", Map.put(activity, :selected, false)) %>
|
||||
<% end %>
|
||||
<p id="pagination">
|
||||
<%= if @prev_page_id do %>
|
||||
<%= link "«", to: "?min_id=" <> @prev_page_id %>
|
||||
<% else %>
|
||||
<%= for user <- @timeline do %>
|
||||
<%= render("_user_card.html", %{user: user}) %>
|
||||
<% end %>
|
||||
<%= if @prev_page_id && @next_page_id, do: " | " %>
|
||||
<%= if @next_page_id do %>
|
||||
<%= link "»", to: "?max_id=" <> @next_page_id %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
<%= if @next_page_id do %>
|
||||
<%= link gettext("Show older"), to: "?max_id=" <> @next_page_id, class: "load-posts" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--user-banner: url("<%= Pleroma.User.banner_url(@user) %>");
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -4,4 +4,11 @@
|
|||
|
||||
defmodule Pleroma.Web.LayoutView do
|
||||
use Pleroma.Web, :view
|
||||
import Phoenix.HTML
|
||||
|
||||
def render_html(file) do
|
||||
case :httpc.request(Pleroma.Web.Endpoint.url() <> file) do
|
||||
{:ok, {{_, 200, _}, _headers, body}} -> body
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Binary file not shown.
1
priv/static/static-fe/svg/globe-solid.svg
Normal file
1
priv/static/static-fe/svg/globe-solid.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M352 256c0 22.2-1.2 43.6-3.3 64H163.3c-2.2-20.4-3.3-41.8-3.3-64s1.2-43.6 3.3-64H348.7c2.2 20.4 3.3 41.8 3.3 64zm28.8-64H503.9c5.3 20.5 8.1 41.9 8.1 64s-2.8 43.5-8.1 64H380.8c2.1-20.6 3.2-42 3.2-64s-1.1-43.4-3.2-64zm112.6-32H376.7c-10-63.9-29.8-117.4-55.3-151.6c78.3 20.7 142 77.5 171.9 151.6zm-149.1 0H167.7c6.1-36.4 15.5-68.6 27-94.7c10.5-23.6 22.2-40.7 33.5-51.5C239.4 3.2 248.7 0 256 0s16.6 3.2 27.8 13.8c11.3 10.8 23 27.9 33.5 51.5c11.6 26 21 58.2 27 94.7zm-209 0H18.6C48.6 85.9 112.2 29.1 190.6 8.4C165.1 42.6 145.3 96.1 135.3 160zM8.1 192H131.2c-2.1 20.6-3.2 42-3.2 64s1.1 43.4 3.2 64H8.1C2.8 299.5 0 278.1 0 256s2.8-43.5 8.1-64zM194.7 446.6c-11.6-26-20.9-58.2-27-94.6H344.3c-6.1 36.4-15.5 68.6-27 94.6c-10.5 23.6-22.2 40.7-33.5 51.5C272.6 508.8 263.3 512 256 512s-16.6-3.2-27.8-13.8c-11.3-10.8-23-27.9-33.5-51.5zM135.3 352c10 63.9 29.8 117.4 55.3 151.6C112.2 482.9 48.6 426.1 18.6 352H135.3zm358.1 0c-30 74.1-93.6 130.9-171.9 151.6c25.5-34.2 45.2-87.7 55.3-151.6H493.4z"/></svg>
|
After Width: | Height: | Size: 1.2 KiB |
1
priv/static/static-fe/svg/lock-open-solid.svg
Normal file
1
priv/static/static-fe/svg/lock-open-solid.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M352 144c0-44.2 35.8-80 80-80s80 35.8 80 80v48c0 17.7 14.3 32 32 32s32-14.3 32-32V144C576 64.5 511.5 0 432 0S288 64.5 288 144v48H64c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V256c0-35.3-28.7-64-64-64H352V144z"/></svg>
|
After Width: | Height: | Size: 485 B |
1
priv/static/static-fe/svg/lock-solid.svg
Normal file
1
priv/static/static-fe/svg/lock-solid.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M144 144v48H304V144c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192V144C80 64.5 144.5 0 224 0s144 64.5 144 144v48h16c35.3 0 64 28.7 64 64V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V256c0-35.3 28.7-64 64-64H80z"/></svg>
|
After Width: | Height: | Size: 460 B |
1
priv/static/static-fe/svg/reply-solid.svg
Normal file
1
priv/static/static-fe/svg/reply-solid.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M205 34.8c11.5 5.1 19 16.6 19 29.2v64H336c97.2 0 176 78.8 176 176c0 113.3-81.5 163.9-100.2 174.1c-2.5 1.4-5.3 1.9-8.1 1.9c-10.9 0-19.7-8.9-19.7-19.7c0-7.5 4.3-14.4 9.8-19.5c9.4-8.8 22.2-26.4 22.2-56.7c0-53-43-96-96-96H224v64c0 12.6-7.4 24.1-19 29.2s-25 3-34.4-5.4l-160-144C3.9 225.7 0 217.1 0 208s3.9-17.7 10.6-23.8l160-144c9.4-8.5 22.9-10.6 34.4-5.4z"/></svg>
|
After Width: | Height: | Size: 599 B |
1
priv/static/static-fe/svg/retweet-solid.svg
Normal file
1
priv/static/static-fe/svg/retweet-solid.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M272 416c17.7 0 32-14.3 32-32s-14.3-32-32-32H160c-17.7 0-32-14.3-32-32V192h32c12.9 0 24.6-7.8 29.6-19.8s2.2-25.7-6.9-34.9l-64-64c-12.5-12.5-32.8-12.5-45.3 0l-64 64c-9.2 9.2-11.9 22.9-6.9 34.9s16.6 19.8 29.6 19.8l32 0 0 128c0 53 43 96 96 96H272zM304 96c-17.7 0-32 14.3-32 32s14.3 32 32 32l112 0c17.7 0 32 14.3 32 32l0 128H416c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9l64 64c12.5 12.5 32.8 12.5 45.3 0l64-64c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8l-32 0V192c0-53-43-96-96-96L304 96z"/></svg>
|
After Width: | Height: | Size: 740 B |
1
priv/static/static-fe/svg/star-regular.svg
Normal file
1
priv/static/static-fe/svg/star-regular.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M287.9 0C297.1 0 305.5 5.25 309.5 13.52L378.1 154.8L531.4 177.5C540.4 178.8 547.8 185.1 550.7 193.7C553.5 202.4 551.2 211.9 544.8 218.2L433.6 328.4L459.9 483.9C461.4 492.9 457.7 502.1 450.2 507.4C442.8 512.7 432.1 513.4 424.9 509.1L287.9 435.9L150.1 509.1C142.9 513.4 133.1 512.7 125.6 507.4C118.2 502.1 114.5 492.9 115.1 483.9L142.2 328.4L31.11 218.2C24.65 211.9 22.36 202.4 25.2 193.7C28.03 185.1 35.5 178.8 44.49 177.5L197.7 154.8L266.3 13.52C270.4 5.249 278.7 0 287.9 0L287.9 0zM287.9 78.95L235.4 187.2C231.9 194.3 225.1 199.3 217.3 200.5L98.98 217.9L184.9 303C190.4 308.5 192.9 316.4 191.6 324.1L171.4 443.7L276.6 387.5C283.7 383.7 292.2 383.7 299.2 387.5L404.4 443.7L384.2 324.1C382.9 316.4 385.5 308.5 391 303L476.9 217.9L358.6 200.5C350.7 199.3 343.9 194.3 340.5 187.2L287.9 78.95z"/></svg>
|
After Width: | Height: | Size: 1 KiB |
|
@ -6,6 +6,8 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
|
|||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||
alias Pleroma.Web.ActivityPub.Utils
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
@ -42,8 +44,67 @@ test "profile does not include private messages", %{conn: conn, user: user} do
|
|||
|
||||
html = html_response(conn, 200)
|
||||
|
||||
assert html =~ ">public<"
|
||||
refute html =~ ">private<"
|
||||
assert html =~ "\npublic\n"
|
||||
refute html =~ "\nprivate\n"
|
||||
end
|
||||
|
||||
test "main page does not include replies", %{conn: conn, user: user} do
|
||||
{:ok, op} = CommonAPI.post(user, %{status: "beep"})
|
||||
CommonAPI.post(user, %{status: "boop", in_reply_to_id: op})
|
||||
|
||||
conn = get(conn, "/users/#{user.nickname}")
|
||||
|
||||
html = html_response(conn, 200)
|
||||
|
||||
assert html =~ "\nbeep\n"
|
||||
refute html =~ "\nboop\n"
|
||||
end
|
||||
|
||||
test "media page only includes posts with attachments", %{conn: conn, user: user} do
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpeg",
|
||||
path: Path.absname("test/fixtures/image.jpg"),
|
||||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
{:ok, %{id: media_id}} = ActivityPub.upload(file, actor: user.ap_id)
|
||||
|
||||
CommonAPI.post(user, %{status: "virgin text post"})
|
||||
CommonAPI.post(user, %{status: "chad post with attachment", media_ids: [media_id]})
|
||||
|
||||
conn = get(conn, "/users/#{user.nickname}/media")
|
||||
|
||||
html = html_response(conn, 200)
|
||||
|
||||
assert html =~ "\nchad post with attachment\n"
|
||||
refute html =~ "\nvirgin text post\n"
|
||||
end
|
||||
|
||||
test "show follower list", %{conn: conn, user: user} do
|
||||
follower = insert(:user)
|
||||
CommonAPI.follow(follower, user)
|
||||
|
||||
conn = get(conn, "/users/#{user.nickname}/followers")
|
||||
|
||||
html = html_response(conn, 200)
|
||||
|
||||
assert html =~ "user-card"
|
||||
end
|
||||
|
||||
test "don't show followers if hidden", %{conn: conn, user: user} do
|
||||
follower = insert(:user)
|
||||
CommonAPI.follow(follower, user)
|
||||
|
||||
{:ok, user} =
|
||||
user
|
||||
|> User.update_changeset(%{hide_followers: true})
|
||||
|> User.update_and_set_cache()
|
||||
|
||||
conn = get(conn, "/users/#{user.nickname}/followers")
|
||||
|
||||
html = html_response(conn, 200)
|
||||
|
||||
refute html =~ "user-card"
|
||||
end
|
||||
|
||||
test "pagination", %{conn: conn, user: user} do
|
||||
|
@ -53,10 +114,10 @@ test "pagination", %{conn: conn, user: user} do
|
|||
|
||||
html = html_response(conn, 200)
|
||||
|
||||
assert html =~ ">test30<"
|
||||
assert html =~ ">test11<"
|
||||
refute html =~ ">test10<"
|
||||
refute html =~ ">test1<"
|
||||
assert html =~ "\ntest30\n"
|
||||
assert html =~ "\ntest11\n"
|
||||
refute html =~ "\ntest10\n"
|
||||
refute html =~ "\ntest1\n"
|
||||
end
|
||||
|
||||
test "pagination, page 2", %{conn: conn, user: user} do
|
||||
|
@ -67,10 +128,10 @@ test "pagination, page 2", %{conn: conn, user: user} do
|
|||
|
||||
html = html_response(conn, 200)
|
||||
|
||||
assert html =~ ">test1<"
|
||||
assert html =~ ">test10<"
|
||||
refute html =~ ">test20<"
|
||||
refute html =~ ">test29<"
|
||||
assert html =~ "\ntest1\n"
|
||||
assert html =~ "\ntest10\n"
|
||||
refute html =~ "\ntest20\n"
|
||||
refute html =~ "\ntest29\n"
|
||||
end
|
||||
|
||||
test "does not require authentication on non-federating instances", %{
|
||||
|
@ -104,7 +165,7 @@ test "single notice page", %{conn: conn, user: user} do
|
|||
conn = get(conn, "/notice/#{activity.id}")
|
||||
|
||||
html = html_response(conn, 200)
|
||||
assert html =~ "<header>"
|
||||
assert html =~ "<div class=\"panel conversation\">"
|
||||
assert html =~ user.nickname
|
||||
assert html =~ "testing a thing!"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue