2013-05-11 17:44:25 +01:00
|
|
|
/**
|
|
|
|
* Main controller for Ghost frontend
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*global require, module */
|
|
|
|
|
2014-01-01 15:27:39 +00:00
|
|
|
var moment = require('moment'),
|
2015-04-07 17:34:50 +01:00
|
|
|
rss = require('../data/xml/rss'),
|
2014-02-05 00:40:30 -08:00
|
|
|
_ = require('lodash'),
|
2014-08-17 06:17:23 +00:00
|
|
|
Promise = require('bluebird'),
|
2014-01-01 15:27:39 +00:00
|
|
|
api = require('../api'),
|
|
|
|
config = require('../config'),
|
2014-09-06 20:16:14 +00:00
|
|
|
filters = require('../filters'),
|
2014-02-22 21:16:07 -05:00
|
|
|
template = require('../helpers/template'),
|
2014-05-09 12:11:29 +02:00
|
|
|
errors = require('../errors'),
|
2015-01-22 19:21:47 +00:00
|
|
|
routeMatch = require('path-match')(),
|
2015-03-26 02:01:39 -05:00
|
|
|
path = require('path'),
|
2013-05-11 17:44:25 +01:00
|
|
|
|
2014-02-02 00:29:07 -05:00
|
|
|
frontendControllers,
|
2015-04-07 17:34:50 +01:00
|
|
|
staticPostPermalink;
|
2014-04-11 23:46:15 -04:00
|
|
|
|
|
|
|
// Cache static post permalink regex
|
2015-01-22 19:21:47 +00:00
|
|
|
staticPostPermalink = routeMatch('/:slug/:edit?');
|
2014-02-02 00:29:07 -05:00
|
|
|
|
2014-02-12 22:26:56 -05:00
|
|
|
function getPostPage(options) {
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
return api.settings.read('postsPerPage').then(function (response) {
|
2014-04-27 18:28:50 -05:00
|
|
|
var postPP = response.settings[0],
|
|
|
|
postsPerPage = parseInt(postPP.value, 10);
|
2014-02-12 22:26:56 -05:00
|
|
|
|
|
|
|
// No negative posts per page, must be number
|
|
|
|
if (!isNaN(postsPerPage) && postsPerPage > 0) {
|
|
|
|
options.limit = postsPerPage;
|
|
|
|
}
|
2014-04-27 18:58:34 +02:00
|
|
|
options.include = 'author,tags,fields';
|
2014-02-12 22:26:56 -05:00
|
|
|
return api.posts.browse(options);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-01-20 23:00:38 -08:00
|
|
|
/**
|
|
|
|
* formats variables for handlebars in multi-post contexts.
|
|
|
|
* If extraValues are available, they are merged in the final value
|
2015-02-28 12:53:00 +00:00
|
|
|
* @return {Object} containing page variables
|
2015-01-20 23:00:38 -08:00
|
|
|
*/
|
|
|
|
function formatPageResponse(posts, page, extraValues) {
|
|
|
|
extraValues = extraValues || {};
|
|
|
|
|
2015-02-28 12:53:00 +00:00
|
|
|
var resp = {
|
|
|
|
posts: posts,
|
|
|
|
pagination: page.meta.pagination
|
|
|
|
};
|
|
|
|
return _.extend(resp, extraValues);
|
2014-02-12 22:26:56 -05:00
|
|
|
}
|
|
|
|
|
2015-01-20 23:00:38 -08:00
|
|
|
/**
|
|
|
|
* similar to formatPageResponse, but for single post pages
|
2015-02-28 12:53:00 +00:00
|
|
|
* @return {Object} containing page variables
|
2015-01-20 23:00:38 -08:00
|
|
|
*/
|
2014-07-29 11:23:02 +02:00
|
|
|
function formatResponse(post) {
|
2015-02-28 12:53:00 +00:00
|
|
|
return {
|
|
|
|
post: post
|
|
|
|
};
|
2014-07-29 11:23:02 +02:00
|
|
|
}
|
|
|
|
|
2014-02-12 22:26:56 -05:00
|
|
|
function handleError(next) {
|
|
|
|
return function (err) {
|
2014-08-17 06:17:23 +00:00
|
|
|
return next(err);
|
2014-02-12 22:26:56 -05:00
|
|
|
};
|
|
|
|
}
|
2013-05-11 17:44:25 +01:00
|
|
|
|
2014-09-04 16:07:12 +00:00
|
|
|
function setResponseContext(req, res, data) {
|
|
|
|
var contexts = [],
|
2015-01-30 22:20:47 +00:00
|
|
|
pageParam = req.params.page !== undefined ? parseInt(req.params.page, 10) : 1,
|
|
|
|
tagPattern = new RegExp('^\\/' + config.routeKeywords.tag + '\\/'),
|
2015-05-13 10:26:49 +01:00
|
|
|
authorPattern = new RegExp('^\\/' + config.routeKeywords.author + '\\/'),
|
|
|
|
privatePattern = new RegExp('^\\/' + config.routeKeywords.private + '\\/');
|
2014-09-04 16:07:12 +00:00
|
|
|
|
|
|
|
// paged context
|
|
|
|
if (!isNaN(pageParam) && pageParam > 1) {
|
|
|
|
contexts.push('paged');
|
|
|
|
}
|
|
|
|
|
2015-01-30 22:20:47 +00:00
|
|
|
if (req.route.path === '/' + config.routeKeywords.page + '/:page/') {
|
2014-09-04 16:07:12 +00:00
|
|
|
contexts.push('index');
|
|
|
|
} else if (req.route.path === '/') {
|
|
|
|
contexts.push('home');
|
|
|
|
contexts.push('index');
|
|
|
|
} else if (/\/rss\/(:page\/)?$/.test(req.route.path)) {
|
|
|
|
contexts.push('rss');
|
2015-05-13 10:26:49 +01:00
|
|
|
} else if (privatePattern.test(req.route.path)) {
|
|
|
|
contexts.push('private');
|
2015-01-30 22:20:47 +00:00
|
|
|
} else if (tagPattern.test(req.route.path)) {
|
2014-09-04 16:07:12 +00:00
|
|
|
contexts.push('tag');
|
2015-01-30 22:20:47 +00:00
|
|
|
} else if (authorPattern.test(req.route.path)) {
|
2014-09-04 16:07:12 +00:00
|
|
|
contexts.push('author');
|
|
|
|
} else if (data && data.post && data.post.page) {
|
|
|
|
contexts.push('page');
|
|
|
|
} else {
|
|
|
|
contexts.push('post');
|
|
|
|
}
|
|
|
|
|
|
|
|
res.locals.context = contexts;
|
|
|
|
}
|
|
|
|
|
2014-02-21 20:25:31 -05:00
|
|
|
// Add Request context parameter to the data object
|
|
|
|
// to be passed down to the templates
|
|
|
|
function setReqCtx(req, data) {
|
|
|
|
(Array.isArray(data) ? data : [data]).forEach(function (d) {
|
|
|
|
d.secure = req.secure;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-07-28 23:58:39 -04:00
|
|
|
/**
|
|
|
|
* Returns the paths object of the active theme via way of a promise.
|
|
|
|
* @return {Promise} The promise resolves with the value of the paths.
|
|
|
|
*/
|
|
|
|
function getActiveThemePaths() {
|
|
|
|
return api.settings.read({
|
|
|
|
key: 'activeTheme',
|
|
|
|
context: {
|
|
|
|
internal: true
|
|
|
|
}
|
|
|
|
}).then(function (response) {
|
|
|
|
var activeTheme = response.settings[0],
|
|
|
|
paths = config.paths.availableThemes[activeTheme.value];
|
|
|
|
|
|
|
|
return paths;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-04-16 13:40:32 -06:00
|
|
|
/*
|
|
|
|
* Sets the response context around a post and renders it
|
|
|
|
* with the current theme's post view. Used by post preview
|
|
|
|
* and single post methods.
|
|
|
|
* Returns a function that takes the post to be rendered.
|
|
|
|
*/
|
|
|
|
function renderPost(req, res) {
|
|
|
|
return function (post) {
|
|
|
|
return getActiveThemePaths().then(function (paths) {
|
|
|
|
var view = template.getThemeViewForPost(paths, post),
|
|
|
|
response = formatResponse(post);
|
|
|
|
|
|
|
|
setResponseContext(req, res, response);
|
|
|
|
res.render(view, response);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-05-05 00:21:29 -05:00
|
|
|
function renderChannel(channelOpts) {
|
|
|
|
channelOpts = channelOpts || {};
|
|
|
|
|
|
|
|
return function renderChannel(req, res, next) {
|
2013-12-06 09:51:35 +01:00
|
|
|
var pageParam = req.params.page !== undefined ? parseInt(req.params.page, 10) : 1,
|
2014-02-12 22:26:56 -05:00
|
|
|
options = {
|
|
|
|
page: pageParam
|
2015-05-05 00:21:29 -05:00
|
|
|
},
|
|
|
|
hasSlug,
|
|
|
|
filter, filterKey;
|
|
|
|
|
|
|
|
// Add the slug if it exists in the route
|
|
|
|
if (channelOpts.route.indexOf(':slug') !== -1) {
|
|
|
|
options[channelOpts.name] = req.params.slug;
|
|
|
|
hasSlug = true;
|
2014-01-03 00:37:21 +00:00
|
|
|
}
|
|
|
|
|
2015-05-05 00:21:29 -05:00
|
|
|
function createUrl(page) {
|
|
|
|
var url = config.paths.subdir + channelOpts.route;
|
2014-02-12 22:26:56 -05:00
|
|
|
|
2015-05-05 00:21:29 -05:00
|
|
|
if (hasSlug) {
|
|
|
|
url = url.replace(':slug', options[channelOpts.name]);
|
|
|
|
}
|
2014-02-12 22:26:56 -05:00
|
|
|
|
|
|
|
if (page && page > 1) {
|
|
|
|
url += 'page/' + page + '/';
|
2013-08-21 09:05:17 -05:00
|
|
|
}
|
|
|
|
|
2014-02-12 22:26:56 -05:00
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isNaN(pageParam) || pageParam < 1 || (req.params.page !== undefined && pageParam === 1)) {
|
2015-05-05 00:21:29 -05:00
|
|
|
return res.redirect(createUrl());
|
2014-02-12 22:26:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return getPostPage(options).then(function (page) {
|
2013-08-18 12:41:55 -05:00
|
|
|
// If page is greater than number of pages we have, redirect to last page
|
2014-04-19 17:03:20 +02:00
|
|
|
if (pageParam > page.meta.pagination.pages) {
|
2015-05-05 00:21:29 -05:00
|
|
|
return res.redirect(createUrl(page.meta.pagination.pages));
|
2013-08-18 12:41:55 -05:00
|
|
|
}
|
|
|
|
|
2014-02-21 20:25:31 -05:00
|
|
|
setReqCtx(req, page.posts);
|
2015-05-05 00:21:29 -05:00
|
|
|
if (channelOpts.filter && page.meta.filters[channelOpts.filter]) {
|
|
|
|
filterKey = page.meta.filters[channelOpts.filter];
|
|
|
|
filter = (_.isArray(filterKey)) ? filterKey[0] : filterKey;
|
|
|
|
setReqCtx(req, filter);
|
2014-04-28 19:54:16 +01:00
|
|
|
}
|
2014-02-21 20:25:31 -05:00
|
|
|
|
2015-04-22 23:22:31 +02:00
|
|
|
filters.doFilter('prePostsRender', page.posts, res.locals).then(function (posts) {
|
2014-07-28 23:58:39 -04:00
|
|
|
getActiveThemePaths().then(function (paths) {
|
2015-05-05 00:21:29 -05:00
|
|
|
var view = 'index',
|
|
|
|
result,
|
|
|
|
extra = {};
|
|
|
|
|
|
|
|
if (channelOpts.firstPageTemplate && paths.hasOwnProperty(channelOpts.firstPageTemplate + '.hbs')) {
|
|
|
|
view = (pageParam > 1) ? 'index' : channelOpts.firstPageTemplate;
|
|
|
|
} else if (channelOpts.slugTemplate) {
|
|
|
|
view = template.getThemeViewForChannel(paths, channelOpts.name, options[channelOpts.name]);
|
|
|
|
} else if (paths.hasOwnProperty(channelOpts.name + '.hbs')) {
|
|
|
|
view = channelOpts.name;
|
2015-02-28 12:53:00 +00:00
|
|
|
}
|
2014-07-20 17:32:14 +01:00
|
|
|
|
2015-05-05 00:21:29 -05:00
|
|
|
if (channelOpts.filter) {
|
|
|
|
extra[channelOpts.name] = (filterKey) ? filter : '';
|
2014-07-20 17:32:14 +01:00
|
|
|
|
2015-05-05 00:21:29 -05:00
|
|
|
if (!extra[channelOpts.name]) {
|
|
|
|
return next();
|
|
|
|
}
|
2014-07-20 17:32:14 +01:00
|
|
|
|
2015-05-05 00:21:29 -05:00
|
|
|
result = formatPageResponse(posts, page, extra);
|
|
|
|
} else {
|
|
|
|
result = formatPageResponse(posts, page);
|
2015-02-28 12:53:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setResponseContext(req, res);
|
|
|
|
res.render(view, result);
|
2014-07-20 17:32:14 +01:00
|
|
|
});
|
|
|
|
});
|
2014-08-17 06:17:23 +00:00
|
|
|
}).catch(handleError(next));
|
2015-05-05 00:21:29 -05:00
|
|
|
};
|
|
|
|
}
|
2014-07-20 17:32:14 +01:00
|
|
|
|
2015-05-05 00:21:29 -05:00
|
|
|
frontendControllers = {
|
|
|
|
homepage: renderChannel({
|
|
|
|
name: 'home',
|
|
|
|
route: '/',
|
|
|
|
firstPageTemplate: 'home'
|
|
|
|
}),
|
|
|
|
tag: renderChannel({
|
|
|
|
name: 'tag',
|
|
|
|
route: '/' + config.routeKeywords.tag + '/:slug/',
|
|
|
|
filter: 'tags',
|
|
|
|
slugTemplate: true
|
|
|
|
}),
|
|
|
|
author: renderChannel({
|
|
|
|
name: 'author',
|
|
|
|
route: '/' + config.routeKeywords.author + '/:slug/',
|
|
|
|
filter: 'author',
|
|
|
|
slugTemplate: true
|
|
|
|
}),
|
2015-04-16 13:40:32 -06:00
|
|
|
preview: function (req, res, next) {
|
|
|
|
var params = {
|
|
|
|
uuid: req.params.uuid,
|
|
|
|
status: 'all',
|
|
|
|
include: 'author,tags,fields'
|
|
|
|
};
|
|
|
|
|
|
|
|
api.posts.read(params).then(function (result) {
|
|
|
|
var post = result.posts[0];
|
|
|
|
|
|
|
|
if (!post) {
|
|
|
|
return next();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (post.status === 'published') {
|
|
|
|
return res.redirect(301, config.urlFor('post', {post: post}));
|
|
|
|
}
|
|
|
|
|
|
|
|
setReqCtx(req, post);
|
|
|
|
|
|
|
|
filters.doFilter('prePostsRender', post, res.locals)
|
|
|
|
.then(renderPost(req, res));
|
|
|
|
}).catch(function (err) {
|
|
|
|
if (err.errorType === 'NotFoundError') {
|
|
|
|
return next();
|
|
|
|
}
|
|
|
|
|
|
|
|
return handleError(next)(err);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-09-10 00:06:24 -04:00
|
|
|
single: function (req, res, next) {
|
2014-02-02 00:29:07 -05:00
|
|
|
var path = req.path,
|
|
|
|
params,
|
|
|
|
usingStaticPermalink = false;
|
|
|
|
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 13:41:19 +01:00
|
|
|
api.settings.read('permalinks').then(function (response) {
|
2014-04-27 18:28:50 -05:00
|
|
|
var permalink = response.settings[0],
|
2015-01-22 19:21:47 +00:00
|
|
|
editFormat,
|
|
|
|
postLookup,
|
|
|
|
match;
|
2014-04-27 18:28:50 -05:00
|
|
|
|
2014-02-02 00:29:07 -05:00
|
|
|
editFormat = permalink.value[permalink.value.length - 1] === '/' ? ':edit?' : '/:edit?';
|
|
|
|
|
2015-01-22 19:21:47 +00:00
|
|
|
// Convert saved permalink into a path-match function
|
|
|
|
permalink = routeMatch(permalink.value + editFormat);
|
|
|
|
match = permalink(path);
|
2014-02-02 00:29:07 -05:00
|
|
|
|
|
|
|
// Check if the path matches the permalink structure.
|
|
|
|
//
|
|
|
|
// If there are no matches found we then
|
|
|
|
// need to verify it's not a static post,
|
|
|
|
// and test against that permalink structure.
|
2015-01-22 19:21:47 +00:00
|
|
|
if (match === false) {
|
|
|
|
match = staticPostPermalink(path);
|
2014-02-02 00:29:07 -05:00
|
|
|
// If there are still no matches then return.
|
2015-01-22 19:21:47 +00:00
|
|
|
if (match === false) {
|
2014-05-05 15:51:21 +02:00
|
|
|
// Reject promise chain with type 'NotFound'
|
2014-08-17 06:17:23 +00:00
|
|
|
return Promise.reject(new errors.NotFoundError());
|
2014-02-02 00:29:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
usingStaticPermalink = true;
|
|
|
|
}
|
|
|
|
|
2015-01-22 19:21:47 +00:00
|
|
|
params = match;
|
2014-02-02 00:29:07 -05:00
|
|
|
|
|
|
|
// Sanitize params we're going to use to lookup the post.
|
2015-01-22 19:21:47 +00:00
|
|
|
postLookup = _.pick(params, 'slug', 'id');
|
2014-04-27 18:58:34 +02:00
|
|
|
// Add author, tag and fields
|
|
|
|
postLookup.include = 'author,tags,fields';
|
2014-02-02 00:29:07 -05:00
|
|
|
|
|
|
|
// Query database to find post
|
|
|
|
return api.posts.read(postLookup);
|
2014-04-16 12:09:03 +02:00
|
|
|
}).then(function (result) {
|
|
|
|
var post = result.posts[0],
|
|
|
|
slugDate = [],
|
|
|
|
slugFormat = [];
|
2014-02-02 00:29:07 -05:00
|
|
|
|
|
|
|
if (!post) {
|
|
|
|
return next();
|
|
|
|
}
|
2013-12-30 02:03:29 -05:00
|
|
|
|
|
|
|
function render() {
|
2014-01-19 21:08:39 +00:00
|
|
|
// If we're ready to render the page but the last param is 'edit' then we'll send you to the edit page.
|
2014-08-06 19:02:20 -07:00
|
|
|
if (params.edit) {
|
|
|
|
params.edit = params.edit.toLowerCase();
|
|
|
|
}
|
2014-04-19 21:48:14 -07:00
|
|
|
if (params.edit === 'edit') {
|
2014-07-17 10:33:21 -04:00
|
|
|
return res.redirect(config.paths.subdir + '/ghost/editor/' + post.id + '/');
|
2014-04-19 21:48:14 -07:00
|
|
|
} else if (params.edit !== undefined) {
|
2014-05-05 15:51:21 +02:00
|
|
|
// reject with type: 'NotFound'
|
2014-08-17 06:17:23 +00:00
|
|
|
return Promise.reject(new errors.NotFoundError());
|
2014-01-02 23:32:31 -05:00
|
|
|
}
|
2014-02-21 20:25:31 -05:00
|
|
|
|
|
|
|
setReqCtx(req, post);
|
|
|
|
|
2015-04-16 13:40:32 -06:00
|
|
|
filters.doFilter('prePostsRender', post, res.locals)
|
|
|
|
.then(renderPost(req, res));
|
2013-09-17 01:54:36 +01:00
|
|
|
}
|
|
|
|
|
2014-02-02 00:29:07 -05:00
|
|
|
// If we've checked the path with the static permalink structure
|
|
|
|
// then the post must be a static post.
|
|
|
|
// If it is not then we must return.
|
|
|
|
if (usingStaticPermalink) {
|
2014-06-12 11:44:10 +02:00
|
|
|
if (post.page) {
|
2014-02-02 00:29:07 -05:00
|
|
|
return render();
|
|
|
|
}
|
2013-12-30 02:03:29 -05:00
|
|
|
|
2014-01-01 15:27:39 +00:00
|
|
|
return next();
|
|
|
|
}
|
|
|
|
|
2014-10-25 18:15:24 -07:00
|
|
|
// If there is an author parameter in the slug, check that the
|
|
|
|
// post is actually written by the given author\
|
|
|
|
if (params.author) {
|
|
|
|
if (post.author.slug === params.author) {
|
|
|
|
return render();
|
|
|
|
}
|
|
|
|
return next();
|
|
|
|
}
|
|
|
|
|
2015-03-14 21:50:00 +00:00
|
|
|
// If there is any date based parameter in the slug
|
2014-02-02 00:29:07 -05:00
|
|
|
// we will check it against the post published date
|
|
|
|
// to verify it's correct.
|
|
|
|
if (params.year || params.month || params.day) {
|
|
|
|
if (params.year) {
|
|
|
|
slugDate.push(params.year);
|
|
|
|
slugFormat.push('YYYY');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params.month) {
|
|
|
|
slugDate.push(params.month);
|
|
|
|
slugFormat.push('MM');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params.day) {
|
|
|
|
slugDate.push(params.day);
|
|
|
|
slugFormat.push('DD');
|
|
|
|
}
|
2013-12-30 02:03:29 -05:00
|
|
|
|
2014-02-02 00:29:07 -05:00
|
|
|
slugDate = slugDate.join('/');
|
|
|
|
slugFormat = slugFormat.join('/');
|
|
|
|
|
|
|
|
if (slugDate === moment(post.published_at).format(slugFormat)) {
|
2013-12-30 02:03:29 -05:00
|
|
|
return render();
|
|
|
|
}
|
|
|
|
|
2014-02-02 00:29:07 -05:00
|
|
|
return next();
|
|
|
|
}
|
2013-12-30 02:03:29 -05:00
|
|
|
|
2014-05-05 15:51:21 +02:00
|
|
|
return render();
|
2014-08-17 06:17:23 +00:00
|
|
|
}).catch(function (err) {
|
2014-02-02 00:29:07 -05:00
|
|
|
// If we've thrown an error message
|
2014-05-05 15:51:21 +02:00
|
|
|
// of type: 'NotFound' then we found
|
2014-02-02 00:29:07 -05:00
|
|
|
// no path match.
|
2015-04-22 22:29:45 +02:00
|
|
|
if (err.errorType === 'NotFoundError') {
|
2014-02-02 00:29:07 -05:00
|
|
|
return next();
|
|
|
|
}
|
|
|
|
|
2014-02-12 22:26:56 -05:00
|
|
|
return handleError(next)(err);
|
2013-06-25 12:43:15 +01:00
|
|
|
});
|
2013-08-27 17:31:43 -05:00
|
|
|
},
|
2015-03-26 02:01:39 -05:00
|
|
|
rss: rss,
|
|
|
|
private: function (req, res) {
|
2015-05-13 10:26:49 +01:00
|
|
|
var defaultPage = path.resolve(config.paths.adminViews, 'private.hbs');
|
2015-03-26 02:01:39 -05:00
|
|
|
return getActiveThemePaths().then(function (paths) {
|
2015-05-13 10:26:49 +01:00
|
|
|
var data = {};
|
2015-03-26 02:01:39 -05:00
|
|
|
if (res.error) {
|
|
|
|
data.error = res.error;
|
|
|
|
}
|
2015-05-13 10:26:49 +01:00
|
|
|
|
|
|
|
setResponseContext(req, res);
|
|
|
|
if (paths.hasOwnProperty('private.hbs')) {
|
|
|
|
return res.render('private', data);
|
2015-03-26 02:01:39 -05:00
|
|
|
} else {
|
|
|
|
return res.render(defaultPage, data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-06-25 12:43:15 +01:00
|
|
|
};
|
2013-05-11 17:44:25 +01:00
|
|
|
|
2013-10-18 17:18:49 +00:00
|
|
|
module.exports = frontendControllers;
|