Search v1 (#19)

* Adds description to media items; hooks it up to indexing/media downloading

* Added a search method using postgres fulltext search

* Hooked up search functionality to the search form

* Added persistence to the search form when on search page
This commit is contained in:
Kieran
2024-02-13 14:46:14 -08:00
committed by GitHub
parent 219320ce11
commit 060e340558
25 changed files with 261 additions and 25 deletions
+17
View File
@@ -24,4 +24,21 @@ defmodule Pinchflat.Utils.StringUtils do
|> Base.encode16(case: :lower)
|> String.slice(0..(length - 1))
end
@doc """
Truncates a string to the given length and adds `...` if the string is longer than the given length.
Will break on a word boundary. Nothing happens if the string is shorter than the given length.
Returns binary()
"""
def truncate(string, length) do
if String.length(string) > length do
string
|> String.slice(0..(length - 1))
|> String.replace(~r/\s+\S*$/, "")
|> Kernel.<>("...")
else
string
end
end
end