Skip to content

Commit

Permalink
Minor code cleanup, docs and other bits & pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
ErisDS committed Aug 6, 2013
1 parent eac3047 commit 2f11f05
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 225 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ var path = require('path'),
"core/client/**/*.js"
],
"except": [
"!core/client/assets/**/*.js",
"!core/**/vendor/**/*.js",
"!core/client/tpl/**/*.js"
]
}
Expand Down
58 changes: 21 additions & 37 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,43 @@
// # Ghost Configuration

/**
* global module
**/
var path = require('path'),
config;

/**
* @module config
* @type {Object}
*/
config = {};
config = {};

// ## Admin settings

/**
* @property {string} defaultLang
*/
// Default language
config.defaultLang = 'en';

/**
* @property {boolean} forceI18n
*/
// Force i18n to be on
config.forceI18n = true;

// ## Themes

/**
* @property {string} themeDir
*/
// ## Themes & Plugins

// Themes
// Themes directory, relative to `content/`
config.themeDir = 'themes';

// Current active theme
/**
* @property {string} activeTheme
*/
config.activeTheme = 'casper';


// Current active plugins
config.activePlugins = [
'FancyFirstChar'
];

// Default Navigation Items
/**
* @property {Array} nav
*/
config.nav = [{
title: 'Home',
url: '/'
}];
// ## Default Navigation Items
// Add new objects here to extend the menu output by {{nav}}
config.nav = [
{
// Title is the text shown for this nav item
title: 'Home',
// Url can be a relative path, or external URL
url: '/'
}
// new items go here
];

// ## Environment
// **Warning:** Only change the settings below here if you are sure of what you are doing!
config.env = {
testing: {
database: {
Expand Down Expand Up @@ -80,6 +65,7 @@ config.env = {
}
},

// Default configuration
development: {
database: {
client: 'sqlite3',
Expand Down Expand Up @@ -123,7 +109,5 @@ config.env = {
}
};

/**
* @property {Object} exports
*/
// Export config
module.exports = config;
2 changes: 1 addition & 1 deletion content/themes/casper
38 changes: 16 additions & 22 deletions core/client/views/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
pane: options.pane,
model: this.model
}));

this.$('input').iCheck({
checkboxClass: 'icheckbox_ghost'
});
}
});

Expand Down Expand Up @@ -93,6 +89,10 @@
afterRender: function () {
this.$el.attr('id', this.id);
this.$el.addClass('active');

this.$('input').iCheck({
checkboxClass: 'icheckbox_ghost'
});
},
saveSuccess: function () {
Ghost.notifications.addItem({
Expand Down Expand Up @@ -143,9 +143,8 @@
},

afterRender: function () {
this.$el.attr('id', this.id);
this.$el.addClass('active');
this.$('.js-drop-zone').upload();
Settings.Pane.prototype.afterRender.call(this);
}
});

Expand Down Expand Up @@ -224,27 +223,22 @@
ne2password: ne2Password
},
success: function (msg) {

self.addSubview(new Ghost.Views.NotificationCollection({
model: [{
type: 'success',
message: msg.msg,
status: 'passive',
id: 'success-98'
}]
}));
Ghost.notifications.addItem({
type: 'success',
message: msg.msg,
status: 'passive',
id: 'success-98'
});
self.$('#user-password-old').val('');
self.$('#user-password-new').val('');
self.$('#user-new-password-verification').val('');
},
error: function (obj, string, status) {
self.addSubview(new Ghost.Views.NotificationCollection({
model: [{
type: 'error',
message: 'Invalid username or password',
status: 'passive'
}]
}));
Ghost.notifications.addItem({
type: 'error',
message: 'Invalid username or password',
status: 'passive'
});
}
});
},
Expand Down
76 changes: 16 additions & 60 deletions core/ghost.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// # Ghost Module
// Defines core methods required to build the frontend
// Defines core methods required to build the application

// ## Setup Prerequisites
// Module dependencies
var config = require('./../config'),
when = require('when'),
express = require('express'),
Expand All @@ -12,12 +12,11 @@ var config = require('./../config'),
nodefn = require('when/node/function'),
_ = require('underscore'),
Polyglot = require('node-polyglot'),

models = require('./server/models'),

plugins = require('./server/plugins'),

requireTree = require('./server/require-tree'),

// Variables
themePath = path.resolve(__dirname + '../../content/themes'),
pluginPath = path.resolve(__dirname + '../../content/plugins'),
themeDirectories = requireTree(themePath),
Expand Down Expand Up @@ -79,16 +78,12 @@ Ghost = function () {
// Holds the persistent notifications
instance.notifications = [];

// Holds the available plugins
instance.availablePlugins = {};

app = express();

polyglot = new Polyglot();

// functionality
// load Plugins...
// var f = new FancyFirstChar(ghost).init();

_.extend(instance, {
app: function () { return app; },
config: function () { return config; },
Expand Down Expand Up @@ -120,6 +115,7 @@ Ghost = function () {
return instance;
};

// Initialise the application
Ghost.prototype.init = function () {
var self = this;

Expand All @@ -130,6 +126,7 @@ Ghost.prototype.init = function () {
}, errors.logAndThrowError);
};

// Maintain the internal cache of the settings object
Ghost.prototype.updateSettingsCache = function (settings) {
var self = this;

Expand All @@ -154,12 +151,14 @@ Ghost.prototype.updateSettingsCache = function (settings) {

// ## Template utils

// Compile a template for a handlebars helper
Ghost.prototype.compileTemplate = function (templatePath) {
return nodefn.call(fs.readFile, templatePath).then(function (templateContents) {
return hbs.handlebars.compile(templateContents.toString());
}, errors.logAndThrowError);
};

// Load a template for a handlebars helper
Ghost.prototype.loadTemplate = function (name) {
var self = this,
templateFileName = name + '.hbs',
Expand All @@ -181,38 +180,12 @@ Ghost.prototype.loadTemplate = function (name) {
return deferred.promise;
};

/**
* @param {string} name
* @param {Function} fn
* @return {method} hbs.registerHelper
*/
// Register a handlebars helper for themes
Ghost.prototype.registerThemeHelper = function (name, fn) {
hbs.registerHelper(name, fn);
};

/**
* @param {string} name
* @param {Function} fn
* @return {*}
*/
Ghost.prototype.registerTheme = function (name, fn) {
return this;
};

/**
* @param {string} name
* @param {Function} fn
* @return {*}
*/
Ghost.prototype.registerPlugin = function (name, fn) {
return this;
};

/**
* @param {string} name
* @param {integer} priority
* @param {Function} fn
*/
// Register a new filter callback function
Ghost.prototype.registerFilter = function (name, priority, fn) {
// Curry the priority optional parameter to a default of 5
if (_.isFunction(priority)) {
Expand All @@ -226,11 +199,7 @@ Ghost.prototype.registerFilter = function (name, priority, fn) {
this.filterCallbacks[name][priority].push(fn);
};

/**
* @param {string} name
* @param {integer} priority
* @param {Function} fn
*/
// Unregister a filter callback function
Ghost.prototype.unregisterFilter = function (name, priority, fn) {
// Curry the priority optional parameter to a default of 5
if (_.isFunction(priority)) {
Expand All @@ -245,12 +214,7 @@ Ghost.prototype.unregisterFilter = function (name, priority, fn) {
}
};

/**
* @param {string} name [description]
* @param {*} args
* @param {Function} callback
* @return {method} callback
*/
// Execute filter functions in priority order
Ghost.prototype.doFilter = function (name, args, callback) {
var callbacks = this.filterCallbacks[name];

Expand Down Expand Up @@ -279,11 +243,7 @@ Ghost.prototype.doFilter = function (name, args, callback) {
callback(args);
};

/**
* Initialise plugins. Will load from config.activePlugins by default
*
* @param {Array} pluginsToLoad
*/
// Initialise plugins. Will load from config.activePlugins by default
Ghost.prototype.initPlugins = function (pluginsToLoad) {
pluginsToLoad = pluginsToLoad || config.activePlugins;

Expand All @@ -295,11 +255,7 @@ Ghost.prototype.initPlugins = function (pluginsToLoad) {
}, errors.logAndThrowError);
};

/**
* Initialise Theme
*
* @param {Object} app
*/
// Initialise Theme or admin
Ghost.prototype.initTheme = function (app) {
var self = this;
return function initTheme(req, res, next) {
Expand Down Expand Up @@ -329,4 +285,4 @@ Ghost.prototype.initTheme = function (app) {
// TODO: Expose the defaults for other people to see/manipulate as a static value?
// Ghost.defaults = defaults;

module.exports = Ghost;
module.exports = Ghost;
Loading

0 comments on commit 2f11f05

Please sign in to comment.