From 28eda6caa01c4272d4806546864171f39b2ad3a0 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Wed, 7 Jan 2009 20:42:57 +0000 Subject: [PATCH] improve the files table in the add torrent window add some mimetype support in improve the merge_changes.py script --- deluge/ui/webui/templates/ajax/index.html | 1 + .../templates/ajax/static/js/deluge-add.js | 12 +- .../templates/ajax/static/js/deluge-mime.js | 148 ++++++++++++++++++ .../themes/classic/mime_icons/image.png | Bin 0 -> 693 bytes .../themes/classic/mime_icons/unknown.png | Bin 0 -> 655 bytes .../ajax/static/themes/classic/style.css | 22 +++ 6 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 deluge/ui/webui/templates/ajax/static/js/deluge-mime.js create mode 100644 deluge/ui/webui/templates/ajax/static/themes/classic/mime_icons/image.png create mode 100644 deluge/ui/webui/templates/ajax/static/themes/classic/mime_icons/unknown.png diff --git a/deluge/ui/webui/templates/ajax/index.html b/deluge/ui/webui/templates/ajax/index.html index 57dd3acf9..8f5bbc6d1 100644 --- a/deluge/ui/webui/templates/ajax/index.html +++ b/deluge/ui/webui/templates/ajax/index.html @@ -13,6 +13,7 @@ + diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-add.js b/deluge/ui/webui/templates/ajax/static/js/deluge-add.js index 2c06d3fda..7b190210b 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-add.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-add.js @@ -276,9 +276,15 @@ Deluge.Widgets.AddTorrent.FilesTab = new Class({ if (!torrent) return; $each(torrent['files'], function(file) { row = new Element('tr'); - new Element('td').inject(row); - new Element('td').set('text', file['path']).inject(row); - new Element('td').set('text', file['size'].toBytes()).inject(row); + new Element('td').addClass('fileSelect').inject(row).grab(new Element('input', { + 'type': 'checkbox', + 'checked': 'checked' + })); + var icon = new Element('td').addClass('fileIcon').inject(row); + var mimetype = Deluge.Mime.getMimeType(file['path']); + if (mimetype) icon.addClass(mimetype.replace('/', '_')); + new Element('td').addClass('fileName').set('text', file['path']).inject(row); + new Element('td').addClass('fileSize').set('text', file['size'].toBytes()).inject(row); this.table.grab(row); }, this); } diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-mime.js b/deluge/ui/webui/templates/ajax/static/js/deluge-mime.js new file mode 100644 index 000000000..7b75acab3 --- /dev/null +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-mime.js @@ -0,0 +1,148 @@ +/* +Script: deluge-mime.js + Library for converting mimetypes to extensions and vica versa. + +License: + General Public License v3 + +Copyright: + Damien Churchill (c) 2008 + + + Object: Deluge.Mime + Object containing all mime related functions. + +*/ + +Deluge.Mime = { + types_map: new Hash({ + '.doc': 'application/msword', + '.dot': 'application/msword', + '.wiz': 'application/msword', + '.a': 'application/octet-stream', + '.bin': 'application/octet-stream', + '.dll': 'application/octet-stream', + '.exe': 'application/octet-stream', + '.o': 'application/octet-stream', + '.obj': 'application/octet-stream', + '.so': 'application/octet-stream', + '.oda': 'application/oda', + '.pdf': 'application/pdf', + '.p7c': 'application/pkcs7-mime', + '.ai': 'application/postscript', + '.eps': 'application/postscript', + '.ps': 'application/postscript', + '.xlb': 'application/vnd.ms-excel', + '.xls': 'application/vnd.ms-excel', + '.pot': 'application/vnd.ms-powerpoint', + '.ppa': 'application/vnd.ms-powerpoint', + '.pps': 'application/vnd.ms-powerpoint', + '.ppt': 'application/vnd.ms-powerpoint', + '.pwz': 'application/vnd.ms-powerpoint', + '.bcpio': 'application/x-bcpio', + '.cpio': 'application/x-cpio', + '.csh': 'application/x-csh', + '.dvi': 'application/x-dvi', + '.gtar': 'application/x-gtar', + '.hdf': 'application/x-hdf', + '.js': 'application/x-javascript', + '.latex': 'application/x-latex', + '.mif': 'application/x-mif', + '.cdf': 'application/x-netcdf', + '.nc': 'application/x-netcdf', + '.p12': 'application/x-pkcs12', + '.pfx': 'application/x-pkcs12', + '.ram': 'application/x-pn-realaudio', + '.pyc': 'application/x-python-code', + '.pyo': 'application/x-python-code', + '.sh': 'application/x-sh', + '.shar': 'application/x-shar', + '.swf': 'application/x-shockwave-flash', + '.sv4cpio': 'application/x-sv4cpio', + '.sv4crc': 'application/x-sv4crc', + '.tar': 'application/x-tar', + '.tcl': 'application/x-tcl', + '.tex': 'application/x-tex', + '.texi': 'application/x-texinfo', + '.texinfo': 'application/x-texinfo', + '.roff': 'application/x-troff', + '.t': 'application/x-troff', + '.tr': 'application/x-troff', + '.man': 'application/x-troff-man', + '.me': 'application/x-troff-me', + '.ms': 'application/x-troff-ms', + '.ustar': 'application/x-ustar', + '.src': 'application/x-wais-source', + '.rdf': 'application/xml', + '.wsdl': 'application/xml', + '.xpdl': 'application/xml', + '.xsl': 'application/xml', + '.zip': 'application/zip', + '.au': 'audio/basic', + '.snd': 'audio/basic', + '.mp2': 'audio/mpeg', + '.mp3': 'audio/mpeg', + '.aif': 'audio/x-aiff', + '.aifc': 'audio/x-aiff', + '.aiff': 'audio/x-aiff', + '.ra': 'audio/x-pn-realaudio', + '.wav': 'audio/x-wav', + '.gif': 'image/gif', + '.ief': 'image/ief', + '.jpe': 'image/jpeg', + '.jpeg': 'image/jpeg', + '.jpg': 'image/jpeg', + '.png': 'image/png', + '.tif': 'image/tiff', + '.tiff': 'image/tiff', + '.ras': 'image/x-cmu-raster', + '.bmp': 'image/x-ms-bmp', + '.pnm': 'image/x-portable-anymap', + '.pbm': 'image/x-portable-bitmap', + '.pgm': 'image/x-portable-graymap', + '.ppm': 'image/x-portable-pixmap', + '.rgb': 'image/x-rgb', + '.xbm': 'image/x-xbitmap', + '.xpm': 'image/x-xpixmap', + '.xwd': 'image/x-xwindowdump', + '.eml': 'message/rfc822', + '.mht': 'message/rfc822', + '.mhtml': 'message/rfc822', + '.nws': 'message/rfc822', + '.css': 'text/css', + '.htm': 'text/html', + '.html': 'text/html', + '.bat': 'text/plain', + '.c': 'text/plain', + '.h': 'text/plain', + '.ksh': 'text/plain', + '.pl': 'text/plain', + '.txt': 'text/plain', + '.rtx': 'text/richtext', + '.tsv': 'text/tab-separated-values', + '.py': 'text/x-python', + '.etx': 'text/x-setext', + '.sgm': 'text/x-sgml', + '.sgml': 'text/x-sgml', + '.vcf': 'text/x-vcard', + '.xml': 'text/xml', + '.m1v': 'video/mpeg', + '.mpa': 'video/mpeg', + '.mpe': 'video/mpeg', + '.mpeg': 'video/mpeg', + '.mpg': 'video/mpeg', + '.mov': 'video/quicktime', + '.qt': 'video/quicktime', + '.avi': 'video/x-msvideo', + '.movie': 'video/x-sgi-movie' + }), + + getMimeType: function(filename) { + var extension = filename.match(/^.*(\.\w+)$/) + if (extension) extension = extension[1] + else return null; + + if (this.types_map.has(extension)) return this.types_map[extension]; + else return null; + } +} diff --git a/deluge/ui/webui/templates/ajax/static/themes/classic/mime_icons/image.png b/deluge/ui/webui/templates/ajax/static/themes/classic/mime_icons/image.png new file mode 100644 index 0000000000000000000000000000000000000000..ff783f5c0a073049be995c4d26b30fd2d87564da GIT binary patch literal 693 zcmV;m0!safP)21=K++hkI>dA%kxt7)^jUrInrXsAZ^OIDu}{u^Jrhybh`o6bjur zmB_+XBhzi;X!$Fra48U^{u4D5BwixF z-c#l)l;Wt|66y^ic8@aUoW(gNRYLPc z+RIz4bXJ*C5JJJ)V$Q?OR8Js4Sx)%*`Iys-K8@lNv6?ciN|1z8<*Yf+$-*-E{2HOT z&iA6nZgYq3dVwM^DdESk&2Z!q=P*1bo=8TN408%zA%OS+&X0NiV4I!w0=1M#F6W~C zgg?3AHQ>DBG~j$7(|~F~gQ6M;A&>=6bD@P{!x_KR z5~}GrIv5PU6pdoIyWMPF%ea;t1i;tA^0RY_>-;&Ho2u zOyywEKf3KU^A`qJB~1;gS=#^r03v!+SaefwW^{L9a%BJjc-kv3FW1Y=%Pvk%EJ)SM bFG>dhHrNJO5L3!r00000NkvXXu0mjf;x04J literal 0 HcmV?d00001 diff --git a/deluge/ui/webui/templates/ajax/static/themes/classic/mime_icons/unknown.png b/deluge/ui/webui/templates/ajax/static/themes/classic/mime_icons/unknown.png new file mode 100644 index 0000000000000000000000000000000000000000..bcdf6973f7ad46bff1033534b5683e6a9007e70e GIT binary patch literal 655 zcmV;A0&x9_P)(_DP2J7!cf{JpP*2sOXd#k6p3$8H5*@`J8aotNd~&Gw;K~kVJ}N1(lq~^=X+0w z7ZMc`uH?zr$G>x~Z5oXRR5e$t)jpO=rI#d$d)4iB{jZyw)A#%Pm(^+&?RI;%=L&@a zoO8u;xqPs`zP_WX{~b2QU}IwgYinyC&d<*eTCLWPy}frhJNupqWNkDgBkw)__Ih}L z03goiUvF)1AGO-;PbVj*KP#0AE-o$*kpxMoDntZ91hQZa2Lm|gUTwbE{MKwXw+;^v zGXj#J5-Nho7{qZ5+>3z#(lo_&=NkQf|80^aUyqNEKG*B@i6a%t2%-w_J$k(!mQ|8G zLy{y2A>G;CeN&oDCcm935k-WA003B7Sy?LZv{;054&B>Z7-Qg^omyb#-+Pb#VDP}g z-86D(ia3rTA|Ms2gd-JXgdhPV@x-}>w;N+%t%a&0gshj;j6ju;AV|{`qtOUU6c8DM zd_E5mfoe8AMgtzVF87>R_?PA+fbo;b&E?fq4