fix(strava): rename Icon

This commit is contained in:
Jan De Dobbeleer 2022-01-10 22:14:31 +01:00 committed by Jan De Dobbeleer
parent 3f3ac131b3
commit a36063a580
4 changed files with 17 additions and 15 deletions

View file

@ -8,10 +8,10 @@ import StravaConnect from '/img/strava_connect.svg';
## What ## What
[Strava][strava] ia a popular activity tracker for bike, run or any other traning. [Strava][strava] ia a popular activity tracker for bike, run or any other training.
To keep up with your training goals it is important to be constantly reminded about it. To keep up with your training goals it is important to be reminded about it.
A Strava Oh My Posh segment would show your last activity, An Oh My Posh Strava segment shows your last activity,
and also indicate by a color if it is time to get away from your computer and do some workout. and can also indicate by a color if it is time to get away from your computer and get active.
## Accessing your Strava data ## Accessing your Strava data
@ -27,7 +27,7 @@ Click the following link to connect with Strava:
## Sample Configuration ## Sample Configuration
This configuration sets the background green if you have an activity the last two days, This configuration sets the background green if you have an activity the last two days,
orange if you have one last 5 days, and red else. The `foreground_templates` example below could be set to just a single color, orange if you have one last 5 days, and red otherwise. The `foreground_templates` example below could be set to just a single color,
if that color is visible against any of your backgrounds. if that color is visible against any of your backgrounds.
```json ```json
@ -51,7 +51,7 @@ if that color is visible against any of your backgrounds.
"access_token":"11111111111111111", "access_token":"11111111111111111",
"refresh_token":"1111111111111111", "refresh_token":"1111111111111111",
"http_timeout": 1500, "http_timeout": 1500,
"template": "{{.Name}} {{.Ago}} {{.ActivityIcon}}" "template": "{{.Name}} {{.Ago}} {{.Icon}}"
} }
} }
``` ```
@ -60,6 +60,7 @@ if that color is visible against any of your backgrounds.
- access_token: `string` - token from Strava login, see login link in section above. It has the following format: `1111111111111111111111111` - access_token: `string` - token from Strava login, see login link in section above. It has the following format: `1111111111111111111111111`
- refresh_token: `string` - token from Strava login, see login link in section above. It has the following format: `1111111111111111111111111` - refresh_token: `string` - token from Strava login, see login link in section above. It has the following format: `1111111111111111111111111`
- expires_in: `int` - the default timeout of the token from the Strava login
- http_timeout: `int` - how long do you want to wait before you want to see your prompt more than your strava data? - defaults to 500ms - http_timeout: `int` - how long do you want to wait before you want to see your prompt more than your strava data? - defaults to 500ms
- template: `string` - a go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the properties below. - template: `string` - a go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the properties below.
See the example above. Make sure your NerdFont has the glyph you want or search for one at nerdfonts.com See the example above. Make sure your NerdFont has the glyph you want or search for one at nerdfonts.com
@ -80,7 +81,8 @@ The properties below are availible for use in your template
- `.Hours`: `int` - Number of hours since last activity - `.Hours`: `int` - Number of hours since last activity
- `.Name`: `string` - The name of the activity - `.Name`: `string` - The name of the activity
- `.Duration`: `float64` - Total duration in seconds - `.Duration`: `float64` - Total duration in seconds
- `.Distance`: `float64` - Toatal distance in meters - `.Distance`: `float64` - Total distance in meters
- `.Icon`: `string` - Activity based icon
Now, go out and have a fun ride or run! Now, go out and have a fun ride or run!

View file

@ -15,7 +15,7 @@ type strava struct {
env Environment env Environment
StravaData StravaData
ActivityIcon string Icon string
Ago string Ago string
Hours int Hours int
Authenticate bool Authenticate bool
@ -64,7 +64,7 @@ func (s *strava) enabled() bool {
data, err := s.getResult() data, err := s.getResult()
if err == nil { if err == nil {
s.StravaData = *data s.StravaData = *data
s.ActivityIcon = s.getActivityIcon() s.Icon = s.getActivityIcon()
s.Hours = s.getHours() s.Hours = s.getHours()
s.Ago = s.getAgo() s.Ago = s.getAgo()
return true return true

View file

@ -72,7 +72,7 @@ func TestStravaSegment(t *testing.T) {
Case: "Ride 6", Case: "Ride 6",
JSONResponse: ` JSONResponse: `
[{"type":"Ride","start_date":"` + sixHoursAgo + `","name":"Sesongens første på tjukkas","distance":16144.0}]`, [{"type":"Ride","start_date":"` + sixHoursAgo + `","name":"Sesongens første på tjukkas","distance":16144.0}]`,
Template: "{{.Ago}} {{.ActivityIcon}}", Template: "{{.Ago}} {{.Icon}}",
ExpectedString: "6h \uf5a2", ExpectedString: "6h \uf5a2",
ExpectedEnabled: true, ExpectedEnabled: true,
}, },
@ -80,7 +80,7 @@ func TestStravaSegment(t *testing.T) {
Case: "Run 100", Case: "Run 100",
JSONResponse: ` JSONResponse: `
[{"type":"Run","start_date":"` + fourDaysAgo + `","name":"Sesongens første på tjukkas","distance":16144.0,"moving_time":7665}]`, [{"type":"Run","start_date":"` + fourDaysAgo + `","name":"Sesongens første på tjukkas","distance":16144.0,"moving_time":7665}]`,
Template: "{{.Ago}} {{.ActivityIcon}}", Template: "{{.Ago}} {{.Icon}}",
ExpectedString: "4d \ufc0c", ExpectedString: "4d \ufc0c",
ExpectedEnabled: true, ExpectedEnabled: true,
}, },
@ -99,7 +99,7 @@ func TestStravaSegment(t *testing.T) {
Case: "Run from cache", Case: "Run from cache",
JSONResponse: ` JSONResponse: `
[{"type":"Run","start_date":"` + fourDaysAgo + `","name":"Sesongens første på tjukkas","distance":16144.0,"moving_time":7665}]`, [{"type":"Run","start_date":"` + fourDaysAgo + `","name":"Sesongens første på tjukkas","distance":16144.0,"moving_time":7665}]`,
Template: "{{.Ago}} {{.ActivityIcon}}", Template: "{{.Ago}} {{.Icon}}",
ExpectedString: "4d \ufc0c", ExpectedString: "4d \ufc0c",
ExpectedEnabled: true, ExpectedEnabled: true,
CacheTimeout: 10, CacheTimeout: 10,
@ -108,7 +108,7 @@ func TestStravaSegment(t *testing.T) {
Case: "Run from not found cache", Case: "Run from not found cache",
JSONResponse: ` JSONResponse: `
[{"type":"Run","start_date":"` + fourDaysAgo + `","name":"Morning ride","distance":16144.0,"moving_time":7665}]`, [{"type":"Run","start_date":"` + fourDaysAgo + `","name":"Morning ride","distance":16144.0,"moving_time":7665}]`,
Template: "{{.Ago}} {{.ActivityIcon}} {{.Name}} {{.Hours}}h ago", Template: "{{.Ago}} {{.Icon}} {{.Name}} {{.Hours}}h ago",
ExpectedString: "4d \ufc0c Morning ride 100h ago", ExpectedString: "4d \ufc0c Morning ride 100h ago",
ExpectedEnabled: true, ExpectedEnabled: true,
CacheTimeout: 10, CacheTimeout: 10,
@ -118,7 +118,7 @@ func TestStravaSegment(t *testing.T) {
Case: "Error parsing response", Case: "Error parsing response",
JSONResponse: ` JSONResponse: `
4tffgt4e4567`, 4tffgt4e4567`,
Template: "{{.Ago}}{{.ActivityIcon}}", Template: "{{.Ago}}{{.Icon}}",
ExpectedString: "50", ExpectedString: "50",
ExpectedEnabled: false, ExpectedEnabled: false,
CacheTimeout: 10, CacheTimeout: 10,

View file

@ -85,7 +85,7 @@
"access_token": "0ccbd2ac1e37a5b84101468df3d367177fe02ab3", "access_token": "0ccbd2ac1e37a5b84101468df3d367177fe02ab3",
"refresh_token": "111111111111111111111111111111", "refresh_token": "111111111111111111111111111111",
"http_timeout": 1500, "http_timeout": 1500,
"template": "{{.Name}} {{.Ago}} {{.ActivityIcon}}" "template": "{{.Name}} {{.Ago}} {{.Icon}}"
} }
}, },
{ {