feat(strava): add hyperlink to activity

VirtualRide icon like Ride
Watts, HearRate, Kudos info
This commit is contained in:
lnu 2022-01-11 11:15:26 +01:00 committed by Jan De Dobbeleer
parent a36063a580
commit c687512fba
3 changed files with 30 additions and 7 deletions

View file

@ -16,7 +16,7 @@ and can also indicate by a color if it is time to get away from your computer an
## Accessing your Strava data
To allow Oh My Posh access your Strava data you need to grant access to read your public activities.
This will give you an access and a refresh token. Paste the tokens into your strava segment configuration.
This will give you an access and a refresh token. Paste the tokens into your Strava segment configuration.
Click the following link to connect with Strava:
@ -70,11 +70,13 @@ See the example above. Make sure your NerdFont has the glyph you want or search
- SkiingIcon - defaults to `\ue213`
- WorkOutIcon - defaults to `\ue213`
- UnknownActivityIcon - defaults to `\ue213`
- enable_hyperlink - display an hyperlink to activities - defaults to `false`
## Template Properties
The properties below are availible for use in your template
The properties below are available for use in your template
- `.ID`: `time` - The id of the entry
- `.DateString`: `time` - The timestamp of the entry
- `.Type`: `string` - Activity types as used in strava
- `.UtcOffset`: `int` - The UTC offset
@ -82,6 +84,12 @@ The properties below are availible for use in your template
- `.Name`: `string` - The name of the activity
- `.Duration`: `float64` - Total duration in seconds
- `.Distance`: `float64` - Total distance in meters
- `.DeviceWatts`: `bool` - Device has watts
- `.AverageWatts`: `float64` - Average watts
- `.WeightedAverageWatts`:`float64` - Weighted average watts
- `.AverageHeartRate`:`float64` - Average heart rate
- `.MaxHeartRate`: `float64` - Max heart rate
- `.KudosCount`: `int` - Kudos count
- `.Icon`: `string` - Activity based icon
Now, go out and have a fun ride or run!

View file

@ -39,11 +39,18 @@ const (
// StravaData struct contains the API data
type StravaData struct {
Type string `json:"type"`
StartDate time.Time `json:"start_date"`
Name string `json:"name"`
Distance float64 `json:"distance"`
Duration float64 `json:"moving_time"`
ID int `json:"id"`
Type string `json:"type"`
StartDate time.Time `json:"start_date"`
Name string `json:"name"`
Distance float64 `json:"distance"`
Duration float64 `json:"moving_time"`
DeviceWatts bool `json:"device_watts"`
AverageWatts float64 `json:"average_watts"`
WeightedAverageWatts float64 `json:"weighted_average_watts"`
AverageHeartRate float64 `json:"average_heartrate"`
MaxHeartRate float64 `json:"max_heartrate"`
KudosCount int `json:"kudos_count"`
}
type TokenExchange struct {
@ -91,6 +98,8 @@ func (s *strava) getAgo() string {
func (s *strava) getActivityIcon() string {
switch s.Type {
case "VirtualRide":
fallthrough
case "Ride":
return s.props.getString(RideIcon, "\uf5a2")
case "Run":
@ -121,6 +130,9 @@ func (s *strava) string() string {
if err != nil {
return err.Error()
}
if s.props.getBool(EnableHyperlink, false) {
text = fmt.Sprintf("[%s](https://www.strava.com/activities/%d)", text, s.ID)
}
return text
}

View file

@ -1664,6 +1664,9 @@
},
"template": {
"$ref": "#/definitions/template"
},
"enable_hyperlink": {
"$ref": "#/definitions/enable_hyperlink"
}
}
}