General cleanup

- Cleanup some todos, comments, and unused variables
This commit is contained in:
Hannah Wolfe 2014-01-19 21:08:39 +00:00
parent 9190257508
commit f185a5d616
15 changed files with 10 additions and 40 deletions

View File

@ -16,7 +16,6 @@
resp.draft = resp.status === 'draft'; resp.draft = resp.status === 'draft';
} }
if (resp.tags) { if (resp.tags) {
// TODO: parse tags into it's own collection on the model (this.tags)
return resp; return resp;
} }
return resp; return resp;

View File

@ -226,7 +226,6 @@
var saved = this.model.save(_.extend({ var saved = this.model.save(_.extend({
title: $('#entry-title').val(), title: $('#entry-title').val(),
// TODO: The content_raw getter here isn't great, shouldn't rely on currentView.
markdown: Ghost.currentView.getEditorValue() markdown: Ghost.currentView.getEditorValue()
}, data)); }, data));

View File

@ -114,7 +114,6 @@
saveSuccess: function (model, response, options) { saveSuccess: function (model, response, options) {
/*jslint unparam:true*/ /*jslint unparam:true*/
Ghost.notifications.clearEverything(); Ghost.notifications.clearEverything();
// TODO: better messaging here?
Ghost.notifications.addItem({ Ghost.notifications.addItem({
type: 'success', type: 'success',
message: 'Saved', message: 'Saved',
@ -140,8 +139,6 @@
} }
}); });
// TODO: use some kind of data-binding for forms
// ### General settings // ### General settings
Settings.general = Settings.Pane.extend({ Settings.general = Settings.Pane.extend({
id: "general", id: "general",

View File

@ -17,6 +17,7 @@ var _ = require('underscore'),
// ## Request Handlers // ## Request Handlers
function cacheInvalidationHeader(req, result) { function cacheInvalidationHeader(req, result) {
//TODO: don't set x-cache-invalidate header for drafts
var parsedUrl = req._parsedUrl.pathname.replace(/\/$/, '').split('/'), var parsedUrl = req._parsedUrl.pathname.replace(/\/$/, '').split('/'),
method = req.method, method = req.method,
endpoint = parsedUrl[4], endpoint = parsedUrl[4],

View File

@ -91,7 +91,6 @@ users = {
}, },
generateResetToken: function generateResetToken(email) { generateResetToken: function generateResetToken(email) {
// TODO: Do we want to be able to pass this in?
var expires = Date.now() + ONE_DAY; var expires = Date.now() + ONE_DAY;
return settings.read('dbHash').then(function (dbHash) { return settings.read('dbHash').then(function (dbHash) {
return dataProvider.User.generateResetToken(email, expires, dbHash); return dataProvider.User.generateResetToken(email, expires, dbHash);

View File

@ -1,7 +1,6 @@
var Store = require('express').session.Store, var Store = require('express').session.Store,
time12h = 12 * 60 * 60 * 1000, time12h = 12 * 60 * 60 * 1000,
BSStore, BSStore,
dataProvider,
db, db,
client; client;

View File

@ -12,7 +12,6 @@ var config = require('../config'),
adminControllers, adminControllers,
loginSecurity = []; loginSecurity = [];
// TODO: combine path/navClass to single "slug(?)" variable with no prefix
adminNavbar = { adminNavbar = {
content: { content: {
name: 'Content', name: 'Content',
@ -93,7 +92,7 @@ adminControllers = {
if (req.body.redirect) { if (req.body.redirect) {
redirect += decodeURIComponent(req.body.redirect); redirect += decodeURIComponent(req.body.redirect);
} }
// If this IP address successfully logins we // If this IP address successfully logs in we
// can remove it from the array of failed login attempts. // can remove it from the array of failed login attempts.
loginSecurity = _.reject(loginSecurity, function (ipTime) { loginSecurity = _.reject(loginSecurity, function (ipTime) {
return ipTime.ip === remoteAddress; return ipTime.ip === remoteAddress;
@ -212,7 +211,6 @@ adminControllers = {
}, function failure(error) { }, function failure(error) {
// TODO: This is kind of sketchy, depends on magic string error.message from Bookshelf. // TODO: This is kind of sketchy, depends on magic string error.message from Bookshelf.
// TODO: It's debatable whether we want to just tell the user we sent the email in this case or not, we are giving away sensitive info here.
if (error && error.message === 'EmptyResponse') { if (error && error.message === 'EmptyResponse') {
error.message = "Invalid email address"; error.message = "Invalid email address";
} }
@ -264,7 +262,6 @@ adminControllers = {
res.json(200, {redirect: config.paths().subdir + '/ghost/signin/'}); res.json(200, {redirect: config.paths().subdir + '/ghost/signin/'});
}); });
}).otherwise(function (err) { }).otherwise(function (err) {
// TODO: Better error message if we can tell whether the passwords didn't match or something
res.json(401, {error: err.message}); res.json(401, {error: err.message});
}); });
}, },
@ -318,9 +315,7 @@ adminControllers = {
}); });
}, },
'settings': function (req, res, next) { 'settings': function (req, res, next) {
// TODO: Centralise list/enumeration of settings panes, so we don't run into trouble in future.
// TODO: Centralise list/enumeration of settings panes, so we don't
// run into trouble in future.
var allowedSections = ['', 'general', 'user'], var allowedSections = ['', 'general', 'user'],
section = req.url.replace(/(^\/ghost\/settings[\/]*|\/$)/ig, ''); section = req.url.replace(/(^\/ghost\/settings[\/]*|\/$)/ig, '');
@ -333,7 +328,7 @@ adminControllers = {
adminNav: setSelected(adminNavbar, 'settings') adminNav: setSelected(adminNavbar, 'settings')
}); });
}, },
'debug': { /* ugly temporary stuff for managing the app before it's properly finished */ 'debug': {
index: function (req, res) { index: function (req, res) {
/*jslint unparam:true*/ /*jslint unparam:true*/
res.render('debug', { res.render('debug', {

View File

@ -14,7 +14,6 @@ var moment = require('moment'),
config = require('../config'), config = require('../config'),
errors = require('../errorHandling'), errors = require('../errorHandling'),
filters = require('../../server/filters'), filters = require('../../server/filters'),
coreHelpers = require('../helpers'),
frontendControllers; frontendControllers;
@ -77,9 +76,7 @@ frontendControllers = {
post = promises[1]; post = promises[1];
function render() { function render() {
// If we're ready to render the page // If we're ready to render the page but the last param is 'edit' then we'll send you to the edit page.
// but the last param is 'edit' then we'll
// actually kick you to the edit page.
if (req.params[2] && req.params[2] === 'edit') { if (req.params[2] && req.params[2] === 'edit') {
return res.redirect(config.paths().subdir + '/ghost/editor/' + post.id + '/'); return res.redirect(config.paths().subdir + '/ghost/editor/' + post.id + '/');
} }
@ -103,8 +100,7 @@ frontendControllers = {
} }
// A page can only be rendered when there is no date in the url. // A page can only be rendered when there is no date in the url.
// A post can either be rendered with a date in the url // A post can either be rendered with a date in the url depending on the permalink setting.
// depending on the permalink setting.
// For all other conditions return 404. // For all other conditions return 404.
if (post.page === 1 && dateInSlug === false) { if (post.page === 1 && dateInSlug === false) {
return render(); return render();
@ -141,7 +137,7 @@ frontendControllers = {
return res.redirect(config.paths().subdir + '/rss/'); return res.redirect(config.paths().subdir + '/rss/');
} }
//needs refact for multi user to not use first user as default // TODO: needs refactor for multi user to not use first user as default
return when.settle([ return when.settle([
api.users.read({id : 1}), api.users.read({id : 1}),
api.settings.read('title'), api.settings.read('title'),

View File

@ -1,7 +1,3 @@
// If no env is set, default to development
// This needs to be above all other require()
// modules to ensure config gets right setting.
// Module dependencies // Module dependencies
var crypto = require('crypto'), var crypto = require('crypto'),
express = require('express'), express = require('express'),
@ -75,8 +71,7 @@ function initDbHashAndFirstRun() {
} }
// Sets up the express server instance. // Sets up the express server instance.
// Instantiates the ghost singleton, // Instantiates the ghost singleton, helpers, routes, middleware, and plugins.
// helpers, routes, middleware, and plugins.
// Finally it starts the http server. // Finally it starts the http server.
function setup(server) { function setup(server) {

View File

@ -208,7 +208,6 @@ module.exports = function (server, dbHash) {
expressServer.use(subdir, express.favicon(corePath + '/shared/favicon.ico')); expressServer.use(subdir, express.favicon(corePath + '/shared/favicon.ico'));
// Static assets // Static assets
// For some reason send divides the max age number by 1000
expressServer.use(subdir + '/shared', express['static'](path.join(corePath, '/shared'), {maxAge: ONE_HOUR_MS})); expressServer.use(subdir + '/shared', express['static'](path.join(corePath, '/shared'), {maxAge: ONE_HOUR_MS}));
expressServer.use(subdir + '/content/images', storage.get_storage().serve()); expressServer.use(subdir + '/content/images', storage.get_storage().serve());
expressServer.use(subdir + '/ghost/scripts', express['static'](path.join(corePath, '/built/scripts'), {maxAge: ONE_YEAR_MS})); expressServer.use(subdir + '/ghost/scripts', express['static'](path.join(corePath, '/built/scripts'), {maxAge: ONE_YEAR_MS}));
@ -254,11 +253,9 @@ module.exports = function (server, dbHash) {
cookie: cookie cookie: cookie
})); }));
// enable express csrf protection // enable express csrf protection
expressServer.use(middleware.conditionalCSRF); expressServer.use(middleware.conditionalCSRF);
// local data // local data
expressServer.use(ghostLocals); expressServer.use(ghostLocals);
// So on every request we actually clean out redundant passive notifications from the server side // So on every request we actually clean out redundant passive notifications from the server side

View File

@ -57,7 +57,6 @@ var middleware = {
// Authenticate a request to the API by responding with a 401 and json error details // Authenticate a request to the API by responding with a 401 and json error details
authAPI: function (req, res, next) { authAPI: function (req, res, next) {
if (!req.session.user) { if (!req.session.user) {
// TODO: standardize error format/codes/messages
res.json(401, { error: 'Please sign in' }); res.json(401, { error: 'Please sign in' });
return; return;
} }

View File

@ -5,7 +5,6 @@ var admin = require('../controllers/admin'),
module.exports = function (server) { module.exports = function (server) {
var subdir = config.paths().subdir; var subdir = config.paths().subdir;
// ### Admin routes // ### Admin routes
/* TODO: put these somewhere in admin */
server.get('/logout/', function redirect(req, res) { server.get('/logout/', function redirect(req, res) {
/*jslint unparam:true*/ /*jslint unparam:true*/
res.redirect(301, subdir + '/ghost/signout/'); res.redirect(301, subdir + '/ghost/signout/');

View File

@ -3,7 +3,6 @@ var middleware = require('../middleware').middleware,
module.exports = function (server) { module.exports = function (server) {
// ### API routes // ### API routes
/* TODO: auth should be public auth not user auth */
// #### Posts // #### Posts
server.get('/ghost/api/v0.1/posts', middleware.authAPI, api.requestHandler(api.posts.browse)); server.get('/ghost/api/v0.1/posts', middleware.authAPI, api.requestHandler(api.posts.browse));
server.post('/ghost/api/v0.1/posts', middleware.authAPI, api.requestHandler(api.posts.add)); server.post('/ghost/api/v0.1/posts', middleware.authAPI, api.requestHandler(api.posts.add));

View File

@ -193,7 +193,6 @@ describe('Post API', function () {
headers: {'X-CSRF-Token': csrfToken}, headers: {'X-CSRF-Token': csrfToken},
json: newPost}, function (error, response, draftPost) { json: newPost}, function (error, response, draftPost) {
response.should.have.status(200); response.should.have.status(200);
//TODO: do drafts really need a x-cache-invalidate header
response.should.be.json; response.should.be.json;
draftPost.should.exist; draftPost.should.exist;
draftPost.title.should.eql(newTitle); draftPost.title.should.eql(newTitle);
@ -308,7 +307,7 @@ describe('Post API', function () {
headers: {'X-CSRF-Token': csrfToken}, headers: {'X-CSRF-Token': csrfToken},
json: newPost}, function (error, response, draftPost) { json: newPost}, function (error, response, draftPost) {
response.should.have.status(200); response.should.have.status(200);
//TODO: do drafts really need a x-cache-invalidate header
response.should.be.json; response.should.be.json;
draftPost.should.exist; draftPost.should.exist;
draftPost.title.should.eql(newTitle); draftPost.title.should.eql(newTitle);
@ -317,7 +316,6 @@ describe('Post API', function () {
request.del({uri: testUtils.API.getApiURL('posts/' + draftPost.id + '/'), request.del({uri: testUtils.API.getApiURL('posts/' + draftPost.id + '/'),
headers: {'X-CSRF-Token': csrfToken}}, function (error, response, body) { headers: {'X-CSRF-Token': csrfToken}}, function (error, response, body) {
response.should.have.status(200); response.should.have.status(200);
//TODO: do drafts really need a x-cache-invalidate header
response.should.be.json; response.should.be.json;
var jsonResponse = JSON.parse(body); var jsonResponse = JSON.parse(body);
jsonResponse.should.exist; jsonResponse.should.exist;

View File

@ -124,8 +124,6 @@ describe('Local File System Storage', function () {
describe('on Windows', function () { describe('on Windows', function () {
// TODO tests to check for working on windows
var truePathSep = path.sep; var truePathSep = path.sep;
beforeEach(function () { beforeEach(function () {