diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-06-09 16:53:02 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-06-09 16:53:02 -0400 |
| commit | 50046f0197c5ef3d997dd06e95f3dcd008a654f6 (patch) | |
| tree | 13199487b196a463e1fbff787405eb85905f1b25 | |
| parent | 1165ef5440e643252635aeea73a14cba0bb2e461 (diff) | |
edits
| -rw-r--r-- | public/assets/javascripts/vendor/ModalFormView.js | 10 | ||||
| -rw-r--r-- | server/lib/api.js | 3 | ||||
| -rw-r--r-- | server/lib/schemas/Documentation.js | 4 | ||||
| -rw-r--r-- | server/lib/schemas/User.js | 3 | ||||
| -rw-r--r-- | views/docs.ejs | 4 | ||||
| -rw-r--r-- | views/partials/edit-documentation.ejs (renamed from views/staff/edit-docs.ejs) | 0 | ||||
| -rw-r--r-- | views/partials/footer.ejs | 2 |
7 files changed, 18 insertions, 8 deletions
diff --git a/public/assets/javascripts/vendor/ModalFormView.js b/public/assets/javascripts/vendor/ModalFormView.js index 3ef7810..3cc2691 100644 --- a/public/assets/javascripts/vendor/ModalFormView.js +++ b/public/assets/javascripts/vendor/ModalFormView.js @@ -24,18 +24,21 @@ var ModalFormView = ModalView.extend({ showErrors: function(errors){ if (errors && errors.length) { - this.$errors.show(); + this.$errorList.empty(); for (var i in errors) { this.$errorList.append('<div>' + errors[i] + '</div>'); } + this.$errors.css("opacity", 1.0); + setTimeout($.proxy(function(){ + this.$errors.show().css("opacity", 1.0); + }, this), 200) } }, submit: function(e){ e.preventDefault() - this.$errors.hide(); - this.$errorList.empty(); + this.$errors.hide().css("opacity", 0.0); if (this.validate) { var errors = this.validate() @@ -74,7 +77,6 @@ var ModalFormView = ModalView.extend({ }); request.done($.proxy(function (response) { if (response.error) { - this.$errors.show(); var errors = [] for (var key in response.error.errors) { errors.push(response.error.errors[key].message); diff --git a/server/lib/api.js b/server/lib/api.js index 9a8a1fc..958c40d 100644 --- a/server/lib/api.js +++ b/server/lib/api.js @@ -86,7 +86,8 @@ var api = { create: function(req, res){ var data = util.cleanQuery(req.body) - data.name = data.new_name + data.name = util.sanitize(data.new_name) + data.displayName = util.sanitize(data.displayName) delete data.new_name new Documentation(data).save(function(err, doc){ if (err || ! doc) { return res.json({ error: err }) } diff --git a/server/lib/schemas/Documentation.js b/server/lib/schemas/Documentation.js index 35cf34f..0381e0b 100644 --- a/server/lib/schemas/Documentation.js +++ b/server/lib/schemas/Documentation.js @@ -2,6 +2,7 @@ var mongoose = require('mongoose'), + uniqueValidator = require('mongoose-unique-validator'), _ = require('lodash'), util = require('../util'); @@ -28,6 +29,7 @@ var DocumentationSchema = new mongoose.Schema({ updated_at: { type: Date }, }); +DocumentationSchema.plugin(uniqueValidator, { message: '{PATH} is already in use.' }) -module.exports = exports = mongoose.model('documentation', DocumentationSchema); +module.exports = exports = mongoose.model('documentation', DocumentationSchema) exports.schema = DocumentationSchema; diff --git a/server/lib/schemas/User.js b/server/lib/schemas/User.js index 5a93df2..9aa2add 100644 --- a/server/lib/schemas/User.js +++ b/server/lib/schemas/User.js @@ -1,6 +1,7 @@ /* jshint node: true */ var mongoose = require('mongoose'), + uniqueValidator = require('mongoose-unique-validator'), _ = require('lodash'), crypto = require('crypto'), config = require('../../../config.json'); @@ -63,6 +64,8 @@ var UserSchema = new mongoose.Schema({ last_ip: { type: Number }, }); +UserSchema.plugin(uniqueValidator, { message: '{PATH} is already taken.' }) + UserSchema.methods.validPassword = function (pw) { var shasum = crypto.createHash('sha1') shasum.update(pw) diff --git a/views/docs.ejs b/views/docs.ejs index 601f40f..fee5545 100644 --- a/views/docs.ejs +++ b/views/docs.ejs @@ -15,7 +15,7 @@ [[ if (user.isStaff) { ]] <a href="#" data-role="edit-document-modal" data-name="[[- doc.name ]]">Edit this document</a> - [[ include staff/edit-docs ]] + [[ include partials/edit-documentation ]] [[ } ]] <div class="content"> @@ -34,7 +34,7 @@ <p> <a href="#" data-role="new-document-modal" data-name="[[- doc.name ]]">Create this document</a> </p> - [[ include staff/edit-docs ]] + [[ include partials/edit-documentation ]] [[ } ]] [[ } ]] diff --git a/views/staff/edit-docs.ejs b/views/partials/edit-documentation.ejs index cecce10..cecce10 100644 --- a/views/staff/edit-docs.ejs +++ b/views/partials/edit-documentation.ejs diff --git a/views/partials/footer.ejs b/views/partials/footer.ejs index a40a873..1df179a 100644 --- a/views/partials/footer.ejs +++ b/views/partials/footer.ejs @@ -2,6 +2,8 @@ <a href="/about">About</a> <a href="/about/faq">FAQ</a> + <a href="/about/terms">Terms</a> + <a href="/about/privacy">Privacy</a> <span>©2014 VVALLS Inc.</span> |
