summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-04-22 15:56:43 -0400
committerJules Laplace <jules@okfoc.us>2015-04-22 15:56:43 -0400
commitdcdab8238719d5f6515cf39b6ada31420f83b0de (patch)
tree9780be3cd8155407febf348b5f3271fe2078db9f
parente97ee16a8d9189437a79e1076f7e9ea249ccc9b2 (diff)
parent8d79bf977208b643b54de7abf56666844b934ef0 (diff)
Merge branch 'twohustlers' of github.com:okfocus/okcms into twohustlers
-rw-r--r--app/index.js3
-rw-r--r--app/node_modules/okschema/index.js12
-rw-r--r--themes/okadmin/templates/index.liquid3
-rw-r--r--themes/okadmin/templates/partials/inputs.liquid4
4 files changed, 19 insertions, 3 deletions
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({
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/index.liquid b/themes/okadmin/templates/index.liquid
index d25100f..e9ad538 100644
--- a/themes/okadmin/templates/index.liquid
+++ b/themes/okadmin/templates/index.liquid
@@ -17,7 +17,8 @@
{% for data in resource.data %}
<li>
<a href="{{resource.type}}/{{data.id}}/">{{data.title}}</a>
- <input class="resource-input" type="hidden" name="{{resource.type}}[{{forloop.index0}}]" value='{{data | stringify}}'>
+ <input class="resource-input" type="hidden" name="{{resource.type}}[{{forloop.index0}}]"
+ value='{{data | stringify | escape_once}}'>
</li>
{% endfor %}
</ol>
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' %}
<textarea
name="{{name}}">{{spec.value}}</textarea>
+ {% elsif type == 'number' %}
+ <input
+ type="number"
+ name="{{name}}" value="{{spec.value}}">
{% elsif type == 'enum' %}
<select
name="{{name}}">