| 1 | package tinyclient |
| 2 | |
| 3 | import "strings" |
| 4 | |
| 5 | // customViewState is the row state on the Views page: paused when the |
| 6 | // owner or the relay paused the view, active otherwise. |
| 7 | func customViewState(view any) string { |
| 8 | if valueMap(view)["enabled" ] == false { |
| 9 | return "paused" |
| 10 | } |
| 11 | return "active" |
| 12 | } |
| 13 | |
| 14 | // customViewKinds lists the kinds a custom view watches. |
| 15 | func customViewKinds(view any) string { |
| 16 | return joinValues(valueMap(view)["kinds" ]) |
| 17 | } |
| 18 | |
| 19 | // customViewLanguages lists the fenced block languages a custom view renders. |
| 20 | func customViewLanguages(view any) string { |
| 21 | return joinValues(valueMap(view)["languages" ]) |
| 22 | } |
| 23 | |
| 24 | func joinValues(value any) string { |
| 25 | items, _ := value.([]any) |
| 26 | parts := make([]string, 0, len(items)) |
| 27 | for _, item := range items { |
| 28 | parts = append(parts, plainString(item)) |
| 29 | } |
| 30 | return strings.Join(parts, ", " ) |
| 31 | } |