Merge branch 'feature/mastodon-context-microformat' into 'develop'
formatter: use class='mention' on links to user profiles See merge request pleroma/pleroma!178
This commit is contained in:
commit
8216d5e40e
|
@ -200,7 +200,9 @@ def add_user_links({subs, text}, mentions) do
|
||||||
ap_id = info["source_data"]["url"] || ap_id
|
ap_id = info["source_data"]["url"] || ap_id
|
||||||
|
|
||||||
short_match = String.split(match, "@") |> tl() |> hd()
|
short_match = String.split(match, "@") |> tl() |> hd()
|
||||||
{uuid, "<span><a href='#{ap_id}'>@<span>#{short_match}</span></a></span>"}
|
|
||||||
|
{uuid,
|
||||||
|
"<span><a class='mention' href='#{ap_id}'>@<span>#{short_match}</span></a></span>"}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
{subs, uuid_text}
|
{subs, uuid_text}
|
||||||
|
|
|
@ -109,9 +109,9 @@ test "gives a replacement for user links" do
|
||||||
Enum.each(subs, fn {uuid, _} -> assert String.contains?(text, uuid) end)
|
Enum.each(subs, fn {uuid, _} -> assert String.contains?(text, uuid) end)
|
||||||
|
|
||||||
expected_text =
|
expected_text =
|
||||||
"<span><a href='#{gsimg.ap_id}'>@<span>gsimg</span></a></span> According to <span><a href='#{
|
"<span><a class='mention' href='#{gsimg.ap_id}'>@<span>gsimg</span></a></span> According to <span><a class='mention' href='#{
|
||||||
"https://archeme/@archaeme"
|
"https://archeme/@archaeme"
|
||||||
}'>@<span>archaeme</span></a></span>, that is @daggsy. Also hello <span><a href='#{
|
}'>@<span>archaeme</span></a></span>, that is @daggsy. Also hello <span><a class='mention' href='#{
|
||||||
archaeme_remote.ap_id
|
archaeme_remote.ap_id
|
||||||
}'>@<span>archaeme</span></a></span>"
|
}'>@<span>archaeme</span></a></span>"
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ test "create a status" do
|
||||||
{:ok, activity = %Activity{}} = TwitterAPI.create_status(user, input)
|
{:ok, activity = %Activity{}} = TwitterAPI.create_status(user, input)
|
||||||
|
|
||||||
expected_text =
|
expected_text =
|
||||||
"Hello again, <span><a href='shp'>@<span>shp</span></a></span>.<script></script><br>This is on another :moominmamma: line. <a href='http://localhost:4001/tag/2hu' rel='tag'>#2hu</a> <a href='http://localhost:4001/tag/epic' rel='tag'>#epic</a> <a href='http://localhost:4001/tag/phantasmagoric' rel='tag'>#phantasmagoric</a><br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
|
"Hello again, <span><a class='mention' href='shp'>@<span>shp</span></a></span>.<script></script><br>This is on another :moominmamma: line. <a href='http://localhost:4001/tag/2hu' rel='tag'>#2hu</a> <a href='http://localhost:4001/tag/epic' rel='tag'>#epic</a> <a href='http://localhost:4001/tag/phantasmagoric' rel='tag'>#phantasmagoric</a><br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
|
||||||
|
|
||||||
assert get_in(activity.data, ["object", "content"]) == expected_text
|
assert get_in(activity.data, ["object", "content"]) == expected_text
|
||||||
assert get_in(activity.data, ["object", "type"]) == "Note"
|
assert get_in(activity.data, ["object", "type"]) == "Note"
|
||||||
|
|
Loading…
Reference in a new issue