mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-22 18:56:00 +02:00
* Tons of work with menu/prompts refactoring -- more to come soon
* More work with menu/prompt accets
This commit is contained in:
parent
5faa11664b
commit
bac2f63c1a
21 changed files with 871 additions and 238 deletions
|
@ -1,7 +1,11 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
var assert = require('assert');
|
||||
|
||||
exports.parseAsset = parseAsset;
|
||||
exports.getArtAsset = getArtAsset;
|
||||
|
||||
var ALL_ASSETS = [
|
||||
'art',
|
||||
|
@ -10,8 +14,7 @@ var ALL_ASSETS = [
|
|||
'prompt',
|
||||
];
|
||||
|
||||
// \@(art|menu|method)\:([\w\.]*)(?:\/?([\w\d\_]+))*
|
||||
var ASSET_RE = new RegExp('\\@(' + ALL_ASSETS.join('|') + ')\\:([\\w\\.]*)(?:\\?/([\\w\\d\\_]+))*');
|
||||
var ASSET_RE = new RegExp('\\@(' + ALL_ASSETS.join('|') + ')\\:([\\w\\d\\.]*)(?:\\/([\\w\\d\\_]+))*');
|
||||
|
||||
function parseAsset(s) {
|
||||
var m = ASSET_RE.exec(s);
|
||||
|
@ -28,4 +31,22 @@ function parseAsset(s) {
|
|||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
function getArtAsset(art, cb) {
|
||||
if(!_.isString(art)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if('@' === art[0]) {
|
||||
var artAsset = parseAsset(art);
|
||||
assert('art' === artAsset.type || 'method' === artAsset.type);
|
||||
|
||||
return artAsset;
|
||||
} else {
|
||||
return {
|
||||
type : 'art',
|
||||
asset : art,
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue