2019-01-04 23:59:39 +03:00
|
|
|
const should = require('should');
|
|
|
|
const sinon = require('sinon');
|
2020-05-25 11:49:38 +03:00
|
|
|
const errors = require('@tryghost/errors');
|
2021-04-23 15:22:45 +03:00
|
|
|
const themeEngine = require('../../../../core/frontend/services/theme-engine');
|
2020-03-30 18:26:47 +03:00
|
|
|
const validate = require('../../../../core/frontend/services/settings/validate');
|
✨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
|
|
|
|
|
|
|
should.equal(true, true);
|
|
|
|
|
|
|
|
describe('UNIT: services/settings/validate', function () {
|
2019-01-04 23:59:39 +03:00
|
|
|
let apiVersion;
|
✨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
|
|
|
before(function () {
|
2021-04-23 15:22:45 +03:00
|
|
|
sinon.stub(themeEngine, 'getActive').returns({
|
2019-01-04 23:59:39 +03:00
|
|
|
engine: () => {
|
|
|
|
return apiVersion;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
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('v2', function () {
|
|
|
|
before(function () {
|
|
|
|
apiVersion = 'v2';
|
|
|
|
});
|
✨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('no type definitions / empty yaml file', function () {
|
|
|
|
const object = validate({});
|
✨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
|
|
|
object.should.eql({collections: {}, routes: {}, 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
|
|
|
|
2019-08-09 17:25:12 +03:00
|
|
|
it('throws error when using :\w+ notiation in collection', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/{slug}/'
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error when using :\w+ notiation in taxonomies', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/categories/:slug/'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error when using an undefined taxonomy', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
taxonomies: {
|
|
|
|
sweet_baked_good: '/patisserie/{slug}'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error when permalink is missing (collection)', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
about: 'about'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
'/about': 'about'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
'about/': 'about'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'magic/': {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
magic: {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic': {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '{slug}'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('no validation error for routes', function () {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
'/': 'home'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('no validation error for / collection', function () {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/{primary_tag}/{slug}/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('transforms {.*} notation into :\w+', function () {
|
|
|
|
const object = validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/{year}/{slug}/'
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/tags/{slug}/',
|
|
|
|
author: '/authors/{slug}/'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
routes: {},
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/tags/:slug/',
|
|
|
|
author: '/authors/:slug/'
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/:year/:slug/',
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('template definitions', function () {
|
|
|
|
it('single value', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/about/': 'about',
|
|
|
|
'/me/': {
|
|
|
|
template: 'me'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
template: 'test'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/about/': {
|
|
|
|
templates: ['about']
|
|
|
|
},
|
|
|
|
'/me/': {
|
|
|
|
templates: ['me']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['test']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('array', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/about/': 'about',
|
|
|
|
'/me/': {
|
|
|
|
template: ['me']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
template: ['test']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/about/': {
|
|
|
|
templates: ['about']
|
|
|
|
},
|
|
|
|
'/me/': {
|
|
|
|
templates: ['me']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['test']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('data definitions', function () {
|
|
|
|
it('shortform', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: 'tag.food'
|
|
|
|
},
|
|
|
|
'/music/': {
|
|
|
|
data: 'tag.music'
|
|
|
|
},
|
|
|
|
'/ghost/': {
|
|
|
|
data: 'author.ghost'
|
|
|
|
},
|
|
|
|
'/sleep/': {
|
|
|
|
data: {
|
|
|
|
bed: 'tag.bed',
|
|
|
|
dream: 'tag.dream'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/lala/': {
|
|
|
|
data: 'author.carsten'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/more/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
home: 'page.home'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/podcast/{slug}/',
|
|
|
|
data: {
|
|
|
|
something: 'tag.something'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: 'tag.sport'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'food',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'food'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/ghost/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
author: {
|
|
|
|
controller: 'authorsPublic',
|
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'ghost'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: true, slug: 'ghost'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/music/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'music',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'music'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/sleep/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
bed: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'bed',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
dream: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'dream',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'bed'}, {redirect: true, slug: 'dream'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/lala/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
author: {
|
|
|
|
controller: 'authorsPublic',
|
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'carsten'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: true, slug: 'carsten'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/more/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
home: {
|
|
|
|
controller: 'pagesPublic',
|
|
|
|
resource: 'pages',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'home'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
pages: [{redirect: true, slug: 'home'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/podcast/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
something: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'something',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'something'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'sport',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'sport'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('longform', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: {
|
|
|
|
food: {
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'browse'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/wellness/': {
|
|
|
|
data: {
|
|
|
|
posts: {
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
redirect: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/partyparty/': {
|
|
|
|
data: {
|
|
|
|
people: {
|
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
slug: 'djgutelaune',
|
|
|
|
redirect: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/yoga/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
gym: {
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
slug: 'ups',
|
|
|
|
status: 'draft'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
food: {
|
|
|
|
controller: 'postsPublic',
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'browse',
|
|
|
|
options: {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: true}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/wellness/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
posts: {
|
|
|
|
controller: 'postsPublic',
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: '%s'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: false}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/partyparty/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
people: {
|
|
|
|
controller: 'authorsPublic',
|
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'djgutelaune'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: true, slug: 'djgutelaune'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/yoga/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
gym: {
|
|
|
|
controller: 'postsPublic',
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'ups',
|
|
|
|
status: 'draft'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: true, slug: 'ups'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('errors: data shortform incorrect', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: 'tag:test'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('errors: data longform resource is missing', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
type: 'edit'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('errors: data longform type is missing', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
resource: 'subscribers'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('errors: data longform name is author', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
author: {
|
|
|
|
resource: 'users'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('errors: data longform does not use a custom name at all', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
resource: 'users'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-08-09 17:25:12 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('canary', function () {
|
|
|
|
before(function () {
|
|
|
|
apiVersion = 'canary';
|
|
|
|
});
|
|
|
|
|
|
|
|
it('no type definitions / empty yaml file', function () {
|
|
|
|
const object = validate({});
|
|
|
|
|
|
|
|
object.should.eql({collections: {}, routes: {}, taxonomies: {}});
|
|
|
|
});
|
|
|
|
|
2019-09-03 10:03:31 +03:00
|
|
|
it('throws error when using :\w+ notiation in collection', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/{slug}/'
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error when using :\w+ notiation in taxonomies', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/categories/:slug/'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error when using an undefined taxonomy', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
taxonomies: {
|
|
|
|
sweet_baked_good: '/patisserie/{slug}'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error when permalink is missing (collection)', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
about: 'about'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
'/about': 'about'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
'about/': 'about'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'magic/': {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
magic: {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic': {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '{slug}'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('no validation error for routes', function () {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
'/': 'home'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('no validation error for / collection', function () {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/{primary_tag}/{slug}/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('transforms {.*} notation into :\w+', function () {
|
|
|
|
const object = validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/{year}/{slug}/'
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/tags/{slug}/',
|
|
|
|
author: '/authors/{slug}/'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
routes: {},
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/tags/:slug/',
|
|
|
|
author: '/authors/:slug/'
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/:year/:slug/',
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('template definitions', function () {
|
|
|
|
it('single value', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/about/': 'about',
|
|
|
|
'/me/': {
|
|
|
|
template: 'me'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
template: 'test'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/about/': {
|
|
|
|
templates: ['about']
|
|
|
|
},
|
|
|
|
'/me/': {
|
|
|
|
templates: ['me']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['test']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('array', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/about/': 'about',
|
|
|
|
'/me/': {
|
|
|
|
template: ['me']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
template: ['test']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/about/': {
|
|
|
|
templates: ['about']
|
|
|
|
},
|
|
|
|
'/me/': {
|
|
|
|
templates: ['me']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['test']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('data definitions', function () {
|
|
|
|
it('shortform', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: 'tag.food'
|
|
|
|
},
|
|
|
|
'/music/': {
|
|
|
|
data: 'tag.music'
|
|
|
|
},
|
|
|
|
'/ghost/': {
|
|
|
|
data: 'author.ghost'
|
|
|
|
},
|
|
|
|
'/sleep/': {
|
|
|
|
data: {
|
|
|
|
bed: 'tag.bed',
|
|
|
|
dream: 'tag.dream'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/lala/': {
|
|
|
|
data: 'author.carsten'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/more/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
home: 'page.home'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/podcast/{slug}/',
|
|
|
|
data: {
|
|
|
|
something: 'tag.something'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: 'tag.sport'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'food',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'food'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/ghost/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
author: {
|
|
|
|
controller: 'authorsPublic',
|
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'ghost'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: true, slug: 'ghost'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/music/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'music',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'music'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/sleep/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
bed: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'bed',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
dream: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'dream',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'bed'}, {redirect: true, slug: 'dream'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/lala/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
author: {
|
|
|
|
controller: 'authorsPublic',
|
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'carsten'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: true, slug: 'carsten'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/more/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
home: {
|
|
|
|
controller: 'pagesPublic',
|
|
|
|
resource: 'pages',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'home'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
pages: [{redirect: true, slug: 'home'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/podcast/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
something: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'something',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'something'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'sport',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'sport'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('longform', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: {
|
|
|
|
food: {
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'browse'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/wellness/': {
|
|
|
|
data: {
|
|
|
|
posts: {
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
redirect: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/partyparty/': {
|
|
|
|
data: {
|
|
|
|
people: {
|
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
slug: 'djgutelaune',
|
|
|
|
redirect: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/yoga/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
gym: {
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
slug: 'ups',
|
|
|
|
status: 'draft'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
food: {
|
|
|
|
controller: 'postsPublic',
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'browse',
|
|
|
|
options: {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: true}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/wellness/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
posts: {
|
|
|
|
controller: 'postsPublic',
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: '%s'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: false}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/partyparty/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
people: {
|
|
|
|
controller: 'authorsPublic',
|
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'djgutelaune'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: true, slug: 'djgutelaune'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/yoga/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
gym: {
|
|
|
|
controller: 'postsPublic',
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'ups',
|
|
|
|
status: 'draft'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: true, slug: 'ups'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('errors: data shortform incorrect', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: 'tag:test'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('errors: data longform resource is missing', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
type: 'edit'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('errors: data longform type is missing', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
resource: 'subscribers'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('errors: data longform name is author', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
author: {
|
|
|
|
resource: 'users'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('errors: data longform does not use a custom name at all', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
resource: 'users'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-09-03 10:03:31 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('v3', function () {
|
|
|
|
before(function () {
|
|
|
|
apiVersion = 'v3';
|
|
|
|
});
|
|
|
|
|
|
|
|
it('no type definitions / empty yaml file', function () {
|
|
|
|
const object = validate({});
|
|
|
|
|
|
|
|
object.should.eql({collections: {}, routes: {}, taxonomies: {}});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('throws error when using :\w+ notiation in collection', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/{slug}/'
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
✨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
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error when using :\w+ notiation in taxonomies', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/categories/: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
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
✨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
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
✨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('throws error when using an undefined taxonomy', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
taxonomies: {
|
|
|
|
sweet_baked_good: '/patisserie/{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
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
✨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
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
✨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('throws error when permalink is missing (collection)', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
✨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
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
✨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
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
✨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('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
about: 'about'
|
✨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
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
✨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
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
✨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('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
'/about': 'about'
|
✨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
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
✨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
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
✨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('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
'about/': 'about'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
✨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
|
|
|
|
|
|
|
throw new Error('should fail');
|
✨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('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'magic/': {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
✨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
|
|
|
|
|
|
|
throw new Error('should fail');
|
✨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('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
magic: {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
✨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
|
|
|
|
|
|
|
throw new Error('should fail');
|
✨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('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic': {
|
|
|
|
permalink: '/{slug}/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
✨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
|
|
|
|
|
|
|
throw new Error('should fail');
|
✨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-21 16:46:42 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}'
|
|
|
|
}
|
2018-06-21 16:46:42 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('throws error without leading or trailing slashes', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '{slug}'
|
|
|
|
}
|
2018-06-21 16:46:42 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('no validation error for routes', function () {
|
|
|
|
validate({
|
|
|
|
routes: {
|
|
|
|
'/': 'home'
|
2018-06-21 16:46:42 +03:00
|
|
|
}
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-21 16:46:42 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('no validation error for / collection', function () {
|
|
|
|
validate({
|
2018-06-21 16:46:42 +03:00
|
|
|
collections: {
|
|
|
|
'/': {
|
2019-01-04 23:59:39 +03:00
|
|
|
permalink: '/{primary_tag}/{slug}/'
|
2018-06-21 16:46:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('transforms {.*} notation into :\w+', function () {
|
2018-06-21 16:46:42 +03:00
|
|
|
const object = validate({
|
|
|
|
collections: {
|
2019-01-04 23:59:39 +03:00
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/{year}/{slug}/'
|
|
|
|
},
|
2018-06-21 16:46:42 +03:00
|
|
|
'/': {
|
2019-01-04 23:59:39 +03:00
|
|
|
permalink: '/{slug}/'
|
2018-06-21 16:46:42 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
},
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/tags/{slug}/',
|
2019-07-05 14:40:43 +03:00
|
|
|
author: '/authors/{slug}/'
|
2018-06-21 16:46:42 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
2019-01-04 23:59:39 +03:00
|
|
|
routes: {},
|
|
|
|
taxonomies: {
|
|
|
|
tag: '/tags/:slug/',
|
|
|
|
author: '/authors/:slug/'
|
2018-06-21 16:46:42 +03:00
|
|
|
},
|
|
|
|
collections: {
|
2019-01-04 23:59:39 +03:00
|
|
|
'/magic/': {
|
|
|
|
permalink: '/magic/:year/:slug/',
|
|
|
|
templates: []
|
|
|
|
},
|
2018-06-21 16:46:42 +03:00
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
2019-01-04 23:59:39 +03:00
|
|
|
templates: []
|
2018-06-21 16:46:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2018-06-24 01:32:02 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('template definitions', function () {
|
|
|
|
it('single value', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/about/': 'about',
|
|
|
|
'/me/': {
|
|
|
|
template: 'me'
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
template: 'test'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/about/': {
|
|
|
|
templates: ['about']
|
|
|
|
},
|
|
|
|
'/me/': {
|
|
|
|
templates: ['me']
|
|
|
|
}
|
2018-08-16 12:48:33 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['test']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('array', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/about/': 'about',
|
|
|
|
'/me/': {
|
|
|
|
template: ['me']
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
2018-11-07 17:29:37 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
template: ['test']
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/about/': {
|
|
|
|
templates: ['about']
|
|
|
|
},
|
|
|
|
'/me/': {
|
|
|
|
templates: ['me']
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
templates: ['test']
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:02 +03:00
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:02 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
describe('data definitions', function () {
|
|
|
|
it('shortform', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: 'tag.food'
|
|
|
|
},
|
|
|
|
'/music/': {
|
|
|
|
data: 'tag.music'
|
|
|
|
},
|
|
|
|
'/ghost/': {
|
|
|
|
data: 'author.ghost'
|
|
|
|
},
|
|
|
|
'/sleep/': {
|
|
|
|
data: {
|
|
|
|
bed: 'tag.bed',
|
|
|
|
dream: 'tag.dream'
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
'/lala/': {
|
|
|
|
data: 'author.carsten'
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/more/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
home: 'page.home'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/podcast/{slug}/',
|
|
|
|
data: {
|
|
|
|
something: 'tag.something'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: 'tag.sport'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'food',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
2018-08-16 12:48:33 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'food'}]
|
2018-08-16 12:48:33 +03:00
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
templates: []
|
2018-08-16 12:48:33 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
'/ghost/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
author: {
|
2019-02-25 21:52:17 +03:00
|
|
|
controller: 'authorsPublic',
|
2019-01-04 23:59:39 +03:00
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'ghost'
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: true, slug: 'ghost'}]
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
templates: []
|
2018-06-24 01:32:02 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
'/music/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'music',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'music'}]
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
templates: []
|
2018-06-24 01:32:02 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
'/sleep/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
bed: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'bed',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
dream: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'dream',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
2018-11-07 17:29:37 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'bed'}, {redirect: true, slug: 'dream'}]
|
2018-11-07 17:29:37 +03:00
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
templates: []
|
2018-11-07 17:29:37 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
'/lala/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
author: {
|
2019-02-25 21:52:17 +03:00
|
|
|
controller: 'authorsPublic',
|
2019-01-04 23:59:39 +03:00
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'carsten'
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: true, slug: 'carsten'}]
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
templates: []
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
collections: {
|
|
|
|
'/more/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
home: {
|
2019-02-22 06:17:14 +03:00
|
|
|
controller: 'pagesPublic',
|
2019-01-04 23:59:39 +03:00
|
|
|
resource: 'pages',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'home'
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
},
|
|
|
|
router: {
|
|
|
|
pages: [{redirect: true, slug: 'home'}]
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
templates: []
|
2018-06-24 01:32:02 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
'/podcast/': {
|
|
|
|
permalink: '/podcast/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
something: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'something',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'something'}]
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
templates: []
|
2018-06-24 01:32:02 +03:00
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
'/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
tag: {
|
|
|
|
controller: 'tagsPublic',
|
|
|
|
resource: 'tags',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'sport',
|
|
|
|
visibility: 'public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
tags: [{redirect: true, slug: 'sport'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:02 +03:00
|
|
|
});
|
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('longform', function () {
|
|
|
|
const object = validate({
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: {
|
2018-06-24 01:32:02 +03:00
|
|
|
food: {
|
|
|
|
resource: 'posts',
|
2019-01-04 23:59:39 +03:00
|
|
|
type: 'browse'
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
'/wellness/': {
|
|
|
|
data: {
|
2018-06-24 01:32:02 +03:00
|
|
|
posts: {
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
2019-01-04 23:59:39 +03:00
|
|
|
redirect: false
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-01-04 23:59:39 +03:00
|
|
|
'/partyparty/': {
|
|
|
|
data: {
|
2018-11-07 17:29:37 +03:00
|
|
|
people: {
|
2019-01-04 23:59:39 +03:00
|
|
|
resource: 'authors',
|
2018-06-24 01:32:02 +03:00
|
|
|
type: 'read',
|
2019-01-04 23:59:39 +03:00
|
|
|
slug: 'djgutelaune',
|
|
|
|
redirect: true
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
collections: {
|
|
|
|
'/yoga/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
2018-06-24 01:32:02 +03:00
|
|
|
gym: {
|
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
2019-01-04 23:59:39 +03:00
|
|
|
slug: 'ups',
|
|
|
|
status: 'draft'
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
}
|
2019-07-05 14:40:43 +03:00
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-06-24 01:32:02 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
object.should.eql({
|
|
|
|
taxonomies: {},
|
|
|
|
routes: {
|
|
|
|
'/food/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
food: {
|
2019-02-22 06:17:14 +03:00
|
|
|
controller: 'postsPublic',
|
2019-01-04 23:59:39 +03:00
|
|
|
resource: 'posts',
|
|
|
|
type: 'browse',
|
|
|
|
options: {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: true}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/wellness/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
posts: {
|
2019-02-22 06:17:14 +03:00
|
|
|
controller: 'postsPublic',
|
2019-01-04 23:59:39 +03:00
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: '%s'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: false}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
},
|
|
|
|
'/partyparty/': {
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
people: {
|
2019-02-25 21:52:17 +03:00
|
|
|
controller: 'authorsPublic',
|
2019-01-04 23:59:39 +03:00
|
|
|
resource: 'authors',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'djgutelaune'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
authors: [{redirect: true, slug: 'djgutelaune'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
|
|
|
}
|
|
|
|
},
|
2018-06-24 01:32:02 +03:00
|
|
|
collections: {
|
2019-01-04 23:59:39 +03:00
|
|
|
'/yoga/': {
|
|
|
|
permalink: '/:slug/',
|
|
|
|
data: {
|
|
|
|
query: {
|
|
|
|
gym: {
|
2019-02-22 06:17:14 +03:00
|
|
|
controller: 'postsPublic',
|
2019-01-04 23:59:39 +03:00
|
|
|
resource: 'posts',
|
|
|
|
type: 'read',
|
|
|
|
options: {
|
|
|
|
slug: 'ups',
|
|
|
|
status: 'draft'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
router: {
|
|
|
|
posts: [{redirect: true, slug: 'ups'}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
templates: []
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
2018-08-16 12:48:33 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('errors: data shortform incorrect', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: 'tag:test'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('errors: data longform resource is missing', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
type: 'edit'
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
2018-08-16 12:48:33 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('errors: data longform type is missing', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
resource: 'subscribers'
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
}
|
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
2018-06-24 01:32:02 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
2018-08-16 12:48:33 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('errors: data longform name is author', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
author: {
|
|
|
|
resource: 'users'
|
|
|
|
}
|
2018-08-16 12:48:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
2018-08-16 12:48:33 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
2018-08-16 12:48:33 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
it('errors: data longform does not use a custom name at all', function () {
|
|
|
|
try {
|
|
|
|
validate({
|
|
|
|
collections: {
|
|
|
|
'/magic/': {
|
|
|
|
permalink: '/{slug}/',
|
|
|
|
data: {
|
|
|
|
resource: 'users'
|
|
|
|
}
|
2018-08-16 12:48:33 +03:00
|
|
|
}
|
|
|
|
}
|
2019-01-04 23:59:39 +03:00
|
|
|
});
|
|
|
|
} catch (err) {
|
2020-05-25 11:49:38 +03:00
|
|
|
(err instanceof errors.ValidationError).should.be.true();
|
2019-01-04 23:59:39 +03:00
|
|
|
return;
|
|
|
|
}
|
2018-08-16 12:48:33 +03:00
|
|
|
|
2019-01-04 23:59:39 +03:00
|
|
|
throw new Error('should fail');
|
|
|
|
});
|
2018-08-16 12:48:33 +03:00
|
|
|
});
|
2018-06-24 01:32:02 +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
|
|
|
});
|