WIP. Implement oembed route and handle both json/xml for "Note" type activity

This commit is contained in:
raeno 2018-12-10 23:08:02 +04:00
commit 8902942128
9 changed files with 142 additions and 5 deletions

View file

@ -163,4 +163,20 @@ defmodule Pleroma.Formatter do
String.replace(result_text, uuid, replacement)
end)
end
def truncate(text, opts \\ []) do
max_length = opts[:max_length] || 200
omission = opts[:omission] || "..."
cond do
not String.valid?(text) ->
text
String.length(text) < max_length ->
text
true ->
length_with_omission = max_length - String.length(omission)
"#{String.slice(text, 0, length_with_omission)}#{omission}"
end
end
end