Monorepo for Tangled tangled.org

appview/pages: add "reverse" funcmap function #966

merged opened by oppi.li targeting master from op/vyrymqtwolsn

also removes unused functions such as filetree.

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3mcjiyey6ls22
+20 -9
Diff #0
+20 -9
appview/pages/funcmap.go
··· 26 26 "github.com/go-enry/go-enry/v2" 27 27 "github.com/yuin/goldmark" 28 28 emoji "github.com/yuin/goldmark-emoji" 29 - "tangled.org/core/appview/filetree" 30 29 "tangled.org/core/appview/models" 31 30 "tangled.org/core/appview/pages/markup" 32 31 "tangled.org/core/crypto" ··· 334 333 }, 335 334 "deref": func(v any) any { 336 335 val := reflect.ValueOf(v) 337 - if val.Kind() == reflect.Ptr && !val.IsNil() { 336 + if val.Kind() == reflect.Pointer && !val.IsNil() { 338 337 return val.Elem().Interface() 339 338 } 340 339 return nil ··· 348 347 return template.HTML(data) 349 348 }, 350 349 "cssContentHash": p.CssContentHash, 351 - "fileTree": filetree.FileTree, 352 350 "pathEscape": func(s string) string { 353 351 return url.PathEscape(s) 354 352 }, ··· 366 364 return p.AvatarUrl(handle, "") 367 365 }, 368 366 "langColor": enry.GetColor, 369 - "layoutSide": func() string { 370 - return "col-span-1 md:col-span-2 lg:col-span-3" 371 - }, 372 - "layoutCenter": func() string { 373 - return "col-span-1 md:col-span-8 lg:col-span-6" 374 - }, 367 + "reverse": func(s any) any { 368 + if s == nil { 369 + return nil 370 + } 371 + 372 + v := reflect.ValueOf(s) 373 + 374 + if v.Kind() != reflect.Slice { 375 + return s 376 + } 377 + 378 + length := v.Len() 379 + reversed := reflect.MakeSlice(v.Type(), length, length) 375 380 381 + for i := range length { 382 + reversed.Index(i).Set(v.Index(length - 1 - i)) 383 + } 384 + 385 + return reversed.Interface() 386 + }, 376 387 "normalizeForHtmlId": func(s string) string { 377 388 normalized := strings.ReplaceAll(s, ":", "_") 378 389 normalized = strings.ReplaceAll(normalized, ".", "_")

History

2 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview/pages: add "reverse" funcmap function
3/3 success
expand
expand 0 comments
pull request successfully merged
oppi.li submitted #0
1 commit
expand
appview/pages: add "reverse" funcmap function
3/3 success
expand
expand 0 comments