|
| 1 | +# Preview |
| 2 | + |
| 3 | + |
| 4 | +# Notes |
| 5 | +- In the preview this widget was used in a column between two small side columns. All other configurations have not been tested. |
| 6 | +- No additional configuration is necessary for this widget. |
| 7 | + |
| 8 | +# Update Frequency |
| 9 | +Every 10 minutes by default (can be changed). |
| 10 | + |
| 11 | +# YAML |
| 12 | +```yaml |
| 13 | +- type: custom-api |
| 14 | + title: UFC Fight Tracker |
| 15 | + cache: 10m |
| 16 | + url: https://site.api.espn.com/apis/site/v2/sports/mma/ufc/scoreboard |
| 17 | + template: | |
| 18 | + <ul class="list collapsible-container flex flex-column gap-10" data-collapse-after="3" style="list-style: none; padding: 0; margin: 0;"> |
| 19 | + |
| 20 | + {{ $events := .JSON.Array "events" }} |
| 21 | + |
| 22 | + {{ if $events }} |
| 23 | + {{ range $events }} |
| 24 | + {{ $status := .String "status.type.state" }} |
| 25 | + {{ $dateStr := .String "date" }} |
| 26 | + {{ $eventName := .String "name" }} |
| 27 | + |
| 28 | + {{ range .Array "competitions" }} |
| 29 | + |
| 30 | + {{/* VENUE LOGIC: Combine Name + City/State/Country */}} |
| 31 | + {{ $vName := .String "venue.fullName" }} |
| 32 | + {{ $vCity := .String "venue.address.city" }} |
| 33 | + {{ $vCountry := .String "venue.address.country" }} |
| 34 | + |
| 35 | + {{/* Build location string based on what is available */}} |
| 36 | + {{ $location := $vName }} |
| 37 | + {{ if $vCity }} |
| 38 | + {{ $location = print $location " • " $vCity }} |
| 39 | + {{ if $vCountry }} |
| 40 | + {{ $location = print $location ", " $vCountry }} |
| 41 | + {{ end }} |
| 42 | + {{ end }} |
| 43 | + |
| 44 | + <li> |
| 45 | + <div style="background: rgba(255,255,255,0.03); border-radius: 8px; padding: 12px; border: 1px solid rgba(255,255,255,0.05);"> |
| 46 | + |
| 47 | + <div class="flex justify-between items-center" style="margin-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 8px;"> |
| 48 | + <div class="text-truncate" style="font-weight: 700; color: var(--color-highlight); font-size: 0.9em; max-width: 60%;"> |
| 49 | + {{ $eventName }} |
| 50 | + </div> |
| 51 | + <div style="font-size: 0.75em; font-family: monospace; text-align: right;"> |
| 52 | + {{ if eq $status "in" }} |
| 53 | + <span style="color: #ef4444; font-weight: bold; animation: pulse 2s infinite;">🔴 LIVE R{{ .String "status.period" }}</span> |
| 54 | + {{ else if eq $status "post" }} |
| 55 | + <span style="color: var(--color-subdue);">FINAL</span> |
| 56 | + {{ else }} |
| 57 | + {{ if $dateStr }} |
| 58 | + {{ $t := parseTime "2006-01-02T15:04Z" $dateStr }} |
| 59 | + 📅 {{ $t.Local.Format "02. Jan • 15:04" }} |
| 60 | + {{ end }} |
| 61 | + {{ end }} |
| 62 | + </div> |
| 63 | + </div> |
| 64 | + |
| 65 | + <div style="display: grid; grid-template-columns: 1fr 40px 1fr; align-items: center;"> |
| 66 | + {{ range $index, $competitor := .Array "competitors" }} |
| 67 | + |
| 68 | + {{ if eq $index 1 }} |
| 69 | + <div style="text-align: center; font-size: 0.75em; color: var(--color-subdue); font-weight: bold; grid-column: 2;">VS</div> |
| 70 | + {{ end }} |
| 71 | + |
| 72 | + <div style="grid-column: {{ if eq $index 0 }}1{{ else }}3{{ end }}; display: flex; align-items: center; {{ if eq $index 0 }}justify-content: flex-end; text-align: right;{{ else }}justify-content: flex-start; text-align: left;{{ end }}"> |
| 73 | + |
| 74 | + <div style="display: flex; align-items: center; gap: 12px; {{ if eq $index 1 }}flex-direction: row-reverse;{{ end }}"> |
| 75 | + <div style="min-width: 0;"> |
| 76 | + <div style="display: flex; align-items: center; gap: 6px; {{ if eq $index 0 }}justify-content: flex-end;{{ else }}justify-content: flex-start;{{ end }}"> |
| 77 | + {{ if and (eq $index 0) (.String "athlete.flag.href") }} |
| 78 | + <img src="{{ .String "athlete.flag.href" }}" style="width: 14px; height: 10px; opacity: 0.8; border-radius: 2px;"> |
| 79 | + {{ end }} |
| 80 | + |
| 81 | + <span class="text-truncate" style="font-weight: bold; font-size: 0.9em; {{ if .Bool "winner" }}color: #22c55e;{{ end }}"> |
| 82 | + {{ .String "athlete.displayName" }} |
| 83 | + </span> |
| 84 | + |
| 85 | + {{ if and (eq $index 1) (.String "athlete.flag.href") }} |
| 86 | + <img src="{{ .String "athlete.flag.href" }}" style="width: 14px; height: 10px; opacity: 0.8; border-radius: 2px;"> |
| 87 | + {{ end }} |
| 88 | + </div> |
| 89 | + |
| 90 | + <div style="font-size: 0.75em; opacity: 0.6; margin-top: 2px;"> |
| 91 | + {{ if .String "curatedRank.current" }}<span style="color:var(--color-highlight)">#{{ .String "curatedRank.current" }}</span> • {{ end }} |
| 92 | + {{ .String "records.0.summary" }} |
| 93 | + </div> |
| 94 | + </div> |
| 95 | + |
| 96 | + <div style="position: relative; width: 42px; height: 42px; shrink: 0;"> |
| 97 | + <img src="{{ .String "athlete.headshot.href" }}" |
| 98 | + style="width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1);" |
| 99 | + onerror="this.style.opacity='0'"> |
| 100 | + </div> |
| 101 | + </div> |
| 102 | + </div> |
| 103 | + {{ end }} |
| 104 | + </div> |
| 105 | + |
| 106 | + <div style="margin-top: 10px; font-size: 0.7em; text-align: center; opacity: 0.4;"> |
| 107 | + 📍 {{ $location }} |
| 108 | + </div> |
| 109 | + |
| 110 | + </div> |
| 111 | + </li> |
| 112 | + {{ end }} |
| 113 | + {{ end }} |
| 114 | + {{ else }} |
| 115 | + <div class="color-subdue">No scheduled fights found.</div> |
| 116 | + {{ end }} |
| 117 | + </ul> |
| 118 | +``` |
0 commit comments