forked from tangled.org/core
this repo has no description

appview/strings: allow extensionless filenames

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

authored by harperandrews.org and committed by Tangled a7dac889 6be6a26b

Changed files
+2 -21
appview
db
pages
templates
strings
fragments
strings
+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 } ··· 113 105 filename = excluded.filename, 114 106 description = excluded.description, 115 107 content = excluded.content, 116 - edited = case 108 + edited = case 117 109 when 118 110 strings.content != excluded.content 119 111 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" ··· 288 287 fail("Empty filename.", nil) 289 288 return 290 289 } 291 - if !strings.Contains(filename, ".") { 292 - // TODO: make this a htmx form validation 293 - fail("No extension provided for filename.", nil) 294 - return 295 - } 296 290 297 291 content := r.FormValue("content") 298 292 if content == "" { ··· 373 367 filename := r.FormValue("filename") 374 368 if filename == "" { 375 369 fail("Empty filename.", nil) 376 - return 377 - } 378 - if !strings.Contains(filename, ".") { 379 - // TODO: make this a htmx form validation 380 - fail("No extension provided for filename.", nil) 381 370 return 382 371 } 383 372