From 07014ba5b0cc023cf20aa94c78a25f7e37d7a564 Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Tue, 28 Jul 2026 12:36:55 +0200 Subject: [PATCH] files emojis --- apps/api/app/admin/files.rb | 45 ++++++++++++------- .../app/assets/stylesheets/active_admin.scss | 2 + 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/apps/api/app/admin/files.rb b/apps/api/app/admin/files.rb index d8ab670..2d0c247 100644 --- a/apps/api/app/admin/files.rb +++ b/apps/api/app/admin/files.rb @@ -68,14 +68,34 @@ ActiveAdmin.register_page "Files" do {} end + # File icon helper + file_icon = ->(name) do + ext = File.extname(name).downcase + case ext + when ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".webp", ".svg" then "🖼️" + when ".mp3", ".ogg", ".wav", ".flac", ".aac" then "🔊" + when ".mp4", ".avi", ".mkv", ".webm", ".mov" then "🎬" + when ".zip", ".gz", ".tar", ".rar", ".7z", ".bz2" then "📦" + when ".pdf" then "📕" + when ".doc", ".docx", ".odt", ".txt", ".md", ".rtf" then "📄" + when ".xls", ".xlsx", ".csv", ".ods" then "📊" + when ".html", ".htm", ".css", ".js", ".ts", ".json", ".xml" then "📝" + when ".rb", ".py", ".lua", ".c", ".cpp", ".h", ".rs", ".go" then "💻" + when ".tic", ".rom", ".bin", ".prg", ".crt", ".d64", ".t64" then "🎮" + when ".love" then "🎮" + when ".exe", ".dmg", ".appimage", ".msi" then "⚙️" + when ".wasm" then "⚙️" + else "📄" + end + end + thead do tr do - th "Type", style: "width:60px" th "Name" th "Size", style: "width:100px" th "DL", style: "width:50px" th "Modified", style: "width:160px" - th "Actions", style: "width:#{picker_mode ? '340' : '240'}px" + th "", style: "width:#{picker_mode ? '160' : '120'}px" end end @@ -87,8 +107,8 @@ ActiveAdmin.register_page "Files" do picker_params = picker_mode ? { picker: 1, field: picker_field } : {} tr do - td "DIR" td do + span "📁 ", style: "font-size:15px;" a "..", href: admin_files_path(picker_params.merge(dir: parent)) end td "" @@ -100,14 +120,13 @@ ActiveAdmin.register_page "Files" do entries.each do |entry| tr do - td class: "fm-type" do - entry[:type] == :directory ? "DIR" : "FILE" - end td do picker_params = picker_mode ? { picker: 1, field: picker_field } : {} if entry[:type] == :directory + span "📁 ", style: "font-size:15px;" a entry[:name], href: admin_files_path(picker_params.merge(dir: entry[:path])) else + span "#{file_icon.call(entry[:name])} ", style: "font-size:15px;" span entry[:name] end end @@ -128,28 +147,24 @@ ActiveAdmin.register_page "Files" do # Download (files only) if entry[:type] != :directory - a "Download", href: "/softwares/#{entry[:path]}", class: "fm-action-link", download: entry[:name] - text_node " " + a "⬇️", href: "/softwares/#{entry[:path]}", class: "fm-icon-btn", title: "Download", download: entry[:name] end # Rename - a "Rename", href: "#", class: "fm-action-link", onclick: "var n=prompt('New name:','#{j entry[:name]}');if(n){var f=document.getElementById('rename-#{entry_id}');f.querySelector('[name=new_name]').value=n;f.submit();}return false;" - - text_node " " + a "✏️", href: "#", class: "fm-icon-btn", title: "Rename", + onclick: "var n=prompt('New name:','#{j entry[:name]}');if(n){var f=document.getElementById('rename-#{entry_id}');f.querySelector('[name=new_name]').value=n;f.submit();}return false;" # Delete - a "Delete", href: "#", class: "fm-action-link fm-danger", + a "🗑️", href: "#", class: "fm-icon-btn fm-icon-danger", title: "Delete", onclick: "if(confirm('Delete \\'#{j entry[:name]}\\'?')){document.getElementById('delete-#{entry_id}').submit();}return false;" # Stats (files only) if entry[:type] != :directory - text_node " " - a "Stats", href: admin_downloads_path(q: { file_path_cont: entry[:path] }), class: "fm-action-link" + a "📊", href: admin_downloads_path(q: { file_path_cont: entry[:path] }), class: "fm-icon-btn", title: "Stats" end # Picker mode: Select button if picker_mode - text_node " " abs_path = "/softwares/#{entry[:path]}" a "Select", href: "#", class: "fm-btn fm-btn-select", onclick: "var inp=window.parent.document.getElementById('#{j picker_field}');if(inp){inp.value='#{j abs_path}';}var ov=window.parent.document.querySelector('.fm-modal-overlay');if(ov){ov.remove();window.parent.document.body.style.overflow='';}return false;" diff --git a/apps/api/app/assets/stylesheets/active_admin.scss b/apps/api/app/assets/stylesheets/active_admin.scss index 5578098..e42fda7 100644 --- a/apps/api/app/assets/stylesheets/active_admin.scss +++ b/apps/api/app/assets/stylesheets/active_admin.scss @@ -24,6 +24,8 @@ } .fm-type { font-family: monospace; font-size: 11px; color: #999; } .fm-action-link { font-size: 12px; color: #5a6268; text-decoration: none; margin-right: 8px; &:hover { text-decoration: underline; } } +.fm-icon-btn { font-size: 16px; text-decoration: none; margin-right: 6px; opacity: 0.7; cursor: pointer; &:hover { opacity: 1; } } +.fm-icon-danger:hover { filter: brightness(1.3); } .fm-danger { color: #dc3545; } .fm-entry-actions { white-space: nowrap; } .fm-drop-hint { font-size: 12px; color: #999; margin-left: 8px; }