Skip to content

Commit

Permalink
construct audio url from infopanel data, and requested language.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrasca committed Apr 7, 2018
1 parent d501215 commit 91fcf39
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions web.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ String.prototype.formatU = function() {
return str;
};

var sizethree = function (i) {
var result = '000' + (i || 0);
return (result).substr(result.length-3);
}

app.set('views', __dirname + '/views');
app.set('view engine', "pug");
app.engine('pug', require('pug').__express);
Expand Down Expand Up @@ -70,8 +75,8 @@ app.get("/panels/:garden_id/:language?", (req, res) => {
cursor().
exec().
on('data', (doc) => {
doc.url = ("http://www.ghini.me/raw/" +
doc.audio.substr(0,6) + language + doc.audio.substr(5));
doc.url = ("http://www.ghini.me/raw/g_{0}_{1}_{2}.mp3").formatU(
sizethree(doc.garden_id), language, sizethree(doc.id_within_garden));
result.push(doc);
}).
on('error', (err) => {
Expand Down

0 comments on commit 91fcf39

Please sign in to comment.