diff --git a/package.json b/package.json index 9322ed4..7cfe4da 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "start": "node app.js" }, "dependencies": { + "async": "^0.9.0", "express": "3.x", "slug": "~0.4.0", "express-resource": "~1.0.0", diff --git a/public/images/playwithsix.png b/public/images/playwithsix.png new file mode 100644 index 0000000..21784b5 Binary files /dev/null and b/public/images/playwithsix.png differ diff --git a/public/js/tpl/mods/list_item.html b/public/js/tpl/mods/list_item.html index ef8a63b..6da8f12 100644 --- a/public/js/tpl/mods/list_item.html +++ b/public/js/tpl/mods/list_item.html @@ -1,9 +1,13 @@ <%-name%> + + <% if (playWithSix) { %> + + <% } %> <% if (outdated) { %> - + Update diff --git a/routes/mods.js b/routes/mods.js index 14c0898..7e67117 100644 --- a/routes/mods.js +++ b/routes/mods.js @@ -1,5 +1,6 @@ var fs = require('fs') , path = require('path') +, async = require('async') , playwithsix = require('playwithsix') , when = require('when') , nodefn = require('when/node/function'); @@ -47,6 +48,15 @@ function walk (directory) { }); }; +function isPlayWithSixMod(modPath, cb) { + var pwsFile = path.join(modPath, '.repository.yml'); + fs.exists(pwsFile, function (exists) { + if (cb) { + cb(exists); + } + }); +}; + exports.index = function(req, res){ fs.readdir(config.path, function (err, files) { if (err) { @@ -57,9 +67,14 @@ exports.index = function(req, res){ }); playwithsix.checkOutdated(config.path, function (err, outdatedMods) { - res.send(mods.map(function (mod) { - return { name: mod, outdated: outdatedMods.indexOf(mod) >= 0 }; - })); + async.map(mods, function (mod, cb) { + var modPath = path.join(config.path, mod); + isPlayWithSixMod(modPath, function (isPlayWithSixMod) { + cb(null, { name: mod, outdated: outdatedMods.indexOf(mod) >= 0, playWithSix: isPlayWithSixMod }); + }); + }, function (err, mods) { + res.send(mods); + }); }); } });