0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

added ghost_head and ghost_foot helpers

closes #382, closes #383

 - added helper called ghost_head to insert meta data with current version of ghost
 - added helper called ghost_foot to insert script tag for jquery
 - added unit test for both helpers
 - removed trailing slash from ghost.js for 'shared' path and removed from outside of loop as it is shared on front and backend
This commit is contained in:
cobbspur 2013-08-25 14:19:27 +01:00
parent b9f43aecf4
commit 00d36e976d
3 changed files with 43 additions and 2 deletions

View file

@ -301,10 +301,9 @@ Ghost.prototype.initTheme = function (app) {
app.set('views', self.paths().adminViews);
app.use('/public', express['static'](path.join(__dirname, '/client/assets')));
app.use('/public', express['static'](path.join(__dirname, '/client')));
app.use('/shared', express['static'](path.join(__dirname, '/shared/')));
}
app.use(express['static'](self.paths().activeTheme));
app.use('/shared', express['static'](path.join(__dirname, '/shared')));
app.use('/content/images', express['static'](path.join(__dirname, '/../content/images')));
next();
};

View file

@ -127,7 +127,25 @@ coreHelpers = function (ghost) {
});
});
ghost.registerThemeHelper('ghost_head', function (options) {
var head = [];
head.push('<meta name="generator" content="Ghost ' + this.version + '" />');
return ghost.doFilter('ghost_head', head, function (head) {
var headString = _.reduce(head, function (memo, item) { return memo + ' ' + item; }, '');
return new hbs.handlebars.SafeString(headString.trim());
});
});
ghost.registerThemeHelper('ghost_foot', function (options) {
var foot = [];
foot.push('<script src="/shared/vendor/jquery/jquery.js"></script>');
return ghost.doFilter('ghost_foot', foot, function (foot) {
var footString = _.reduce(foot, function (memo, item) { return memo + ' ' + item; }, '');
return new hbs.handlebars.SafeString(footString.trim());
});
});
/**
* [ description]
*

View file

@ -177,6 +177,30 @@ describe('Core Helpers', function () {
});
});
describe('ghost_head Helper', function () {
it('has loaded ghost_head helper', function () {
should.exist(handlebars.helpers.ghost_head);
});
it('returns meta tag string', function () {
var rendered = handlebars.helpers.ghost_head.call({version: "0.3"});
should.exist(rendered);
rendered.string.should.equal('<meta name="generator" content="Ghost 0.3" />');
});
});
describe('ghost_foot Helper', function () {
it('has loaded ghost_foot helper', function () {
should.exist(handlebars.helpers.ghost_foot);
});
it('returns meta tag string', function () {
var rendered = handlebars.helpers.ghost_foot.call();
should.exist(rendered);
rendered.string.should.equal('<script src="/shared/vendor/jquery/jquery.js"></script>');
});
});
describe('Navigation Helper', function () {
it('has loaded nav helper', function () {