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",
"js": "JavaScript File",
"lnk": "Shortcut",
"url": "Shortcut",
"ini": ".ini Config File"
"lnk": "Shortcut (.lnk)",
"url": "Shortcut (.url)",
"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",
"xlsx": "excel",
"xls": "excel",
"gitignore": "git"
"gitignore": "git",
"7z": "zip",
"jar": "java",
"der": "certificate",
"py": "python"
},
"folder": {

@ -17,9 +17,9 @@ module.exports = (fpath, name) => {
}
}*/
else {
//console.log(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`;}
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`;}
let ext = name.startsWith('.') ? name : path.extname(name);
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((ext.toLowerCase()).slice(1))) {icon = `./assets/icons/extension/${icons.file[(ext.toLowerCase()).slice(1)]}.svg`;}
else {icon = './assets/icons/base/file.svg';}
}
} catch {icon = './assets/icons/base/file.svg';}

@ -17,7 +17,7 @@ module.exports = (check=false) => {
let ofile = {};
ofile.icon = fileIcon(`${dir}/${file}`, 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();}
try {ofile.lastModified = new Date(fs.lstatSync(`${dir}/${file}`).mtimeMs);}
catch {ofile.lastModified = 0;}

Loading…
Cancel
Save