Show PWS icon on mods installed from PWS

This commit is contained in:
Björn Dahlgren 2014-07-28 19:46:01 +02:00
parent 4ff59ddca5
commit 36bfcf7db3
4 changed files with 24 additions and 4 deletions

View File

@ -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",

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -1,9 +1,13 @@
<td style="width: 100%;">
<a href='#mods/<%-name%>'><%-name%></a>
<% if (playWithSix) { %>
<img src="/images/playwithsix.png" height="20px" width="20px" />
<% } %>
</td>
<td>
<% if (outdated) { %>
<a class="btn btn-primary btn-xs update pull-right ladda-button" data-style="expand-left">
<a class="btn btn-primary btn-xs update ladda-button" data-style="expand-left">
<span class="glyphicon glyphicon-save"></span>
Update
</a>

View File

@ -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);
});
});
}
});