82 lines
1.7 KiB
Markdown
82 lines
1.7 KiB
Markdown
# OG Share Service
|
|
|
|
This service powers dynamic Open Graph share pages and images for Portfolio Journal.
|
|
|
|
## Endpoints
|
|
|
|
- `/share?data=BASE64URL` renders the HTML page with OG tags.
|
|
- `/og?data=BASE64URL` renders the 1200x630 PNG image.
|
|
|
|
Payload (JSON, base64url-encoded):
|
|
|
|
```json
|
|
{
|
|
"n": "Goal name",
|
|
"r": 12500.5,
|
|
"g": 20000,
|
|
"c": "USD",
|
|
"td": "2026-12-31",
|
|
"ec": "2026-10-15",
|
|
"p": false
|
|
}
|
|
```
|
|
|
|
Fields:
|
|
- `n` goal name
|
|
- `r` current amount
|
|
- `g` goal amount
|
|
- `c` currency code (ISO 4217)
|
|
- `td` target date (YYYY-MM-DD, optional)
|
|
- `ec` estimated completion date (YYYY-MM-DD, optional)
|
|
- `p` privacy mode; when true, hides the current amount
|
|
|
|
## Run locally
|
|
|
|
```bash
|
|
cd og-service
|
|
GO111MODULE=on go run .
|
|
```
|
|
|
|
## OpenRC (Alpine) service
|
|
|
|
Example steps (requires root):
|
|
|
|
```bash
|
|
# Build and install the binary
|
|
make build
|
|
cp og-service/bin/portfoliojournal-og /usr/local/bin/portfoliojournal-og
|
|
chmod +x /usr/local/bin/portfoliojournal-og
|
|
|
|
# Install the OpenRC script
|
|
cp og-service/portfoliojournal-og.openrc /etc/init.d/portfoliojournal-og
|
|
chmod +x /etc/init.d/portfoliojournal-og
|
|
|
|
# Enable and start
|
|
rc-update add portfoliojournal-og default
|
|
rc-service portfoliojournal-og start
|
|
```
|
|
|
|
Or run the helper script (requires root):
|
|
|
|
```bash
|
|
sudo sh og-service/install-openrc.sh
|
|
```
|
|
|
|
## NGINX example
|
|
|
|
```nginx
|
|
location /share {
|
|
proxy_pass http://127.0.0.1:8090;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
}
|
|
|
|
location /og {
|
|
proxy_pass http://127.0.0.1:8090;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
}
|
|
```
|