Skip to content

Commit e5f053a

Browse files
authored
feat: add border_radius URL parameter for customizable container corners (#124)
This PR adds a new `border_radius` URL parameter that allows users to customize the border radius of the card container across all themes. Changes: - Added `border_radius` parameter to view.py (default: 10px) - Updated all Jinja2 templates to use dynamic border_radius value - Added comprehensive "Customization" section to README documenting all available URL parameters Usage example: ``` ?uid=YOUR_UID&border_radius=15 ``` This allows users to better match the Spotify widget styling with other GitHub profile widgets that may use different border radius values.
1 parent 2f8326c commit e5f053a

9 files changed

Lines changed: 45 additions & 17 deletions

README.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ Vercel change the package the free tier is not enough for our usage. I moved ser
1212

1313
Please replace your old endpoint `https://spotify-github-profile.vercel.app` to `https://spotify-github-profile.kittinanx.com`
1414

15-
## Table of Contents
16-
[Connect And Grant Permission](#connect-and-grant-permission)
17-
[Example](#example)
18-
[Running for development locally](#running-for-development-locally)
19-
[Setting up Vercel](#setting-up-vercel)
20-
[Setting up Firebase](#setting-up-firebase)
21-
[Setting up Spotify dev](#setting-up-spotify-dev)
22-
[Running locally](#running-locally)
23-
[How to Contribute](#how-to-contribute)
24-
[Known Bugs](#known-bugs)
25-
[Features in Progress](#features-in-progress)
15+
## Table of Contents
16+
[Connect And Grant Permission](#connect-and-grant-permission)
17+
[Example](#example)
18+
[Customization](#customization)
19+
[Running for development locally](#running-for-development-locally)
20+
[Setting up Vercel](#setting-up-vercel)
21+
[Setting up Firebase](#setting-up-firebase)
22+
[Setting up Spotify dev](#setting-up-spotify-dev)
23+
[Running locally](#running-locally)
24+
[How to Contribute](#how-to-contribute)
25+
[Known Bugs](#known-bugs)
2626
[Credit](#credit)
2727

2828
## Connect And Grant Permission
@@ -57,6 +57,28 @@ Please replace your old endpoint `https://spotify-github-profile.vercel.app` to
5757

5858
![spotify-github-profile](/img/spotify-embed.svg)
5959

60+
## Customization
61+
62+
You can customize the appearance by adding query parameters to your URL:
63+
64+
| Parameter | Description | Default |
65+
|-----------|-------------|---------|
66+
| `theme` | Theme to use (`default`, `compact`, `natemoo-re`, `novatorem`, `karaoke`, `spotify-embed`, `apple`) | `default` |
67+
| `background_color` | Background color (hex without #) | `121212` |
68+
| `border_radius` | Border radius in pixels | `10` |
69+
| `bar_color` | Equalizer bar color (hex without #) | `53b14f` |
70+
| `bar_color_cover` | Extract bar color from album cover (`true`/`false`) | `false` |
71+
| `cover_image` | Show album cover image (`true`/`false`) | `true` |
72+
| `show_offline` | Show offline status when not playing (`true`/`false`) | `false` |
73+
| `interchange` | Swap artist and song name positions (`true`/`false`) | `false` |
74+
| `mode` | Color mode for supported themes (`light`/`dark`) | `light` |
75+
76+
### Example
77+
78+
```
79+
https://spotify-github-profile.kittinanx.com/api/view?uid=YOUR_UID&cover_image=true&theme=default&border_radius=15&bar_color=53b14f
80+
```
81+
6082
## Running for development locally without Vercel
6183

6284
To run the application locally without Vercel:

api/templates/spotify.apple.html.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<foreignObject width="343" height="534">
33
<style>
44
.container {
5-
border-radius: 12px;
5+
border-radius: {{border_radius}}px;
66
{% if mode == 'dark' %}
77
background-color: #1a1a1a;
88
{% else %}

api/templates/spotify.compact.html.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
.container {
1010
background-color: #{{background_color}};
11-
border-radius: 10px;
11+
border-radius: {{border_radius}}px;
1212
1313
padding: 10px 10px
1414
}

api/templates/spotify.default.html.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
.container {
1010
background-color: #{{background_color}};
11-
border-radius: 10px;
11+
border-radius: {{border_radius}}px;
1212
1313
padding: 10px 10px
1414
}

api/templates/spotify.karaoke.html.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
99
.container {
1010
background-color: #{{background_color}};
11+
border-radius: {{border_radius}}px;
1112
1213
padding: 10px 10px
1314
}

api/templates/spotify.natemoo-re.html.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
display: flex;
1111
align-items: center;
1212
13-
border-radius: 10px;
13+
border-radius: {{border_radius}}px;
1414
1515
padding: 10px 10px
1616
}

api/templates/spotify.novatorem.html.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
display: flex;
1111
align-items: center;
1212
13-
border-radius: 10px;
13+
border-radius: {{border_radius}}px;
1414
1515
padding: 10px 10px
1616
}

api/templates/spotify.spotify-embed.html.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
{% else %}
1616
background-color: #ffffff;
1717
{% endif %}
18-
border-radius: 8px;
18+
border-radius: {{border_radius}}px;
1919
padding: 16px;
2020
display: flex;
2121
align-items: center;

api/view.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def make_svg(
139139
show_offline,
140140
background_color,
141141
mode,
142+
border_radius="10",
142143
progress_ms=None,
143144
duration_ms=None,
144145
):
@@ -210,6 +211,7 @@ def make_svg(
210211
"mode": mode,
211212
"is_now_playing": is_now_playing,
212213
"progress_data": progress_data,
214+
"border_radius": border_radius,
213215
}
214216

215217
return render_template(f"spotify.{theme}.html.j2", **rendered_data)
@@ -352,6 +354,7 @@ def catch_all(path):
352354
show_offline = request.args.get("show_offline", default="false") == "true"
353355
interchange = request.args.get("interchange", default="false") == "true"
354356
mode = request.args.get("mode", default="light")
357+
border_radius = request.args.get("border_radius", default="10")
355358
is_enable_profanity = request.args.get("profanity", default="false") == "true"
356359
hide_remaster = request.args.get("hide_remaster", default="false") == "true"
357360

@@ -390,6 +393,7 @@ def catch_all(path):
390393
show_offline,
391394
background_color,
392395
mode,
396+
border_radius,
393397
progress_ms,
394398
duration_ms,
395399
)
@@ -476,6 +480,7 @@ def catch_all(path):
476480
show_offline,
477481
background_color,
478482
mode,
483+
border_radius,
479484
progress_ms,
480485
duration_ms,
481486
)

0 commit comments

Comments
 (0)