Starchik1 commited on
Commit
e7fbfe0
·
verified ·
1 Parent(s): e2611e7

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +40 -1
main.py CHANGED
@@ -135,13 +135,52 @@ def proxy(path):
135
  img['src'] = proxy_url
136
  img['style'] = 'max-width: 100%; height: auto; border: 1px solid #ddd; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin: 10px 0;'
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  # Add "Open Original Image" button next to each image
139
  button = soup.new_tag('a')
140
  button['href'] = proxy_url
141
  button['target'] = '_blank'
142
  button['class'] = 'open-image-btn'
143
  button.string = 'Открыть оригинал изображения'
144
- button['style'] = 'display: inline-flex; align-items: center; justify-content: center; min-height: 48px; margin: 10px; padding: 12px 24px; background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%); background-size: 200% 200%; border: none; border-radius: 8px; text-decoration: none; color: white; font-weight: 500; transition: all 0.3s ease; box-shadow: 0 4px 6px rgba(0,0,0,0.1); text-align: center; line-height: 1.4; width: fit-content; white-space: normal; word-wrap: break-word; max-width: 100%; hyphens: auto; cursor: pointer; overflow-wrap: break-word; animation: gradient 3s ease infinite; @media (max-width: 768px) { padding: 10px 16px; min-height: 40px; font-size: 14px; } @media (max-width: 480px) { padding: 8px 12px; min-height: 36px; font-size: 13px; }'
145
  img.insert_after(button)
146
 
147
  # Add modal container for fullscreen image view
 
135
  img['src'] = proxy_url
136
  img['style'] = 'max-width: 100%; height: auto; border: 1px solid #ddd; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin: 10px 0;'
137
 
138
+ # Add responsive styles
139
+ style_tag = soup.new_tag('style')
140
+ style_tag.string = '''
141
+ /* Base styles */
142
+ body { margin: 0; padding: 15px; font-family: Arial, sans-serif; }
143
+ table { width: 100%; border-collapse: collapse; margin: 15px 0; }
144
+ td, th { padding: 8px; border: 1px solid #ddd; }
145
+ img { max-width: 100%; height: auto; }
146
+ .open-image-btn { 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); }
147
+
148
+ /* Responsive styles */
149
+ @media (max-width: 768px) {
150
+ body { padding: 10px; }
151
+ table { font-size: 14px; }
152
+ td, th { padding: 6px; }
153
+ .open-image-btn { display: block; margin: 10px 0; text-align: center; }
154
+ }
155
+
156
+ @media (max-width: 480px) {
157
+ table { font-size: 12px; }
158
+ td, th { padding: 4px; }
159
+ img { margin: 5px 0; }
160
+ .zoom-controls { display: flex; justify-content: space-between; width: 100%; margin-bottom: 10px; }
161
+ .zoom-btn { flex: 1; margin: 0 2px; }
162
+ }
163
+ '''
164
+
165
+ if soup.head:
166
+ soup.head.append(style_tag)
167
+ else:
168
+ head_tag = soup.new_tag('head')
169
+ head_tag.append(style_tag)
170
+ if soup.html:
171
+ soup.html.insert(0, head_tag)
172
+ else:
173
+ html_tag = soup.new_tag('html')
174
+ html_tag.append(head_tag)
175
+ soup.append(html_tag)
176
+
177
  # Add "Open Original Image" button next to each image
178
  button = soup.new_tag('a')
179
  button['href'] = proxy_url
180
  button['target'] = '_blank'
181
  button['class'] = 'open-image-btn'
182
  button.string = 'Открыть оригинал изображения'
183
+ 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);'
184
  img.insert_after(button)
185
 
186
  # Add modal container for fullscreen image view