Browse Source

Merge pull request #6 from newsdev/feature/semantic_filenamees

James Thomas 7 years ago
parent
commit
f07ded742f
2 changed files with 11 additions and 4 deletions
  1. 5 3
      audiogram/index.js
  2. 6 1
      client/index.js

+ 5 - 3
audiogram/index.js View File

145
 Audiogram.prototype.render = function(cb) {
145
 Audiogram.prototype.render = function(cb) {
146
 
146
 
147
   var self = this,
147
   var self = this,
148
-      q = queue(1);
148
+      q = queue(1),
149
+      identifier = self.settings.identifier;
150
+ ;
149
 
151
 
150
   this.status("audio-download");
152
   this.status("audio-download");
151
 
153
 
170
   q.defer(this.combineFrames.bind(this));
172
   q.defer(this.combineFrames.bind(this));
171
 
173
 
172
   // Upload video to S3 or move to local storage
174
   // Upload video to S3 or move to local storage
173
-  q.defer(transports.uploadVideo, this.videoPath, "video/" + this.id + ".mp4");
175
+  q.defer(transports.uploadVideo, this.videoPath, "video/" + identifier + ".mp4");
174
 
176
 
175
   // Delete working directory
177
   // Delete working directory
176
   q.defer(rimraf, this.dir);
178
   q.defer(rimraf, this.dir);
179
   q.await(function(err){
181
   q.await(function(err){
180
 
182
 
181
     if (!err) {
183
     if (!err) {
182
-      self.set("url", transports.getURL(self.id));
184
+      self.set("url", transports.getURL(identifier));
183
     }
185
     }
184
 
186
 
185
     logger.debug(self.profiler.print());
187
     logger.debug(self.profiler.print());

+ 6 - 1
client/index.js View File

61
       citation = preview.citation(),
61
       citation = preview.citation(),
62
       label = preview.label(),
62
       label = preview.label(),
63
       selection = preview.selection(),
63
       selection = preview.selection(),
64
-      file = preview.file();
64
+      file = preview.file(),
65
+      identifier;
66
+
67
+  // for easy-to-scan filenames
68
+  identifier = caption.replace(/\s+/g, '_').replace(/\'|\"|\.|\?|\!/g, '').toLowerCase().slice(0, 20);
65
 
69
 
66
   if (!file) {
70
   if (!file) {
67
     d3.select("#row-audio").classed("error", true);
71
     d3.select("#row-audio").classed("error", true);
94
   formData.append("caption", caption);
98
   formData.append("caption", caption);
95
   formData.append("citation", citation);
99
   formData.append("citation", citation);
96
   formData.append("label", label);
100
   formData.append("label", label);
101
+  formData.append("identifier", identifier);
97
 
102
 
98
   setClass("loading");
103
   setClass("loading");
99
   d3.select("#loading-message").text("Uploading audio...");
104
   d3.select("#loading-message").text("Uploading audio...");