Skip to content

Commit 25b5f2e

Browse files
authored
Merge pull request #54 from TimUx/copilot/add-buy-me-a-coffee-button
Add Buy Me a Coffee button to donation page
2 parents c66116a + f214755 commit 25b5f2e

File tree

7 files changed

+76
-4
lines changed

7 files changed

+76
-4
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ DONATION_POOL_ID='abc123?sr=example'
4949
DONATION_CAMPAIGN_NAME=Spendenaktion Lichtershow
5050
DONATION_SUBTITLE=Unterstütze unsere Lichtershow!
5151
DONATION_TEXT=Deine Spende hilft uns, die Lichtershow auch im nächsten Jahr zu ermöglichen.
52+
# Buy Me a Coffee Username (optional, wenn gesetzt erscheint ein Button)
53+
BUYMEACOFFEE_USERNAME=
5254

5355
# ==========================================
5456
# SOCIAL MEDIA (optional, leer lassen wenn nicht genutzt)

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Serverseitige (Python/Flask) Steuer-Seite für den Falcon Player (FPP). Der Cont
5353

5454
**Spendenseite:**
5555

56-
<img src="screenshot_donation.png" width="400">
56+
<img src="https://github.com/user-attachments/assets/41e940e6-b523-4b7b-8964-f5f28738f555" width="400">
5757

5858
**Hauptseite außerhalb des Showzeitraums (Buttons deaktiviert):**
5959

@@ -99,6 +99,7 @@ DONATION_POOL_ID='abc?123$=pool'
9999
DONATION_CAMPAIGN_NAME=Winter Lights
100100
DONATION_SUBTITLE=Unterstütze die Lichtershow
101101
DONATION_TEXT=
102+
BUYMEACOFFEE_USERNAME=example
102103
103104
# Social Media Links
104105
SOCIAL_FACEBOOK=https://facebook.com/example
@@ -144,6 +145,7 @@ Eine ausfüllbare Vorlage liegt als `.env.example` bei.
144145
- `DONATION_CAMPAIGN_NAME`: Optionaler Name der Spendenaktion.
145146
- `DONATION_SUBTITLE`: Unterzeile speziell für die Spendenseite.
146147
- `DONATION_TEXT`: Freier Beschreibungstext auf der Spendenseite. Leer lassen, wenn kein Text angezeigt werden soll.
148+
- `BUYMEACOFFEE_USERNAME`: Benutzername von buymeacoffee.com. Wenn gesetzt, erscheint ein zusätzlicher Button mit einem Hinweis, dass die Spende direkt dem Betreiber zugutekommt.
147149

148150
#### Social Media
149151
- `SOCIAL_FACEBOOK`: URL zur Facebook-Seite.

config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ window.FPP_CONFIG = {
77
donationCampaignName: 'FPP Weihnachtsaktion',
88
donationSubtitle: 'Unterstütze die Lichtershow',
99
donationText: 'Vielen Dank für deine Unterstützung!',
10+
buyMeACoffeeUsername: 'example',
1011
previewMode: true,
1112
accessCode: '1234',
1213
socialFacebook: 'https://facebook.com/example',

config.template.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ window.FPP_CONFIG = {
77
donationCampaignName: '${DONATION_CAMPAIGN_NAME:-}',
88
donationSubtitle: '${DONATION_SUBTITLE:-Unterstütze die Lichtershow}',
99
donationText: '${DONATION_TEXT-}',
10+
buyMeACoffeeUsername: '${BUYMEACOFFEE_USERNAME:-}',
1011
previewMode: ${PREVIEW_MODE:-false},
1112
accessCode: '${ACCESS_CODE:-}',
1213
socialFacebook: '${SOCIAL_FACEBOOK:-}',

docker-entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ set -e
3333
: "${DONATION_CAMPAIGN_NAME:=}"
3434
: "${DONATION_SUBTITLE:=Unterstütze die Lichtershow}"
3535
: "${DONATION_TEXT:=}"
36+
: "${BUYMEACOFFEE_USERNAME:=}"
3637

3738
# Social media
3839
: "${SOCIAL_FACEBOOK:=}"
@@ -62,6 +63,7 @@ config = {
6263
"donationText": "Vielen Dank für deine Unterstützung!"
6364
if donation_text_env is None
6465
else donation_text_env,
66+
"buyMeACoffeeUsername": os.getenv("BUYMEACOFFEE_USERNAME", ""),
6567
"previewMode": os.getenv("PREVIEW_MODE", "false").lower()
6668
in ["true", "1", "yes", "on"],
6769
"accessCode": os.getenv("ACCESS_CODE", ""),

donation.html

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,40 @@ <h3 class="social-footer-title">Unsere Kanäle:</h3>
8787
link.appendChild(icon);
8888
link.appendChild(label);
8989
donationLinks.appendChild(link);
90-
} else {
91-
donationLinks.innerHTML = '<p>Kein PayPal-Pool konfiguriert.</p>';
90+
}
91+
92+
// Buy Me a Coffee Button
93+
const bmcUsername = (config.buyMeACoffeeUsername || '').trim();
94+
// Validate username: only alphanumeric characters, underscores and hyphens allowed
95+
const isValidBmcUsername = bmcUsername && /^[a-zA-Z0-9_-]+$/.test(bmcUsername);
96+
if (isValidBmcUsername) {
97+
const bmcLink = document.createElement('a');
98+
bmcLink.className = 'donation-link bmc-link';
99+
bmcLink.href = `https://buymeacoffee.com/${encodeURIComponent(bmcUsername)}`;
100+
bmcLink.target = '_blank';
101+
bmcLink.rel = 'noopener noreferrer';
102+
103+
const bmcIcon = document.createElement('span');
104+
bmcIcon.className = 'bmc-icon';
105+
bmcIcon.setAttribute('aria-hidden', 'true');
106+
107+
const bmcLabel = document.createElement('span');
108+
bmcLabel.className = 'donation-label';
109+
bmcLabel.textContent = 'Buy me a Coffee';
110+
111+
bmcLink.appendChild(bmcIcon);
112+
bmcLink.appendChild(bmcLabel);
113+
donationLinks.appendChild(bmcLink);
114+
115+
// Add hint text for Buy Me a Coffee
116+
const bmcHint = document.createElement('p');
117+
bmcHint.className = 'bmc-hint note';
118+
bmcHint.textContent = 'Hinweis: Spenden über „Buy me a Coffee" kommen mir persönlich und direkt zugute – sie werden nicht an andere Vereine oder Organisationen weitergeleitet.';
119+
donationLinks.parentNode.insertBefore(bmcHint, donationLinks.nextSibling);
120+
}
121+
122+
if (!poolId && !isValidBmcUsername) {
123+
donationLinks.innerHTML = '<p>Keine Spendenmöglichkeit konfiguriert.</p>';
92124
}
93125

94126
backHome.addEventListener('click', () => {

styles.css

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,9 @@ button.action:disabled {
552552

553553
.donation-links {
554554
display: flex;
555-
justify-content: center;
555+
flex-direction: column;
556+
align-items: center;
557+
gap: 12px;
556558
margin-top: 6px;
557559
}
558560

@@ -576,6 +578,36 @@ button.action:disabled {
576578
min-width: min(360px, 100%);
577579
}
578580

581+
.donation-link.bmc-link {
582+
background: #ffdd00;
583+
color: #000;
584+
border-color: rgba(0, 0, 0, 0.1);
585+
}
586+
587+
.donation-link.bmc-link:hover,
588+
.donation-link.bmc-link:focus {
589+
background: #ffe44d;
590+
border-color: rgba(0, 0, 0, 0.15);
591+
}
592+
593+
.bmc-icon {
594+
width: 24px;
595+
height: 24px;
596+
display: inline-block;
597+
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 884 1279'%3E%3Cpath fill='%23000' d='M791.1 297.4c0-47.7-35.4-186.8-247.3-186.8l-41.6-60.3c-11.8-16.9-30.7-27.2-51.3-27.2h-159c-22.9 0-43.6 12.6-54.6 32.7L210.6 114c-209 16.4-209 162.3-209 183.4s7 156.6 189.8 188.9l46.2 460.6c9.5 89.8 83.8 160 174 160H632c90.2 0 164.5-70.2 174-160l32-318.4c86.7-53.8 119.9-131.9 119.9-179 0-51.4-33.2-100.6-79.9-121.3-7-25.8-25.1-48.6-86.9-30.8zm-51.3 255.4-34.4 351c-4.8 45.7-42.6 81.2-88.4 81.2H411.6c-45.8 0-83.6-35.5-88.4-81.2l-45-448.7h363.2c48.1 0 87.4-38.4 89.4-86.2 33.8 22.9 55.8 61.9 57.8 102.7-22 31.9-48.8 81.2-48.8 81.2zM539.7 134.9l25.5 37.1H340.5l19.2-37.1h180zm124.9 274.7H203.9l-5-46.1c57.2-1.9 132.1-24.4 205.7-47.6 77.7-24.5 152.4-48 210.5-48h88.8l-5 46.1c-4.8 45.8-42.6 95.6-34.3 95.6z'/%3E%3C/svg%3E") center / contain no-repeat;
598+
}
599+
600+
.bmc-hint {
601+
text-align: center;
602+
font-size: 0.85rem;
603+
color: rgba(255, 255, 255, 0.75);
604+
margin-top: 8px;
605+
padding: 10px 16px;
606+
background: rgba(255, 221, 0, 0.08);
607+
border-radius: 10px;
608+
border: 1px solid rgba(255, 221, 0, 0.15);
609+
}
610+
579611
.donation-label {
580612
display: inline-block;
581613
line-height: 1.2;

0 commit comments

Comments
 (0)