end)
end
+ defp shortname(name) do
+ if String.length(name) < 30 do
+ name
+ else
+ String.slice(name, 0..30) <> "…"
+ end
+ end
+
def add_attachments(text, attachments) do
attachment_text = Enum.map(attachments, fn
(%{"url" => [%{"href" => href} | _]}) ->
- "<a href=\"#{URI.encode(href)}\" class='attachment'>#{Path.basename(href)}</a>"
+ name = URI.decode(Path.basename(href))
+ "<a href=\"#{href}\" class='attachment'>#{shortname(name)}</a>"
_ -> ""
end)
- Enum.join([text | attachment_text], "<br />\n")
+ Enum.join([text | attachment_text], "<br>\n")
end
def format_input(text, mentions) do
HtmlSanitizeEx.strip_tags(text)
|> Formatter.linkify
- |> String.replace("\n", "<br />\n")
+ |> String.replace("\n", "<br>\n")
|> add_user_links(mentions)
end
end)
end
- def wrap_in_p(text), do: "<p>#{text}</p>"
-
def make_content_html(status, mentions, attachments) do
status
|> format_input(mentions)
|> add_attachments(attachments)
- |> wrap_in_p
end
def make_context(%Activity{data: %{"context" => context}}), do: context