@reldens/cms 0.15.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -34
- package/admin/reldens-admin-client.css +39 -23
- package/admin/reldens-admin-client.js +7 -0
- package/admin/templates/cache-clean-button.html +4 -0
- package/admin/templates/edit.html +3 -1
- package/admin/templates/fields/view/textarea.html +1 -0
- package/admin/templates/sections/editForm/cms-pages.html +15 -0
- package/admin/templates/sections/viewForm/cms-pages.html +15 -0
- package/admin/templates/view.html +1 -0
- package/bin/reldens-cms-generate-entities.js +116 -5
- package/bin/reldens-cms.js +26 -8
- package/install/js/installer.js +5 -0
- package/install/success.html +1 -1
- package/lib/admin-manager/contents-builder.js +256 -0
- package/lib/admin-manager/router-contents.js +576 -0
- package/lib/admin-manager/router.js +208 -0
- package/lib/admin-manager.js +114 -944
- package/lib/cache/add-cache-button-subscriber.js +101 -0
- package/lib/cache/cache-manager.js +129 -0
- package/lib/cache/cache-routes-handler.js +76 -0
- package/lib/cms-pages-route-manager.js +117 -0
- package/lib/frontend.js +207 -64
- package/lib/installer.js +44 -20
- package/lib/json-fields-parser.js +74 -0
- package/lib/manager.js +55 -10
- package/lib/template-engine.js +361 -41
- package/lib/templates-list.js +10 -0
- package/migrations/default-blocks.sql +1 -1
- package/migrations/default-entity-access.sql +2 -2
- package/migrations/default-homepage.sql +27 -7
- package/migrations/install.sql +33 -36
- package/package.json +3 -3
- package/templates/index.js.dist +3 -3
- package/templates/js/scripts.js +5 -0
- package/templates/layouts/default.html +4 -4
- package/templates/page.html +14 -10
- package/templates/partials/footer.html +2 -23
- package/templates/partials/header.html +2 -35
package/lib/manager.js
CHANGED
|
@@ -14,8 +14,10 @@ const { TemplatesToPathMapper } = require('./templates-to-path-mapper');
|
|
|
14
14
|
const { AdminEntitiesGenerator } = require('./admin-entities-generator');
|
|
15
15
|
const { LoadedEntitiesProcessor } = require('./loaded-entities-processor');
|
|
16
16
|
const { AdminManager } = require('./admin-manager');
|
|
17
|
+
const { CmsPagesRouteManager } = require('./cms-pages-route-manager');
|
|
17
18
|
const { Installer } = require('./installer');
|
|
18
19
|
const { Frontend } = require('./frontend');
|
|
20
|
+
const { CacheManager } = require('./cache/cache-manager');
|
|
19
21
|
const { EventsManagerSingleton, Logger, sc } = require('@reldens/utils');
|
|
20
22
|
const { DriversMap } = require('@reldens/storage');
|
|
21
23
|
const { AppServerFactory, FileHandler, Encryptor } = require('@reldens/server-utils');
|
|
@@ -47,6 +49,7 @@ class Manager
|
|
|
47
49
|
this.mimeTypes = sc.get(props, 'mimeTypes', MimeTypes);
|
|
48
50
|
this.allowedExtensions = sc.get(props, 'allowedExtensions', AllowedExtensions)
|
|
49
51
|
this.adminRoleId = sc.get(props, 'adminRoleId', 99);
|
|
52
|
+
this.mappedAdminTemplates = TemplatesToPathMapper.map(this.adminTemplatesList, this.projectAdminTemplatesPath);
|
|
50
53
|
this.stylesFilePath = sc.get(props, 'stylesFilePath', '/css/reldens-admin-client.css');
|
|
51
54
|
this.scriptsFilePath = sc.get(props, 'scriptsFilePath', '/js/reldens-admin-client.js');
|
|
52
55
|
this.companyName = sc.get(props, 'companyName', 'Reldens - CMS');
|
|
@@ -56,22 +59,30 @@ class Manager
|
|
|
56
59
|
this.domainMapping = sc.get(props, 'domainMapping', sc.toJson(process.env.RELDENS_DOMAIN_MAPPING));
|
|
57
60
|
this.siteKeyMapping = sc.get(props, 'siteKeyMapping', sc.toJson(process.env.RELDENS_SITE_KEY_MAPPING));
|
|
58
61
|
this.templateExtensions = sc.get(props, 'templateExtensions', ['.html', '.template']);
|
|
62
|
+
this.cache = sc.get(props, 'cache', false);
|
|
59
63
|
this.app = sc.get(props, 'app', false);
|
|
60
64
|
this.appServer = sc.get(props, 'appServer', false);
|
|
61
65
|
this.dataServer = sc.get(props, 'dataServer', false);
|
|
62
66
|
this.adminManager = sc.get(props, 'adminManager', false);
|
|
63
67
|
this.frontend = sc.get(props, 'frontend', false);
|
|
64
68
|
this.renderEngine = sc.get(props, 'renderEngine', mustache);
|
|
69
|
+
this.prismaClient = sc.get(props, 'prismaClient', false);
|
|
65
70
|
this.appServerFactory = new AppServerFactory();
|
|
66
71
|
this.adminEntitiesGenerator = new AdminEntitiesGenerator();
|
|
72
|
+
this.cacheManager = new CacheManager({projectRoot: this.projectRoot, enabled: this.cache});
|
|
67
73
|
this.installer = new Installer({
|
|
68
74
|
projectRoot: this.projectRoot,
|
|
75
|
+
prismaClient: this.prismaClient,
|
|
69
76
|
postInstallCallback: this.initializeCmsAfterInstall.bind(this)
|
|
70
77
|
});
|
|
71
78
|
this.useProvidedServer = this.validateProvidedServer();
|
|
72
79
|
this.useProvidedDataServer = this.validateProvidedDataServer();
|
|
73
80
|
this.useProvidedAdminManager = this.validateProvidedAdminManager();
|
|
74
81
|
this.useProvidedFrontend = this.validateProvidedFrontend();
|
|
82
|
+
this.cmsPagesRouteManager = new CmsPagesRouteManager({
|
|
83
|
+
dataServer: this.dataServer,
|
|
84
|
+
events: this.events
|
|
85
|
+
});
|
|
75
86
|
}
|
|
76
87
|
|
|
77
88
|
validateProvidedServer()
|
|
@@ -206,8 +217,10 @@ class Manager
|
|
|
206
217
|
|
|
207
218
|
async initializeServices()
|
|
208
219
|
{
|
|
220
|
+
this.events.emit('reldens.cmsManagerInitializeServices', {manager: this});
|
|
209
221
|
if(!this.useProvidedDataServer){
|
|
210
222
|
if(!await this.initializeDataServer()){
|
|
223
|
+
Logger.debug('Initialize Data Server failed.');
|
|
211
224
|
return false;
|
|
212
225
|
}
|
|
213
226
|
}
|
|
@@ -215,32 +228,41 @@ class Manager
|
|
|
215
228
|
await this.setupEntityAccess();
|
|
216
229
|
}
|
|
217
230
|
if(!this.loadProcessedEntities()){
|
|
231
|
+
Logger.debug('Load Processed Entities for Entities failed.');
|
|
218
232
|
return false;
|
|
219
233
|
}
|
|
220
234
|
if(!await this.generateAdminEntities()){
|
|
235
|
+
Logger.debug('Generate Admin Entities for Entities failed.');
|
|
221
236
|
return false;
|
|
222
237
|
}
|
|
223
238
|
if(!this.useProvidedAdminManager){
|
|
224
239
|
if(!await this.initializeAdminManager()){
|
|
240
|
+
Logger.debug('Initialize Admin Manager failed.');
|
|
225
241
|
return false;
|
|
226
242
|
}
|
|
227
243
|
}
|
|
244
|
+
if(!await this.initializeCmsPagesRouteManager()){
|
|
245
|
+
Logger.debug('Initialize CMS Pages Route Manager failed.');
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
228
248
|
if(!this.useProvidedFrontend){
|
|
229
249
|
if(!await this.initializeFrontend()){
|
|
250
|
+
Logger.debug('Initialize Frontend failed.');
|
|
230
251
|
return false;
|
|
231
252
|
}
|
|
232
253
|
}
|
|
233
254
|
if(!this.useProvidedServer){
|
|
234
255
|
await this.appServer.listen(this.config.port);
|
|
235
256
|
}
|
|
257
|
+
Logger.debug('Initialize Services successfully.');
|
|
236
258
|
return true;
|
|
237
259
|
}
|
|
238
260
|
|
|
239
261
|
async setupEntityAccess()
|
|
240
262
|
{
|
|
241
|
-
let accessEntity = this.dataServer.getEntity('
|
|
263
|
+
let accessEntity = this.dataServer.getEntity('entitiesAccess');
|
|
242
264
|
if(!accessEntity){
|
|
243
|
-
Logger.warning('
|
|
265
|
+
Logger.warning('Entities Access not found.');
|
|
244
266
|
return;
|
|
245
267
|
}
|
|
246
268
|
for(let entityName of Object.keys(this.entityAccess)){
|
|
@@ -305,12 +327,15 @@ class Manager
|
|
|
305
327
|
},
|
|
306
328
|
rawEntities: this.rawRegisteredEntities
|
|
307
329
|
};
|
|
308
|
-
let
|
|
309
|
-
if(!
|
|
330
|
+
let driverClass = DriversMap[this.config.database.driver];
|
|
331
|
+
if(!driverClass){
|
|
310
332
|
Logger.critical('Invalid database driver: '+this.config.database.driver);
|
|
311
333
|
return false;
|
|
312
334
|
}
|
|
313
|
-
this.
|
|
335
|
+
if('prisma' === this.config.database.driver && this.prismaClient){
|
|
336
|
+
dbConfig.prismaClient = this.prismaClient;
|
|
337
|
+
}
|
|
338
|
+
this.dataServer = new driverClass(dbConfig);
|
|
314
339
|
if(!await this.dataServer.connect()){
|
|
315
340
|
Logger.critical('Failed to connect to database.');
|
|
316
341
|
return false;
|
|
@@ -347,6 +372,14 @@ class Manager
|
|
|
347
372
|
return passwordResult;
|
|
348
373
|
};
|
|
349
374
|
}
|
|
375
|
+
let adminFilesContents = await AdminTemplatesLoader.fetchAdminFilesContents(this.mappedAdminTemplates);
|
|
376
|
+
let translations = AdminTranslations.appendTranslations(this.entitiesTranslations || {});
|
|
377
|
+
this.events.emit('reldens.manager.initializeAdminManager', {
|
|
378
|
+
manager: this,
|
|
379
|
+
authenticationCallback,
|
|
380
|
+
adminFilesContents,
|
|
381
|
+
translations
|
|
382
|
+
});
|
|
350
383
|
let adminConfig = {
|
|
351
384
|
events: this.events,
|
|
352
385
|
dataServer: this.dataServer,
|
|
@@ -358,15 +391,14 @@ class Manager
|
|
|
358
391
|
renderCallback: this.renderCallback.bind(this),
|
|
359
392
|
secret: this.config.adminSecret,
|
|
360
393
|
rootPath: this.config.adminPath,
|
|
361
|
-
translations:
|
|
362
|
-
adminFilesContents
|
|
363
|
-
TemplatesToPathMapper.map(this.adminTemplatesList, this.projectAdminTemplatesPath)
|
|
364
|
-
),
|
|
394
|
+
translations: translations,
|
|
395
|
+
adminFilesContents,
|
|
365
396
|
mimeTypes: this.mimeTypes,
|
|
366
397
|
allowedExtensions: this.allowedExtensions,
|
|
367
398
|
adminRoleId: this.adminRoleId,
|
|
368
399
|
stylesFilePath: this.stylesFilePath,
|
|
369
400
|
scriptsFilePath: this.scriptsFilePath,
|
|
401
|
+
cacheManager: this.cacheManager,
|
|
370
402
|
branding: {
|
|
371
403
|
companyName: this.companyName,
|
|
372
404
|
logo: this.logo,
|
|
@@ -381,6 +413,17 @@ class Manager
|
|
|
381
413
|
return true;
|
|
382
414
|
}
|
|
383
415
|
|
|
416
|
+
async initializeCmsPagesRouteManager()
|
|
417
|
+
{
|
|
418
|
+
if(!this.dataServer){
|
|
419
|
+
Logger.warning('CmsPagesRouteManager initialization skipped - missing dataServer.');
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
422
|
+
this.cmsPagesRouteManager.dataServer = this.dataServer;
|
|
423
|
+
Logger.debug('CmsPagesRouteManager initialized successfully');
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
|
|
384
427
|
async renderCallback(template, params = {})
|
|
385
428
|
{
|
|
386
429
|
if(!template){
|
|
@@ -400,7 +443,9 @@ class Manager
|
|
|
400
443
|
defaultDomain: this.defaultDomain,
|
|
401
444
|
domainMapping: this.domainMapping,
|
|
402
445
|
siteKeyMapping: this.siteKeyMapping,
|
|
403
|
-
templateExtensions: this.templateExtensions
|
|
446
|
+
templateExtensions: this.templateExtensions,
|
|
447
|
+
entitiesConfig: this.entitiesConfig,
|
|
448
|
+
cacheManager: this.cacheManager
|
|
404
449
|
});
|
|
405
450
|
return await this.frontend.initialize();
|
|
406
451
|
}
|