* Allow relative or absolute paths in for art
* Misc cleanup
This commit is contained in:
parent
396e7cc747
commit
9e573e6810
|
@ -384,7 +384,29 @@ function getThemeArt(options, cb) {
|
|||
//
|
||||
async.waterfall(
|
||||
[
|
||||
function fromSuppliedTheme(callback) {
|
||||
function fromPath(callback) {
|
||||
//
|
||||
// We allow relative (to enigma-bbs) or full paths
|
||||
//
|
||||
if('/' === options.name[0]) {
|
||||
// just take the path as-is
|
||||
options.basePath = paths.dirname(options.name);
|
||||
} else if(options.name.indexOf('/') > -1) {
|
||||
// make relative to base BBS dir
|
||||
options.basePath = paths.join(__dirname, '../', paths.dirname(options.name));
|
||||
} else {
|
||||
return callback(null, null);
|
||||
}
|
||||
|
||||
art.getArt(options.name, options, (err, artInfo) => {
|
||||
return callback(null, artInfo);
|
||||
});
|
||||
},
|
||||
function fromSuppliedTheme(artInfo, callback) {
|
||||
if(artInfo) {
|
||||
return callback(null, artInfo);
|
||||
}
|
||||
|
||||
options.basePath = paths.join(Config.paths.themes, options.themeId);
|
||||
|
||||
art.getArt(options.name, options, function artLoaded(err, artInfo) {
|
||||
|
@ -563,10 +585,9 @@ function displayThemedAsset(assetSpec, client, options, cb) {
|
|||
options = {};
|
||||
}
|
||||
|
||||
var artAsset = asset.getArtAsset(assetSpec);
|
||||
const artAsset = asset.getArtAsset(assetSpec);
|
||||
if(!artAsset) {
|
||||
cb(new Error('Asset not found: ' + assetSpec));
|
||||
return;
|
||||
return cb(new Error('Asset not found: ' + assetSpec));
|
||||
}
|
||||
|
||||
// :TODO: just use simple merge of options -> displayOptions
|
||||
|
@ -580,7 +601,7 @@ function displayThemedAsset(assetSpec, client, options, cb) {
|
|||
switch(artAsset.type) {
|
||||
case 'art' :
|
||||
displayThemeArt(dispOpts, function displayed(err, artData) {
|
||||
cb(err, err ? null : { mciMap : artData.mciMap, height : artData.extraInfo.height } );
|
||||
return cb(err, err ? null : { mciMap : artData.mciMap, height : artData.extraInfo.height } );
|
||||
});
|
||||
break;
|
||||
|
||||
|
@ -595,7 +616,6 @@ function displayThemedAsset(assetSpec, client, options, cb) {
|
|||
break;
|
||||
|
||||
default :
|
||||
cb(new Error('Unsupported art asset type: ' + artAsset.type));
|
||||
break;
|
||||
return cb(new Error('Unsupported art asset type: ' + artAsset.type));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue