|
| 1 | +# Daily Tsumego (Go Problem) from goproblems.com |
| 2 | + |
| 3 | + |
| 4 | +Simple widget for displaying daily tsumego (go problem) from goproblems.com website. |
| 5 | + |
| 6 | +``` |
| 7 | + - type: custom-api |
| 8 | + title: Daily Go Problem |
| 9 | + cache: 6h |
| 10 | + url: https://www.goproblems.com/api/v2/problems/daily |
| 11 | + template: | |
| 12 | + {{ $targetCategory := "medium" }} |
| 13 | +
|
| 14 | + {{ range .JSON.Array "entries" }} |
| 15 | + {{ if eq (.String "category") $targetCategory }} |
| 16 | + {{ $id := .Int "id" }} |
| 17 | + {{ $imageUrl := .String "imageUrl" }} |
| 18 | + {{ $diffVal := .Int "difficulty.value" }} |
| 19 | + {{ $diffUnit := .String "difficulty.unit" }} |
| 20 | + {{ $genre := .String "genre" }} |
| 21 | + {{ $problemUrl := printf "https://www.goproblems.com/problems/%d" $id }} |
| 22 | + {{ $difficulty := printf "%d %s" $diffVal $diffUnit }} |
| 23 | +
|
| 24 | + <div style="text-align: center;"> |
| 25 | + <h3 style="font-size: 1.4rem; margin: 0 0 4px 0"> |
| 26 | + Medium Problem of the Day |
| 27 | + </h3> |
| 28 | + <div style="margin-bottom: 6px; font-size: 0.85rem"> |
| 29 | + {{ $difficulty }} {{ $genre }} |
| 30 | + </div> |
| 31 | + <a href="{{ $problemUrl }}" target="_blank"> |
| 32 | + <img src="{{ $imageUrl }}" |
| 33 | + alt="Go Problem of the Day" |
| 34 | + style="max-width:100%; height:auto; border-radius: 3px; display: inline"> |
| 35 | + </a> |
| 36 | + </div> |
| 37 | + {{ end }} |
| 38 | + {{ end }} |
| 39 | +``` |
| 40 | + |
| 41 | +## Configuration |
| 42 | + |
| 43 | +- `cache: 6h` – reasonable since the problem updates daily. |
| 44 | +- Change `{{ $targetCategory := "medium" }}` to `begubber`, `easy` or `hard`, to select a different difficulty. |
0 commit comments