mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
#73: Remap app.locals done
This commit is contained in:
parent
237af40f2e
commit
e7c0d13f7c
5 changed files with 40 additions and 37 deletions
7
app.js
7
app.js
|
@ -28,7 +28,9 @@
|
||||||
* Create new Ghost object
|
* Create new Ghost object
|
||||||
* @type {Ghost}
|
* @type {Ghost}
|
||||||
*/
|
*/
|
||||||
ghost = new Ghost();
|
ghost = new Ghost(),
|
||||||
|
ghostGlobals = ghost.globals();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ghost.app().configure('development', function () {
|
ghost.app().configure('development', function () {
|
||||||
|
@ -44,6 +46,9 @@
|
||||||
// bind locals - options which appear in every view - perhaps this should be admin only
|
// bind locals - options which appear in every view - perhaps this should be admin only
|
||||||
ghost.app().use(function (req, res, next) {
|
ghost.app().use(function (req, res, next) {
|
||||||
res.locals.messages = req.flash();
|
res.locals.messages = req.flash();
|
||||||
|
res.locals.siteTitle = ghostGlobals.title;
|
||||||
|
res.locals.siteDescription = ghostGlobals.description;
|
||||||
|
res.locals.siteUrl = ghostGlobals.url;
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,6 +12,15 @@
|
||||||
*/
|
*/
|
||||||
var config = {};
|
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
|
// ## Admin settings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,10 +6,9 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
|
||||||
<title>Ghost</title>
|
<title>{{siteTitle}}</title>
|
||||||
<meta name="description" content="">
|
<meta name="description" content="{{siteDescription}}">
|
||||||
<meta name="author" content="">
|
<meta name="author" content="">
|
||||||
|
|
||||||
<meta name="HandheldFriendly" content="True">
|
<meta name="HandheldFriendly" content="True">
|
||||||
<meta name="MobileOptimized" content="320">
|
<meta name="MobileOptimized" content="320">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
bookshelfDataProvider = new BookshelfDataProvider(),
|
bookshelfDataProvider = new BookshelfDataProvider(),
|
||||||
ExampleFilter = require('../content/plugins/exampleFilters'),
|
ExampleFilter = require('../content/plugins/exampleFilters'),
|
||||||
Ghost,
|
Ghost,
|
||||||
|
|
||||||
instance,
|
instance,
|
||||||
statuses;
|
statuses;
|
||||||
|
|
||||||
|
|
||||||
// ## Article Statuses
|
// ## Article Statuses
|
||||||
/**
|
/**
|
||||||
* A list of atricle status types
|
* A list of atricle status types
|
||||||
|
@ -48,12 +48,18 @@
|
||||||
plugin,
|
plugin,
|
||||||
polyglot;
|
polyglot;
|
||||||
|
|
||||||
|
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
instance = this;
|
instance = this;
|
||||||
plugin = new ExampleFilter(instance).init();
|
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;
|
globals = data;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,43 +9,27 @@
|
||||||
var _ = require('underscore'),
|
var _ = require('underscore'),
|
||||||
when = require('when'),
|
when = require('when'),
|
||||||
DataProvider,
|
DataProvider,
|
||||||
blogData,
|
instance;
|
||||||
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."
|
|
||||||
};
|
|
||||||
|
|
||||||
DataProvider = function () {
|
DataProvider = function () {
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
instance = this;
|
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;
|
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;
|
module.exports = DataProvider;
|
||||||
}());
|
}());
|
Loading…
Add table
Reference in a new issue