From 1bebb88d0ecc1949da6645f05a7c33e6265b1e88 Mon Sep 17 00:00:00 2001
From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com>
Date: Tue, 28 May 2024 18:01:26 +0100
Subject: [PATCH] Rename Stocks to Markets
Also fix bug that would remove markets if a network request failed
and not show them again until Glance was restarted
---
docs/configuration.md | 24 +++++-----
...preview.png => markets-widget-preview.png} | Bin
internal/assets/static/main.css | 6 +--
internal/assets/templates.go | 2 +-
.../templates/{stocks.html => markets.html} | 14 +++---
internal/feed/primitives.go | 18 +++++---
internal/feed/yahoo.go | 41 ++++++++----------
internal/widget/stocks.go | 33 ++++++++------
internal/widget/widget.go | 4 +-
9 files changed, 74 insertions(+), 68 deletions(-)
rename docs/images/{stocks-widget-preview.png => markets-widget-preview.png} (100%)
rename internal/assets/templates/{stocks.html => markets.html} (78%)
diff --git a/docs/configuration.md b/docs/configuration.md
index 90d9d7d..f57c0ad 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -20,7 +20,7 @@
- [Bookmarks](#bookmarks)
- [Calendar](#calendar)
- [Clock](#clock)
- - [Stocks](#stocks)
+ - [Markets](#markets)
- [Twitch Channels](#twitch-channels)
- [Twitch Top Games](#twitch-top-games)
- [iframe](#iframe)
@@ -80,8 +80,8 @@ pages:
- type: weather
location: London, United Kingdom
- - type: stocks
- stocks:
+ - type: markets
+ markets:
- symbol: SPY
name: S&P 500
- symbol: BTC-USD
@@ -1146,14 +1146,14 @@ Preview:
>
> There is currently no customizability available for the calendar. Extra features will be added in the future.
-### Stocks
-Display a list of stocks, their current value, change for the day and a small 21d chart. Data is taken from Yahoo Finance.
+### Markets
+Display a list of markets, their current value, change for the day and a small 21d chart. Data is taken from Yahoo Finance.
Example:
```yaml
-- type: stocks
- stocks:
+- type: markets
+ markets:
- symbol: SPY
name: S&P 500
- symbol: BTC-USD
@@ -1168,21 +1168,21 @@ Example:
Preview:
-![](images/stocks-widget-preview.png)
+![](images/markets-widget-preview.png)
#### Properties
| Name | Type | Required |
| ---- | ---- | -------- |
-| stocks | array | yes |
+| markets | array | yes |
| sort-by | string | no |
| style | string | no |
-##### `stocks`
-An array of stocks for which to display information about.
+##### `markets`
+An array of markets for which to display information about.
##### `sort-by`
-By default the stocks are displayed in the order they were defined. You can customize their ordering by setting the `sort-by` property to `absolute-change` for descending order based on the stock's absolute price change.
+By default the markets are displayed in the order they were defined. You can customize their ordering by setting the `sort-by` property to `absolute-change` for descending order based on the stock's absolute price change.
##### `style`
To make the widget scale appropriately in a `full` size column, set the style to the experimental `dynamic-columns-experimental` option.
diff --git a/docs/images/stocks-widget-preview.png b/docs/images/markets-widget-preview.png
similarity index 100%
rename from docs/images/stocks-widget-preview.png
rename to docs/images/markets-widget-preview.png
diff --git a/internal/assets/static/main.css b/internal/assets/static/main.css
index 4546d8e..d975c8b 100644
--- a/internal/assets/static/main.css
+++ b/internal/assets/static/main.css
@@ -622,16 +622,16 @@ kbd:active {
color: var(--color-text-highlight);
}
-.stock-chart {
+.market-chart {
margin-left: auto;
width: 6.5rem;
}
-.stock-chart svg {
+.market-chart svg {
width: 100%;
}
-.stock-values {
+.market-values {
min-width: 8rem;
}
diff --git a/internal/assets/templates.go b/internal/assets/templates.go
index 6ff1c89..cc91b49 100644
--- a/internal/assets/templates.go
+++ b/internal/assets/templates.go
@@ -26,7 +26,7 @@ var (
ChangeDetectionTemplate = compileTemplate("change-detection.html", "widget-base.html")
VideosTemplate = compileTemplate("videos.html", "widget-base.html", "video-card-contents.html")
VideosGridTemplate = compileTemplate("videos-grid.html", "widget-base.html", "video-card-contents.html")
- StocksTemplate = compileTemplate("stocks.html", "widget-base.html")
+ MarketsTemplate = compileTemplate("markets.html", "widget-base.html")
RSSListTemplate = compileTemplate("rss-list.html", "widget-base.html")
RSSDetailedListTemplate = compileTemplate("rss-detailed-list.html", "widget-base.html")
RSSHorizontalCardsTemplate = compileTemplate("rss-horizontal-cards.html", "widget-base.html")
diff --git a/internal/assets/templates/stocks.html b/internal/assets/templates/markets.html
similarity index 78%
rename from internal/assets/templates/stocks.html
rename to internal/assets/templates/markets.html
index eb348c0..9d8b33e 100644
--- a/internal/assets/templates/stocks.html
+++ b/internal/assets/templates/markets.html
@@ -3,31 +3,31 @@
{{ define "widget-content" }}
{{ if ne .Style "dynamic-columns-experimental" }}