mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 14:51:03 +00:00
fix!: eliminate the x- prefix in mime-types (#1927)
This commit is contained in:
parent
202751b46a
commit
22e7d579d2
10 changed files with 29 additions and 31 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
# Contributor Covenant Code of Conduct
|
# Code of Conduct
|
||||||
|
|
||||||
## Goal
|
## Goal
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ Our standards are as follows:
|
||||||
Examples of unacceptable behavior include:
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
- Trolling, insulting or derogatory comments, and personal attacks
|
- Trolling, insulting or derogatory comments, and personal attacks
|
||||||
- Harasing or bullying another person
|
- Harassing or bullying another person
|
||||||
- Publishing others' private information without their explicit permission
|
- Publishing others' private information without their explicit permission
|
||||||
- Posting things unrelated to the topic being discussed
|
- Posting things unrelated to the topic being discussed
|
||||||
- Other conduct that could reasonably be considered inappropriate in a professional setting
|
- Other conduct that could reasonably be considered inappropriate in a professional setting
|
||||||
|
|
@ -191,13 +191,13 @@ rules = [
|
||||||
|
|
||||||
# Archives
|
# Archives
|
||||||
{ mime = "application/{,g}zip", fg = "red" },
|
{ mime = "application/{,g}zip", fg = "red" },
|
||||||
{ mime = "application/x-{tar,bzip*,7z-compressed,xz,rar}", fg = "red" },
|
{ mime = "application/{tar,bzip*,7z-compressed,xz,rar}", fg = "red" },
|
||||||
|
|
||||||
# Documents
|
# Documents
|
||||||
{ mime = "application/{pdf,doc,rtf,vnd.*}", fg = "cyan" },
|
{ mime = "application/{pdf,doc,rtf,vnd.*}", fg = "cyan" },
|
||||||
|
|
||||||
# Empty files
|
# Empty files
|
||||||
# { mime = "inode/x-empty", fg = "red" },
|
# { mime = "inode/empty", fg = "red" },
|
||||||
|
|
||||||
# Special files
|
# Special files
|
||||||
{ name = "*", is = "orphan", bg = "red" },
|
{ name = "*", is = "orphan", bg = "red" },
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,12 @@ rules = [
|
||||||
{ mime = "{audio,video}/*", use = [ "play", "reveal" ] },
|
{ mime = "{audio,video}/*", use = [ "play", "reveal" ] },
|
||||||
# Archive
|
# Archive
|
||||||
{ mime = "application/{,g}zip", use = [ "extract", "reveal" ] },
|
{ mime = "application/{,g}zip", use = [ "extract", "reveal" ] },
|
||||||
{ mime = "application/x-{tar,bzip*,7z-compressed,xz,rar}", use = [ "extract", "reveal" ] },
|
{ mime = "application/{tar,bzip*,7z-compressed,xz,rar}", use = [ "extract", "reveal" ] },
|
||||||
# JSON
|
# JSON
|
||||||
{ mime = "application/{json,x-ndjson}", use = [ "edit", "reveal" ] },
|
{ mime = "application/{json,ndjson}", use = [ "edit", "reveal" ] },
|
||||||
{ mime = "*/javascript", use = [ "edit", "reveal" ] },
|
{ mime = "*/javascript", use = [ "edit", "reveal" ] },
|
||||||
# Empty file
|
# Empty file
|
||||||
{ mime = "inode/x-empty", use = [ "edit", "reveal" ] },
|
{ mime = "inode/empty", use = [ "edit", "reveal" ] },
|
||||||
# Fallback
|
# Fallback
|
||||||
{ name = "*", use = [ "open", "reveal" ] },
|
{ name = "*", use = [ "open", "reveal" ] },
|
||||||
]
|
]
|
||||||
|
|
@ -96,7 +96,7 @@ spotters = [
|
||||||
{ name = "*/", run = "folder" },
|
{ name = "*/", run = "folder" },
|
||||||
# Code
|
# Code
|
||||||
{ mime = "text/*", run = "code" },
|
{ mime = "text/*", run = "code" },
|
||||||
{ mime = "*/{xml,javascript,x-wine-extension-ini}", run = "code" },
|
{ mime = "*/{xml,javascript,wine-extension-ini}", run = "code" },
|
||||||
# Image
|
# Image
|
||||||
{ mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
|
{ mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
|
||||||
{ mime = "image/*", run = "image" },
|
{ mime = "image/*", run = "image" },
|
||||||
|
|
@ -121,9 +121,9 @@ previewers = [
|
||||||
{ name = "*/", run = "folder", sync = true },
|
{ name = "*/", run = "folder", sync = true },
|
||||||
# Code
|
# Code
|
||||||
{ mime = "text/*", run = "code" },
|
{ mime = "text/*", run = "code" },
|
||||||
{ mime = "*/{xml,javascript,x-wine-extension-ini}", run = "code" },
|
{ mime = "*/{xml,javascript,wine-extension-ini}", run = "code" },
|
||||||
# JSON
|
# JSON
|
||||||
{ mime = "application/{json,x-ndjson}", run = "json" },
|
{ mime = "application/{json,ndjson}", run = "json" },
|
||||||
# Image
|
# Image
|
||||||
{ mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
|
{ mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
|
||||||
{ mime = "image/*", run = "image" },
|
{ mime = "image/*", run = "image" },
|
||||||
|
|
@ -133,12 +133,12 @@ previewers = [
|
||||||
{ mime = "application/pdf", run = "pdf" },
|
{ mime = "application/pdf", run = "pdf" },
|
||||||
# Archive
|
# Archive
|
||||||
{ mime = "application/{,g}zip", run = "archive" },
|
{ mime = "application/{,g}zip", run = "archive" },
|
||||||
{ mime = "application/x-{tar,bzip*,7z-compressed,xz,rar,iso9660-image}", run = "archive" },
|
{ mime = "application/{tar,bzip*,7z-compressed,xz,rar,iso9660-image}", run = "archive" },
|
||||||
# Font
|
# Font
|
||||||
{ mime = "font/*", run = "font" },
|
{ mime = "font/*", run = "font" },
|
||||||
{ mime = "application/vnd.ms-opentype", run = "font" },
|
{ mime = "application/vnd.ms-opentype", run = "font" },
|
||||||
# Empty file
|
# Empty file
|
||||||
{ mime = "inode/x-empty", run = "empty" },
|
{ mime = "inode/empty", run = "empty" },
|
||||||
# Fallback
|
# Fallback
|
||||||
{ name = "*", run = "file" },
|
{ name = "*", run = "file" },
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,6 @@ function M:seek(units)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:spot(args) require("file"):spot(args) end
|
function M:spot(job) require("file"):spot(job) end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,13 @@ local hovered_mime = ya.sync(function()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function M:spot(args)
|
function M:spot(job)
|
||||||
local mime = hovered_mime()
|
local mime = hovered_mime()
|
||||||
if not mime then
|
if not mime then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local file = args.file
|
local file = job.file
|
||||||
local spotter = PLUGIN.spotter(file.url, mime)
|
local spotter = PLUGIN.spotter(file.url, mime)
|
||||||
local previewer = PLUGIN.previewer(file.url, mime)
|
local previewer = PLUGIN.previewer(file.url, mime)
|
||||||
local fetchers = PLUGIN.fetchers(file.url, mime)
|
local fetchers = PLUGIN.fetchers(file.url, mime)
|
||||||
|
|
@ -64,7 +64,7 @@ function M:spot(args)
|
||||||
row(" Preloaders:", #preloaders ~= 0 and preloaders or "-")
|
row(" Preloaders:", #preloaders ~= 0 and preloaders or "-")
|
||||||
|
|
||||||
ya.spot_table(
|
ya.spot_table(
|
||||||
args,
|
job,
|
||||||
ui.Table(rows)
|
ui.Table(rows)
|
||||||
:area(ui.Pos { "center", w = 60, h = 20 })
|
:area(ui.Pos { "center", w = 60, h = 20 })
|
||||||
:row(1)
|
:row(1)
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,6 @@ function M:seek(units)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:spot(args) require("file"):spot(args) end
|
function M:spot(job) require("file"):spot(job) end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ function M:preload()
|
||||||
return ya.image_precache(self.file.url, cache) and 1 or 2
|
return ya.image_precache(self.file.url, cache) and 1 or 2
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:spot(args)
|
function M:spot(job)
|
||||||
local info = ya.image_info(args.file.url)
|
local info = ya.image_info(job.file.url)
|
||||||
|
|
||||||
local rows = {}
|
local rows = {}
|
||||||
local row = function(key, value)
|
local row = function(key, value)
|
||||||
|
|
@ -37,10 +37,10 @@ function M:spot(args)
|
||||||
row("Color:", tostring(info.color))
|
row("Color:", tostring(info.color))
|
||||||
|
|
||||||
ya.spot_table(
|
ya.spot_table(
|
||||||
args,
|
job,
|
||||||
ui.Table(rows)
|
ui.Table(rows)
|
||||||
:area(ui.Pos { "center", w = 60, h = 20 })
|
:area(ui.Pos { "center", w = 60, h = 20 })
|
||||||
:row(args.skip)
|
:row(job.skip)
|
||||||
:col(1)
|
:col(1)
|
||||||
:col_style(ui.Style():fg("blue"))
|
:col_style(ui.Style():fg("blue"))
|
||||||
:cell_style(ui.Style():fg("yellow"):reverse())
|
:cell_style(ui.Style():fg("yellow"):reverse())
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,6 @@ function M:preload()
|
||||||
return status and status.success and 1 or 2
|
return status and status.success and 1 or 2
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:spot(args) require("file"):spot(args) end
|
function M:spot(job) require("file"):spot(job) end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,15 @@ local SUPPORTED_TYPES = "application/audio/biosig/chemical/font/image/inode/mess
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function match_mimetype(s)
|
local function match_mimetype(s)
|
||||||
local type, sub = s:match("([-a-z]+/)([+-.a-zA-Z0-9]+)%s*$")
|
local type, sub = s:match("^([-a-z]+/)([+-.a-zA-Z0-9]+)%s*$")
|
||||||
if type and sub and SUPPORTED_TYPES:find(type, 1, true) then
|
if type and sub and SUPPORTED_TYPES:find(type, 1, true) then
|
||||||
return type .. sub
|
return type:gsub("^x%-", "", 1) .. sub:gsub("^x%-", "", 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:fetch(args)
|
function M:fetch(job)
|
||||||
local urls = {}
|
local urls = {}
|
||||||
for _, file in ipairs(args.files) do
|
for _, file in ipairs(job.files) do
|
||||||
urls[#urls + 1] = tostring(file.url)
|
urls[#urls + 1] = tostring(file.url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -44,9 +44,7 @@ function M:fetch(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
valid = match_mimetype(line)
|
valid = match_mimetype(line)
|
||||||
if valid and line:find(valid, 1, true) ~= 1 then
|
if valid then
|
||||||
goto continue
|
|
||||||
elseif valid then
|
|
||||||
j, updates[urls[i]] = j + 1, valid
|
j, updates[urls[i]] = j + 1, valid
|
||||||
flush(false)
|
flush(false)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,6 @@ function M:preload()
|
||||||
return status and status.success and 1 or 2
|
return status and status.success and 1 or 2
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:spot(args) require("file"):spot(args) end
|
function M:spot(job) require("file"):spot(job) end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue