Skip to content

Commit d821b11

Browse files
committed
Sort filenames, smaller thumbs
1 parent ce9f3ed commit d821b11

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

Diff for: sample.coffee

+20-12
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ if Meteor.isClient
9191
#####################
9292
# UI template helpers
9393

94+
shorten = (name, w = 16) ->
95+
w++ if w % 2
96+
w = (w-2)/2
97+
if name.length > w
98+
name[0..w] + '...' + name[-w-1..-1]
99+
else
100+
name
101+
94102
Template.top.helpers
95103
loginToken: () ->
96104
Meteor.userId()
@@ -109,12 +117,7 @@ if Meteor.isClient
109117
"#{this._id}"
110118

111119
shortFilename: (w = 16) ->
112-
w++ if w % 2
113-
w = (w-2)/2
114-
if this.filename.length > w
115-
this.filename[0..w] + '...' + this.filename[-w-1..-1]
116-
else
117-
this.filename
120+
shorten this.filename, w
118121

119122
uploadStatus: () ->
120123
percent = Session.get "#{this._id}"
@@ -132,6 +135,12 @@ if Meteor.isClient
132135
isImage: () ->
133136
imageTypes[this.contentType]?
134137

138+
altMessage: () ->
139+
if this.length isnt 0
140+
"Processing thumbnail of #{shorten this.filename, 20}..."
141+
else
142+
"Uploading #{shorten this.filename, 20}..."
143+
135144
fileTableEvents =
136145
# Wire up the event to remove a file by clicking the `X`
137146
'click .del-file': (e, t) ->
@@ -141,7 +150,7 @@ if Meteor.isClient
141150

142151
Template.gallery.dataEntries = () ->
143152
# Reactively populate the table
144-
this.find({ 'metadata.thumb': { $exists: true }})
153+
this.find({'metadata.thumbOf': {$exists: false}}, {sort:{filename: 1}})
145154

146155
Template.gallery.thumb = () ->
147156
"#{this.metadata.thumb}"
@@ -159,7 +168,7 @@ if Meteor.isClient
159168
Template.fileTable.helpers fileTableHelpers
160169
Template.fileTable.dataEntries = () ->
161170
# Reactively populate the table
162-
this.find({})
171+
this.find({}, {sort:{filename: 1}})
163172

164173
Template.fileTable.events fileTableEvents
165174

@@ -193,7 +202,6 @@ if Meteor.isClient
193202

194203
jobTableHelpers =
195204
jobEntries: () ->
196-
console.log "jobEntries", this
197205
# Reactively populate the table
198206
this.find({})
199207

@@ -218,13 +226,13 @@ if Meteor.isClient
218226
}[this.status]
219227

220228
numRepeats: () ->
221-
if this.repeats > Math.pow 2, 31
229+
if this.repeats is parent.Forever
222230
""
223231
else
224232
this.repeats
225233

226234
numRetries: () ->
227-
if this.retries > Math.pow 2, 31
235+
if this.retries is parent.Forever
228236
""
229237
else
230238
this.retries
@@ -485,7 +493,7 @@ if Meteor.isServer
485493
job.progress 20, 100
486494

487495
gm(inStream)
488-
.resize(250,250)
496+
.resize(150,150)
489497
.stream('png')
490498
.pipe(outStream, (err) ->
491499
console.warn 'Error running graphicsmagick:', err

Diff for: sample.css

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ body {
1111
flex: 1 0 auto;
1212
flex-wrap: wrap;
1313
align-items: center;
14+
justify-content: space-around;
1415
}
1516

1617
.panel, .panel-heading, .panel-body {

Diff for: sample.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ <h3>fileCollection + jobCollection Test App</h3>
5252
<div class="panel-body {{root}}DropZone">
5353
<div class="row equal">
5454
{{#each dataEntries}}
55-
<div class="col-sm-6 col-lg-3">
55+
<div class="col-sm-6 col-lg-2">
5656
<div class="thumbnail">
5757
{{#if isImage}}
58-
<a href="{{../baseURL}}/{{id}}"><img class="img-thumbnail" alt="[ preview of {{shortFilename}} will display here ]" src="{{../baseURL}}/{{thumb}}"></a>
59-
<div class="caption text-center">{{shortFilename 20}}</div>
58+
<a href="{{../baseURL}}/{{id}}"><img class="img-thumbnail" alt="{{altMessage}}" src="{{../baseURL}}/{{thumb}}"></a>
59+
<div class="caption text-center">{{shortFilename 16}}</div>
6060
{{else}}
6161
<span class="text-muted text-center">No preview</span>
6262
{{/if}}

0 commit comments

Comments
 (0)