mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-02 07:43:11 +03:00
Group channel-handling code together
refs #5091 - Move all of the code to do with handling channels into one folder - Still keeping all the shared/simlar code for rendering etc inside weird frontend folder until I am sure what this will look like
This commit is contained in:
parent
e659766f55
commit
05729d2f29
@ -2,7 +2,7 @@ var express = require('express'),
|
||||
path = require('path'),
|
||||
config = require('../config'),
|
||||
controllers = require('../controllers'),
|
||||
channels = require('../controllers/frontend/channels'),
|
||||
channels = require('../controllers/channels'),
|
||||
utils = require('../utils');
|
||||
|
||||
module.exports = function frontendRoutes() {
|
||||
|
1
core/server/controllers/channels/index.js
Normal file
1
core/server/controllers/channels/index.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports.router = require('./router');
|
@ -5,8 +5,8 @@ var express = require('express'),
|
||||
i18n = require('../../i18n'),
|
||||
rss = require('../../data/xml/rss'),
|
||||
utils = require('../../utils'),
|
||||
channelConfig = require('./channel-config'),
|
||||
renderChannel = require('./render-channel'),
|
||||
channelLoader = require('./loader'),
|
||||
renderChannel = require('../frontend/render-channel'),
|
||||
rssRouter,
|
||||
channelsRouter;
|
||||
|
||||
@ -95,7 +95,7 @@ function buildChannelRouter(channel) {
|
||||
channelsRouter = function router() {
|
||||
var channelsRouter = express.Router({mergeParams: true});
|
||||
|
||||
_.each(channelConfig.list(), function (channel) {
|
||||
_.each(channelLoader.list(), function (channel) {
|
||||
var channelRoute = channel.route.replace(/:rkw-([a-zA-Z]+)/, function (fullMatch, keyword) {
|
||||
return config.get('routeKeywords')[keyword];
|
||||
});
|
||||
@ -107,4 +107,4 @@ channelsRouter = function router() {
|
||||
return channelsRouter;
|
||||
};
|
||||
|
||||
module.exports.router = channelsRouter;
|
||||
module.exports = channelsRouter;
|
@ -3,8 +3,8 @@ var should = require('should'), // jshint ignore:line
|
||||
_ = require('lodash'),
|
||||
|
||||
// Stuff we are testing
|
||||
channelConfig = require('../../../../server/controllers/frontend/channel-config'),
|
||||
channels = require('../../../../server/controllers/frontend/channels'),
|
||||
channelLoader = require('../../../../server/controllers/channels/loader'),
|
||||
channels = require('../../../../server/controllers/channels'),
|
||||
|
||||
sandbox = sinon.sandbox.create();
|
||||
|
||||
@ -135,7 +135,7 @@ describe('Custom Channels', function () {
|
||||
});
|
||||
|
||||
it('allows basic custom config', function () {
|
||||
sandbox.stub(channelConfig, 'list').returns({
|
||||
sandbox.stub(channelLoader, 'list').returns({
|
||||
home: {
|
||||
name: 'home',
|
||||
route: '/home/'
|
||||
@ -182,7 +182,7 @@ describe('Custom Channels', function () {
|
||||
});
|
||||
|
||||
it('allow multiple channels to be defined', function () {
|
||||
sandbox.stub(channelConfig, 'list').returns({
|
||||
sandbox.stub(channelLoader, 'list').returns({
|
||||
home: {
|
||||
name: 'home',
|
||||
route: '/home/'
|
||||
@ -247,7 +247,7 @@ describe('Custom Channels', function () {
|
||||
});
|
||||
|
||||
it('allows rss to be disabled', function () {
|
||||
sandbox.stub(channelConfig, 'list').returns({
|
||||
sandbox.stub(channelLoader, 'list').returns({
|
||||
home: {
|
||||
name: 'home',
|
||||
route: '/home/',
|
||||
@ -295,7 +295,7 @@ describe('Custom Channels', function () {
|
||||
});
|
||||
|
||||
it('allows pagination to be disabled', function () {
|
||||
sandbox.stub(channelConfig, 'list').returns({
|
||||
sandbox.stub(channelLoader, 'list').returns({
|
||||
home: {
|
||||
name: 'home',
|
||||
route: '/home/',
|
@ -2,13 +2,13 @@ var should = require('should'), // jshint ignore:line
|
||||
_ = require('lodash'),
|
||||
rewire = require('rewire'),
|
||||
channelUtils = require('../../../utils/channelUtils'),
|
||||
channelConfig = rewire('../../../../server/controllers/frontend/channel-config');
|
||||
channelLoader = rewire('../../../../server/controllers/channels/loader');
|
||||
|
||||
describe('Channel Config', function () {
|
||||
var channelReset;
|
||||
|
||||
before(function () {
|
||||
channelReset = channelConfig.__set__('loadConfig', function () {
|
||||
channelReset = channelLoader.__set__('loadConfig', function () {
|
||||
return channelUtils.getDefaultChannels();
|
||||
});
|
||||
});
|
||||
@ -18,7 +18,7 @@ describe('Channel Config', function () {
|
||||
});
|
||||
|
||||
it('should build a list of channels', function () {
|
||||
var channels = channelConfig.list();
|
||||
var channels = channelLoader.list();
|
||||
channels.should.be.an.Object();
|
||||
|
||||
_.map(channels, 'name').should.eql(['index', 'tag', 'author']);
|
@ -4,7 +4,7 @@ var should = require('should'),
|
||||
_ = require('lodash'),
|
||||
|
||||
// Stuff we are testing
|
||||
channels = require('../../../../server/controllers/frontend/channels'),
|
||||
channels = require('../../../../server/controllers/channels'),
|
||||
api = require('../../../../server/api'),
|
||||
themes = require('../../../../server/themes'),
|
||||
sandbox = sinon.sandbox.create();
|
@ -1,4 +1,4 @@
|
||||
var defaultChannels = require('../../server/controllers/frontend/config.channels.json');
|
||||
var defaultChannels = require('../../server/controllers/channels/config.channels.json');
|
||||
|
||||
// This is a function to get a fake or test channel
|
||||
// It's currently based on the default config in Ghost itself
|
||||
|
Loading…
Reference in New Issue
Block a user