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/pages: add "reverse" funcmap function

also removes unused functions such as filetree.

authored by

oppiliappan and committed by tangled.org 525aa795 d7c6aa99

+20 -9
+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/oauth" 32 31 "tangled.org/core/appview/pages/markup" ··· 334 335 }, 335 336 "deref": func(v any) any { 336 337 val := reflect.ValueOf(v) 337 - if val.Kind() == reflect.Ptr && !val.IsNil() { 338 + if val.Kind() == reflect.Pointer && !val.IsNil() { 338 339 return val.Elem().Interface() 339 340 } 340 341 return nil ··· 348 349 return template.HTML(data) 349 350 }, 350 351 "cssContentHash": p.CssContentHash, 351 - "fileTree": filetree.FileTree, 352 352 "pathEscape": func(s string) string { 353 353 return url.PathEscape(s) 354 354 }, ··· 365 367 return p.AvatarUrl(handle, "") 366 368 }, 367 369 "langColor": enry.GetColor, 368 - "layoutSide": func() string { 369 - return "col-span-1 md:col-span-2 lg:col-span-3" 370 - }, 371 - "layoutCenter": func() string { 372 - return "col-span-1 md:col-span-8 lg:col-span-6" 373 - }, 370 + "reverse": func(s any) any { 371 + if s == nil { 372 + return nil 373 + } 374 374 375 + v := reflect.ValueOf(s) 376 + 377 + if v.Kind() != reflect.Slice { 378 + return s 379 + } 380 + 381 + length := v.Len() 382 + reversed := reflect.MakeSlice(v.Type(), length, length) 383 + 384 + for i := range length { 385 + reversed.Index(i).Set(v.Index(length - 1 - i)) 386 + } 387 + 388 + return reversed.Interface() 389 + }, 375 390 "normalizeForHtmlId": func(s string) string { 376 391 normalized := strings.ReplaceAll(s, ":", "_") 377 392 normalized = strings.ReplaceAll(normalized, ".", "_")