Skip to content

Commit

Permalink
Modified how the default controller and its views work.
Browse files Browse the repository at this point in the history
  • Loading branch information
roncli committed Feb 26, 2015
1 parent bc1e966 commit 77b2c86
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 258 deletions.
15 changes: 8 additions & 7 deletions roncli.com/app/controllers/default_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
/**
* The default view.
* @param {object} params The parameters to use in the controller.
* @param {function((null | object), object=)} callback The callback to run upon completion of the controller running.
* @param {function} callback The callback to run upon completion of the controller running.
*/
index: function(params, callback) {
"use strict";
Expand All @@ -21,28 +21,29 @@ module.exports = {
}

if (err) {
result = {error: true};
if (err.status) {
// This is a known error.
if (app && app.req && app.req.res) {
app.req.res.status(err.status);
}

result["status" + err.status] = true;
callback(null, result);
if (err.status === 404) {
callback(null, "error/404", result);
} else {
callback(null, "error/other", result);
}
return;
}

// This is an unknown error.
if (app && app.req && app.req.res) {
app.req.res.status(500);
}
callback(null, result);
callback(null, "error/other", result);
return;
}

// This matched a page.
result.error = false;
if (app.req) {
page = result.page.get("page");
content = page.content.replace("\n", " ").replace("\r", " ").replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
Expand All @@ -68,7 +69,7 @@ module.exports = {
};
}

callback(err, result);
callback(err, "page/index", result);
});
}
};
2 changes: 1 addition & 1 deletion roncli.com/app/controllers/music_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module.exports = {
app.fetch({
page: {model: "PageOptional", params: {url: "/" + params[0]}},
song: {model: "Song_GetFromUrl", params: {url: "/" + params[0]}}
}, function(err, result) {
}, function(err, result) {console.log(app);
var content;

if (app.req) {
Expand Down
9 changes: 0 additions & 9 deletions roncli.com/app/templates/default/index.hbs

This file was deleted.

241 changes: 0 additions & 241 deletions roncli.com/app/views/default/index.js

This file was deleted.

9 changes: 9 additions & 0 deletions roncli.com/app/views/error/404.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*global bootbox*/
var BaseView = require("rendr/shared/base/view");

// Sets up the 404 view.
module.exports = BaseView.extend({
className: "error_404_view"
});

module.exports.id = "error/404";
9 changes: 9 additions & 0 deletions roncli.com/app/views/error/other.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*global bootbox*/
var BaseView = require("rendr/shared/base/view");

// Sets up the other error view.
module.exports = BaseView.extend({
className: "error_other_view"
});

module.exports.id = "error/other";
Loading

0 comments on commit 77b2c86

Please sign in to comment.