Skip to content

Commit 38ced9f

Browse files
authored
Merge pull request #223 from ccarpo/main
Add Tsumego Daily widget
2 parents bf77246 + b656170 commit 38ced9f

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

widgets/tsumego-daily/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Daily Tsumego (Go Problem) from goproblems.com
2+
![image](./preview.png)
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.

widgets/tsumego-daily/meta.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
title: Tsumego Daily
2+
description: Shows daily Go Problems (Tsumego) from goproblems.com
3+
author: ccarpo

widgets/tsumego-daily/preview.png

10.8 KB
Loading

0 commit comments

Comments
 (0)