mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
#73: Remap app.locals done
This commit is contained in:
parent
237af40f2e
commit
e7c0d13f7c
7
app.js
7
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();
|
||||
});
|
||||
});
|
||||
|
@ -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
|
||||
|
||||
/**
|
||||
|
@ -6,10 +6,9 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Ghost</title>
|
||||
<meta name="description" content="">
|
||||
<title>{{siteTitle}}</title>
|
||||
<meta name="description" content="{{siteDescription}}">
|
||||
<meta name="author" content="">
|
||||
|
||||
<meta name="HandheldFriendly" content="True">
|
||||
<meta name="MobileOptimized" content="320">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
@ -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;
|
||||
});
|
||||
|
||||
|
@ -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;
|
||||
}());
|
Loading…
Reference in New Issue
Block a user