From a27392f8903a90fc89a76f7903f8d76cc9ce7fcf Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Thu, 16 Apr 2015 21:40:28 -0400 Subject: Add debug flag to meta info --- app/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/index.js b/app/index.js index d487bd7..5ac88dd 100644 --- a/app/index.js +++ b/app/index.js @@ -40,7 +40,8 @@ function OKCMS(options) { var metaUser = options.meta || {}; var metaDefault = { - project: 'OKCMS' + project: 'OKCMS', + debug: debug }; var meta = assign({ -- cgit v1.2.3-70-g09d2 From 43063c3242ccaf95e39fff240d501de38131f7c5 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Thu, 16 Apr 2015 23:38:16 -0400 Subject: Add number type support --- app/node_modules/okschema/index.js | 12 +++++++++++- themes/okadmin/templates/partials/inputs.liquid | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/node_modules/okschema/index.js b/app/node_modules/okschema/index.js index d53ed7b..c5a56c4 100644 --- a/app/node_modules/okschema/index.js +++ b/app/node_modules/okschema/index.js @@ -68,6 +68,9 @@ var types = { * OKSchema! * Meant as a thin wrapper around some existing schema validation * module, mostly to allow for the extension of types. + * + * NOTE: Currently just assumes spec is valid. If you give a bad spec + * strange things may or may not happen */ function OKSchema(spec) { if (!(this instanceof OKSchema)) return new OKSchema(spec); @@ -138,11 +141,18 @@ OKSchema.prototype.assertValid = function(data) { var type = spec[prop].type; if (types[type]) { types[type].assertValid(spec[prop], data[prop]); + // Also check if it's a number type and try to cast it + // otherwise pass and let mschema handle + } else if (type === 'number') { + try { + data[prop] = parseFloat(data[prop]); + } catch (err) {} } }); var result = mschema.validate(data, this.toMschema()); - if (!result.valid) + if (!result.valid) { throw result.errors; + } }; /** diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid index c9a4d92..4d31413 100644 --- a/themes/okadmin/templates/partials/inputs.liquid +++ b/themes/okadmin/templates/partials/inputs.liquid @@ -12,6 +12,10 @@ {% elsif type == 'text' %} + {% elsif type == 'number' %} + {% elsif type == 'enum' %}