|
| 1 | +<% if attachment.content_type&.start_with?('image/') %> |
| 2 | + <div class="space-y-2"> |
| 3 | + <div class="flex items-center gap-3 text-sm"> |
| 4 | + <svg class="w-4 h-4 text-gray-400 dark:text-gray-500 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 5 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"></path> |
| 6 | + </svg> |
| 7 | + <%= link_to attachment.filename.to_s, rails_blob_path(attachment, disposition: "attachment"), class: "text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 font-medium" %> |
| 8 | + <span class="text-gray-500 dark:text-gray-400">(<%= number_to_human_size(attachment.byte_size) %>)</span> |
| 9 | + </div> |
| 10 | + <%= image_tag rails_blob_path(attachment), class: "max-w-full h-auto rounded border border-gray-300 dark:border-gray-600", alt: attachment.filename.to_s %> |
| 11 | + </div> |
| 12 | +<% elsif attachment.content_type&.start_with?('text/') %> |
| 13 | + <div class="space-y-2"> |
| 14 | + <div class="flex items-center gap-3 text-sm"> |
| 15 | + <svg class="w-4 h-4 text-gray-400 dark:text-gray-500 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 16 | + <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> |
| 17 | + </svg> |
| 18 | + <%= link_to attachment.filename.to_s, rails_blob_path(attachment, disposition: "attachment"), class: "text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 font-medium" %> |
| 19 | + <span class="text-gray-500 dark:text-gray-400">(<%= number_to_human_size(attachment.byte_size) %>, <%= attachment.content_type %>)</span> |
| 20 | + </div> |
| 21 | + <% if attachment.byte_size < 100_000 %> |
| 22 | + <pre class="whitespace-pre-wrap font-mono text-sm text-gray-800 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 p-4 rounded border border-gray-300 dark:border-gray-600 overflow-x-auto"><%= attachment.download %></pre> |
| 23 | + <% end %> |
| 24 | + </div> |
| 25 | +<% elsif attachment.content_type == 'application/pdf' %> |
| 26 | + <div class="flex items-center gap-3 text-sm"> |
| 27 | + <svg class="w-4 h-4 text-red-500 dark:text-red-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 28 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path> |
| 29 | + </svg> |
| 30 | + <%= link_to attachment.filename.to_s, rails_blob_path(attachment, disposition: "attachment"), class: "text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 font-medium" %> |
| 31 | + <span class="text-gray-500 dark:text-gray-400">(<%= number_to_human_size(attachment.byte_size) %>, PDF)</span> |
| 32 | + </div> |
| 33 | +<% elsif attachment.content_type&.match?(/zip|tar|gzip|compress|bzip|lha/) %> |
| 34 | + <div class="flex items-center gap-3 text-sm"> |
| 35 | + <svg class="w-4 h-4 text-gray-400 dark:text-gray-500 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 36 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 19a2 2 0 01-2-2V7a2 2 0 012-2h4l2 2h4a2 2 0 012 2v1M5 19h14a2 2 0 002-2v-5a2 2 0 00-2-2H9a2 2 0 00-2 2v5a2 2 0 01-2 2z"></path> |
| 37 | + </svg> |
| 38 | + <%= link_to attachment.filename.to_s, rails_blob_path(attachment, disposition: "attachment"), class: "text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 font-medium" %> |
| 39 | + <span class="text-gray-500 dark:text-gray-400">(<%= number_to_human_size(attachment.byte_size) %>, Archive)</span> |
| 40 | + </div> |
| 41 | +<% else %> |
| 42 | + <div class="flex items-center gap-3 text-sm"> |
| 43 | + <svg class="w-4 h-4 text-gray-400 dark:text-gray-500 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 44 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"></path> |
| 45 | + </svg> |
| 46 | + <%= link_to attachment.filename.to_s, rails_blob_path(attachment, disposition: "attachment"), class: "text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 font-medium" %> |
| 47 | + <span class="text-gray-500 dark:text-gray-400">(<%= number_to_human_size(attachment.byte_size) %><% if attachment.content_type %>, <%= attachment.content_type %><% end %>)</span> |
| 48 | + </div> |
| 49 | +<% end %> |
0 commit comments