Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview/strings: allow extensionless filenames

Signed-off-by: ItsHarper <git-f4cbe@harperandrews.org>

authored by

ItsHarper and committed by
Tangled
a7dac889 6be6a26b

+2 -21
+1 -9
appview/db/strings.go
··· 50 50 func (s String) Validate() error { 51 51 var err error 52 52 53 - if !strings.Contains(s.Filename, ".") { 54 - err = errors.Join(err, fmt.Errorf("missing filename extension")) 55 - } 56 - 57 - if strings.HasSuffix(s.Filename, ".") { 58 - err = errors.Join(err, fmt.Errorf("filename ends with `.`")) 59 - } 60 - 61 53 if utf8.RuneCountInString(s.Filename) > 140 { 62 54 err = errors.Join(err, fmt.Errorf("filename too long")) 63 55 } ··· 105 113 filename = excluded.filename, 106 114 description = excluded.description, 107 115 content = excluded.content, 108 - edited = case 116 + edited = case 109 117 when 110 118 strings.content != excluded.content 111 119 or strings.filename != excluded.filename
+1 -1
appview/pages/templates/strings/fragments/form.html
··· 13 13 type="text" 14 14 id="filename" 15 15 name="filename" 16 - placeholder="Filename with extension" 16 + placeholder="Filename" 17 17 required 18 18 value="{{ .String.Filename }}" 19 19 class="md:max-w-64 dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:placeholder-gray-400 px-3 py-2 border rounded"
-11
appview/strings/strings.go
··· 7 7 "path" 8 8 "slices" 9 9 "strconv" 10 - "strings" 11 10 "time" 12 11 13 12 "tangled.sh/tangled.sh/core/api/tangled" ··· 287 288 fail("Empty filename.", nil) 288 289 return 289 290 } 290 - if !strings.Contains(filename, ".") { 291 - // TODO: make this a htmx form validation 292 - fail("No extension provided for filename.", nil) 293 - return 294 - } 295 291 296 292 content := r.FormValue("content") 297 293 if content == "" { ··· 367 373 filename := r.FormValue("filename") 368 374 if filename == "" { 369 375 fail("Empty filename.", nil) 370 - return 371 - } 372 - if !strings.Contains(filename, ".") { 373 - // TODO: make this a htmx form validation 374 - fail("No extension provided for filename.", nil) 375 376 return 376 377 } 377 378