* 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(
|
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);
|
options.basePath = paths.join(Config.paths.themes, options.themeId);
|
||||||
|
|
||||||
art.getArt(options.name, options, function artLoaded(err, artInfo) {
|
art.getArt(options.name, options, function artLoaded(err, artInfo) {
|
||||||
|
@ -563,10 +585,9 @@ function displayThemedAsset(assetSpec, client, options, cb) {
|
||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
var artAsset = asset.getArtAsset(assetSpec);
|
const artAsset = asset.getArtAsset(assetSpec);
|
||||||
if(!artAsset) {
|
if(!artAsset) {
|
||||||
cb(new Error('Asset not found: ' + assetSpec));
|
return cb(new Error('Asset not found: ' + assetSpec));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// :TODO: just use simple merge of options -> displayOptions
|
// :TODO: just use simple merge of options -> displayOptions
|
||||||
|
@ -578,24 +599,23 @@ function displayThemedAsset(assetSpec, client, options, cb) {
|
||||||
};
|
};
|
||||||
|
|
||||||
switch(artAsset.type) {
|
switch(artAsset.type) {
|
||||||
case 'art' :
|
case 'art' :
|
||||||
displayThemeArt(dispOpts, function displayed(err, artData) {
|
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;
|
break;
|
||||||
|
|
||||||
case 'method' :
|
case 'method' :
|
||||||
// :TODO: fetch & render via method
|
// :TODO: fetch & render via method
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'inline ' :
|
case 'inline ' :
|
||||||
// :TODO: think about this more in relation to themes, etc. How can this come
|
// :TODO: think about this more in relation to themes, etc. How can this come
|
||||||
// from a theme (with override from menu.json) ???
|
// from a theme (with override from menu.json) ???
|
||||||
// look @ client.currentTheme.inlineArt[name] -> menu/prompt[name]
|
// look @ client.currentTheme.inlineArt[name] -> menu/prompt[name]
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
cb(new Error('Unsupported art asset type: ' + artAsset.type));
|
return cb(new Error('Unsupported art asset type: ' + artAsset.type));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue