Compare commits
No commits in common. "dcd2cb04c9ca23abef2e07c9e259740545347f24" and "fd336f0bed2d777664b09330502719e1fb45b1ad" have entirely different histories.
dcd2cb04c9
...
fd336f0bed
|
@ -157,10 +157,6 @@ ul.notifications-list {
|
||||||
|
|
||||||
a {
|
a {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
|
|
||||||
&.local-actor-link {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="status-content">
|
<div class="status-content">
|
||||||
<%= render_status_content(@original_activity) %>
|
<%= raw(@original_note["content"]) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="status-actions">
|
<div class="status-actions">
|
||||||
<a href="<%= Routes.frontend_path(@conn, :reply, @original_activity.id) %>">Reply</a>
|
<a href="<%= Routes.frontend_path(@conn, :reply, @original_activity.id) %>">Reply</a>
|
||||||
|
|
|
@ -16,15 +16,9 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="status-content e-content">
|
<div class="status-content e-content">
|
||||||
<%= unless is_nil(@conn.assigns[:user]) do %>
|
|
||||||
<%= render_status_content(@status) %>
|
|
||||||
<% else %>
|
|
||||||
<%= raw(@note["content"]) %>
|
<%= raw(@note["content"]) %>
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
<%= unless is_nil(@conn.assigns[:user]) do %>
|
|
||||||
<div class="status-actions">
|
<div class="status-actions">
|
||||||
<a href="<%= Routes.frontend_path(@conn, :reply, @status.id) %>">Reply</a>
|
<a href="<%= Routes.frontend_path(@conn, :reply, @status.id) %>">Reply</a>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<%= render "_status.html", conn: @conn, author: @author, status: @status, note: @status.data["object"] %>
|
<%= render "_status.html", conn: @conn, author: @author, status: @status, note: @status.data["object"] %>
|
||||||
|
|
||||||
<%= unless is_nil(@current_user) do %>
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<%= form_tag Routes.frontend_path(@conn, :post_status), method: :post, class: "compose-status" do %>
|
<%= form_tag Routes.frontend_path(@conn, :post_status), method: :post, class: "compose-status" do %>
|
||||||
|
@ -9,4 +8,3 @@
|
||||||
<%= submit "Post" %>
|
<%= submit "Post" %>
|
||||||
<hr>
|
<hr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ defmodule ClacksWeb.FrontendView do
|
||||||
alias Clacks.{Actor, Activity, Repo, Notification}
|
alias Clacks.{Actor, Activity, Repo, Notification}
|
||||||
alias ClacksWeb.Router.Helpers, as: Routes
|
alias ClacksWeb.Router.Helpers, as: Routes
|
||||||
alias ClacksWeb.Endpoint
|
alias ClacksWeb.Endpoint
|
||||||
require Logger
|
|
||||||
|
|
||||||
@spec display_username(actor :: Actor.t()) :: String.t()
|
@spec display_username(actor :: Actor.t()) :: String.t()
|
||||||
|
|
||||||
|
@ -127,52 +126,4 @@ defmodule ClacksWeb.FrontendView do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp mentions_for_replying_to(_), do: ""
|
defp mentions_for_replying_to(_), do: ""
|
||||||
|
|
||||||
@spec render_status_content(activity :: Activity.t()) :: String.t()
|
|
||||||
defp render_status_content(%Activity{
|
|
||||||
data: %{
|
|
||||||
"type" => "Create",
|
|
||||||
"object" => %{"type" => "Note", "content" => content} = note
|
|
||||||
}
|
|
||||||
}) do
|
|
||||||
with %{"tag" => tags} <- note,
|
|
||||||
{:ok, tree} <- Floki.parse_fragment(content) do
|
|
||||||
tree
|
|
||||||
|> Floki.traverse_and_update(fn
|
|
||||||
{"a", attrs, _children} = orig_tree ->
|
|
||||||
{"href", href} = Enum.find(attrs, fn {name, _} -> name == "href" end)
|
|
||||||
|
|
||||||
has_matching_tag =
|
|
||||||
Enum.any?(tags, fn
|
|
||||||
%{"type" => "Mention", "href" => ^href} -> true
|
|
||||||
_ -> false
|
|
||||||
end)
|
|
||||||
|
|
||||||
with true <- has_matching_tag,
|
|
||||||
%Actor{local: false} = actor <- Actor.get_cached_by_ap_id(href) do
|
|
||||||
{
|
|
||||||
"span",
|
|
||||||
[],
|
|
||||||
[
|
|
||||||
orig_tree,
|
|
||||||
{"a", [{"href", local_actor_link(actor)}, {"class", "local-actor-link"}], ["🔗"]}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_ ->
|
|
||||||
orig_tree
|
|
||||||
end
|
|
||||||
|
|
||||||
tree ->
|
|
||||||
tree
|
|
||||||
end)
|
|
||||||
|> Floki.raw_html()
|
|
||||||
# remove the <html> and </html> from the floki rendered output
|
|
||||||
|> String.slice(6..-8)
|
|
||||||
|> raw()
|
|
||||||
else
|
|
||||||
_ ->
|
|
||||||
content
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue