remove contenttype and tweak file icons

pull/258/head
nightwing 2016-02-18 01:42:50 +04:00
rodzic 7e4e4690a7
commit 7f655d8883
3 zmienionych plików z 62 dodań i 96 usunięć

Wyświetl plik

@ -31,80 +31,38 @@ define(function(require, exports, module) {
}; };
var SupportedIcons = { var SupportedIcons = {
"application/xhtml+xml":"html", "c9search": "page_white_magnify",
"text/css": "css", "js": "page_white_code",
"text/x-scss": "css", "jsx": "page_white_code_red",
"text/x-sass": "css", "ts": "page_white_code",
"text/html":"html", "tsx": "page_white_code_red",
"application/pdf":"page_white_acrobat", "json": "page_white_code",
"image":"image", "css": "css",
"application/xml":"page_white_code_red", "scss": "css",
"image/svg+xml": "page_white_picture", "sass": "css",
"text/plain": "page_white_text", "less": "css",
"application/javascript": "page_white_code", "xml": "page_white_code_red",
"application/json": "page_white_code", "svg": "page_white_picture",
"text/x-script.python": "page_white_code", "php": "page_white_php",
"text/x-script.ocaml": "page_white_code", "phtml": "page_white_php",
"text/x-script.clojure": "page_white_code", "html": "html",
"application/x-httpd-php": "page_white_php", "xhtml": "html",
"application/x-sh": "page_white_wrench", "coffee": "page_white_cup",
"text/x-coldfusion": "page_white_coldfusion", "py": "page_white_code",
"text/x-script.ruby": "page_white_ruby", "go": "page_white_code",
"text/x-script.coffeescript": "page_white_cup", "java": "page_white_cup",
"text/cpp": "page_white_cplusplus", "logic": "logiql",
"text/x-c": "page_white_c", "ru": "page_white_ruby",
"text/x-logiql": "logiql", "gemspec": "page_white_ruby",
"text/x-csharp": "page_white_csharp", "rake": "page_white_ruby",
"text/x-java-source": "page_white_cup", "rb": "page_white_ruby",
"text/x-markdown": "page_white_text", "c": "page_white_c",
"text/x-xquery": "page_white_code", "cc": "page_white_c",
"text/x-go": "page_white_code", "cpp": "page_white_cplusplus",
}; "cxx": "page_white_c",
"h": "page_white_h",
var contentTypes = { "hh": "page_white_h",
"c9search": "text/x-c9search", "hpp": "page_white_h",
"js": "application/javascript",
"json": "application/json",
"run": "application/javascript",
"build": "application/javascript",
"css": "text/css",
"scss": "text/x-scss",
"sass": "text/x-sass",
"xml": "application/xml",
"rdf": "application/rdf+xml",
"rss": "application/rss+xml",
"svg": "image/svg+xml",
"wsdl": "application/wsdl+xml",
"xslt": "application/xslt+xml",
"atom": "application/atom+xml",
"mathml": "application/mathml+xml",
"mml": "application/mathml+xml",
"php": "application/x-httpd-php",
"phtml": "application/x-httpd-php",
"html": "text/html",
"xhtml": "application/xhtml+xml",
"coffee": "text/x-script.coffeescript",
"py": "text/x-script.python",
"go": "text/x-go",
"java": "text/x-java-source",
"logic": "text/x-logiql",
"ru": "text/x-script.ruby",
"gemspec": "text/x-script.ruby",
"rake": "text/x-script.ruby",
"rb": "text/x-script.ruby",
"c": "text/x-c",
"cc": "text/x-c",
"cpp": "text/x-c",
"cxx": "text/x-c",
"h": "text/x-c",
"hh": "text/x-c",
"hpp": "text/x-c",
"bmp": "image", "bmp": "image",
"djv": "image", "djv": "image",
"djvu": "image", "djvu": "image",
@ -123,19 +81,32 @@ define(function(require, exports, module) {
"tiff": "image", "tiff": "image",
"xbm": "image", "xbm": "image",
"xpm": "image", "xpm": "image",
"pdf": "page_white_acrobat",
"clj": "text/x-script.clojure", "clj": "page_white_code",
"ml": "text/x-script.ocaml", "ml": "page_white_code",
"mli": "text/x-script.ocaml", "mli": "page_white_code",
"cfm": "text/x-coldfusion", "cfm": "page_white_coldfusion",
"sql": "text/x-sql", "sql": "page_white_database",
"db": "page_white_database",
"sh": "application/x-sh", "sh": "page_white_wrench",
"bash": "application/x-sh", "bash": "page_white_wrench",
"xq": "page_white_code",
"xq": "text/x-xquery", "xz": "page_white_zip",
"gz": "page_white_zip",
"terminal": "terminal" "bz": "page_white_zip",
"zip": "page_white_zip",
"tar": "page_white_zip",
"rar": "page_white_compressed",
"exe": "page_white_swoosh",
"o": "page_white_swoosh",
"lnk": "page_white_swoosh",
"txt": "page_white_text",
"settings": "page_white_gear",
"run": "page_white_gear",
"build": "page_white_gear",
"gitignore": "page_white_gear",
"profile": "page_white_gear",
"bashrc": "page_white_gear",
}; };
plugin.getFileIcon = function(name) { plugin.getFileIcon = function(name) {
@ -144,7 +115,7 @@ define(function(require, exports, module) {
if (name) { if (name) {
ext = name.split(".").pop().toLowerCase(); ext = name.split(".").pop().toLowerCase();
icon = SupportedIcons[contentTypes[ext]] || "page_white_text"; icon = SupportedIcons[ext] || "page_white_text";
} }
return icon; return icon;
}; };
@ -167,8 +138,8 @@ define(function(require, exports, module) {
}; };
plugin.getContentType = function(filename) { plugin.getContentType = function(filename) {
var type = filename.split(".").pop().split("!").pop().toLowerCase() || ""; console.warn("util content type is deprecated");
return contentTypes[type] || "text/plain"; return "text/plain";
}; };
// taken from http://xregexp.com/ // taken from http://xregexp.com/

Wyświetl plik

@ -25,11 +25,7 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
function main(options, imports, register) { function main(options, imports, register) {
var util = imports.util; var util = imports.util;
describe('getContentType, getFileIcon', function() { describe('getFileIcon', function() {
it('should retrieve the content type based on a filename', function() {
expect(util.getContentType("test.js")).to.equal("application/javascript");
expect(util.getContentType("test.html")).to.equal("text/html");
});
it('should retrieve the icon class name based on a filename', function() { it('should retrieve the icon class name based on a filename', function() {
expect(util.getFileIcon("test.js")).to.equal("page_white_code"); expect(util.getFileIcon("test.js")).to.equal("page_white_code");
expect(util.getFileIcon("test.html")).to.equal("html"); expect(util.getFileIcon("test.html")).to.equal("html");

Wyświetl plik

@ -571,7 +571,6 @@ define(function(require, exports, module) {
if (isFolder) { if (isFolder) {
node.status = node.status || "pending"; node.status = node.status || "pending";
} else { } else {
node.contenttype = stat.mime || util.getContentType(name);
node.status = "loaded"; node.status = "loaded";
} }
if (typeof stat.mtime !== "number" && stat.mtime) { if (typeof stat.mtime !== "number" && stat.mtime) {