Eluza133 commited on
Commit
09e98b7
·
verified ·
1 Parent(s): fbabad4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -63,11 +63,11 @@ input, select { width: 100%; padding: 14px; margin: 8px 0; border: 1px solid #33
63
  .flash { text-align: center; margin-bottom: 15px; padding: 12px; border-radius: 10px; background: rgba(0, 221, 235, 0.1); color: var(--secondary); }
64
  .flash.error { background: rgba(255, 68, 68, 0.1); color: var(--delete-color); }
65
  .file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; }
66
- .item { background: var(--card-bg-dark); border-radius: 16px; text-align: center; transition: var(--transition); position: relative; border: 2px solid transparent; user-select: none; padding: 10px; display: flex; flex-direction: column; }
67
  .item:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
68
  .item:active { transform: scale(0.97); }
69
  .item.selected { border-color: var(--accent); background-color: var(--selection-color); }
70
- .item-preview-wrapper { position: relative; width: 100%; padding-top: 75%; border-radius: 10px; overflow: hidden; margin-bottom: 10px; cursor: pointer; background: #2a2a2a; }
71
  .item-preview { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
72
  .item.folder .item-preview { object-fit: contain; font-size: 3.5em; color: var(--folder-color); }
73
  .item-name { font-size: 0.9em; font-weight: 500; word-break: break-all; margin: 5px 0; flex-grow: 1; }
@@ -343,8 +343,8 @@ TMA_DASHBOARD_HTML_TEMPLATE = '''
343
  <div id="progress-container"><div id="progress-bar"></div></div>
344
  <div class="file-grid" id="file-container">
345
  {% for item in items %}
346
- <div class="item {{ item.type }}" data-id="{{ item.id }}" data-type="{{ item.type }}">
347
- <div class="item-preview-wrapper" {% if item.type != 'folder' %}onclick="openModal('{{ hf_file_url_jinja(item.path) if item.file_type not in ['text', 'pdf'] else (url_for('get_text_content_tma', file_id=item.id) if item.file_type == 'text' else hf_file_url_jinja(item.path, True)) }}', '{{ item.file_type }}', '{{ item.id }}')"{% else %}onclick="window.Telegram.WebApp.HapticFeedback.impactOccurred('light'); window.location.href='{{ url_for('tma_dashboard', folder_id=item.id) }}'"{% endif %}>
348
  {% if item.type == 'folder' %}
349
  <div class="item-preview"><i class="fa-solid fa-folder"></i></div>
350
  {% elif item.type == 'file' %}
@@ -738,8 +738,9 @@ def download_tma(file_id):
738
  r.raise_for_status()
739
 
740
  resp = Response(r.iter_content(chunk_size=8192), mimetype='application/octet-stream')
 
741
  encoded_filename = quote(original_filename)
742
- resp.headers['Content-Disposition'] = f"attachment; filename=\"{encoded_filename}\"; filename*=UTF-8''{encoded_filename}"
743
  return resp
744
  except Exception as e:
745
  logging.error(f"Error downloading {file_id} from HF: {e}")
 
63
  .flash { text-align: center; margin-bottom: 15px; padding: 12px; border-radius: 10px; background: rgba(0, 221, 235, 0.1); color: var(--secondary); }
64
  .flash.error { background: rgba(255, 68, 68, 0.1); color: var(--delete-color); }
65
  .file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; }
66
+ .item { background: var(--card-bg-dark); border-radius: 16px; text-align: center; transition: var(--transition); position: relative; border: 2px solid transparent; user-select: none; padding: 10px; display: flex; flex-direction: column; cursor: pointer; }
67
  .item:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
68
  .item:active { transform: scale(0.97); }
69
  .item.selected { border-color: var(--accent); background-color: var(--selection-color); }
70
+ .item-preview-wrapper { position: relative; width: 100%; padding-top: 75%; border-radius: 10px; overflow: hidden; margin-bottom: 10px; background: #2a2a2a; }
71
  .item-preview { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
72
  .item.folder .item-preview { object-fit: contain; font-size: 3.5em; color: var(--folder-color); }
73
  .item-name { font-size: 0.9em; font-weight: 500; word-break: break-all; margin: 5px 0; flex-grow: 1; }
 
343
  <div id="progress-container"><div id="progress-bar"></div></div>
344
  <div class="file-grid" id="file-container">
345
  {% for item in items %}
346
+ <div class="item {{ item.type }}" data-id="{{ item.id }}" data-type="{{ item.type }}" {% if item.type != 'folder' %}onclick="openModal('{{ hf_file_url_jinja(item.path) if item.file_type not in ['text', 'pdf'] else (url_for('get_text_content_tma', file_id=item.id) if item.file_type == 'text' else hf_file_url_jinja(item.path, True)) }}', '{{ item.file_type }}', '{{ item.id }}')"{% else %}onclick="window.Telegram.WebApp.HapticFeedback.impactOccurred('light'); window.location.href='{{ url_for('tma_dashboard', folder_id=item.id) }}'"{% endif %}>
347
+ <div class="item-preview-wrapper">
348
  {% if item.type == 'folder' %}
349
  <div class="item-preview"><i class="fa-solid fa-folder"></i></div>
350
  {% elif item.type == 'file' %}
 
738
  r.raise_for_status()
739
 
740
  resp = Response(r.iter_content(chunk_size=8192), mimetype='application/octet-stream')
741
+ sanitized_filename = original_filename.replace('"', '_')
742
  encoded_filename = quote(original_filename)
743
+ resp.headers['Content-Disposition'] = f"attachment; filename=\"{sanitized_filename}\"; filename*=UTF-8''{encoded_filename}"
744
  return resp
745
  except Exception as e:
746
  logging.error(f"Error downloading {file_id} from HF: {e}")