Skip to content

Commit 68b2d37

Browse files
authored
Merge pull request #45 from codebude/feature/update-dashy-integration-docs
Add customapi widget Dashy integration to docs
2 parents 2306934 + d7a468c commit 68b2d37

3 files changed

Lines changed: 59 additions & 18 deletions

File tree

docs/api/integrations/dashy.md

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,57 @@
11
# Dashy
22

33
LibrisLog can be integrated into [Dashy](https://dashy.to/), a self-hosted
4-
dashboard for your services, using its
5-
[HTML embedded widget](https://dashy.to/docs/widgets#html-embedded-widget).
4+
dashboard for your services, using one of its widget types:
65

7-
This widget displays your reading statistics as styled stat cards directly on
8-
your Dashy dashboard.
6+
- **[Custom API widget](#custom-api-widget-recommended)** (Dashy ≥4.3.1) —
7+
a simple, built-in widget that fetches your stats directly (recommended).
8+
- **[HTML embedded widget](#html-embedded-widget)** — a fully customizable
9+
widget with styled stat cards.
910

1011
## Prerequisites
1112

1213
- A running LibrisLog instance reachable from your Dashy server
1314
- An [API key](/api/integrations/#api-keys) with access to the
1415
statistics endpoint
15-
- **CORS must be configured** — add your Dashy URL to the
16-
[`CORS_ORIGINS`](/guide/configuration#core-settings) environment variable
17-
of the LibrisLog backend so that the browser can fetch the API directly
1816

19-
## Configuration
17+
## Custom API Widget (Recommended)
18+
19+
Since Dashy v4.3.1 you can use the built-in
20+
[custom API widget](https://dashy.to/docs/widgets#api-response).
21+
Add the following to your Dashy `conf.yml`:
22+
23+
```yaml
24+
widgets:
25+
- type: customapi
26+
options:
27+
url: <LIBRISLOG-URL>/api/books/stats
28+
headers:
29+
X-API-Key: "<API-KEY>"
30+
refreshInterval: 60000
31+
display: block
32+
mappings:
33+
- field: books_read
34+
label: Read
35+
format: number
36+
- field: books_reading
37+
label: Reading
38+
format: number
39+
- field: books_want_to_read
40+
label: Want to read
41+
format: number
42+
- field: total_books
43+
label: Total
44+
format: number
45+
```
46+
47+
The `refreshInterval` is specified in milliseconds. `60000` equals 1 minute.
48+
49+
## HTML Embedded Widget
2050

21-
Add the following to the Dashy `conf.yml` under the section or item where you
22-
want the widget to appear:
51+
For full control over the appearance you can use the
52+
[HTML embedded widget](https://dashy.to/docs/widgets#html-embedded-widget).
53+
54+
Add the following to your Dashy `conf.yml`:
2355

2456
```yaml
2557
widgets:
@@ -112,26 +144,35 @@ widgets:
112144
})();
113145
```
114146

147+
The `updateInterval` is specified in seconds. `300` equals 5 minutes.
148+
149+
## Placeholders
150+
115151
Replace the placeholders with your own values:
116152

117153
| Placeholder | Example | Description |
118154
|---|---|---|
119155
| `<LIBRISLOG-URL>` | `http://192.168.1.100:8000` | The base URL of your LibrisLog instance (http or https) |
120156
| `<API-KEY>` | `lk_nRHsF3jxIBDa9u....` | An API key with access to the statistics endpoint |
121157

122-
The `updateInterval` is specified in seconds. `300` equals 5 minutes.
123-
124158
## CORS
125159

126-
Since the widget runs inside the Dashy iframe and fetches the LibrisLog API
127-
directly from the browser, you must add your Dashy URL to the
160+
The embed widget runs inside the Dashy iframe and fetches the API directly from
161+
the browser. You must add your Dashy URL to the
128162
[`CORS_ORIGINS`](/guide/configuration#core-settings) environment variable of
129-
the LibrisLog backend. For example:
163+
the LibrisLog backend:
130164

131165
```
132-
CORS_ORIGINS=["https://dashy.YOUR-DOMAIN"]
166+
CORS_ORIGINS=["<LIBRISLOG-URL>"]
133167
```
134168

135-
## Result
169+
The custom API widget also requires CORS if Dashy is configured to render
170+
widgets client-side. If CORS errors occur, add the origin as shown above.
171+
172+
## Results
173+
174+
### Custom API (API Response) Widget
175+
![Dashy Custom API Widget](/screenshots/integrations-dashy-customapi.png)
136176

137-
![Dashy Widget](/screenshots/integrations-dashy.png)
177+
### HTML Embed Widget
178+
![Dashy HTML Embedded Widget](/screenshots/integrations-dashy-embed.png)
9.11 KB
Loading
File renamed without changes.

0 commit comments

Comments
 (0)