2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Merge branch 'master' of github.com:javorszky/Ghost into javorszky-master

Conflicts:
	app.js
This commit is contained in:
ErisDS 2013-05-29 08:26:57 +01:00
commit 077c602d61
7 changed files with 76 additions and 26 deletions

3
app.js
View file

@ -30,6 +30,7 @@
*/ */
ghost = new Ghost(); ghost = new Ghost();
ghost.app().configure('development', function () { ghost.app().configure('development', function () {
ghost.app().use(express.favicon(__dirname + '/content/images/favicon.ico')); ghost.app().use(express.favicon(__dirname + '/content/images/favicon.ico'));
ghost.app().use(express.errorHandler({ dumpExceptions: true, showStack: true })); ghost.app().use(express.errorHandler({ dumpExceptions: true, showStack: true }));
@ -119,7 +120,7 @@
ghost.app().post('/ghost/register/', admin.doRegister); ghost.app().post('/ghost/register/', admin.doRegister);
ghost.app().get('/ghost/editor/:id', auth, admin.editor); ghost.app().get('/ghost/editor/:id', auth, admin.editor);
ghost.app().get('/ghost/editor', auth, admin.editor); ghost.app().get('/ghost/editor', auth, admin.editor);
ghost.app().get('/ghost/blog', auth, admin.blog); ghost.app().get('/ghost/content', auth, admin.content);
ghost.app().get('/ghost/settings', auth, admin.settings); ghost.app().get('/ghost/settings', auth, admin.settings);
ghost.app().get('/ghost/debug', auth, admin.debug.index); ghost.app().get('/ghost/debug', auth, admin.debug.index);
ghost.app().get('/ghost/debug/db/delete/', auth, admin.debug.dbdelete); ghost.app().get('/ghost/debug/db/delete/', auth, admin.debug.dbdelete);

View file

@ -0,0 +1,27 @@
(function(){
"use strict";
/**
* Because I didn't want to write over FancyFirstChar
*/
var ExampleFilter;
var ExampleFilter = function(ghost){
this.ghost = function() {
return ghost;
}
}
ExampleFilter.prototype.init = function() {
this.ghost().registerFilter('messWithAdmin', function(adminNavbar){
console.log('adminnavbar settings run');
delete adminNavbar.add;
return adminNavbar;
});
};
module.exports = ExampleFilter;
}());

View file

@ -9,6 +9,7 @@
return ghost; return ghost;
}; };
}; };
FancyFirstChar.prototype.init = function () { FancyFirstChar.prototype.init = function () {
this.ghost().registerFilter('prePostsRender', function (posts) { this.ghost().registerFilter('prePostsRender', function (posts) {
var post, var post,
@ -41,5 +42,7 @@
FancyFirstChar.prototype.activate = function () {}; FancyFirstChar.prototype.activate = function () {};
FancyFirstChar.prototype.deactivate = function () {}; FancyFirstChar.prototype.deactivate = function () {};
module.exports = FancyFirstChar; module.exports = FancyFirstChar;
}()); }());

View file

@ -17,32 +17,36 @@
name: 'Dashboard', name: 'Dashboard',
navClass: 'dashboard', navClass: 'dashboard',
key: 'admin.navbar.dashboard', key: 'admin.navbar.dashboard',
defaultString: 'dashboard', // defaultString: 'dashboard',
path: '' path: '/'
}, },
blog: { content: {
name: 'Content', name: 'Content',
navClass: 'content', navClass: 'content',
key: 'admin.navbar.blog', key: 'admin.navbar.content',
defaultString: 'blog', // defaultString: 'content',
path: '/blog' path: '/content/'
}, },
add: { add: {
name: 'New Post', name: 'New Post',
navClass: 'editor', navClass: 'editor',
key: 'admin.navbar.editor', key: 'admin.navbar.editor',
defaultString: 'editor', // defaultString: 'editor',
path: '/editor' path: '/editor/'
}, },
settings: { settings: {
name: 'Settings', name: 'Settings',
navClass: 'settings', navClass: 'settings',
key: 'admin.navbar.settings', key: 'admin.navbar.settings',
defaultString: 'settings', // defaultString: 'settings',
path: '/settings' path: '/settings/'
} }
}; };
ghost.doFilter('messWithAdmin', adminNavbar, function() {
console.log('the dofilter hook called in /core/admin/controllers/index.js');
});
// TODO - make this a util or helper // TODO - make this a util or helper
function setSelected(list, name) { function setSelected(list, name) {
_.each(list, function (item, key) { _.each(list, function (item, key) {
@ -114,7 +118,7 @@
.then(function (post) { .then(function (post) {
res.render('editor', { res.render('editor', {
bodyClass: 'editor', bodyClass: 'editor',
adminNav: setSelected(adminNavbar, 'blog'), adminNav: setSelected(adminNavbar, 'content'),
title: post.get('title'), title: post.get('title'),
content: post.get('content') content: post.get('content')
}); });
@ -126,12 +130,12 @@
}); });
} }
}, },
'blog': function (req, res) { 'content': function (req, res) {
api.posts.browse() api.posts.browse()
.then(function (posts) { .then(function (posts) {
res.render('blog', { res.render('content', {
bodyClass: 'manage', bodyClass: 'manage',
adminNav: setSelected(adminNavbar, 'blog'), adminNav: setSelected(adminNavbar, 'content'),
posts: posts.toJSON() posts: posts.toJSON()
}); });
}); });

View file

@ -1,3 +1,4 @@
<header id="global-header" class="navbar"> <header id="global-header" class="navbar">
<a id="ghost" href="#" data-off-canvas="left"><span class="hidden">Ghost</span></a> <a id="ghost" href="#" data-off-canvas="left"><span class="hidden">Ghost</span></a>
<nav id="global-nav" role="navigation"> <nav id="global-nav" role="navigation">

View file

@ -17,10 +17,10 @@
jsonDataProvider = new JsonDataProvider(), jsonDataProvider = new JsonDataProvider(),
BookshelfDataProvider = require('./shared/models/dataProvider.bookshelf'), BookshelfDataProvider = require('./shared/models/dataProvider.bookshelf'),
bookshelfDataProvider = new BookshelfDataProvider(), bookshelfDataProvider = new BookshelfDataProvider(),
ExampleFilter = require('../content/plugins/exampleFilters'),
Ghost, Ghost,
instance,
filterCallbacks = {},
instance,
statuses; statuses;
// ## Article Statuses // ## Article Statuses
@ -45,10 +45,12 @@
Ghost = function () { Ghost = function () {
var app, var app,
globals, globals,
plugin,
polyglot; polyglot;
if (!instance) { if (!instance) {
instance = this; instance = this;
plugin = new ExampleFilter(instance).init();
// Temporary loading of settings // Temporary loading of settings
jsonDataProvider.globals.findAll(function (error, data) { jsonDataProvider.globals.findAll(function (error, data) {
@ -70,6 +72,7 @@
dataProvider: function () { return bookshelfDataProvider; }, dataProvider: function () { return bookshelfDataProvider; },
statuses: function () { return statuses; }, statuses: function () { return statuses; },
polyglot: function () { return polyglot; }, polyglot: function () { return polyglot; },
plugin: function() { return plugin; },
paths: function () { paths: function () {
return { return {
'activeTheme': __dirname + '/../content/' + config.themeDir + '/' + config.activeTheme + '/', 'activeTheme': __dirname + '/../content/' + config.themeDir + '/' + config.activeTheme + '/',
@ -80,10 +83,21 @@
} }
}); });
} }
return instance; return instance;
}; };
/**
* Holds the filters
* @type {Array}
*/
Ghost.prototype.filterCallbacks = [];
/**
* Holds the filter hooks (that are built in to Ghost Core)
* @type {Array}
*/
Ghost.prototype.filters = [];
/** /**
* @param {string} name * @param {string} name
* @param {Function} fn * @param {Function} fn
@ -116,11 +130,11 @@
* @param {Function} fn * @param {Function} fn
*/ */
Ghost.prototype.registerFilter = function (name, fn) { Ghost.prototype.registerFilter = function (name, fn) {
if (!filterCallbacks.hasOwnProperty(name)) { if (!this.filterCallbacks.hasOwnProperty(name)) {
filterCallbacks[name] = []; this.filterCallbacks[name] = [];
} }
console.log('registering filter for ', name); console.log('registering filter for ', name);
filterCallbacks[name].push(fn); this.filterCallbacks[name].push(fn);
}; };
/** /**
@ -132,11 +146,11 @@
Ghost.prototype.doFilter = function (name, args, callback) { Ghost.prototype.doFilter = function (name, args, callback) {
var fn; var fn;
if (filterCallbacks.hasOwnProperty(name)) { if (this.filterCallbacks.hasOwnProperty(name)) {
for (fn in filterCallbacks[name]) { for (fn in this.filterCallbacks[name]) {
if (filterCallbacks[name].hasOwnProperty(fn)) { if (this.filterCallbacks[name].hasOwnProperty(fn)) {
console.log('doing filter for ', name); console.log('doing filter for ', name);
args = filterCallbacks[name][fn](args); args = this.filterCallbacks[name][fn](args);
} }
} }
} }