          return "active" if pill is "#{this}"
 
    fileTableHelpers =
+      dataEntries: () ->
+         # Reactively populate the table
+         this.find({}, {sort:{filename: 1}})
+
       owner: () ->
          this.metadata?._auth?.owner
 
       id: () ->
          "#{this._id}"
 
-      shortFilename: (w = 16) ->
-         shorten this.filename, w
+      shortFilename: shortFilename
 
       uploadStatus: () ->
          percent = Session.get "#{this._id}"

      uploadProgress: () ->
         percent = Session.get "#{this._id}"

      isImage: () ->
         imageTypes[this.contentType]?

      altMessage: () ->
         if this.length isnt 0
            "Processing thumbnail of #{shorten this.filename, 20}..."
         else
            "Uploading #{shorten this.filename, 20}..."

   fileTableEvents =
      # Wire up the event to remove a file by clicking the `X`
      'click .del-file': (e, t) ->
         t.data.remove this._id

   Template.gallery.helpers fileTableHelpers

   Template.gallery.helpers
      dataEntries: () ->

      { method: 'get', path: '/:_id', lookup: (params, query) -> return { _id: params._id }},
      { method: 'put', path: '/put/:_id', lookup: (params, query) -> return { _id: params._id }}
   ]}
)

myJobs = JobCollection 'queue', { idGeneration: 'MONGO' }
