Update main.py
Browse files
main.py
CHANGED
@@ -136,6 +136,115 @@ def proxy(path):
|
|
136 |
button['style'] = 'display: inline-block; margin: 10px; padding: 8px 15px; background-color: #4a90e2; border: none; border-radius: 4px; text-decoration: none; color: white; font-weight: 500; transition: all 0.3s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.1);'
|
137 |
img.insert_after(button)
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
# Add modal container for fullscreen image view
|
140 |
modal_div = soup.new_tag('div')
|
141 |
modal_div['id'] = 'imageModal'
|
|
|
136 |
button['style'] = 'display: inline-block; margin: 10px; padding: 8px 15px; background-color: #4a90e2; border: none; border-radius: 4px; text-decoration: none; color: white; font-weight: 500; transition: all 0.3s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.1);'
|
137 |
img.insert_after(button)
|
138 |
|
139 |
+
# Add theme toggle button
|
140 |
+
theme_toggle = soup.new_tag('button')
|
141 |
+
theme_toggle['id'] = 'themeToggle'
|
142 |
+
theme_toggle['style'] = 'position: fixed; top: 20px; right: 20px; padding: 10px; border-radius: 50%; width: 40px; height: 40px; border: none; cursor: pointer; z-index: 1000; transition: all 0.3s ease; display: flex; align-items: center; justify-content: center;'
|
143 |
+
theme_toggle.string = '🌓'
|
144 |
+
if soup.body:
|
145 |
+
soup.body.insert(0, theme_toggle)
|
146 |
+
|
147 |
+
# Add theme styles
|
148 |
+
style_tag = soup.new_tag('style')
|
149 |
+
style_tag.string = '''
|
150 |
+
:root {
|
151 |
+
--bg-color: #ffffff;
|
152 |
+
--text-color: #333333;
|
153 |
+
--link-color: #4a90e2;
|
154 |
+
--border-color: #ddd;
|
155 |
+
--shadow-color: rgba(0,0,0,0.1);
|
156 |
+
--button-bg: #4a90e2;
|
157 |
+
--button-text: white;
|
158 |
+
--modal-bg: rgba(0,0,0,0.8);
|
159 |
+
}
|
160 |
+
|
161 |
+
[data-theme="dark"] {
|
162 |
+
--bg-color: #1a1a1a;
|
163 |
+
--text-color: #e0e0e0;
|
164 |
+
--link-color: #66b3ff;
|
165 |
+
--border-color: #404040;
|
166 |
+
--shadow-color: rgba(0,0,0,0.3);
|
167 |
+
--button-bg: #2d5a8c;
|
168 |
+
--button-text: #ffffff;
|
169 |
+
--modal-bg: rgba(0,0,0,0.9);
|
170 |
+
}
|
171 |
+
|
172 |
+
body {
|
173 |
+
background-color: var(--bg-color);
|
174 |
+
color: var(--text-color);
|
175 |
+
transition: all 0.3s ease;
|
176 |
+
}
|
177 |
+
|
178 |
+
a {
|
179 |
+
color: var(--link-color);
|
180 |
+
}
|
181 |
+
|
182 |
+
img {
|
183 |
+
border-color: var(--border-color) !important;
|
184 |
+
box-shadow: 0 2px 4px var(--shadow-color) !important;
|
185 |
+
}
|
186 |
+
|
187 |
+
.open-image-btn {
|
188 |
+
background-color: var(--button-bg) !important;
|
189 |
+
color: var(--button-text) !important;
|
190 |
+
}
|
191 |
+
|
192 |
+
#themeToggle {
|
193 |
+
background-color: var(--bg-color);
|
194 |
+
color: var(--text-color);
|
195 |
+
box-shadow: 0 2px 4px var(--shadow-color);
|
196 |
+
}
|
197 |
+
|
198 |
+
.modal {
|
199 |
+
background-color: var(--modal-bg);
|
200 |
+
}
|
201 |
+
|
202 |
+
.zoom-controls button {
|
203 |
+
background-color: var(--button-bg);
|
204 |
+
color: var(--button-text);
|
205 |
+
border: 1px solid var(--border-color);
|
206 |
+
}
|
207 |
+
'''
|
208 |
+
if soup.head:
|
209 |
+
soup.head.append(style_tag)
|
210 |
+
else:
|
211 |
+
head_tag = soup.new_tag('head')
|
212 |
+
head_tag.append(style_tag)
|
213 |
+
if soup.html:
|
214 |
+
soup.html.insert(0, head_tag)
|
215 |
+
else:
|
216 |
+
html_tag = soup.new_tag('html')
|
217 |
+
html_tag.append(head_tag)
|
218 |
+
soup.append(html_tag)
|
219 |
+
|
220 |
+
# Add JavaScript for theme toggle
|
221 |
+
script_tag = soup.new_tag('script')
|
222 |
+
script_tag.string = '''
|
223 |
+
document.addEventListener('DOMContentLoaded', function() {
|
224 |
+
const themeToggle = document.getElementById('themeToggle');
|
225 |
+
const savedTheme = localStorage.getItem('theme');
|
226 |
+
|
227 |
+
if (savedTheme === 'dark') {
|
228 |
+
document.documentElement.setAttribute('data-theme', 'dark');
|
229 |
+
}
|
230 |
+
|
231 |
+
themeToggle.addEventListener('click', function() {
|
232 |
+
const currentTheme = document.documentElement.getAttribute('data-theme');
|
233 |
+
const newTheme = currentTheme === 'dark' ? null : 'dark';
|
234 |
+
|
235 |
+
if (newTheme) {
|
236 |
+
document.documentElement.setAttribute('data-theme', newTheme);
|
237 |
+
localStorage.setItem('theme', newTheme);
|
238 |
+
} else {
|
239 |
+
document.documentElement.removeAttribute('data-theme');
|
240 |
+
localStorage.removeItem('theme');
|
241 |
+
}
|
242 |
+
});
|
243 |
+
});
|
244 |
+
'''
|
245 |
+
if soup.body:
|
246 |
+
soup.body.append(script_tag)
|
247 |
+
|
248 |
# Add modal container for fullscreen image view
|
249 |
modal_div = soup.new_tag('div')
|
250 |
modal_div['id'] = 'imageModal'
|