mirror of
https://github.com/atom/atom.git
synced 2026-02-12 23:55:10 -05:00
Use image, pdf, and compressed file icons
This commit is contained in:
@@ -1,18 +1,50 @@
|
||||
{View, $$} = require 'space-pen'
|
||||
$ = require 'jquery'
|
||||
Git = require 'git'
|
||||
fs = require 'fs'
|
||||
_ = require 'underscore'
|
||||
|
||||
module.exports =
|
||||
class FileView extends View
|
||||
|
||||
@COMPRESSED_EXTENSIONS: [
|
||||
'.zip'
|
||||
'.jar'
|
||||
'.tar'
|
||||
'.gz'
|
||||
]
|
||||
|
||||
@IMAGE_EXTENSIONS: [
|
||||
'.jpeg'
|
||||
'.jpg'
|
||||
'.gif'
|
||||
'.png'
|
||||
]
|
||||
|
||||
@PDF_EXTENSIONS: [
|
||||
'.pdf'
|
||||
]
|
||||
|
||||
@content: (file) ->
|
||||
@li class: 'file entry', =>
|
||||
@span file.getBaseName(), class: 'name'
|
||||
@span file.getBaseName(), class: 'name', outlet: 'fileName'
|
||||
@span "", class: 'highlight'
|
||||
|
||||
file: null
|
||||
|
||||
initialize: (@file) ->
|
||||
@addClass('ignored') if new Git(@getPath()).isPathIgnored(@getPath())
|
||||
path = @getPath()
|
||||
extension = fs.extension(path)
|
||||
if _.contains(FileView.COMPRESSED_EXTENSIONS, extension)
|
||||
@fileName.addClass('compressed-name')
|
||||
else if _.contains(FileView.IMAGE_EXTENSIONS, extension)
|
||||
@fileName.addClass('image-name')
|
||||
else if _.contains(FileView.PDF_EXTENSIONS, extension)
|
||||
@fileName.addClass('pdf-name')
|
||||
else
|
||||
@fileName.addClass('text-name')
|
||||
|
||||
@addClass('ignored') if new Git(path).isPathIgnored(path)
|
||||
|
||||
getPath: ->
|
||||
@file.path
|
||||
|
||||
Reference in New Issue
Block a user