WIP. Implement oembed route and handle both json/xml for "Note" type activity
This commit is contained in:
parent
21afdf6d99
commit
8902942128
9 changed files with 142 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue