1
+ pub fn generate_donation_page ( yaml_str : & str ) -> anyhow:: Result < String > {
2
+
3
+ // Parse FUNDING.yml
4
+ #[ derive( serde_derive:: Deserialize , Debug ) ]
5
+ struct FundingConfig {
6
+ github : Option < String > ,
7
+ ko_fi : Option < String > ,
8
+ liberapay : Option < String > ,
9
+ custom : Option < Vec < String > > ,
10
+ }
11
+
12
+ let funding: FundingConfig = serde_yaml:: from_str ( yaml_str) ?;
13
+
14
+ let mut donation_options = String :: new ( ) ;
15
+
16
+ // GitHub Sponsors
17
+ if let Some ( github_user) = & funding. github {
18
+ donation_options. push_str ( & format ! (
19
+ r#"<div class="donation-option">
20
+ <h2>GitHub Sponsors</h2>
21
+ <p>Support development directly through GitHub Sponsors.</p>
22
+ <a href="https://github.com/sponsors/{}" class="donation-button github">
23
+ Sponsor on GitHub
24
+ </a>
25
+ </div>"# ,
26
+ github_user
27
+ ) ) ;
28
+ }
29
+
30
+ // Ko-fi
31
+ if let Some ( kofi_user) = & funding. ko_fi {
32
+ donation_options. push_str ( & format ! (
33
+ r#"<div class="donation-option">
34
+ <h2>Ko-fi</h2>
35
+ <p>Buy me a coffee to keep development going.</p>
36
+ <a href="https://ko-fi.com/{}" class="donation-button kofi">
37
+ Support on Ko-fi
38
+ </a>
39
+ </div>"# ,
40
+ kofi_user
41
+ ) ) ;
42
+ }
43
+
44
+ // Liberapay
45
+ if let Some ( liberapay_user) = & funding. liberapay {
46
+ donation_options. push_str ( & format ! (
47
+ r#"<div class="donation-option">
48
+ <h2>Liberapay</h2>
49
+ <p>Support through Liberapay, an open source donation platform.</p>
50
+ <a href="https://liberapay.com/{}" class="donation-button liberapay">
51
+ Donate on Liberapay
52
+ </a>
53
+ </div>"# ,
54
+ liberapay_user
55
+ ) ) ;
56
+ }
57
+
58
+ // Custom options
59
+ if let Some ( custom_options) = & funding. custom {
60
+ for url in custom_options {
61
+ let ( service, button_class) = if url. contains ( "paypal.me" ) {
62
+ ( "PayPal" , "paypal" )
63
+ } else if url. contains ( "wise.com" ) {
64
+ ( "Wise" , "wise" )
65
+ } else {
66
+ ( "Other" , "other" )
67
+ } ;
68
+
69
+ donation_options. push_str ( & format ! (
70
+ r#"<div class="donation-option">
71
+ <h2>{}</h2>
72
+ <p>Direct payment through {}.</p>
73
+ <a href="{}" class="donation-button {}">
74
+ Donate via {}
75
+ </a>
76
+ </div>"# ,
77
+ service, service, url, button_class, service
78
+ ) ) ;
79
+ }
80
+ }
81
+
82
+ // Get common head tags and sidebar
83
+ let common_head_tags = crate :: docgen:: get_common_head_tags ( ) ;
84
+ let sidebar = crate :: docgen:: get_sidebar ( ) ;
85
+
86
+ // Additional CSS for the donation page
87
+ let donation_css = r#"
88
+ .donation-container {
89
+ display: flex;
90
+ flex-wrap: wrap;
91
+ gap: 2rem;
92
+ margin-top: 2rem;
93
+ }
94
+
95
+ .donation-option {
96
+ background-color: #f5f7fa;
97
+ border-radius: 10px;
98
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
99
+ padding: 2rem;
100
+ width: 300px;
101
+ transition: transform 0.2s, box-shadow 0.2s;
102
+ }
103
+
104
+ .donation-option:hover {
105
+ transform: translateY(-5px);
106
+ box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
107
+ }
108
+
109
+ .donation-option h2 {
110
+ color: #004e92;
111
+ margin-bottom: 1rem;
112
+ font-size: 1.5rem;
113
+ }
114
+
115
+ .donation-option p {
116
+ margin-bottom: 1.5rem;
117
+ color: #555;
118
+ line-height: 1.4;
119
+ }
120
+
121
+ .donation-button {
122
+ display: inline-block;
123
+ background-color: #004e92;
124
+ color: white;
125
+ padding: 0.75rem 1.5rem;
126
+ border-radius: 5px;
127
+ text-decoration: none;
128
+ font-weight: bold;
129
+ transition: background-color 0.2s;
130
+ text-align: center;
131
+ width: 100%;
132
+ box-sizing: border-box;
133
+ }
134
+
135
+ .donation-button:hover {
136
+ background-color: #003366;
137
+ }
138
+
139
+ .donation-intro {
140
+ max-width: 800px;
141
+ line-height: 1.6;
142
+ font-size: 1.2rem;
143
+ }
144
+
145
+ .github { background-color: #24292e; }
146
+ .github:hover { background-color: #1a1e22; }
147
+
148
+ .kofi { background-color: #29abe0; }
149
+ .kofi:hover { background-color: #2180ab; }
150
+
151
+ .liberapay { background-color: #f6c915; color: #1a171b; }
152
+ .liberapay:hover { background-color: #e0b50e; }
153
+
154
+ .paypal { background-color: #003087; }
155
+ .paypal:hover { background-color: #001e53; }
156
+
157
+ .wise { background-color: #9fe870; color: #1a171b; }
158
+ .wise:hover { background-color: #8ad057; }
159
+
160
+ @media (max-width: 768px) {
161
+ .donation-container {
162
+ flex-direction: column;
163
+ align-items: center;
164
+ }
165
+
166
+ .donation-option {
167
+ width: 100%;
168
+ max-width: 300px;
169
+ }
170
+
171
+ .donation-intro {
172
+ padding: 0 1rem;
173
+ }
174
+ }
175
+ "# ;
176
+
177
+ // Generate the full HTML page
178
+ let html = format ! (
179
+ r#"<!DOCTYPE html>
180
+ <html lang="en">
181
+ <head>
182
+ <title>Support Azul GUI Framework Development</title>
183
+ {common_head_tags}
184
+ <style>
185
+ {donation_css}
186
+ </style>
187
+ </head>
188
+ <body>
189
+ <div class="center">
190
+ <aside>
191
+ <header>
192
+ <h1 style="display:none;">Azul GUI Framework</h1>
193
+ <a href="{html_root}">
194
+ <img src="{html_root}/logo.svg">
195
+ </a>
196
+ </header>
197
+ <nav>
198
+ {sidebar}
199
+ </nav>
200
+ </aside>
201
+ <main>
202
+ <h1>Support Azul Development</h1>
203
+
204
+ <div class="donation-intro">
205
+ <p>Azul is an open-source GUI framework that relies on community support to continue development.
206
+ Your contributions help maintain the project, implement new features, and keep resources available to everyone.</p>
207
+ <p>Choose one of the options below to support the project:</p>
208
+ </div>
209
+
210
+ <div class="donation-container">
211
+ {donation_options}
212
+ </div>
213
+
214
+ <div class="donation-intro" style="margin-top: 2rem;">
215
+ <p>Thank you for considering supporting Azul! Every contribution helps the project grow.</p>
216
+ <p>If you have any questions about donations, please reach out via
217
+ <a href="https://github.com/fschutt/azul/issues">GitHub</a> or
218
+ <a href="https://discord.gg/V96ZGKqQvn">Discord</a>.</p>
219
+ </div>
220
+ </main>
221
+ </div>
222
+ <script async type="text/javascript" src="{html_root}/prism_code_highlighter.js"></script>
223
+ </body>
224
+ </html>"# ,
225
+ common_head_tags = common_head_tags,
226
+ donation_css = donation_css,
227
+ html_root = crate :: docgen:: HTML_ROOT ,
228
+ sidebar = sidebar,
229
+ donation_options = donation_options
230
+ ) ;
231
+
232
+ Ok ( html)
233
+ }
0 commit comments