mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
5e5b90ac29
refs #9192 - Introduces a url service that can be initialised - Added a concept of Resources and resource config.json that contains details about the resources in the system that we may want to make customisable - Note that individual resources know how to create their own Urls... this is important for later - Url Service loads all of the resources, and stores their URLs - The UrlService binds to all events, so that when a resource changes its url and related data can be updated if needed - There is a temporary config guard so that this can be turned off easily
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const debug = require('ghost-ignition').debug('services:url:init'),
|
|
config = require('../../config'),
|
|
events = require('../../events'),
|
|
UrlService = require('./UrlService');
|
|
|
|
// @TODO we seriously should move this or make it do almost nothing...
|
|
module.exports.init = function init() {
|
|
// Temporary config value just in case this causes problems
|
|
// @TODO delete this
|
|
if (config.get('disableUrlService')) {
|
|
return;
|
|
}
|
|
|
|
// Kick off the constructor
|
|
const urlService = new UrlService();
|
|
|
|
urlService.bind();
|
|
|
|
// Hardcoded routes
|
|
// @TODO figure out how to do this from channel or other config
|
|
// @TODO get rid of name concept (for compat with sitemaps)
|
|
UrlService.cacheRoute('/', {name: 'home'});
|
|
// @TODO figure out how to do this from apps
|
|
// @TODO only do this if subscribe is enabled!
|
|
UrlService.cacheRoute('/subscribe/', {});
|
|
|
|
// Register a listener for server-start to load all the known urls
|
|
events.on('server:start', function loadAllUrls() {
|
|
debug('URL service, loading all URLS');
|
|
urlService.loadResourceUrls();
|
|
});
|
|
};
|