Starchik1 commited on
Commit
bbd8d94
·
verified ·
1 Parent(s): efe1ece

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +132 -0
main.py CHANGED
@@ -136,6 +136,81 @@ def proxy(path):
136
  button['style'] = 'display: inline-block; margin: 5px; padding: 5px 10px; background-color: #f0f0f0; border: 1px solid #ccc; border-radius: 3px; text-decoration: none; color: #333;'
137
  img.insert_after(button)
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  # Add CSS styles to improve design
140
  style_tag = soup.new_tag('style')
141
  style_tag.string = '''
@@ -284,6 +359,55 @@ def proxy(path):
284
  background: linear-gradient(to right, transparent, rgba(44, 62, 80, 0.2), transparent);
285
  margin: 30px 0;
286
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
  @media (max-width: 768px) {
288
  body { padding: 15px; }
289
  .breadcrumb {
@@ -301,6 +425,14 @@ def proxy(path):
301
  width: 100%;
302
  text-align: center;
303
  }
 
 
 
 
 
 
 
 
304
  }
305
  '''
306
  # Check if head exists, if not create it
 
136
  button['style'] = 'display: inline-block; margin: 5px; padding: 5px 10px; background-color: #f0f0f0; border: 1px solid #ccc; border-radius: 3px; text-decoration: none; color: #333;'
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'
142
+ modal_div['class'] = 'modal'
143
+ modal_div['style'] = 'display: none;'
144
+
145
+ modal_img = soup.new_tag('img')
146
+ modal_img['id'] = 'modalImage'
147
+ modal_img['src'] = ''
148
+ modal_img['alt'] = 'Fullscreen Image'
149
+
150
+ close_btn = soup.new_tag('span')
151
+ close_btn['class'] = 'close'
152
+ close_btn.string = '×'
153
+
154
+ modal_div.append(close_btn)
155
+ modal_div.append(modal_img)
156
+
157
+ if soup.body:
158
+ soup.body.append(modal_div)
159
+ else:
160
+ body_tag = soup.new_tag('body')
161
+ body_tag.append(modal_div)
162
+ if soup.html:
163
+ soup.html.append(body_tag)
164
+ else:
165
+ html_tag = soup.new_tag('html')
166
+ html_tag.append(body_tag)
167
+ soup.append(html_tag)
168
+
169
+ # Add JavaScript for modal functionality
170
+ script_tag = soup.new_tag('script')
171
+ script_tag.string = '''
172
+ document.addEventListener('DOMContentLoaded', function() {
173
+ var modal = document.getElementById('imageModal');
174
+ var modalImg = document.getElementById('modalImage');
175
+ var closeBtn = document.getElementsByClassName('close')[0];
176
+
177
+ // Add click event to all images
178
+ document.querySelectorAll('img:not(#modalImage)').forEach(function(img) {
179
+ img.style.cursor = 'pointer';
180
+ img.addEventListener('click', function() {
181
+ modal.style.display = 'flex';
182
+ modalImg.src = this.src;
183
+ document.body.style.overflow = 'hidden';
184
+ setTimeout(function() {
185
+ modal.classList.add('show');
186
+ }, 10);
187
+ });
188
+ });
189
+
190
+ // Close modal on click
191
+ function closeModal() {
192
+ modal.classList.remove('show');
193
+ setTimeout(function() {
194
+ modal.style.display = 'none';
195
+ document.body.style.overflow = 'auto';
196
+ }, 300);
197
+ }
198
+
199
+ closeBtn.onclick = closeModal;
200
+ modal.onclick = function(e) {
201
+ if (e.target === modal) closeModal();
202
+ };
203
+
204
+ // Close on escape key
205
+ document.addEventListener('keydown', function(e) {
206
+ if (e.key === 'Escape') closeModal();
207
+ });
208
+ });
209
+ '''
210
+
211
+ if soup.body:
212
+ soup.body.append(script_tag)
213
+
214
  # Add CSS styles to improve design
215
  style_tag = soup.new_tag('style')
216
  style_tag.string = '''
 
359
  background: linear-gradient(to right, transparent, rgba(44, 62, 80, 0.2), transparent);
360
  margin: 30px 0;
361
  }
362
+ .modal {
363
+ display: none;
364
+ position: fixed;
365
+ top: 0;
366
+ left: 0;
367
+ width: 100%;
368
+ height: 100%;
369
+ background: rgba(0, 0, 0, 0.9);
370
+ z-index: 1000;
371
+ justify-content: center;
372
+ align-items: center;
373
+ opacity: 0;
374
+ transition: opacity 0.3s ease;
375
+ }
376
+
377
+ .modal.show {
378
+ opacity: 1;
379
+ }
380
+
381
+ .modal img {
382
+ max-width: 90%;
383
+ max-height: 90vh;
384
+ margin: auto;
385
+ display: block;
386
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
387
+ transform: scale(0.9);
388
+ transition: transform 0.3s ease;
389
+ }
390
+
391
+ .modal.show img {
392
+ transform: scale(1);
393
+ }
394
+
395
+ .close {
396
+ position: absolute;
397
+ top: 15px;
398
+ right: 25px;
399
+ color: #f1f1f1;
400
+ font-size: 40px;
401
+ font-weight: bold;
402
+ cursor: pointer;
403
+ z-index: 1001;
404
+ transition: color 0.3s ease;
405
+ }
406
+
407
+ .close:hover {
408
+ color: #3498db;
409
+ }
410
+
411
  @media (max-width: 768px) {
412
  body { padding: 15px; }
413
  .breadcrumb {
 
425
  width: 100%;
426
  text-align: center;
427
  }
428
+ .modal img {
429
+ max-width: 95%;
430
+ max-height: 95vh;
431
+ }
432
+ .close {
433
+ top: 10px;
434
+ right: 15px;
435
+ }
436
  }
437
  '''
438
  # Check if head exists, if not create it