diff --git a/app.js b/app.js index 02709deebc..8aa6197989 100755 --- a/app.js +++ b/app.js @@ -28,7 +28,9 @@ * Create new Ghost object * @type {Ghost} */ - ghost = new Ghost(); + ghost = new Ghost(), + ghostGlobals = ghost.globals(); + ghost.app().configure('development', function () { @@ -44,6 +46,9 @@ // bind locals - options which appear in every view - perhaps this should be admin only ghost.app().use(function (req, res, next) { res.locals.messages = req.flash(); + res.locals.siteTitle = ghostGlobals.title; + res.locals.siteDescription = ghostGlobals.description; + res.locals.siteUrl = ghostGlobals.url; next(); }); }); diff --git a/config.js b/config.js index 7792c4a6f6..86b2d6fd04 100644 --- a/config.js +++ b/config.js @@ -12,6 +12,15 @@ */ var config = {}; + + /** + * Blog settings + */ + config.blogData = { + url: 'http://local.tryghost.org', //'http://john.onolan.org', + title: "Ghost Development", + description: "Interactive designer, public speaker, startup advisor and writer. Living in Austria, attempting world domination via keyboard." + }; // ## Admin settings /** diff --git a/core/admin/views/default.hbs b/core/admin/views/default.hbs index 05deea33ed..9746870273 100644 --- a/core/admin/views/default.hbs +++ b/core/admin/views/default.hbs @@ -6,10 +6,9 @@ - Ghost - + {{siteTitle}} + - diff --git a/core/ghost.js b/core/ghost.js index 6912bb7aeb..fbd8dec330 100644 --- a/core/ghost.js +++ b/core/ghost.js @@ -19,10 +19,10 @@ bookshelfDataProvider = new BookshelfDataProvider(), ExampleFilter = require('../content/plugins/exampleFilters'), Ghost, - instance, statuses; + // ## Article Statuses /** * A list of atricle status types @@ -48,12 +48,18 @@ plugin, polyglot; + if (!instance) { instance = this; plugin = new ExampleFilter(instance).init(); - // Temporary loading of settings - jsonDataProvider.globals.findAll(function (error, data) { + /** + * Save the global bits here so that it can + * be reused in app.js + * @author javorszky (blame me) + */ + jsonDataProvider.save(config.blogData); + jsonDataProvider.findAll(function (error, data) { globals = data; }); diff --git a/core/shared/models/dataProvider.json.js b/core/shared/models/dataProvider.json.js index 993f911ffa..ef9ba6b704 100644 --- a/core/shared/models/dataProvider.json.js +++ b/core/shared/models/dataProvider.json.js @@ -9,43 +9,27 @@ var _ = require('underscore'), when = require('when'), DataProvider, - blogData, - instance, - d; - - blogData = { - url: 'http://localhost:3333', //'http://john.onolan.org', - title: "John O'Nolan", - description: "Interactive designer, public speaker, startup advisor and writer. Living in Austria, attempting world domination via keyboard." - }; + instance; DataProvider = function () { if (!instance) { instance = this; + _.extend(instance, { + data: [], + findAll: function(callback) { + callback(null, instance.data); + }, + save: function (globals) { + _.each(globals, function (global, key) { + instance.data[key] = global; + }, instance); + + return when(globals); + } + }); } return instance; }; - DataProvider.prototype.globals = {}; - DataProvider.prototype.globals.data = []; - - - DataProvider.prototype.globals.findAll = function () { - return when(this.data); - }; - - DataProvider.prototype.globals.save = function (globals) { - _.each(globals, function (global, key) { - this.data[key] = global; - }, this); - - return when(globals); - }; - - /* Lets bootstrap with dummy data */ - d = new DataProvider(); - d.globals.save(blogData, function (error) { - if (error) { throw error; } - }); module.exports = DataProvider; }()); \ No newline at end of file