Get rid of @data in views and use separate fields.
This commit is contained in:
parent
e944a2213d
commit
41fde63def
@ -17,22 +17,20 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
|
|||||||
def show_notice(%{assigns: %{notice_id: notice_id}} = conn, _params) do
|
def show_notice(%{assigns: %{notice_id: notice_id}} = conn, _params) do
|
||||||
with {:ok, data} <- ActivityRepresenter.represent(notice_id) do
|
with {:ok, data} <- ActivityRepresenter.represent(notice_id) do
|
||||||
context = data.object.data["context"]
|
context = data.object.data["context"]
|
||||||
activities = ActivityPub.fetch_activities_for_context(context, %{})
|
|
||||||
|
|
||||||
data =
|
activities =
|
||||||
for a <- Enum.reverse(activities) do
|
for a <- Enum.reverse(ActivityPub.fetch_activities_for_context(context, %{})) do
|
||||||
ActivityRepresenter.prepare_activity(data.user, a)
|
ActivityRepresenter.prepare_activity(data.user, a)
|
||||||
|> Map.put(:selected, a.object.id == data.object.id)
|
|> Map.put(:selected, a.object.id == data.object.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
render(conn, "conversation.html", data: data)
|
render(conn, "conversation.html", activities: activities)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_user(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do
|
def show_user(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do
|
||||||
with {:ok, data} <- UserRepresenter.represent(username_or_id) do
|
{:ok, data} = UserRepresenter.represent(username_or_id)
|
||||||
render(conn, "profile.html", data: data)
|
render(conn, "profile.html", %{user: data.user, timeline: data.timeline})
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts),
|
def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts),
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
<div class="activity" <%= if @data[:selected] do %> id="selected" <% end %>>
|
<div class="activity" <%= if @selected do %> id="selected" <% end %>>
|
||||||
<p class="pull-right">
|
<p class="pull-right">
|
||||||
<%= link @data.published, to: @data.link, class: "activity-link" %>
|
<%= link @published, to: @link, class: "activity-link" %>
|
||||||
</p>
|
</p>
|
||||||
<%= render("user_card.html", %{user: @data.user}) %>
|
<%= render("user_card.html", %{user: @user}) %>
|
||||||
<div class="activity-content">
|
<div class="activity-content">
|
||||||
<%= if @data.title != "" do %>
|
<%= if @title != "" do %>
|
||||||
<details>
|
<details>
|
||||||
<summary><%= raw @data.title %></summary>
|
<summary><%= raw @title %></summary>
|
||||||
<div class="e-content"><%= raw @data.content %></div>
|
<div class="e-content"><%= raw @content %></div>
|
||||||
</details>
|
</details>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="e-content"><%= raw @data.content %></div>
|
<div class="e-content"><%= raw @content %></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= for %{"name" => name, "url" => [url | _]} <- @data.attachment do %>
|
<%= for %{"name" => name, "url" => [url | _]} <- @attachment do %>
|
||||||
<%= if @data.sensitive do %>
|
<%= if @sensitive do %>
|
||||||
<details class="nsfw">
|
<details class="nsfw">
|
||||||
<summary><%= Gettext.gettext("sensitive media") %></summary>
|
<summary><%= Gettext.gettext("sensitive media") %></summary>
|
||||||
<div>
|
<div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<div class="conversation">
|
<div class="conversation">
|
||||||
<%= for notice <- @data do %>
|
<%= for activity <- @activities do %>
|
||||||
<%= render("_notice.html", %{data: notice}) %>
|
<%= render("_notice.html", activity) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
<h1>
|
<h1>
|
||||||
<form class="pull-right collapse" method="POST" action="<%= Helpers.util_path(@conn, :remote_subscribe) %>">
|
<form class="pull-right collapse" method="POST" action="<%= Helpers.util_path(@conn, :remote_subscribe) %>">
|
||||||
<input type="hidden" name="nickname" value="<%= @data.user.nickname %>">
|
<input type="hidden" name="nickname" value="<%= @user.nickname %>">
|
||||||
<input type="hidden" name="profile" value="">
|
<input type="hidden" name="profile" value="">
|
||||||
<button type="submit" class="collapse">Remote follow</button>
|
<button type="submit" class="collapse">Remote follow</button>
|
||||||
</form>
|
</form>
|
||||||
<%= raw (@data.user.name |> Formatter.emojify(emoji_for_user(@data.user))) %>
|
<%= raw (@user.name |> Formatter.emojify(emoji_for_user(@user))) %>
|
||||||
</h1>
|
</h1>
|
||||||
<p><%= raw @data.user.bio %></p>
|
<p><%= raw @user.bio %></p>
|
||||||
<div class="activity-stream">
|
<div class="activity-stream">
|
||||||
<%= for activity <- @data.timeline do %>
|
<%= for activity <- @timeline do %>
|
||||||
<%= render("_notice.html", %{data: activity}) %>
|
<%= render("_notice.html", Map.put(activity, :selected, false)) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user