2018-06-02 22:48:23 +03:00
|
|
|
const should = require('should'),
|
2018-02-14 19:21:31 +03:00
|
|
|
sinon = require('sinon'),
|
2018-06-24 01:32:08 +03:00
|
|
|
_ = require('lodash'),
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
cheerio = require('cheerio'),
|
2018-04-26 18:34:47 +03:00
|
|
|
testUtils = require('../../utils'),
|
|
|
|
configUtils = require('../../utils/configUtils'),
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils = require('../../utils/urlUtils'),
|
2019-02-27 19:50:20 +03:00
|
|
|
appsService = require('../../../server/services/apps'),
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
settingsService = require('../../../server/services/settings'),
|
2019-01-04 23:59:39 +03:00
|
|
|
themeService = require('../../../server/services/themes'),
|
2019-01-21 19:53:44 +03:00
|
|
|
siteApp = require('../../../server/web/parent-app');
|
2018-02-14 19:21:31 +03:00
|
|
|
|
|
|
|
describe('Integration - Web - Site', function () {
|
2018-06-12 21:26:16 +03:00
|
|
|
let app;
|
2018-02-14 19:21:31 +03:00
|
|
|
|
2019-01-14 21:04:22 +03:00
|
|
|
before(testUtils.integrationTesting.urlService.resetGenerators);
|
2018-06-24 01:32:08 +03:00
|
|
|
before(testUtils.teardown);
|
2018-06-12 21:26:16 +03:00
|
|
|
before(testUtils.setup('users:roles', 'posts'));
|
2018-02-14 19:21:31 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('v0.1', function () {
|
|
|
|
const api = require('../../../server/api')["v0.1"];
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('default routes.yaml', function () {
|
|
|
|
before(function () {
|
2019-02-27 19:50:20 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon, {amp: true, apps: true});
|
2019-01-04 23:59:39 +03:00
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
2019-02-27 19:50:20 +03:00
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
return appsService.init();
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
before(function () {
|
2019-01-04 23:59:39 +03:00
|
|
|
configUtils.set('url', 'http://example.com');
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.stubUrlUtilsFromConfig();
|
|
|
|
});
|
2018-02-14 19:21:31 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
beforeEach(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.spy(api.posts, 'browse');
|
2018-02-14 19:21:31 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
afterEach(function () {
|
|
|
|
api.posts.browse.restore();
|
2018-02-14 19:21:31 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
after(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('behaviour: default cases', function () {
|
|
|
|
it('serve post', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
2019-01-04 23:59:39 +03:00
|
|
|
secure: true,
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('post');
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-02-27 19:50:20 +03:00
|
|
|
it('serve amp', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/amp/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.match(/amp\.hbs/);
|
|
|
|
response.body.should.match(/<h1>HTML Ipsum Presents<\/h1>/);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('post not found', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
2019-01-04 23:59:39 +03:00
|
|
|
secure: true,
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/not-found/',
|
|
|
|
host: 'example.com'
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve static page', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
2019-01-04 23:59:39 +03:00
|
|
|
secure: true,
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/static-page-test/',
|
|
|
|
host: 'example.com'
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('page');
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve author', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
2019-01-04 23:59:39 +03:00
|
|
|
secure: true,
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/author/joe-bloggs/',
|
|
|
|
host: 'example.com'
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('author');
|
|
|
|
|
|
|
|
$('.author-bio').length.should.equal(1);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve tag', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
2019-01-04 23:59:39 +03:00
|
|
|
secure: true,
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/tag/bacon/',
|
|
|
|
host: 'example.com'
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('tag');
|
|
|
|
|
|
|
|
api.posts.browse.args[0][0].filter.should.eql('tags:\'bacon\'+tags.visibility:public');
|
|
|
|
api.posts.browse.args[0][0].page.should.eql(1);
|
|
|
|
api.posts.browse.args[0][0].limit.should.eql(2);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve tag rss', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
2019-01-04 23:59:39 +03:00
|
|
|
secure: true,
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/tag/bacon/rss/',
|
|
|
|
host: 'example.com'
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve collection', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
2019-01-04 23:59:39 +03:00
|
|
|
secure: true,
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/',
|
|
|
|
host: 'example.com'
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
|
|
|
|
$('.post-card').length.should.equal(2);
|
|
|
|
|
|
|
|
should.exist(response.res.locals.context);
|
|
|
|
should.exist(response.res.locals.version);
|
|
|
|
should.exist(response.res.locals.safeVersion);
|
|
|
|
should.exist(response.res.locals.safeVersion);
|
|
|
|
should.exist(response.res.locals.relativeUrl);
|
|
|
|
should.exist(response.res.locals.secure);
|
|
|
|
should.exist(response.res.routerOptions);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve collection: page 2', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
2019-01-04 23:59:39 +03:00
|
|
|
secure: true,
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/page/2/',
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
|
|
|
|
$('.post-card').length.should.equal(2);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve public asset', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/public/ghost-sdk.js',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve theme asset', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
2019-01-04 23:59:39 +03:00
|
|
|
secure: true,
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/assets/css/screen.css',
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('behaviour: prettify', function () {
|
|
|
|
it('url without slash', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/prettify-me',
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
2019-01-04 23:59:39 +03:00
|
|
|
response.headers.location.should.eql('/prettify-me/');
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('behaviour: url redirects', function () {
|
|
|
|
describe('pagination', function () {
|
|
|
|
it('redirect /page/1/ to /', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
host: 'example.com',
|
|
|
|
method: 'GET',
|
|
|
|
url: '/page/1/'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/');
|
|
|
|
});
|
|
|
|
});
|
2018-06-13 22:01:05 +03:00
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('rss', function () {
|
|
|
|
it('redirect /feed/ to /rss/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
host: 'example.com',
|
|
|
|
method: 'GET',
|
|
|
|
url: '/feed/'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/rss/');
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('redirect /rss/1/ to /rss/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
host: 'example.com',
|
|
|
|
method: 'GET',
|
|
|
|
url: '/rss/1/'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/rss/');
|
|
|
|
});
|
2018-06-13 22:01:05 +03:00
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2019-06-18 16:13:55 +03:00
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
describe('https', function () {
|
|
|
|
before(function () {
|
|
|
|
configUtils.set('url', 'https://example.com');
|
|
|
|
urlUtils.stubUrlUtilsFromConfig();
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
after(function () {
|
|
|
|
urlUtils.restore();
|
|
|
|
configUtils.restore();
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
describe('protocol', function () {
|
|
|
|
it('blog is https, request is http', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
host: 'example.com',
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum'
|
|
|
|
};
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('https://example.com/html-ipsum/');
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
it('blog is https, request is http, trailing slash exists already', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('https://example.com/html-ipsum/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
describe('assets', function () {
|
|
|
|
it('blog is https, request is http', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/public/ghost-sdk.js',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('https://example.com/public/ghost-sdk.js');
|
|
|
|
});
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
it('blog is https, request is http', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/favicon.png',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('https://example.com/favicon.png');
|
|
|
|
});
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
it('blog is https, request is http', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/assets/css/main.css',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('https://example.com/assets/css/main.css');
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-02-14 19:21:31 +03:00
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-02-14 19:21:31 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('extended routes.yaml: collections', function () {
|
|
|
|
describe('2 collections', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {
|
|
|
|
'/': 'home'
|
|
|
|
},
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/podcast/:slug/',
|
|
|
|
filter: 'featured:true'
|
|
|
|
},
|
2018-02-14 19:21:31 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
'/something/': {
|
|
|
|
permalink: '/something/:slug/',
|
|
|
|
filter: 'featured:false'
|
|
|
|
}
|
|
|
|
},
|
2018-02-14 19:21:31 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
taxonomies: {
|
|
|
|
tag: '/categories/:slug/',
|
|
|
|
author: '/authors/:slug/'
|
|
|
|
}
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve static route', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2018-06-13 22:01:05 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('default');
|
|
|
|
});
|
2018-06-13 22:01:05 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve rss', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/podcast/rss/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2018-06-13 22:01:05 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
2018-06-13 22:01:05 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve post', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/something/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2018-06-13 22:01:05 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('post');
|
|
|
|
});
|
|
|
|
});
|
2018-06-13 22:01:05 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve collection: podcast', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/podcast/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2018-06-13 22:01:05 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
2018-06-13 22:01:05 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
$('.post-card').length.should.equal(2);
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve collection: something', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/something/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
2018-02-14 19:21:31 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
$('.post-card').length.should.equal(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-02-14 19:21:31 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('no collections', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {
|
|
|
|
'/test/': 'test'
|
|
|
|
},
|
|
|
|
collections: {},
|
|
|
|
taxonomies: {}
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
2018-02-14 19:21:31 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve route', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/test/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('default');
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('static permalink route', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/featured/',
|
|
|
|
filter: 'featured:true'
|
|
|
|
},
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/'
|
|
|
|
}
|
|
|
|
},
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
taxonomies: {}
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve post', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/featured/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
// We can't find a post with the slug "featured"
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve post', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('post');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve author', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/author/joe-bloggs/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve tag', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/tag/bacon/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('primary author permalink', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/something/': {
|
|
|
|
permalink: '/:primary_author/:slug/'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
taxonomies: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve post', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/joe-bloggs/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('post');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('post without author', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('page', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/static-page-test/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('page');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('primary tag permalink', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/something/': {
|
|
|
|
permalink: '/something/:primary_tag/:slug/'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
taxonomies: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve post', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/something/kitchen-sink/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('post');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('post without tag', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/something/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('post without tag', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('page', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/static-page-test/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('page');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('collection with data key', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/food/': {
|
|
|
|
permalink: '/food/:slug/',
|
|
|
|
filter: 'tag:bacon',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tags',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'bacon'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'bacon'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/sport/': {
|
|
|
|
permalink: '/sport/:slug/',
|
|
|
|
filter: 'tag:pollo',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
apollo: {
|
|
|
|
controller: 'tags',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'pollo'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: false, slug: 'bacon'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/categories/:slug/',
|
|
|
|
author: '/authors/:slug/'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve /food/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/food/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve bacon tag', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/categories/bacon/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve /sport/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/sport/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve pollo tag', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/categories/pollo/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('extended routes.yaml: templates', function () {
|
|
|
|
describe('default template, no template', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['default']
|
|
|
|
},
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/:slug/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve collection', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('default');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve second collectiom', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/magic/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('two templates', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['something', 'default']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve collection', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('default');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('home.hbs priority', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['something', 'default']
|
|
|
|
},
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/:slug/',
|
|
|
|
templates: ['something', 'default']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve collection', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('home');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve second page collection: should use index.hbs', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/magic/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('something');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('extended routes.yaml: routes', function () {
|
|
|
|
describe('channels', function () {
|
2019-01-14 21:04:22 +03:00
|
|
|
before(testUtils.integrationTesting.urlService.resetGenerators);
|
2019-01-04 23:59:39 +03:00
|
|
|
before(testUtils.teardown);
|
|
|
|
before(testUtils.setup('users:roles', 'posts'));
|
|
|
|
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme-channels'});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {
|
|
|
|
'/channel1/': {
|
|
|
|
controller: 'channel',
|
|
|
|
filter: 'tag:kitchen-sink',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tags',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'kitchen-sink'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'kitchen-sink'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
'/channel2/': {
|
|
|
|
controller: 'channel',
|
|
|
|
filter: 'tag:bacon',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tags',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'bacon'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'bacon'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: ['default']
|
|
|
|
},
|
|
|
|
|
|
|
|
'/channel3/': {
|
|
|
|
controller: 'channel',
|
|
|
|
filter: 'author:joe-bloggs',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
joe: {
|
|
|
|
controller: 'users',
|
|
|
|
resource: 'users',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'joe-bloggs',
|
|
|
|
redirect: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: false, slug: 'joe-bloggs'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
'/channel4/': {
|
|
|
|
controller: 'channel',
|
|
|
|
filter: 'author:joe-bloggs'
|
|
|
|
},
|
|
|
|
|
|
|
|
'/channel5/': {
|
|
|
|
controller: 'channel',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'users',
|
|
|
|
resource: 'users',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'joe-bloggs',
|
|
|
|
redirect: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: false, slug: 'joe-bloggs'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
'/channel6/': {
|
|
|
|
controller: 'channel',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
post: {
|
|
|
|
controller: 'posts',
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'html-ipsum',
|
|
|
|
redirect: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: true, slug: 'html-ipsum'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
'/channel7/': {
|
|
|
|
controller: 'channel',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
post: {
|
|
|
|
controller: 'posts',
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'static-page-test',
|
|
|
|
redirect: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: true, slug: 'static-page-test'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/tag/:slug/',
|
|
|
|
author: '/author/:slug/'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(10);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve channel 1', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel1/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
|
|
|
|
$('.post-card').length.should.equal(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve channel 1: rss', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel1/rss/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.headers['content-type'].should.eql('text/xml; charset=UTF-8');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve channel 2', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel2/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('default');
|
|
|
|
|
|
|
|
// default tempalte does not list posts
|
|
|
|
$('.post-card').length.should.equal(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve channel 3', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel3/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('channel3');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve channel 4', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel4/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
|
|
|
|
$('.post-card').length.should.equal(4);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve channel 5', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel5/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
|
|
|
|
$('.post-card').length.should.equal(4);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve channel 6', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel6/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
|
|
|
|
$('.post-card').length.should.equal(4);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve channel 7', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel7/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
|
|
|
|
$('.post-card').length.should.equal(4);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve kitching-sink: redirect', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/tag/kitchen-sink/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/channel1/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve html-ipsum: redirect', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/channel6/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve html-ipsum: redirect', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/static-page-test/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/channel7/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve chorizo: no redirect', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/tag/chorizo/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve joe-bloggs', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/author/joe-bloggs/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('extended routes.yaml (5): rss override', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {
|
|
|
|
'/about/': 'about',
|
|
|
|
'/podcast/rss/': {
|
|
|
|
templates: ['podcast/rss'],
|
|
|
|
content_type: 'xml'
|
|
|
|
},
|
|
|
|
'/cooking/': {
|
|
|
|
controller: 'channel',
|
|
|
|
rss: false
|
|
|
|
},
|
|
|
|
'/flat/': {
|
|
|
|
controller: 'channel'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
filter: 'featured:true',
|
|
|
|
templates: ['home'],
|
|
|
|
rss: false
|
|
|
|
},
|
|
|
|
'/music/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
rss: false
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
taxonomies: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v0.1');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve /rss/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/rss/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve /music/rss/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/music/rss/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve /cooking/rss/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/cooking/rss/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve /flat/rss/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/flat/rss/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve /podcast/rss/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/podcast/rss/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('podcast/rss');
|
|
|
|
response.headers['content-type'].should.eql('text/xml; charset=utf-8');
|
|
|
|
response.body.match(/<link>/g).length.should.eql(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve /podcast/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/podcast/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
$('head link')[2].attribs.href.should.eql('https://127.0.0.1:2369/rss/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('v2', function () {
|
|
|
|
let postSpy;
|
|
|
|
|
|
|
|
describe('default routes.yaml', function () {
|
|
|
|
before(function () {
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-02-27 19:50:20 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon, {amp: true, apps: true});
|
2019-01-04 23:59:39 +03:00
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
2019-02-27 19:50:20 +03:00
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
return appsService.init();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
before(function () {
|
|
|
|
configUtils.set('url', 'http://example.com');
|
|
|
|
urlUtils.stubUrlUtilsFromConfig();
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
beforeEach(function () {
|
2019-02-25 22:40:19 +03:00
|
|
|
const postsAPI = require('../../../server/api/v2/posts-public');
|
2019-01-21 19:53:44 +03:00
|
|
|
postSpy = sinon.spy(postsAPI.browse, 'query');
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
postSpy.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('behaviour: default cases', function () {
|
|
|
|
it('serve post', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('post');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-02-27 19:50:20 +03:00
|
|
|
it('serve amp', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/amp/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.match(/amp\.hbs/);
|
|
|
|
response.body.should.match(/<h1>HTML Ipsum Presents<\/h1>/);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('post not found', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/not-found/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve static page', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/static-page-test/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('page');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve author', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/author/joe-bloggs/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('author');
|
|
|
|
|
|
|
|
$('.author-bio').length.should.equal(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve tag', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/tag/bacon/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('tag');
|
|
|
|
|
2019-01-21 15:38:53 +03:00
|
|
|
postSpy.args[0][0].options.filter.should.eql('(tags:\'bacon\'+tags.visibility:public)+page:false');
|
2019-01-04 23:59:39 +03:00
|
|
|
postSpy.args[0][0].options.page.should.eql(1);
|
|
|
|
postSpy.args[0][0].options.limit.should.eql(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve tag rss', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/tag/bacon/rss/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve collection', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
|
|
|
|
$('.post-card').length.should.equal(2);
|
|
|
|
|
|
|
|
should.exist(response.res.locals.context);
|
|
|
|
should.exist(response.res.locals.version);
|
|
|
|
should.exist(response.res.locals.safeVersion);
|
|
|
|
should.exist(response.res.locals.safeVersion);
|
|
|
|
should.exist(response.res.locals.relativeUrl);
|
|
|
|
should.exist(response.res.locals.secure);
|
|
|
|
should.exist(response.res.routerOptions);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve collection: page 2', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/page/2/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
|
|
|
|
$('.post-card').length.should.equal(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve public asset', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/public/ghost-sdk.js',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve theme asset', function () {
|
|
|
|
//configUtils.set('url', 'https://example.com');
|
|
|
|
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/assets/css/screen.css',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('behaviour: prettify', function () {
|
|
|
|
it('url without slash', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/prettify-me',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/prettify-me/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('behaviour: url redirects', function () {
|
|
|
|
describe('pagination', function () {
|
|
|
|
it('redirect /page/1/ to /', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
host: 'example.com',
|
|
|
|
method: 'GET',
|
|
|
|
url: '/page/1/'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('rss', function () {
|
|
|
|
it('redirect /feed/ to /rss/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
host: 'example.com',
|
|
|
|
method: 'GET',
|
|
|
|
url: '/feed/'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/rss/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('redirect /rss/1/ to /rss/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
host: 'example.com',
|
|
|
|
method: 'GET',
|
|
|
|
url: '/rss/1/'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/rss/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2019-06-18 16:13:55 +03:00
|
|
|
});
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
describe('https', function () {
|
|
|
|
before(function () {
|
|
|
|
configUtils.set('url', 'https://example.com');
|
|
|
|
urlUtils.stubUrlUtilsFromConfig();
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
after(function () {
|
|
|
|
urlUtils.restore();
|
|
|
|
configUtils.restore();
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
describe('protocol', function () {
|
|
|
|
it('blog is https, request is http', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
host: 'example.com',
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum'
|
|
|
|
};
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('https://example.com/html-ipsum/');
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
it('blog is https, request is http, trailing slash exists already', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('https://example.com/html-ipsum/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
describe('assets', function () {
|
|
|
|
it('blog is https, request is http', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/public/ghost-sdk.js',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('https://example.com/public/ghost-sdk.js');
|
|
|
|
});
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
it('blog is https, request is http', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/favicon.png',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('https://example.com/favicon.png');
|
|
|
|
});
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
it('blog is https, request is http', function () {
|
|
|
|
const req = {
|
|
|
|
secure: false,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/assets/css/main.css',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-06-18 16:13:55 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('https://example.com/assets/css/main.css');
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('extended routes.yaml: collections', function () {
|
|
|
|
describe('2 collections', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {
|
|
|
|
'/': 'home'
|
|
|
|
},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/podcast/:slug/',
|
|
|
|
filter: 'featured:true'
|
|
|
|
},
|
|
|
|
|
|
|
|
'/something/': {
|
|
|
|
permalink: '/something/:slug/',
|
|
|
|
filter: 'featured:false'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/categories/:slug/',
|
|
|
|
author: '/authors/:slug/'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve static route', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('default');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve rss', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/podcast/rss/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve post', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/something/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('post');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve collection: podcast', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/podcast/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
|
|
|
|
$('.post-card').length.should.equal(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve collection: something', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/something/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
|
|
|
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
|
|
|
|
$('.post-card').length.should.equal(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('no collections', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {
|
|
|
|
'/test/': 'test'
|
|
|
|
},
|
|
|
|
collections: {},
|
|
|
|
taxonomies: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve route', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/test/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('default');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('static permalink route', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/featured/',
|
|
|
|
filter: 'featured:true'
|
|
|
|
},
|
|
|
|
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
taxonomies: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve post', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/featured/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
// We can't find a post with the slug "featured"
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve post', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('post');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve author', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/author/joe-bloggs/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve tag', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/tag/bacon/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('primary author permalink', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/something/': {
|
|
|
|
permalink: '/:primary_author/:slug/'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
taxonomies: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve post', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/joe-bloggs/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('post');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('post without author', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('page', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/static-page-test/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('page');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('primary tag permalink', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/something/': {
|
|
|
|
permalink: '/something/:primary_tag/:slug/'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
taxonomies: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve post', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/something/kitchen-sink/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('post');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('post without tag', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/something/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('post without tag', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(404);
|
|
|
|
response.template.should.eql('error-404');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('page', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/static-page-test/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('page');
|
|
|
|
});
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
|
2019-03-13 13:13:52 +03:00
|
|
|
describe('collection/routes with data key', function () {
|
2019-01-04 23:59:39 +03:00
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-03-13 13:13:52 +03:00
|
|
|
routes: {
|
|
|
|
'/my-page/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
page: {
|
|
|
|
controller: 'pagesPublic',
|
|
|
|
resource: 'pages',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'static-page-test'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
pages: [{redirect: true, slug: 'static-page-test'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
collections: {
|
|
|
|
'/food/': {
|
|
|
|
permalink: '/food/:slug/',
|
|
|
|
filter: 'tag:bacon+tag:-chorizo',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'bacon'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'bacon'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/sport/': {
|
|
|
|
permalink: '/sport/:slug/',
|
|
|
|
filter: 'tag:chorizo+tag:-bacon',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
apollo: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'chorizo'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: false, slug: 'chorizo'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
taxonomies: {
|
|
|
|
tag: '/categories/:slug/',
|
|
|
|
author: '/authors/:slug/'
|
|
|
|
}
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve /food/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/food/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve bacon tag', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/categories/bacon/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve /sport/', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/sport/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve chorizo tag', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/categories/chorizo/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
2019-03-13 13:13:52 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve my-page', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/my-page/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('extended routes.yaml: templates', function () {
|
|
|
|
describe('default template, no template', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['default']
|
|
|
|
},
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/:slug/'
|
|
|
|
}
|
2018-06-24 01:32:08 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve collection', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('default');
|
|
|
|
});
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve second collectiom', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/magic/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
|
|
|
});
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('two templates', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['something', 'default']
|
|
|
|
}
|
|
|
|
}
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon);
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve collection', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('default');
|
|
|
|
});
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('home.hbs priority', function () {
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['something', 'default']
|
|
|
|
},
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/:slug/',
|
|
|
|
templates: ['something', 'default']
|
|
|
|
}
|
|
|
|
}
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('serve collection', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('home');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('serve second page collection: should use index.hbs', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/magic/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('something');
|
|
|
|
});
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('extended routes.yaml: routes', function () {
|
|
|
|
describe('channels', function () {
|
2019-01-14 21:04:22 +03:00
|
|
|
before(testUtils.integrationTesting.urlService.resetGenerators);
|
2019-01-04 23:59:39 +03:00
|
|
|
before(testUtils.teardown);
|
|
|
|
before(testUtils.setup('users:roles', 'posts'));
|
|
|
|
|
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme-channels'});
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {
|
|
|
|
'/channel1/': {
|
|
|
|
controller: 'channel',
|
|
|
|
filter: 'tag:kitchen-sink',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'kitchen-sink'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'kitchen-sink'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
'/channel2/': {
|
|
|
|
controller: 'channel',
|
|
|
|
filter: 'tag:bacon',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'bacon'
|
|
|
|
}
|
2018-06-24 01:32:08 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'bacon'}]
|
2018-06-24 01:32:08 +03:00
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
templates: ['default']
|
|
|
|
},
|
|
|
|
|
|
|
|
'/channel3/': {
|
|
|
|
controller: 'channel',
|
|
|
|
filter: 'author:joe-bloggs',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
joe: {
|
2019-02-25 21:52:17 +03:00
|
|
|
controller: 'authorsPublic',
|
2019-01-04 23:59:39 +03:00
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'joe-bloggs',
|
|
|
|
redirect: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: false, slug: 'joe-bloggs'}]
|
|
|
|
}
|
2018-06-24 01:32:08 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
'/channel4/': {
|
|
|
|
controller: 'channel',
|
|
|
|
filter: 'author:joe-bloggs'
|
|
|
|
},
|
|
|
|
|
|
|
|
'/channel5/': {
|
|
|
|
controller: 'channel',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
2019-02-25 21:52:17 +03:00
|
|
|
controller: 'authorsPublic',
|
2019-01-04 23:59:39 +03:00
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'joe-bloggs',
|
|
|
|
redirect: false
|
|
|
|
}
|
2018-06-24 01:32:08 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: false, slug: 'joe-bloggs'}]
|
2018-06-24 01:32:08 +03:00
|
|
|
}
|
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
},
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
'/channel6/': {
|
|
|
|
controller: 'channel',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
post: {
|
2019-02-25 22:40:19 +03:00
|
|
|
controller: 'postsPublic',
|
2019-01-04 23:59:39 +03:00
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'html-ipsum',
|
|
|
|
redirect: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: true, slug: 'html-ipsum'}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/'
|
|
|
|
}
|
|
|
|
},
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
taxonomies: {
|
|
|
|
tag: '/tag/:slug/',
|
|
|
|
author: '/author/:slug/'
|
|
|
|
}
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(10);
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
app = siteApp({start: true});
|
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve channel 1', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel1/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
$('.post-card').length.should.equal(2);
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve channel 1: rss', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel1/rss/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.headers['content-type'].should.eql('text/xml; charset=UTF-8');
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve channel 2', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel2/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('default');
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
// default tempalte does not list posts
|
|
|
|
$('.post-card').length.should.equal(0);
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve channel 3', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel3/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('channel3');
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve channel 4', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel4/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
$('.post-card').length.should.equal(4);
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve channel 5', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel5/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
$('.post-card').length.should.equal(4);
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve channel 6', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/channel6/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
response.template.should.eql('index');
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
$('.post-card').length.should.equal(4);
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve kitching-sink: redirect', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/tag/kitchen-sink/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/channel1/');
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve html-ipsum: redirect', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/html-ipsum/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(301);
|
|
|
|
response.headers.location.should.eql('/channel6/');
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve chorizo: no redirect', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/tag/chorizo/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve joe-bloggs', function () {
|
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
|
|
|
url: '/author/joe-bloggs/',
|
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('extended routes.yaml (5): rss override', function () {
|
2018-06-24 01:32:08 +03:00
|
|
|
before(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(settingsService, 'get').returns({
|
2018-06-24 01:32:08 +03:00
|
|
|
routes: {
|
2019-01-04 23:59:39 +03:00
|
|
|
'/about/': 'about',
|
|
|
|
'/podcast/rss/': {
|
|
|
|
templates: ['podcast/rss'],
|
|
|
|
content_type: 'xml'
|
2018-06-24 01:32:08 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
'/cooking/': {
|
2018-12-03 22:31:48 +03:00
|
|
|
controller: 'channel',
|
2019-01-04 23:59:39 +03:00
|
|
|
rss: false
|
2018-12-03 22:31:48 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
'/flat/': {
|
|
|
|
controller: 'channel'
|
2018-06-24 01:32:08 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-12-03 22:31:48 +03:00
|
|
|
collections: {
|
2019-01-04 23:59:39 +03:00
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
filter: 'featured:true',
|
|
|
|
templates: ['home'],
|
|
|
|
rss: false
|
|
|
|
},
|
|
|
|
'/music/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
rss: false
|
|
|
|
},
|
2018-12-03 22:31:48 +03:00
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/'
|
|
|
|
}
|
|
|
|
},
|
2018-06-24 01:32:08 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
taxonomies: {}
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
|
2018-06-24 01:32:08 +03:00
|
|
|
testUtils.integrationTesting.urlService.resetGenerators();
|
2019-01-21 19:53:44 +03:00
|
|
|
testUtils.integrationTesting.defaultMocks(sinon, {theme: 'test-theme'});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2018-06-24 01:32:08 +03:00
|
|
|
return testUtils.integrationTesting.initGhost()
|
|
|
|
.then(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.stub(themeService.getActive(), 'engine').withArgs('ghost-api').returns('v2');
|
|
|
|
sinon.stub(themeService.getActive(), 'config').withArgs('posts_per_page').returns(2);
|
2019-01-04 23:59:39 +03:00
|
|
|
|
2018-08-06 18:18:59 +03:00
|
|
|
app = siteApp({start: true});
|
2018-06-24 01:32:08 +03:00
|
|
|
return testUtils.integrationTesting.urlService.waitTillFinished();
|
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2018-06-24 01:32:08 +03:00
|
|
|
beforeEach(function () {
|
|
|
|
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2019-06-18 16:13:55 +03:00
|
|
|
urlUtils.restore();
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve /rss/', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/rss/',
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve /music/rss/', function () {
|
2018-06-24 01:32:08 +03:00
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/music/rss/',
|
2018-06-24 01:32:08 +03:00
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2018-06-24 01:32:08 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(404);
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve /cooking/rss/', function () {
|
2018-06-24 01:32:08 +03:00
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/cooking/rss/',
|
2018-06-24 01:32:08 +03:00
|
|
|
host: 'example.com'
|
|
|
|
};
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2018-06-24 01:32:08 +03:00
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
2019-01-04 23:59:39 +03:00
|
|
|
response.statusCode.should.eql(404);
|
2018-06-24 01:32:08 +03:00
|
|
|
});
|
|
|
|
});
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve /flat/rss/', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/flat/rss/',
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve /podcast/rss/', function () {
|
2018-12-03 22:31:48 +03:00
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/podcast/rss/',
|
2018-12-03 22:31:48 +03:00
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
response.statusCode.should.eql(200);
|
2019-01-04 23:59:39 +03:00
|
|
|
response.template.should.eql('podcast/rss');
|
|
|
|
response.headers['content-type'].should.eql('text/xml; charset=utf-8');
|
|
|
|
response.body.match(/<link>/g).length.should.eql(2);
|
2018-12-03 22:31:48 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('serve /podcast/', function () {
|
2018-12-03 22:31:48 +03:00
|
|
|
const req = {
|
|
|
|
secure: true,
|
|
|
|
method: 'GET',
|
2019-01-04 23:59:39 +03:00
|
|
|
url: '/podcast/',
|
2018-12-03 22:31:48 +03:00
|
|
|
host: 'example.com'
|
|
|
|
};
|
|
|
|
|
|
|
|
return testUtils.mocks.express.invoke(app, req)
|
|
|
|
.then(function (response) {
|
|
|
|
const $ = cheerio.load(response.body);
|
2018-08-10 15:11:13 +03:00
|
|
|
response.statusCode.should.eql(200);
|
2019-01-04 23:59:39 +03:00
|
|
|
$('head link')[2].attribs.href.should.eql('https://127.0.0.1:2369/rss/');
|
2018-02-14 19:21:31 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|