improve icon/ext support

toast
Kit Kasune 3 years ago
parent 330b3d951f
commit 701cf9dc95
  1. 32
      json/extensions.json
  2. 6
      json/icons.json
  3. 6
      scripts/fileview/fileicon.js
  4. 2
      scripts/fileview/load/load.js

@ -1,7 +1,33 @@
{ {
"zip": "Compressed Folder", "zip": "Compressed Folder",
"js": "JavaScript File", "js": "JavaScript File",
"lnk": "Shortcut", "lnk": "Shortcut (.lnk)",
"url": "Shortcut", "url": "Shortcut (.url)",
"ini": ".ini Config File" "ini": ".ini Config File",
"html": "HTML Web Document",
"css": "CSS Stylesheet",
"json": "JS Obj. Notation File",
"gitignore": "SCM Config File",
"bat": "Win. CMD Executable",
"md": "Markdown File",
"jshintrc": "JS Linter Config File",
"py": "Python Source File",
"txt": "Text File",
"docx": "Word Document",
"mp4": ".mp4 Video File",
"mp3": ".mp3 Audio File",
"ogg": "OGG Audio File",
"wav": ".wav Audio File",
"mov": ".mov Video File",
"png": "Portable Network Graphic",
"jpg": "JPG Image",
"gif": "Animated Image (.gif)",
"svg": ".svg Image",
"jar": "Java Executable",
"msi": "Windows Installer",
"exe": "Windows Application",
"pdf": "Portable Document File",
"der": "Certificate",
"7z": "Compressed Folder (7zip)",
"7zip": "Compressed Folder (7zip)"
} }

@ -17,7 +17,11 @@
"js": "javascript", "js": "javascript",
"xlsx": "excel", "xlsx": "excel",
"xls": "excel", "xls": "excel",
"gitignore": "git" "gitignore": "git",
"7z": "zip",
"jar": "java",
"der": "certificate",
"py": "python"
}, },
"folder": { "folder": {

@ -17,9 +17,9 @@ module.exports = (fpath, name) => {
} }
}*/ }*/
else { else {
//console.log(path.extname(name)); let ext = name.startsWith('.') ? name : path.extname(name);
if (name.includes('.') && fs.existsSync(`./assets/icons/extension/${(path.extname(name).toLowerCase()).slice(1)}.svg`)) {icon = `./assets/icons/extension/${(path.extname(name).toLowerCase()).slice(1)}.svg`;} if (name.includes('.') && fs.existsSync(`./assets/icons/extension/${(ext.toLowerCase()).slice(1)}.svg`)) {icon = `./assets/icons/extension/${(ext.toLowerCase()).slice(1)}.svg`;}
else if (name.includes('.') && Object.keys(icons.file).includes((path.extname(name).toLowerCase()).slice(1))) {icon = `./assets/icons/extension/${icons.file[(path.extname(name).toLowerCase()).slice(1)]}.svg`;} else if (name.includes('.') && Object.keys(icons.file).includes((ext.toLowerCase()).slice(1))) {icon = `./assets/icons/extension/${icons.file[(ext.toLowerCase()).slice(1)]}.svg`;}
else {icon = './assets/icons/base/file.svg';} else {icon = './assets/icons/base/file.svg';}
} }
} catch {icon = './assets/icons/base/file.svg';} } catch {icon = './assets/icons/base/file.svg';}

@ -17,7 +17,7 @@ module.exports = (check=false) => {
let ofile = {}; let ofile = {};
ofile.icon = fileIcon(`${dir}/${file}`, file); ofile.icon = fileIcon(`${dir}/${file}`, file);
ofile.name = trimext.includes(path.extname(file)) ? file.slice(0, file.length - path.extname(file).length) : file; ofile.name = trimext.includes(path.extname(file)) ? file.slice(0, file.length - path.extname(file).length) : file;
try {ofile.type = fs.lstatSync(`${dir}/${file}`).isDirectory() ? "File Folder" : (extensions[path.extname(file).slice(1)] || "File");} try {ofile.type = fs.lstatSync(`${dir}/${file}`).isDirectory() ? "File Folder" : (extensions[(file.startsWith('.') ? file : path.extname(file)).slice(1)] || "File");}
catch {ofile.type = `${path.extname(file)} File`.trim();} catch {ofile.type = `${path.extname(file)} File`.trim();}
try {ofile.lastModified = new Date(fs.lstatSync(`${dir}/${file}`).mtimeMs);} try {ofile.lastModified = new Date(fs.lstatSync(`${dir}/${file}`).mtimeMs);}
catch {ofile.lastModified = 0;} catch {ofile.lastModified = 0;}

Loading…
Cancel
Save