WIP open file for a while
This commit is contained in:
parent
f937019e42
commit
d280fb9af3
122 changed files with 5702 additions and 10 deletions
24
lib/plugin/auto/tentity/auto-tentity-tcode.js
Normal file
24
lib/plugin/auto/tentity/auto-tentity-tcode.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
module.exports = (function () {
|
||||
|
||||
var filterCode = function(ctx,value) {
|
||||
return ctx.filterValue(value,[' ','_','-','.',','],'',function (part) {
|
||||
return part.toLowerCase();
|
||||
});
|
||||
}
|
||||
|
||||
return function AutoTEntityTCodePlugin() {
|
||||
|
||||
this.configPlugin = function (ctx) {
|
||||
ctx.key='autoTEntityTCode';
|
||||
ctx.description='Fills and filters tcode to be code-safe for generating variables/functions.';
|
||||
};
|
||||
|
||||
this.fillTEntity = function(ctx) {
|
||||
if (ctx.tentity.tcode === null || ctx.tentity.tcode === null) {
|
||||
ctx.tentity.tcode = ctx.tentity.tid;
|
||||
}
|
||||
ctx.tentity.tcode = filterCode(ctx,ctx.tentity.tcode);
|
||||
};
|
||||
};
|
||||
})();
|
||||
29
lib/plugin/auto/tentity/auto-tentity-tkey.js
Normal file
29
lib/plugin/auto/tentity/auto-tentity-tkey.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
module.exports = (function () {
|
||||
|
||||
var makeTKey = function(ctx) {
|
||||
var keySlug = '';
|
||||
for (var i = 0; i < ctx.tentity.tmeta.tmodel.tkeys.length; i++) {
|
||||
var key = ctx.tentity.tmeta.tmodel.tkeys[i];
|
||||
keySlug += ':'+key;
|
||||
if (i < (ctx.tentity.tmeta.tmodel.tkeys.length - 1)) {
|
||||
keySlug += '/';
|
||||
}
|
||||
}
|
||||
return keySlug;
|
||||
};
|
||||
|
||||
return function AutoTEntityTKeyPlugin() {
|
||||
|
||||
this.configPlugin = function (ctx) {
|
||||
ctx.key='autoTEntityTKey';
|
||||
ctx.description='Auto creates the tmode.tkey parameter slug.';
|
||||
};
|
||||
|
||||
this.fillTEntity = function(ctx) {
|
||||
if (ctx.tentity.tmeta.tmodel.tkey === null) {
|
||||
ctx.tentity.tmeta.tmodel.tkey = makeTKey(ctx);
|
||||
}
|
||||
};
|
||||
};
|
||||
})();
|
||||
32
lib/plugin/auto/tentity/auto-tentity-tplural.js
Normal file
32
lib/plugin/auto/tentity/auto-tentity-tplural.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
module.exports = (function () {
|
||||
|
||||
var makePlural = function(name) {
|
||||
if (name.slice(-1) === 's') {
|
||||
return name;
|
||||
}
|
||||
if (name.slice(-1) === 'y') {
|
||||
name = name.slice(0,-1) + 'ie';
|
||||
}
|
||||
return name + 's';
|
||||
}
|
||||
|
||||
return function AutoTEntityTPluralPlugin() {
|
||||
|
||||
this.configPlugin = function (ctx) {
|
||||
ctx.key='autoTEntityTPlural';
|
||||
ctx.description='Auto create tplurals from the tname/tid field.';
|
||||
ctx.dependencies.push('autoTName');
|
||||
};
|
||||
|
||||
this.fillTEntity = function(ctx) {
|
||||
if (ctx.tentity.tplural === null) {
|
||||
if (ctx.tentity.tname === null) {
|
||||
ctx.tentity.tplural = makePlural(ctx.tentity.tid);
|
||||
} else {
|
||||
ctx.tentity.tplural = makePlural(ctx.tentity.tname);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue