From 50046f0197c5ef3d997dd06e95f3dcd008a654f6 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 9 Jun 2014 16:53:02 -0400 Subject: edits --- public/assets/javascripts/vendor/ModalFormView.js | 10 +++--- server/lib/api.js | 3 +- server/lib/schemas/Documentation.js | 4 ++- server/lib/schemas/User.js | 3 ++ views/docs.ejs | 4 +-- views/partials/edit-documentation.ejs | 42 +++++++++++++++++++++++ views/partials/footer.ejs | 2 ++ views/staff/edit-docs.ejs | 42 ----------------------- 8 files changed, 60 insertions(+), 50 deletions(-) create mode 100644 views/partials/edit-documentation.ejs delete mode 100644 views/staff/edit-docs.ejs 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('
' + errors[i] + '
'); } + 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) { ]] Edit this document - [[ include staff/edit-docs ]] + [[ include partials/edit-documentation ]] [[ } ]]
@@ -34,7 +34,7 @@

Create this document

- [[ include staff/edit-docs ]] + [[ include partials/edit-documentation ]] [[ } ]] [[ } ]] diff --git a/views/partials/edit-documentation.ejs b/views/partials/edit-documentation.ejs new file mode 100644 index 0000000..cecce10 --- /dev/null +++ b/views/partials/edit-documentation.ejs @@ -0,0 +1,42 @@ +
+ X +
+ +
+ + +
    +
  • +

    Documentation

    +
  • + +
  • + +
    + +
    +
  • + +
  • + +
    + +
    +
  • + +
  • + + +
  • + +
  • + +
  • +
    +
    There was a problem with your submission:
    +
    +
    +
+
+
+
\ No newline at end of file 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 @@ About FAQ + Terms + Privacy ©2014 VVALLS Inc. diff --git a/views/staff/edit-docs.ejs b/views/staff/edit-docs.ejs deleted file mode 100644 index cecce10..0000000 --- a/views/staff/edit-docs.ejs +++ /dev/null @@ -1,42 +0,0 @@ -
- X -
- -
- - -
    -
  • -

    Documentation

    -
  • - -
  • - -
    - -
    -
  • - -
  • - -
    - -
    -
  • - -
  • - - -
  • - -
  • - -
  • -
    -
    There was a problem with your submission:
    -
    -
    -
-
-
-
\ No newline at end of file -- cgit v1.2.3-70-g09d2