From 199d15133b0605e36553ed6d1bf56e2592ab2418 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Tue, 25 Jun 2013 22:44:34 +0100 Subject: [PATCH] Navigation Helper - renamed helper from ghostNav to nav and file from ghostNav to navigation - switched template to use current-menu-item as per the styles - cleaned up several unused items from config, and removed default link to admin - updated tests --- config.js | 32 ++++--------------- core/frontend/helpers/index.js | 2 +- .../helpers/{ghostNav.js => navigation.js} | 16 +++++----- core/frontend/views/nav.hbs | 2 +- .../ghost/frontend_helpers_ghostNav_spec.js | 12 +++---- 5 files changed, 23 insertions(+), 41 deletions(-) rename core/frontend/helpers/{ghostNav.js => navigation.js} (72%) diff --git a/config.js b/config.js index a4e334b25e..bde0e1806c 100644 --- a/config.js +++ b/config.js @@ -33,27 +33,20 @@ config.forceI18n = true; // Themes config.themeDir = 'themes'; +// Current active theme /** * @property {string} activeTheme */ config.activeTheme = 'casper'; -// ## Homepage settings +// Default Navigation Items /** - * @module homepage - * @type {Object} + * @property {Array} nav */ -config.homepage = {}; - -/** - * @property {number} features - */ -config.homepage.features = 1; - -/** - * @property {number} posts - */ -config.homepage.posts = 4; +config.nav = [{ + title: 'Home', + url: '/' +}]; config.database = { testing: { @@ -85,17 +78,6 @@ config.database = { production: {} }; -/** - * @property {Array} nav - */ -config.nav = [{ - title: 'Home', - url: '/' -}, { - title: 'Admin', - url: '/ghost' -}]; - /** * @property {Object} exports */ diff --git a/core/frontend/helpers/index.js b/core/frontend/helpers/index.js index 60feffdde0..fd9b729125 100644 --- a/core/frontend/helpers/index.js +++ b/core/frontend/helpers/index.js @@ -2,7 +2,7 @@ var _ = require('underscore'), moment = require('moment'), when = require('when'), pagination = require('./paginate'), - navHelper = require('./ghostNav'), + navHelper = require('./navigation'), hbs = require('express-hbs'), coreHelpers; diff --git a/core/frontend/helpers/ghostNav.js b/core/frontend/helpers/navigation.js similarity index 72% rename from core/frontend/helpers/ghostNav.js rename to core/frontend/helpers/navigation.js index c821b0dc26..f88573d440 100644 --- a/core/frontend/helpers/ghostNav.js +++ b/core/frontend/helpers/navigation.js @@ -3,9 +3,9 @@ var fs = require('fs'), _ = require('underscore'), handlebars = require('express-hbs').handlebars, nodefn = require('when/node/function'), - GhostNavHelper; + NavHelper; -GhostNavHelper = function (navTemplate) { +NavHelper = function (navTemplate) { // Bind the context for our methods. _.bindAll(this, 'compileTemplate', 'renderNavItems'); @@ -16,7 +16,7 @@ GhostNavHelper = function (navTemplate) { } }; -GhostNavHelper.prototype.compileTemplate = function (templatePath) { +NavHelper.prototype.compileTemplate = function (templatePath) { var self = this; // Allow people to overwrite the navTemplatePath @@ -28,7 +28,7 @@ GhostNavHelper.prototype.compileTemplate = function (templatePath) { }); }; -GhostNavHelper.prototype.renderNavItems = function (navItems) { +NavHelper.prototype.renderNavItems = function (navItems) { var output; output = this.navTemplateFunc({links: navItems}); @@ -37,13 +37,13 @@ GhostNavHelper.prototype.renderNavItems = function (navItems) { }; // A static helper method for registering with ghost -GhostNavHelper.registerWithGhost = function (ghost) { +NavHelper.registerWithGhost = function (ghost) { var templatePath = path.join(ghost.paths().frontendViews, 'nav.hbs'), - ghostNavHelper = new GhostNavHelper(templatePath); + ghostNavHelper = new NavHelper(templatePath); return ghostNavHelper.compileTemplate().then(function () { - ghost.registerThemeHelper("ghostNav", ghostNavHelper.renderNavItems); + ghost.registerThemeHelper("nav", ghostNavHelper.renderNavItems); }); }; -module.exports = GhostNavHelper; \ No newline at end of file +module.exports = NavHelper; \ No newline at end of file diff --git a/core/frontend/views/nav.hbs b/core/frontend/views/nav.hbs index 72b01d6977..b53b58728b 100644 --- a/core/frontend/views/nav.hbs +++ b/core/frontend/views/nav.hbs @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/core/test/ghost/frontend_helpers_ghostNav_spec.js b/core/test/ghost/frontend_helpers_ghostNav_spec.js index 7311b47a05..a044b0b78d 100644 --- a/core/test/ghost/frontend_helpers_ghostNav_spec.js +++ b/core/test/ghost/frontend_helpers_ghostNav_spec.js @@ -3,15 +3,15 @@ var should = require('should'), sinon = require('sinon'), _ = require('underscore'), path = require('path'), - GhostNavHelper = require('../../frontend/helpers/ghostNav'); + NavHelper = require('../../frontend/helpers/navigation'); -describe('ghostNav Helper', function () { +describe('Navigation Helper', function () { var navTemplatePath = path.join(process.cwd(), 'core/frontend/views/nav.hbs'); - should.exist(GhostNavHelper, "GhostNavHelper exists"); + should.exist(NavHelper, "Navigation helper exists"); it('can compile the nav template', function (done) { - var helper = new GhostNavHelper(navTemplatePath); + var helper = new NavHelper(navTemplatePath); helper.compileTemplate().then(function () { should.exist(helper.navTemplateFunc); @@ -22,7 +22,7 @@ describe('ghostNav Helper', function () { }); it('can render nav items', function () { - var helper = new GhostNavHelper(function (data) { return "rendered " + data.links.length; }), + var helper = new NavHelper(function (data) { return "rendered " + data.links.length; }), templateSpy = sinon.spy(helper, 'navTemplateFunc'), fakeNavItems = [{ title: 'test1', @@ -56,7 +56,7 @@ describe('ghostNav Helper', function () { }, registerStub = sinon.stub(fakeGhost, 'registerThemeHelper'); - GhostNavHelper.registerWithGhost(fakeGhost).then(function () { + NavHelper.registerWithGhost(fakeGhost).then(function () { registerStub.called.should.equal(true); done();