download.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Download - {{ filename }} - HokoriTemp</title>
  7. <!-- SVG Favicon -->
  8. <link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
  9. <link rel="stylesheet" href="/static/css/styles.css">
  10. <script src="https://cdn.tailwindcss.com"></script>
  11. <script>
  12. (function() {
  13. const savedTheme = localStorage.getItem('theme') || 'light';
  14. if (savedTheme === 'dark') {
  15. document.documentElement.classList.add('dark');
  16. }
  17. })();
  18. tailwind.config = {
  19. darkMode: 'class',
  20. theme: {
  21. extend: {
  22. animation: {
  23. 'fade-in': 'fadeIn 0.3s ease-in-out',
  24. 'slide-up': 'slideUp 0.3s ease-out',
  25. 'pulse-slow': 'pulse 2s infinite'
  26. }
  27. }
  28. }
  29. }
  30. </script>
  31. </head>
  32. <body class="bg-gray-50 dark:bg-gray-900 min-h-screen transition-colors duration-300">
  33. <div class="container mx-auto px-4 py-8 max-w-4xl">
  34. <!-- Header -->
  35. <div class="flex justify-between items-center mb-8">
  36. <div class="text-center flex-1">
  37. <h1 class="text-3xl font-bold text-gray-900 dark:text-white mb-2">HokoriTemp</h1>
  38. <p class="text-gray-600 dark:text-gray-400">File Download</p>
  39. </div>
  40. <!-- Theme Toggle Button -->
  41. <button id="themeToggle" class="p-2 rounded-lg bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors ml-4">
  42. <!-- Sun Icon (Light Mode) -->
  43. <svg id="sunIcon" class="w-5 h-5 text-gray-800 dark:text-gray-200 hidden dark:block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  44. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"></path>
  45. </svg>
  46. <!-- Moon Icon (Dark Mode) -->
  47. <svg id="moonIcon" class="w-5 h-5 text-gray-800 dark:text-gray-200 block dark:hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  48. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"></path>
  49. </svg>
  50. </button>
  51. </div>
  52. <!-- File Info Section -->
  53. <div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 mb-6 transition-colors duration-300">
  54. <div class="flex items-center space-x-4 mb-4">
  55. <div class="flex-shrink-0">
  56. <svg class="w-12 h-12 text-blue-600 dark:text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  57. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
  58. </svg>
  59. </div>
  60. <div class="flex-1">
  61. <h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-1">{{ filename }}</h2>
  62. <div class="flex flex-wrap gap-4 text-sm text-gray-600 dark:text-gray-400">
  63. <span>Size: {{ "%.2f"|format(file_size / 1024 / 1024) }} MB</span>
  64. {% if mime_type %}
  65. <span>Type: {{ mime_type }}</span>
  66. {% endif %}
  67. <span>Expires: {{ expiration_date[:19].replace('T', ' ') }}</span>
  68. </div>
  69. </div>
  70. </div>
  71. <!-- Download Button -->
  72. <div class="flex gap-3">
  73. <a href="/download/{{ file_id }}/direct"
  74. class="inline-flex items-center px-6 py-3 bg-blue-600 hover:bg-blue-700 dark:bg-blue-700 dark:hover:bg-blue-600 text-white font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800">
  75. <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  76. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
  77. </svg>
  78. Download File
  79. </a>
  80. <a href="/"
  81. class="inline-flex items-center px-6 py-3 bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800">
  82. <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  83. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2H5a2 2 0 00-2-2z"></path>
  84. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5a2 2 0 012-2h2a2 2 0 012 2v0H8v0z"></path>
  85. </svg>
  86. Upload More Files
  87. </a>
  88. </div>
  89. </div>
  90. <!-- Text File Preview -->
  91. {% if is_text_file and file_content %}
  92. <div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 transition-colors duration-300">
  93. <div class="flex items-center justify-between mb-4">
  94. <h3 class="text-lg font-semibold text-gray-900 dark:text-white">File Preview</h3>
  95. <span class="text-sm text-gray-500 dark:text-gray-400">Text file preview</span>
  96. </div>
  97. <div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-4 overflow-auto max-h-96">
  98. <pre class="text-sm text-gray-800 dark:text-gray-200 whitespace-pre-wrap font-mono">{{ file_content }}</pre>
  99. </div>
  100. <div class="mt-4 text-xs text-gray-500 dark:text-gray-400">
  101. <p>Preview shows the first part of the file content. Download the file to view the complete content.</p>
  102. </div>
  103. </div>
  104. {% elif is_text_file %}
  105. <div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 transition-colors duration-300">
  106. <div class="text-center py-8">
  107. <svg class="w-12 h-12 mx-auto mb-4 text-yellow-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  108. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"></path>
  109. </svg>
  110. <h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">Preview Not Available</h3>
  111. <p class="text-gray-600 dark:text-gray-400">This text file couldn't be previewed. Please download it to view the content.</p>
  112. </div>
  113. </div>
  114. <!-- Archive File Preview -->
  115. {% elif is_archive_file and archive_contents %}
  116. <div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 transition-colors duration-300">
  117. <div class="flex items-center justify-between mb-4">
  118. <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Archive Contents</h3>
  119. <span class="text-sm text-gray-500 dark:text-gray-400">{{ archive_contents.type|upper }} archive preview</span>
  120. </div>
  121. <div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-96 overflow-auto">
  122. <div class="space-y-2">
  123. {% for file in archive_contents.files %}
  124. <div class="flex items-center justify-between py-2 px-3 bg-white dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700">
  125. <div class="flex items-center space-x-3">
  126. {% if file.type == 'directory' %}
  127. <svg class="w-4 h-4 text-blue-500" fill="currentColor" viewBox="0 0 20 20">
  128. <path d="M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"></path>
  129. </svg>
  130. {% else %}
  131. <svg class="w-4 h-4 text-gray-500" fill="currentColor" viewBox="0 0 20 20">
  132. <path fill-rule="evenodd" d="M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z" clip-rule="evenodd"></path>
  133. </svg>
  134. {% endif %}
  135. <span class="text-sm font-medium text-gray-900 dark:text-white truncate">{{ file.name }}</span>
  136. </div>
  137. <div class="flex items-center space-x-4 text-xs text-gray-500 dark:text-gray-400">
  138. {% if file.type != 'directory' %}
  139. <span>{{ "%.1f"|format(file.size / 1024) }} KB</span>
  140. {% if file.compressed_size %}
  141. <span class="text-green-600 dark:text-green-400">{{ "%.1f%%"|format((1 - file.compressed_size / file.size) * 100) }} compressed</span>
  142. {% endif %}
  143. {% endif %}
  144. {% if file.date_time %}
  145. <span>{{ "%04d-%02d-%02d"|format(file.date_time[0], file.date_time[1], file.date_time[2]) }}</span>
  146. {% endif %}
  147. </div>
  148. </div>
  149. {% endfor %}
  150. </div>
  151. </div>
  152. <div class="mt-4 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400">
  153. <p>Archive contains {{ archive_contents.files|length }} items. Download to extract files.</p>
  154. <div class="flex space-x-4">
  155. {% set total_files = archive_contents.files|selectattr('type', 'equalto', 'file')|list|length %}
  156. {% set total_dirs = archive_contents.files|selectattr('type', 'equalto', 'directory')|list|length %}
  157. <span>{{ total_files }} files</span>
  158. {% if total_dirs > 0 %}
  159. <span>{{ total_dirs }} folders</span>
  160. {% endif %}
  161. </div>
  162. </div>
  163. </div>
  164. {% elif is_archive_file %}
  165. <div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 transition-colors duration-300">
  166. <div class="text-center py-8">
  167. <svg class="w-12 h-12 mx-auto mb-4 text-yellow-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  168. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"></path>
  169. </svg>
  170. <h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">Archive Preview Not Available</h3>
  171. <p class="text-gray-600 dark:text-gray-400">This archive file couldn't be previewed. Please download it to view the contents.</p>
  172. </div>
  173. </div>
  174. {% else %}
  175. <div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 transition-colors duration-300">
  176. <div class="text-center py-8">
  177. <svg class="w-12 h-12 mx-auto mb-4 text-gray-400 dark:text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  178. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
  179. </svg>
  180. <h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">Binary File</h3>
  181. <p class="text-gray-600 dark:text-gray-400">This file cannot be previewed. Click the download button above to get the file.</p>
  182. </div>
  183. </div>
  184. {% endif %}
  185. </div>
  186. <!-- Toast Notification -->
  187. <div id="toast" class="fixed top-4 right-4 bg-green-500 text-white px-6 py-3 rounded-lg shadow-lg transform translate-x-full transition-transform duration-300 z-50">
  188. <p id="toastMessage"></p>
  189. </div>
  190. <script>
  191. // Theme management
  192. function initTheme() {
  193. const savedTheme = localStorage.getItem('theme') || 'light';
  194. if (savedTheme === 'dark') {
  195. document.documentElement.classList.add('dark');
  196. } else {
  197. document.documentElement.classList.remove('dark');
  198. }
  199. }
  200. function toggleTheme() {
  201. const isDark = document.documentElement.classList.contains('dark');
  202. if (isDark) {
  203. document.documentElement.classList.remove('dark');
  204. localStorage.setItem('theme', 'light');
  205. } else {
  206. document.documentElement.classList.add('dark');
  207. localStorage.setItem('theme', 'dark');
  208. }
  209. }
  210. // Toast notification
  211. function showToast(message, type = 'success') {
  212. const toast = document.getElementById('toast');
  213. const toastMessage = document.getElementById('toastMessage');
  214. toastMessage.textContent = message;
  215. toast.classList.remove('bg-green-500', 'bg-red-500', 'bg-blue-500');
  216. if (type === 'success') {
  217. toast.classList.add('bg-green-500');
  218. } else if (type === 'error') {
  219. toast.classList.add('bg-red-500');
  220. } else if (type === 'info') {
  221. toast.classList.add('bg-blue-500');
  222. }
  223. toast.classList.remove('translate-x-full');
  224. setTimeout(() => {
  225. toast.classList.add('translate-x-full');
  226. }, 3000);
  227. }
  228. // Initialize
  229. document.addEventListener('DOMContentLoaded', function() {
  230. initTheme();
  231. document.getElementById('themeToggle').addEventListener('click', toggleTheme);
  232. });
  233. </script>
  234. </body>
  235. </html>