@reldens/cms 0.19.0 → 0.21.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 +399 -17
- package/admin/reldens-admin-client.css +156 -99
- package/admin/reldens-admin-client.js +108 -133
- package/admin/templates/clear-all-cache-button.html +7 -7
- package/admin/templates/edit.html +7 -0
- package/admin/templates/layout.html +15 -9
- package/admin/templates/list-content.html +4 -2
- package/admin/templates/list.html +24 -8
- package/admin/templates/view.html +21 -0
- package/lib/admin-manager/admin-filters-manager.js +177 -0
- package/lib/admin-manager/contents-builder.js +1 -0
- package/lib/admin-manager/default-translations.js +38 -0
- package/lib/admin-manager/router-contents.js +50 -45
- package/lib/admin-manager/router.js +19 -0
- package/lib/frontend/content-renderer.js +178 -0
- package/lib/frontend/entity-access-manager.js +63 -0
- package/lib/frontend/request-processor.js +128 -0
- package/lib/frontend/response-manager.js +54 -0
- package/lib/frontend/template-cache.js +102 -0
- package/lib/frontend/template-resolver.js +111 -0
- package/lib/frontend.js +111 -538
- package/lib/manager.js +26 -12
- package/lib/search-renderer.js +15 -7
- package/lib/search-request-handler.js +67 -0
- package/lib/search.js +13 -1
- package/lib/template-engine/asset-transformer.js +41 -0
- package/lib/template-engine/collections-single-transformer.js +28 -5
- package/lib/template-engine/collections-transformer.js +66 -32
- package/lib/template-engine/date-transformer.js +53 -0
- package/lib/template-engine/entities-transformer.js +5 -2
- package/lib/template-engine/partials-transformer.js +8 -5
- package/lib/template-engine/system-variables-provider.js +108 -0
- package/lib/template-engine/translate-transformer.js +98 -0
- package/lib/template-engine/translation-service.js +104 -0
- package/lib/template-engine/url-transformer.js +41 -0
- package/lib/template-engine.js +99 -12
- package/lib/template-reloader.js +307 -0
- package/package.json +4 -4
- package/templates/{browserconfig.xml → assets/favicons/default/browserconfig.xml} +1 -1
- package/templates/assets/favicons/default/favicon.ico +0 -0
- package/templates/{site.webmanifest → assets/favicons/default/site.webmanifest} +3 -3
- package/templates/js/functions.js +144 -0
- package/templates/js/scripts.js +5 -0
- package/templates/page.html +11 -5
- package/templates/partials/pagedCollection.html +1 -1
- package/lib/admin-translations.js +0 -56
- package/templates/favicon.ico +0 -0
- /package/templates/assets/favicons/{android-icon-144x144.png → default/android-icon-144x144.png} +0 -0
- /package/templates/assets/favicons/{android-icon-192x192.png → default/android-icon-192x192.png} +0 -0
- /package/templates/assets/favicons/{android-icon-512x512.png → default/android-icon-512x512.png} +0 -0
- /package/templates/assets/favicons/{apple-touch-icon.png → default/apple-touch-icon.png} +0 -0
- /package/templates/assets/favicons/{favicon-16x16.png → default/favicon-16x16.png} +0 -0
- /package/templates/assets/favicons/{favicon-32x32.png → default/favicon-32x32.png} +0 -0
- /package/templates/assets/favicons/{mstile-150x150.png → default/mstile-150x150.png} +0 -0
- /package/templates/assets/favicons/{safari-pinned-tab.svg → default/safari-pinned-tab.svg} +0 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Reldens CMS
|
|
4
4
|
|
|
5
|
-
A powerful, flexible Content Management System built with Node.js, featuring an admin panel, multi-domain frontend support, enhanced templating with reusable content blocks, and automated installation.
|
|
5
|
+
A powerful, flexible Content Management System built with Node.js, featuring an admin panel, multi-domain frontend support, enhanced templating with reusable content blocks, system variables, internationalization, template reloading, and automated installation.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -24,7 +24,13 @@ A powerful, flexible Content Management System built with Node.js, featuring an
|
|
|
24
24
|
- **Entity access control** for public/private content
|
|
25
25
|
- **Static asset serving** with Express integration as default
|
|
26
26
|
- **Template engine** with Mustache integration as default
|
|
27
|
+
- **System variables** for request, route, and domain context
|
|
28
|
+
- **Enhanced context passing** with currentEntity data in child blocks
|
|
29
|
+
- **Template functions** for URLs, assets, dates, and translations
|
|
30
|
+
- **Event-driven rendering** with hooks for customization
|
|
27
31
|
- **Custom 404 handling**
|
|
32
|
+
- **Advanced search functionality** with template data support
|
|
33
|
+
- **Template reloading** for development with configurable reload strategies
|
|
28
34
|
|
|
29
35
|
### - Admin Panel
|
|
30
36
|
- **Full CRUD operations** for all entities including content blocks
|
|
@@ -46,10 +52,45 @@ A powerful, flexible Content Management System built with Node.js, featuring an
|
|
|
46
52
|
|
|
47
53
|
### - Configuration & Architecture
|
|
48
54
|
- **Environment-based configuration** (.env file)
|
|
49
|
-
- **Modular service architecture**
|
|
55
|
+
- **Modular service architecture** with specialized classes for better maintainability
|
|
50
56
|
- **Event-driven system** with hooks for customization
|
|
51
57
|
- **Extensible authentication** (database users or custom callbacks)
|
|
52
58
|
- **File security** with path validation and dangerous key filtering
|
|
59
|
+
- **Internationalization support** with translation files
|
|
60
|
+
|
|
61
|
+
## Architecture
|
|
62
|
+
|
|
63
|
+
### Core Classes
|
|
64
|
+
The CMS uses a modular architecture with specialized classes:
|
|
65
|
+
|
|
66
|
+
**Frontend Orchestrator:**
|
|
67
|
+
- `Frontend` - Main orchestrator class that coordinates all frontend operations
|
|
68
|
+
|
|
69
|
+
**Template Management:**
|
|
70
|
+
- `TemplateResolver` - Template discovery and domain resolution
|
|
71
|
+
- `TemplateCache` - Template and partial caching management
|
|
72
|
+
- `TemplateReloader` - Template reloading with file change detection
|
|
73
|
+
|
|
74
|
+
**Request Processing:**
|
|
75
|
+
- `RequestProcessor` - HTTP request routing and path handling
|
|
76
|
+
- `SearchRequestHandler` - Dedicated search request processing
|
|
77
|
+
|
|
78
|
+
**Content Management:**
|
|
79
|
+
- `ContentRenderer` - Content generation and template processing
|
|
80
|
+
- `EntityAccessManager` - Entity access control and loading
|
|
81
|
+
|
|
82
|
+
**Response Handling:**
|
|
83
|
+
- `ResponseManager` - HTTP response handling and caching logic
|
|
84
|
+
|
|
85
|
+
**Template Processing:**
|
|
86
|
+
- `TemplateEngine` - Core template rendering with enhanced context
|
|
87
|
+
- `SystemVariablesProvider` - System variables for templates
|
|
88
|
+
|
|
89
|
+
This architecture follows SOLID principles, providing better:
|
|
90
|
+
- **Testability** - Individual components can be tested in isolation
|
|
91
|
+
- **Maintainability** - Changes to one area don't affect others
|
|
92
|
+
- **Reusability** - Components can be reused in different contexts
|
|
93
|
+
- **Readability** - Smaller, focused classes are easier to understand
|
|
53
94
|
|
|
54
95
|
## Installation
|
|
55
96
|
|
|
@@ -97,6 +138,34 @@ RELDENS_DOMAIN_MAPPING={"dev.example.com":"development"}
|
|
|
97
138
|
RELDENS_SITE_KEY_MAPPING={"example.com":"main"}
|
|
98
139
|
```
|
|
99
140
|
|
|
141
|
+
### Template Reloading Configuration
|
|
142
|
+
Configure template reloading for development environments:
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
const cms = new Manager({
|
|
146
|
+
// Development: reload templates on every request when changes detected
|
|
147
|
+
reloadTime: -1,
|
|
148
|
+
|
|
149
|
+
// Production: disable template reloading (default)
|
|
150
|
+
reloadTime: 0,
|
|
151
|
+
|
|
152
|
+
// Interval-based: reload every 5 seconds when changes detected
|
|
153
|
+
reloadTime: 5000
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Template Reloading Options:**
|
|
158
|
+
- **`reloadTime: 0`** (default) - Template reloading disabled. Templates load once at startup.
|
|
159
|
+
- **`reloadTime: -1`** - Reload templates on every request when file changes are detected. Best for active development.
|
|
160
|
+
- **`reloadTime: > 0`** - Check for template changes at specified interval (milliseconds) and reload when needed. Good for development with lower overhead.
|
|
161
|
+
|
|
162
|
+
**How it works:**
|
|
163
|
+
- Tracks file modification times for admin and frontend templates
|
|
164
|
+
- Only reloads templates that have actually changed
|
|
165
|
+
- Automatically updates admin contents and frontend template cache
|
|
166
|
+
- Works with both admin panel templates and frontend templates/partials
|
|
167
|
+
- Zero performance impact when disabled (`reloadTime: 0`)
|
|
168
|
+
|
|
100
169
|
### Custom Entity Configuration
|
|
101
170
|
```javascript
|
|
102
171
|
const entityConfig = {
|
|
@@ -126,8 +195,140 @@ const cms = new Manager({
|
|
|
126
195
|
});
|
|
127
196
|
```
|
|
128
197
|
|
|
198
|
+
## Search Functionality
|
|
199
|
+
|
|
200
|
+
### Basic Search
|
|
201
|
+
```bash
|
|
202
|
+
# Simple search
|
|
203
|
+
/search?search=technology
|
|
204
|
+
|
|
205
|
+
# Entity-specific search with custom limit
|
|
206
|
+
/search?search=javascript&limit=20
|
|
207
|
+
|
|
208
|
+
# Custom template rendering
|
|
209
|
+
/search?search=news&renderPartial=newsListView&renderLayout=minimal
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Advanced Search with Template Data
|
|
213
|
+
```bash
|
|
214
|
+
# Pass custom template variables
|
|
215
|
+
/search?search=articles&templateData[columnsClass]=col-md-4&templateData[showExcerpt]=true
|
|
216
|
+
|
|
217
|
+
# Multiple template variables
|
|
218
|
+
/search?search=technology&templateData[columnsClass]=col-lg-6&templateData[cardClass]=shadow-sm&templateData[showAuthor]=false
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Search Template Variables
|
|
222
|
+
Templates receive dynamic data through URL parameters:
|
|
223
|
+
|
|
224
|
+
**URL:** `/search?search=tech&templateData[columnsClass]=col-md-6&templateData[showDate]=true`
|
|
225
|
+
|
|
226
|
+
**Template (entriesListView.html):**
|
|
227
|
+
```html
|
|
228
|
+
<div class="{{columnsClass}}">
|
|
229
|
+
<div class="card">
|
|
230
|
+
<h3>{{row.title}}</h3>
|
|
231
|
+
<p>{{row.content}}</p>
|
|
232
|
+
{{#showDate}}
|
|
233
|
+
<span class="date">{{row.created_at}}</span>
|
|
234
|
+
{{/showDate}}
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Default Values:**
|
|
240
|
+
- `columnsClass` defaults to `col-lg-6` if not provided or empty
|
|
241
|
+
- Custom variables can be added via `templateData[variableName]=value`
|
|
242
|
+
|
|
243
|
+
### Search Configuration
|
|
244
|
+
```javascript
|
|
245
|
+
// Custom search sets in Manager configuration
|
|
246
|
+
const searchSets = {
|
|
247
|
+
articlesSearch: {
|
|
248
|
+
entities: [{
|
|
249
|
+
name: 'articles',
|
|
250
|
+
fields: ['title', 'content', 'summary'],
|
|
251
|
+
relations: 'authors'
|
|
252
|
+
}],
|
|
253
|
+
pagination: {active: true, limit: 15, sortBy: 'created_at', sortDirection: 'desc'}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const cms = new Manager({
|
|
258
|
+
searchSets: searchSets
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
129
262
|
## Enhanced Templating System
|
|
130
263
|
|
|
264
|
+
### System Variables
|
|
265
|
+
Every template has access to system variables providing context about the current request:
|
|
266
|
+
|
|
267
|
+
```html
|
|
268
|
+
<!-- Current request information -->
|
|
269
|
+
{{currentRequest.baseUrl}} <!-- https://example.com -->
|
|
270
|
+
{{currentRequest.protocol}} <!-- https -->
|
|
271
|
+
{{currentRequest.host}} <!-- example.com -->
|
|
272
|
+
{{currentRequest.path}} <!-- /articles/123 -->
|
|
273
|
+
{{currentRequest.method}} <!-- GET -->
|
|
274
|
+
{{currentRequest.userAgent}} <!-- Browser information -->
|
|
275
|
+
{{currentRequest.isSecure}} <!-- true/false -->
|
|
276
|
+
|
|
277
|
+
<!-- Current route data (if matched) -->
|
|
278
|
+
{{currentRoute.id}} <!-- Route ID -->
|
|
279
|
+
{{currentRoute.path}} <!-- Route path pattern -->
|
|
280
|
+
{{currentRoute.title}} <!-- Route title -->
|
|
281
|
+
{{currentRoute.template}} <!-- Route template -->
|
|
282
|
+
{{currentRoute.layout}} <!-- Route layout -->
|
|
283
|
+
|
|
284
|
+
<!-- Current domain information -->
|
|
285
|
+
{{currentDomain.current}} <!-- Current domain -->
|
|
286
|
+
{{currentDomain.default}} <!-- Default domain -->
|
|
287
|
+
{{currentDomain.resolved}} <!-- Resolved domain -->
|
|
288
|
+
|
|
289
|
+
<!-- System information -->
|
|
290
|
+
{{systemInfo.environment}} <!-- development/production -->
|
|
291
|
+
{{systemInfo.nodeVersion}} <!-- Node.js version -->
|
|
292
|
+
{{systemInfo.timestamp}} <!-- Current timestamp -->
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Template Functions
|
|
296
|
+
Templates support dynamic functions for common operations:
|
|
297
|
+
|
|
298
|
+
```html
|
|
299
|
+
<!-- URL generation with current domain -->
|
|
300
|
+
[url(/articles)] <!-- https://example.com/articles -->
|
|
301
|
+
[url(/contact#form)] <!-- https://example.com/contact#form -->
|
|
302
|
+
[url(/css/styles.css)] <!-- https://example.com/css/styles.css -->
|
|
303
|
+
|
|
304
|
+
<!-- Asset URLs with domain -->
|
|
305
|
+
[asset(/assets/images/logo.png)] <!-- https://example.com/images/logo.png -->
|
|
306
|
+
|
|
307
|
+
<!-- Date formatting -->
|
|
308
|
+
[date()] <!-- Current date with default format -->
|
|
309
|
+
[date(now, Y-m-d)] <!-- 2024-01-15 -->
|
|
310
|
+
[date(2024-01-01, d/m/Y)] <!-- 01/01/2024 -->
|
|
311
|
+
|
|
312
|
+
<!-- Internationalization -->
|
|
313
|
+
[translate(welcome.message)] <!-- Translated text -->
|
|
314
|
+
[t(hello.world, Hello World!)] <!-- With fallback -->
|
|
315
|
+
[t(greeting, Hi {name}!, {name: John})] <!-- With interpolation -->
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Enhanced Context Passing
|
|
319
|
+
Child content blocks and partials receive context from parent pages:
|
|
320
|
+
|
|
321
|
+
```html
|
|
322
|
+
<!-- In a CMS page or layout -->
|
|
323
|
+
<entity name="cmsBlocks" field="name" value="article-sidebar"/>
|
|
324
|
+
|
|
325
|
+
<!-- Inside the article-sidebar block, you can access: -->
|
|
326
|
+
{{currentEntity.title}} <!-- Parent page title -->
|
|
327
|
+
{{currentEntity.id}} <!-- Parent page ID -->
|
|
328
|
+
{{currentEntity.template}} <!-- Parent page template -->
|
|
329
|
+
<!-- Any other parent page properties -->
|
|
330
|
+
```
|
|
331
|
+
|
|
131
332
|
### Template Functions
|
|
132
333
|
Templates support dynamic content blocks, entity rendering, and collections with advanced query options:
|
|
133
334
|
|
|
@@ -230,10 +431,10 @@ Pagination state is managed via URL query parameters:
|
|
|
230
431
|
Create `templates/partials/pagedCollection.html`:
|
|
231
432
|
```html
|
|
232
433
|
<div class="row paginated-contents">
|
|
233
|
-
<div class="collection-content col-lg-12
|
|
434
|
+
<div class="collection-content col-lg-12">
|
|
234
435
|
{{&collectionContentForCurrentPage}}
|
|
235
436
|
</div>
|
|
236
|
-
<div class="pagination col-lg-12
|
|
437
|
+
<div class="pagination col-lg-12">
|
|
237
438
|
<ul class="pagination-list">
|
|
238
439
|
{{#prevPageUrl}}
|
|
239
440
|
<li><a href="{{prevPageUrl}}" class="page-link">{{&prevPageLabel}}</a></li>
|
|
@@ -365,6 +566,55 @@ Collections support advanced query parameters for pagination and sorting:
|
|
|
365
566
|
</collection>
|
|
366
567
|
```
|
|
367
568
|
|
|
569
|
+
## Internationalization
|
|
570
|
+
|
|
571
|
+
### Translation Files
|
|
572
|
+
Create translation files in the `translations` directory:
|
|
573
|
+
|
|
574
|
+
**translations/en.json:**
|
|
575
|
+
```json
|
|
576
|
+
{
|
|
577
|
+
"navigation": {
|
|
578
|
+
"home": "Home",
|
|
579
|
+
"about": "About Us",
|
|
580
|
+
"contact": "Contact"
|
|
581
|
+
},
|
|
582
|
+
"messages": {
|
|
583
|
+
"welcome": "Welcome to our site!",
|
|
584
|
+
"greeting": "Hello {name}!"
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
**translations/es.json:**
|
|
590
|
+
```json
|
|
591
|
+
{
|
|
592
|
+
"navigation": {
|
|
593
|
+
"home": "Inicio",
|
|
594
|
+
"about": "Acerca de",
|
|
595
|
+
"contact": "Contacto"
|
|
596
|
+
},
|
|
597
|
+
"messages": {
|
|
598
|
+
"welcome": "¡Bienvenido a nuestro sitio!",
|
|
599
|
+
"greeting": "¡Hola {name}!"
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
### Using Translations in Templates
|
|
605
|
+
```html
|
|
606
|
+
<!-- Simple translation -->
|
|
607
|
+
[translate(navigation.home)]
|
|
608
|
+
|
|
609
|
+
<!-- With fallback -->
|
|
610
|
+
[t(navigation.home, Home)]
|
|
611
|
+
|
|
612
|
+
<!-- With interpolation -->
|
|
613
|
+
[t(messages.greeting, Hello!, {name: John})]
|
|
614
|
+
|
|
615
|
+
<!-- Locale detection from request headers or ?locale=es parameter -->
|
|
616
|
+
```
|
|
617
|
+
|
|
368
618
|
### Layout System
|
|
369
619
|
The CMS uses a two-tier layout system:
|
|
370
620
|
|
|
@@ -375,11 +625,11 @@ The CMS uses a two-tier layout system:
|
|
|
375
625
|
<head>
|
|
376
626
|
<title>{{title}}</title>
|
|
377
627
|
<meta name="description" content="{{description}}"/>
|
|
378
|
-
<link href="/css/styles.css" rel="stylesheet"/>
|
|
628
|
+
<link href="[url(/css/styles.css)]" rel="stylesheet"/>
|
|
379
629
|
</head>
|
|
380
630
|
<body class="{{siteHandle}}">
|
|
381
631
|
{{&content}}
|
|
382
|
-
<script src="/js/scripts.js"></script>
|
|
632
|
+
<script src="[url(/js/scripts.js)]"></script>
|
|
383
633
|
</body>
|
|
384
634
|
</html>
|
|
385
635
|
```
|
|
@@ -415,7 +665,7 @@ Create reusable content blocks in the `cms_blocks` table via the admin panel:
|
|
|
415
665
|
INSERT INTO cms_blocks (name, title, content) VALUES
|
|
416
666
|
('contact-info', 'Contact Information', '<p>Email: info@example.com</p>'),
|
|
417
667
|
('article-sidebar', 'Article Categories',
|
|
418
|
-
'<div class="categories"><h3>Categories</h3><ul><li><a href="/articles/technology">Technology</a></li></ul></div>');
|
|
668
|
+
'<div class="categories"><h3>Categories</h3><ul><li><a href="[url(/articles/technology)]">Technology</a></li></ul></div>');
|
|
419
669
|
```
|
|
420
670
|
|
|
421
671
|
### Entity Access Control
|
|
@@ -452,12 +702,72 @@ templates/
|
|
|
452
702
|
├── partials/
|
|
453
703
|
│ ├── header.html (default)
|
|
454
704
|
│ └── footer.html (default)
|
|
705
|
+
├── translations/
|
|
706
|
+
│ ├── en.json
|
|
707
|
+
│ ├── es.json
|
|
708
|
+
│ └── fr.json
|
|
455
709
|
├── page.html (base HTML wrapper)
|
|
456
710
|
└── 404.html
|
|
457
711
|
```
|
|
458
712
|
|
|
459
713
|
## Advanced Usage
|
|
460
714
|
|
|
715
|
+
### Template Reloading for Development
|
|
716
|
+
```javascript
|
|
717
|
+
// Different configurations for development vs production
|
|
718
|
+
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
719
|
+
|
|
720
|
+
const cms = new Manager({
|
|
721
|
+
// Enable aggressive template reloading in development
|
|
722
|
+
reloadTime: isDevelopment ? -1 : 0,
|
|
723
|
+
|
|
724
|
+
// Other development-friendly settings
|
|
725
|
+
cache: !isDevelopment,
|
|
726
|
+
|
|
727
|
+
entityAccess: {
|
|
728
|
+
articles: { public: true, operations: ['read'] },
|
|
729
|
+
cmsPages: { public: true, operations: ['read'] }
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
**Development Workflow with Template Reloading:**
|
|
735
|
+
1. Set `reloadTime: -1` for instant template updates
|
|
736
|
+
2. Edit admin templates in `admin/templates/` - changes appear immediately
|
|
737
|
+
3. Edit frontend templates in `templates/` - changes appear on next page load
|
|
738
|
+
4. No server restart needed for template changes
|
|
739
|
+
5. Switch to `reloadTime: 0` in production for optimal performance
|
|
740
|
+
|
|
741
|
+
### Event System
|
|
742
|
+
The CMS provides hooks for customization through event listeners:
|
|
743
|
+
|
|
744
|
+
```javascript
|
|
745
|
+
// Listen for template variable events
|
|
746
|
+
cms.events.on('reldens.afterVariablesCreated', (eventData) => {
|
|
747
|
+
// Add custom variables
|
|
748
|
+
eventData.variables.customData = {
|
|
749
|
+
timestamp: Date.now(),
|
|
750
|
+
version: '1.0.0'
|
|
751
|
+
};
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
// Listen for content processing events
|
|
755
|
+
cms.events.on('reldens.beforeContentProcess', (eventData) => {
|
|
756
|
+
// Modify content before processing
|
|
757
|
+
eventData.content = eventData.content.replace(/\[custom\]/g, 'Custom Value');
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
cms.events.on('reldens.afterContentProcess', (eventData) => {
|
|
761
|
+
// Modify processed content
|
|
762
|
+
eventData.processedContent += '\n<!-- Processed at ' + new Date() + ' -->';
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
// Listen for template reloading events
|
|
766
|
+
cms.events.on('reldens.templateReloader.templatesChanged', (eventData) => {
|
|
767
|
+
console.log('Templates changed:', eventData.changedFiles);
|
|
768
|
+
});
|
|
769
|
+
```
|
|
770
|
+
|
|
461
771
|
### Custom Authentication
|
|
462
772
|
```javascript
|
|
463
773
|
const customAuth = async (email, password, roleId) => {
|
|
@@ -528,20 +838,74 @@ The installer provides checkboxes for:
|
|
|
528
838
|
- `isInstalled()` - Check if CMS is installed
|
|
529
839
|
- `initializeServices()` - Initialize all services
|
|
530
840
|
|
|
531
|
-
### Frontend
|
|
841
|
+
### Frontend Architecture Classes
|
|
842
|
+
|
|
843
|
+
#### Frontend Class (Orchestrator)
|
|
532
844
|
- `initialize()` - Set up frontend routes and templates
|
|
533
845
|
- `handleRequest(req, res)` - Main request handler
|
|
534
|
-
- `
|
|
535
|
-
- `
|
|
846
|
+
- `renderRoute(route, domain, res, req)` - Route-based rendering
|
|
847
|
+
- `setupStaticAssets()` - Configure static asset serving
|
|
848
|
+
|
|
849
|
+
#### TemplateResolver Class
|
|
850
|
+
- `findTemplatePath(templateName, domain)` - Template discovery with domain fallback
|
|
851
|
+
- `findLayoutPath(layoutName, domain)` - Layout path resolution
|
|
852
|
+
- `findTemplateByPath(path, domain)` - Template lookup by URL path
|
|
853
|
+
- `resolveDomainToFolder(domain)` - Domain to folder mapping
|
|
854
|
+
- `resolveDomainToSiteKey(domain)` - Domain to site key mapping
|
|
855
|
+
|
|
856
|
+
#### TemplateCache Class
|
|
857
|
+
- `loadPartials()` - Load and cache template partials
|
|
858
|
+
- `setupDomainTemplates()` - Initialize domain-specific templates
|
|
859
|
+
- `getPartialsForDomain(domain)` - Get domain-specific partials with fallback
|
|
860
|
+
|
|
861
|
+
#### TemplateReloader Class
|
|
862
|
+
- `checkAndReloadAdminTemplates()` - Check and reload admin templates when changed
|
|
863
|
+
- `checkAndReloadFrontendTemplates()` - Check and reload frontend templates when changed
|
|
864
|
+
- `trackTemplateFiles(templatesPaths)` - Start tracking template files for changes
|
|
865
|
+
- `shouldReloadAdminTemplates(mappedAdminTemplates)` - Check if admin templates need reloading
|
|
866
|
+
- `shouldReloadFrontendTemplates(templatesPath, templateExtensions)` - Check if frontend templates need reloading
|
|
867
|
+
- `handleAdminTemplateReload(adminManager)` - Complete admin template reload process
|
|
868
|
+
- `handleFrontendTemplateReload(templateCache, templateResolver)` - Complete frontend template reload process
|
|
869
|
+
|
|
870
|
+
#### RequestProcessor Class
|
|
871
|
+
- `findRouteByPath(path, domain)` - Database route lookup
|
|
872
|
+
- `handleRouteRedirect(route, res)` - Handle route redirects
|
|
873
|
+
- `getDomainFromRequest(req)` - Extract domain from request
|
|
874
|
+
- `buildCacheKey(path, req)` - Generate cache keys
|
|
875
|
+
|
|
876
|
+
#### ContentRenderer Class
|
|
877
|
+
- `renderWithTemplateContent(content, data, domain, req, route)` - Main content rendering
|
|
878
|
+
- `generateRouteContent(route, domain, req)` - Route-based content generation
|
|
879
|
+
- `generateTemplateContent(templatePath, domain, req, data)` - Template-based content generation
|
|
880
|
+
- `fetchMetaFields(data)` - Process meta fields for templates
|
|
881
|
+
|
|
882
|
+
#### EntityAccessManager Class
|
|
883
|
+
- `loadEntityAccessRules()` - Load entity access configuration
|
|
884
|
+
- `isEntityAccessible(entityName)` - Check entity accessibility
|
|
885
|
+
- `findEntityByPath(path)` - Entity lookup by URL path
|
|
886
|
+
|
|
887
|
+
#### ResponseManager Class
|
|
888
|
+
- `renderWithCacheHandler(contentGenerator, errorHandler, responseHandler, domain, res, path, req)` - Generic cached response handler
|
|
889
|
+
- `renderNotFound(domain, res, req)` - 404 error handling
|
|
890
|
+
|
|
891
|
+
#### SearchRequestHandler Class
|
|
892
|
+
- `handleSearchRequest(req, res)` - Process search requests with template data support
|
|
536
893
|
|
|
537
894
|
### TemplateEngine Class
|
|
538
|
-
- `render(template, data, partials)` - Main template rendering with enhanced
|
|
539
|
-
- `
|
|
540
|
-
- `
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
- `
|
|
544
|
-
- `
|
|
895
|
+
- `render(template, data, partials, domain, req, route, currentEntityData)` - Main template rendering with enhanced context
|
|
896
|
+
- `processAllTemplateFunctions(template, domain, req, systemVariables)` - Process all template functions
|
|
897
|
+
- `buildEnhancedRenderData(data, systemVariables, currentEntityData)` - Build template context with system variables
|
|
898
|
+
|
|
899
|
+
### SystemVariablesProvider Class
|
|
900
|
+
- `buildSystemVariables(req, route, domain)` - Create system variables for templates
|
|
901
|
+
- `buildCurrentRequestData(req, domain)` - Build request context
|
|
902
|
+
- `buildCurrentRouteData(route)` - Build route context
|
|
903
|
+
- `buildCurrentDomainData(domain)` - Build domain context
|
|
904
|
+
|
|
905
|
+
### Search Classes
|
|
906
|
+
- `Search.parseSearchParameters(query)` - Parse search query parameters including templateData
|
|
907
|
+
- `Search.executeSearch(config)` - Execute search with configuration
|
|
908
|
+
- `SearchRenderer.renderSearchResults(searchResults, config, domain, req)` - Render search results with template data
|
|
545
909
|
|
|
546
910
|
### AdminManager Class
|
|
547
911
|
- `setupAdmin()` - Initialize admin panel
|
|
@@ -560,12 +924,30 @@ The installer provides checkboxes for:
|
|
|
560
924
|
project/
|
|
561
925
|
├── admin/
|
|
562
926
|
│ └── templates/ # Admin panel templates
|
|
927
|
+
├── lib/
|
|
928
|
+
│ ├── frontend/ # Frontend specialized classes
|
|
929
|
+
│ │ ├── template-resolver.js
|
|
930
|
+
│ │ ├── template-cache.js
|
|
931
|
+
│ │ ├── request-processor.js
|
|
932
|
+
│ │ ├── entity-access-manager.js
|
|
933
|
+
│ │ ├── content-renderer.js
|
|
934
|
+
│ │ └── response-manager.js
|
|
935
|
+
│ ├── frontend.js # Main Frontend orchestrator
|
|
936
|
+
│ ├── template-reloader.js # Template reloading functionality
|
|
937
|
+
│ ├── search-request-handler.js
|
|
938
|
+
│ ├── search.js # Search functionality
|
|
939
|
+
│ ├── search-renderer.js # Search result rendering
|
|
940
|
+
│ └── template-engine.js # Core template processing
|
|
563
941
|
├── templates/
|
|
564
942
|
│ ├── layouts/ # Body content layouts
|
|
565
943
|
│ ├── domains/ # Domain-specific templates
|
|
566
944
|
│ ├── partials/ # Shared template partials
|
|
567
945
|
│ ├── page.html # Base HTML wrapper
|
|
568
946
|
│ └── 404.html # Error page
|
|
947
|
+
├── translations/
|
|
948
|
+
│ ├── en.json # English translations
|
|
949
|
+
│ ├── es.json # Spanish translations
|
|
950
|
+
│ └── fr.json # French translations
|
|
569
951
|
├── public/
|
|
570
952
|
│ ├── css/ # Stylesheets
|
|
571
953
|
│ ├── js/ # Client scripts
|