mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
* Some additional work on ACS
This commit is contained in:
parent
da460dfc7b
commit
a2f8101821
3 changed files with 188 additions and 169 deletions
|
@ -59,11 +59,11 @@ module.exports = (function() {
|
||||||
peg$c20 = "]",
|
peg$c20 = "]",
|
||||||
peg$c21 = { type: "literal", value: "]", description: "\"]\"" },
|
peg$c21 = { type: "literal", value: "]", description: "\"]\"" },
|
||||||
peg$c22 = function(n, a) { return checkAccess(n, a); },
|
peg$c22 = function(n, a) { return checkAccess(n, a); },
|
||||||
peg$c23 = /^[A-Z=]/,
|
peg$c23 = /^[A-Z]/,
|
||||||
peg$c24 = { type: "class", value: "[A-Z\\=]", description: "[A-Z\\=]" },
|
peg$c24 = { type: "class", value: "[A-Z]", description: "[A-Z]" },
|
||||||
peg$c25 = /^[A-Z]/,
|
peg$c25 = function(c) { return c.join(''); },
|
||||||
peg$c26 = { type: "class", value: "[A-Z]", description: "[A-Z]" },
|
peg$c26 = /^[A-Z=]/,
|
||||||
peg$c27 = function(c) { return c.join(''); },
|
peg$c27 = { type: "class", value: "[A-Z\\=]", description: "[A-Z\\=]" },
|
||||||
peg$c28 = /^[A-Za-z0-9\-_+]/,
|
peg$c28 = /^[A-Za-z0-9\-_+]/,
|
||||||
peg$c29 = { type: "class", value: "[A-Za-z0-9\\-_\\+]", description: "[A-Za-z0-9\\-_\\+]" },
|
peg$c29 = { type: "class", value: "[A-Za-z0-9\\-_\\+]", description: "[A-Za-z0-9\\-_\\+]" },
|
||||||
peg$c30 = function(a) { return a.join('') },
|
peg$c30 = function(a) { return a.join('') },
|
||||||
|
@ -567,15 +567,12 @@ module.exports = (function() {
|
||||||
if (peg$silentFails === 0) { peg$fail(peg$c24); }
|
if (peg$silentFails === 0) { peg$fail(peg$c24); }
|
||||||
}
|
}
|
||||||
if (s2 !== peg$FAILED) {
|
if (s2 !== peg$FAILED) {
|
||||||
if (peg$c25.test(input.charAt(peg$currPos))) {
|
if (peg$c23.test(input.charAt(peg$currPos))) {
|
||||||
s3 = input.charAt(peg$currPos);
|
s3 = input.charAt(peg$currPos);
|
||||||
peg$currPos++;
|
peg$currPos++;
|
||||||
} else {
|
} else {
|
||||||
s3 = peg$FAILED;
|
s3 = peg$FAILED;
|
||||||
if (peg$silentFails === 0) { peg$fail(peg$c26); }
|
if (peg$silentFails === 0) { peg$fail(peg$c24); }
|
||||||
}
|
|
||||||
if (s3 === peg$FAILED) {
|
|
||||||
s3 = null;
|
|
||||||
}
|
}
|
||||||
if (s3 !== peg$FAILED) {
|
if (s3 !== peg$FAILED) {
|
||||||
s2 = [s2, s3];
|
s2 = [s2, s3];
|
||||||
|
@ -590,9 +587,18 @@ module.exports = (function() {
|
||||||
}
|
}
|
||||||
if (s1 !== peg$FAILED) {
|
if (s1 !== peg$FAILED) {
|
||||||
peg$savedPos = s0;
|
peg$savedPos = s0;
|
||||||
s1 = peg$c27(s1);
|
s1 = peg$c25(s1);
|
||||||
}
|
}
|
||||||
s0 = s1;
|
s0 = s1;
|
||||||
|
if (s0 === peg$FAILED) {
|
||||||
|
if (peg$c26.test(input.charAt(peg$currPos))) {
|
||||||
|
s0 = input.charAt(peg$currPos);
|
||||||
|
peg$currPos++;
|
||||||
|
} else {
|
||||||
|
s0 = peg$FAILED;
|
||||||
|
if (peg$silentFails === 0) { peg$fail(peg$c27); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return s0;
|
return s0;
|
||||||
}
|
}
|
||||||
|
@ -799,88 +805,93 @@ module.exports = (function() {
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
|
|
||||||
function checkAccess(name, value) {
|
function checkAccess(name, value) {
|
||||||
return {
|
try {
|
||||||
'=' : function isLocalConnection() {
|
return {
|
||||||
return client.isLocal();
|
'=' : function isLocalConnection() {
|
||||||
},
|
return client.isLocal();
|
||||||
A : function ageGreaterOrEqualThan() {
|
},
|
||||||
return !isNaN(value) && user.getAge() >= value;
|
A : function ageGreaterOrEqualThan() {
|
||||||
},
|
return !isNaN(value) && user.getAge() >= value;
|
||||||
EC : function isEncoding() {
|
},
|
||||||
switch(value) {
|
EC : function isEncoding() {
|
||||||
case 0 : return 'cp437' === client.term.outputEncoding.toLowerCase();
|
switch(value) {
|
||||||
case 1 : return 'utf-8' === client.term.outputEncoding.toLowerCase();
|
case 0 : return 'cp437' === client.term.outputEncoding.toLowerCase();
|
||||||
default : return false;
|
case 1 : return 'utf-8' === client.term.outputEncoding.toLowerCase();
|
||||||
}
|
default : return false;
|
||||||
},
|
}
|
||||||
GM : function isOneOfGroups() {
|
},
|
||||||
if(!_.isArray(value)) {
|
GM : function isOneOfGroups() {
|
||||||
return false;
|
if(!_.isArray(value)) {
|
||||||
}
|
return false;
|
||||||
|
|
||||||
value.forEach(function grpEntry(groupName) {
|
|
||||||
if(user.isGroupMember(groupName)) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
value.forEach(function grpEntry(groupName) {
|
||||||
},
|
if(user.isGroupMember(groupName)) {
|
||||||
N : function isNode() {
|
return true;
|
||||||
return client.node === value;
|
}
|
||||||
},
|
});
|
||||||
P : function numberOfPosts() {
|
|
||||||
// :TODO: implement me!!!!
|
return false;
|
||||||
return false;
|
},
|
||||||
},
|
N : function isNode() {
|
||||||
Q : function numberOfCalls() {
|
return client.node === value;
|
||||||
// :TODO: implement me!!
|
},
|
||||||
return false;
|
P : function numberOfPosts() {
|
||||||
},
|
// :TODO: implement me!!!!
|
||||||
SC : function isSecerConnection() {
|
return false;
|
||||||
return client.session.isSecure;
|
},
|
||||||
},
|
Q : function numberOfCalls() {
|
||||||
T : function minutesLeft() {
|
// :TODO: implement me!!
|
||||||
// :TODO: implement me!
|
return false;
|
||||||
return false;
|
},
|
||||||
},
|
SC : function isSecerConnection() {
|
||||||
TH : function termHeight() {
|
return client.session.isSecure;
|
||||||
return !isNaN(value) && client.term.termHeight >= value;
|
},
|
||||||
},
|
T : function minutesLeft() {
|
||||||
TM : function isOneOfThemes() {
|
// :TODO: implement me!
|
||||||
if(!_.isArray(value)) {
|
return false;
|
||||||
|
},
|
||||||
|
TH : function termHeight() {
|
||||||
|
return !isNaN(value) && client.term.termHeight >= value;
|
||||||
|
},
|
||||||
|
TM : function isOneOfThemes() {
|
||||||
|
if(!_.isArray(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.indexOf(client.currentTheme.name) > -1;
|
||||||
|
},
|
||||||
|
TT : function isOneOfTermTypes() {
|
||||||
|
if(!_.isArray(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.indexOf(client.term.termType) > -1;
|
||||||
|
},
|
||||||
|
TW : function termWidth() {
|
||||||
|
return !isNaN(value) && client.term.termWidth >= value;
|
||||||
|
},
|
||||||
|
U : function isUserId(value) {
|
||||||
|
return user.userId === value;
|
||||||
|
},
|
||||||
|
W : function isOneOfDayOfWeek() {
|
||||||
|
// :TODO: return true if DoW
|
||||||
|
if(_.isNumber(value)) {
|
||||||
|
|
||||||
|
} else if(_.isArray(value)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
Y : function isMinutesPastMidnight() {
|
||||||
|
// :TODO: return true if value is >= minutes past midnight sys time
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}[name](value);
|
||||||
return value.indexOf(client.currentTheme.name) > -1;
|
} catch (e) {
|
||||||
},
|
client.log.warn( { name : name, value : value }, 'Invalid ACS string!');
|
||||||
TT : function isOneOfTermTypes() {
|
return false;
|
||||||
if(!_.isArray(value)) {
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value.indexOf(client.term.termType) > -1;
|
|
||||||
},
|
|
||||||
TW : function termWidth() {
|
|
||||||
return !isNaN(value) && client.term.termWidth >= value;
|
|
||||||
},
|
|
||||||
U : function isUserId(value) {
|
|
||||||
return user.userId === value;
|
|
||||||
},
|
|
||||||
W : function isOneOfDayOfWeek() {
|
|
||||||
// :TODO: return true if DoW
|
|
||||||
if(_.isNumber(value)) {
|
|
||||||
|
|
||||||
} else if(_.isArray(value)) {
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
Y : function isMinutesPastMidnight() {
|
|
||||||
// :TODO: return true if value is >= minutes past midnight sys time
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}[name](value) || false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,10 @@ function getConditionalValue(client, condArray, memberName) {
|
||||||
assert(_.isArray(condArray));
|
assert(_.isArray(condArray));
|
||||||
assert(_.isString(memberName));
|
assert(_.isString(memberName));
|
||||||
|
|
||||||
|
console.log(condArray)
|
||||||
|
|
||||||
condArray.forEach(function cond(c) {
|
condArray.forEach(function cond(c) {
|
||||||
if(acsParser.parse( { client : client }, c.acs)) {
|
if(acsParser.parse(c.acs, { client : client })) {
|
||||||
return c[memberName];
|
return c[memberName];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,88 +6,93 @@
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
|
|
||||||
function checkAccess(name, value) {
|
function checkAccess(name, value) {
|
||||||
return {
|
try {
|
||||||
'=' : function isLocalConnection() {
|
return {
|
||||||
return client.isLocal();
|
'=' : function isLocalConnection() {
|
||||||
},
|
return client.isLocal();
|
||||||
A : function ageGreaterOrEqualThan() {
|
},
|
||||||
return !isNaN(value) && user.getAge() >= value;
|
A : function ageGreaterOrEqualThan() {
|
||||||
},
|
return !isNaN(value) && user.getAge() >= value;
|
||||||
EC : function isEncoding() {
|
},
|
||||||
switch(value) {
|
EC : function isEncoding() {
|
||||||
case 0 : return 'cp437' === client.term.outputEncoding.toLowerCase();
|
switch(value) {
|
||||||
case 1 : return 'utf-8' === client.term.outputEncoding.toLowerCase();
|
case 0 : return 'cp437' === client.term.outputEncoding.toLowerCase();
|
||||||
default : return false;
|
case 1 : return 'utf-8' === client.term.outputEncoding.toLowerCase();
|
||||||
}
|
default : return false;
|
||||||
},
|
}
|
||||||
GM : function isOneOfGroups() {
|
},
|
||||||
if(!_.isArray(value)) {
|
GM : function isOneOfGroups() {
|
||||||
return false;
|
if(!_.isArray(value)) {
|
||||||
}
|
return false;
|
||||||
|
|
||||||
value.forEach(function grpEntry(groupName) {
|
|
||||||
if(user.isGroupMember(groupName)) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
value.forEach(function grpEntry(groupName) {
|
||||||
},
|
if(user.isGroupMember(groupName)) {
|
||||||
N : function isNode() {
|
return true;
|
||||||
return client.node === value;
|
}
|
||||||
},
|
});
|
||||||
P : function numberOfPosts() {
|
|
||||||
// :TODO: implement me!!!!
|
return false;
|
||||||
return false;
|
},
|
||||||
},
|
N : function isNode() {
|
||||||
Q : function numberOfCalls() {
|
return client.node === value;
|
||||||
// :TODO: implement me!!
|
},
|
||||||
return false;
|
P : function numberOfPosts() {
|
||||||
},
|
// :TODO: implement me!!!!
|
||||||
SC : function isSecerConnection() {
|
return false;
|
||||||
return client.session.isSecure;
|
},
|
||||||
},
|
Q : function numberOfCalls() {
|
||||||
T : function minutesLeft() {
|
// :TODO: implement me!!
|
||||||
// :TODO: implement me!
|
return false;
|
||||||
return false;
|
},
|
||||||
},
|
SC : function isSecerConnection() {
|
||||||
TH : function termHeight() {
|
return client.session.isSecure;
|
||||||
return !isNaN(value) && client.term.termHeight >= value;
|
},
|
||||||
},
|
T : function minutesLeft() {
|
||||||
TM : function isOneOfThemes() {
|
// :TODO: implement me!
|
||||||
if(!_.isArray(value)) {
|
return false;
|
||||||
|
},
|
||||||
|
TH : function termHeight() {
|
||||||
|
return !isNaN(value) && client.term.termHeight >= value;
|
||||||
|
},
|
||||||
|
TM : function isOneOfThemes() {
|
||||||
|
if(!_.isArray(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.indexOf(client.currentTheme.name) > -1;
|
||||||
|
},
|
||||||
|
TT : function isOneOfTermTypes() {
|
||||||
|
if(!_.isArray(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.indexOf(client.term.termType) > -1;
|
||||||
|
},
|
||||||
|
TW : function termWidth() {
|
||||||
|
return !isNaN(value) && client.term.termWidth >= value;
|
||||||
|
},
|
||||||
|
U : function isUserId(value) {
|
||||||
|
return user.userId === value;
|
||||||
|
},
|
||||||
|
W : function isOneOfDayOfWeek() {
|
||||||
|
// :TODO: return true if DoW
|
||||||
|
if(_.isNumber(value)) {
|
||||||
|
|
||||||
|
} else if(_.isArray(value)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
Y : function isMinutesPastMidnight() {
|
||||||
|
// :TODO: return true if value is >= minutes past midnight sys time
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}[name](value);
|
||||||
return value.indexOf(client.currentTheme.name) > -1;
|
} catch (e) {
|
||||||
},
|
client.log.warn( { name : name, value : value }, 'Invalid ACS string!');
|
||||||
TT : function isOneOfTermTypes() {
|
return false;
|
||||||
if(!_.isArray(value)) {
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value.indexOf(client.term.termType) > -1;
|
|
||||||
},
|
|
||||||
TW : function termWidth() {
|
|
||||||
return !isNaN(value) && client.term.termWidth >= value;
|
|
||||||
},
|
|
||||||
U : function isUserId(value) {
|
|
||||||
return user.userId === value;
|
|
||||||
},
|
|
||||||
W : function isOneOfDayOfWeek() {
|
|
||||||
// :TODO: return true if DoW
|
|
||||||
if(_.isNumber(value)) {
|
|
||||||
|
|
||||||
} else if(_.isArray(value)) {
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
Y : function isMinutesPastMidnight() {
|
|
||||||
// :TODO: return true if value is >= minutes past midnight sys time
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}[name](value) || false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +152,8 @@ acsCheck
|
||||||
= n:name a:arg { return checkAccess(n, a); }
|
= n:name a:arg { return checkAccess(n, a); }
|
||||||
|
|
||||||
name
|
name
|
||||||
= c:([A-Z\=][A-Z]?) { return c.join(''); }
|
= c:([A-Z][A-Z]) { return c.join(''); }
|
||||||
|
/ c:[A-Z\=]
|
||||||
|
|
||||||
argVar
|
argVar
|
||||||
= a:[A-Za-z0-9\-_\+]+ { return a.join('') }
|
= a:[A-Za-z0-9\-_\+]+ { return a.join('') }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue