File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -151,13 +151,24 @@ defmodule DB.Schema.Video do
151
151
|> cast ( params , [ :url , :title , :language ] )
152
152
|> validate_required ( [ :url , :title ] )
153
153
|> parse_video_url ( )
154
- |> validate_length ( :title , min: 5 , max: 120 )
154
+ |> update_change ( :title , & truncate_title / 1 )
155
+ |> validate_length ( :title , min: 5 , max: 130 )
155
156
|> unique_constraint ( :videos_youtube_id_index )
156
157
|> unique_constraint ( :videos_facebook_id_index )
157
158
# Change locales like "en-US" to "en"
158
159
|> update_change ( :language , & format_language / 1 )
159
160
end
160
161
162
+
163
+ defp truncate_title ( title ) do
164
+ trimmed = String . trim ( title )
165
+ if String . length ( trimmed ) > 130 do
166
+ String . slice ( trimmed , 0 .. 128 ) <> "…"
167
+ else
168
+ trimmed
169
+ end
170
+ end
171
+
161
172
defp format_language ( "zxx" ) , do: nil
162
173
163
174
defp format_language ( locale ) do
You can’t perform that action at this time.
0 commit comments