This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add 404 page. Prevent delete button from changing URL.

  • Loading branch information...
1 parent 42256e4 commit 3304d5ebd61ff7b721787bd46968861f6e1ad73d Karthik Viswanathan committed Jul 23, 2012
Showing with 26 additions and 5 deletions.
  1. +8 −0 lib/utils.js
  2. +1 −0 public/javascripts/prototype.js
  3. +4 −3 routes/index.js
  4. +5 −1 settings.js
  5. +1 −1 todo.txt
  6. +7 −0 views/not-found.jade
View
@@ -61,5 +61,13 @@ exports.updateObject = function(req, curObject, allowedFields) {
return false;
};
+/* Render a 404 response page.
+ * Requires: web request, web response
+ */
+exports.render404 = function(req, res) {
+ res.status(404);
+ res.render('not-found', { pageId: 'not-found' });
+};
+
/* No operation placeholder for empty callbacks */
exports.noop = function() {};
@@ -804,6 +804,7 @@ function NapkinClient(window, document, $, data, undefined) {
// remove element when delete button is clicked
removeElement: function(event) {
+ event.preventDefault();
this.layoutView.trigger('removeElement');
},
View
@@ -3,9 +3,10 @@ var screens = require('../lib/screens');
var components = require('../lib/components');
var elements = require('../lib/elements');
var users = require('../lib/users');
+var utils = require('../lib/utils');
module.exports = function(app, nconf, db) {
- app.get('/', function (req, res) {
+ app.get('/', function(req, res) {
if (req.session.email) {
delete req.session.sharedId;
res.render('index', {
@@ -83,7 +84,7 @@ module.exports = function(app, nconf, db) {
if (err) {
next(err);
} else if (!project) {
- next(new Error('Project could not be found.'));
+ utils.render404(req, res);
} else {
req.project = project;
@@ -103,7 +104,7 @@ module.exports = function(app, nconf, db) {
if (err) {
next(err);
} else if (!screen) {
- next(new Error('Screen could not be found.'));
+ utils.render404(req, res);
} else {
req.screen = screen;
View
@@ -1,3 +1,5 @@
+var utils = require('./lib/utils');
+
// Module dependencies.
module.exports = function(app, configurations, express) {
var clientSessions = require('client-sessions');
@@ -37,8 +39,10 @@ module.exports = function(app, configurations, express) {
}));
app.use(express.static(__dirname + '/public'));
-
app.use(app.router);
+
+ // last handler; assume 404 at this point
+ app.use(utils.render404);
});
app.configure('development, test', function(){
View
@@ -6,7 +6,6 @@
======================
- Validate action is an actual screen ID
-- 404 page for invalid projectId/screenId/etc.
- Should auth be implemented for screen sharing page?
- Improve sharing page sidebar
- Add links on sharing page for visibility and return to prototype
@@ -29,3 +28,4 @@
/ Permissions for editing project + screen
/ Ensure project and screen exist to prototype screen page
/ Add validation for projectId and screenId paramters in route
+/ 404 page for invalid projectId/screenId/etc.
View
@@ -0,0 +1,7 @@
+extend layout
+
+block sidebar
+ a.btn.btn-danger#back(href='/') ← Back to home
+
+ h2 Not Found
+ p The page you were looking for was not found. Please return to known territory by using your browser's back button or clicking the home link above.

0 comments on commit 3304d5e

Please sign in to comment.