cyber-elx 1.0.1 → 1.0.4
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/DEV_DOC/README.md +0 -0
- package/{DEV_DOC.md → DEV_DOC/ThemeDev.md} +62 -45
- package/README.md +2 -0
- package/package.json +1 -1
- package/src/files.js +22 -5
- package/src/index.js +45 -11
|
File without changes
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
# CyberOcean Custom Elx Theme
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
- [CyberOcean Custom Elx Theme](#cyberocean-custom-elx-theme)
|
|
6
|
+
- [Summary](#summary)
|
|
7
|
+
- [Steps to create/update the theme](#steps-to-createupdate-the-theme)
|
|
8
|
+
- [Defaults](#defaults)
|
|
9
|
+
- [Customization](#customization)
|
|
10
|
+
- [Layout](#layout)
|
|
11
|
+
- [Sections](#sections)
|
|
12
|
+
- [Templates](#templates)
|
|
13
|
+
- [Available Liquid Variables](#available-liquid-variables)
|
|
14
|
+
- [Website URLs](#website-urls)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Steps to create/update the theme
|
|
18
|
+
|
|
19
|
+
Note: Even in a new fresh theme, The files are already created, but empty, the only files you need to create are the additional sections you plan to use (if you won't use some empty files, just keep them empty, removing is not required)
|
|
4
20
|
|
|
5
21
|
1. Make a detailled plan of the website
|
|
6
22
|
- Layout
|
|
@@ -13,20 +29,20 @@
|
|
|
13
29
|
+ Ask for images/icons if you need (The user can upload files from the admin dashboard and give you back the links)
|
|
14
30
|
+ Ask about the language to use
|
|
15
31
|
+ Ask about the colors to use
|
|
16
|
-
2. Start by
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
32
|
+
2. Start by updating the layout
|
|
33
|
+
- Update the `layouts/theme.liquid` file
|
|
34
|
+
- Update the `sections/header.liquid` file
|
|
35
|
+
- Update the `sections/footer.liquid` file
|
|
20
36
|
- **Important**: If there will be modifications on the existing, then always start by creating a fresh copy from the default files, and then modify it
|
|
21
|
-
3.
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
37
|
+
3. Update the rest of the pages (With the sections IN CASE YOU USED THEM)
|
|
38
|
+
- Update the `templates/home_page.liquid`
|
|
39
|
+
- Update the `templates/course_page.liquid`
|
|
40
|
+
- Update the `templates/about_page.liquid`
|
|
41
|
+
- Update the `templates/category_page.liquid`
|
|
42
|
+
- Update the `templates/courses_page.liquid`
|
|
43
|
+
- Update the `templates/contact_page.liquid`
|
|
44
|
+
- Update the `templates/blogs_page.liquid`
|
|
45
|
+
- Update the `templates/blog_page.liquid`
|
|
30
46
|
- Rules:
|
|
31
47
|
+ **Do not** use translation unless asked for it
|
|
32
48
|
+ **Do not** try to always to copy paste the default files, use them as a reference, unless asked for it
|
|
@@ -35,6 +51,8 @@
|
|
|
35
51
|
+ **Always** keep sections, templates and layouts file names simple
|
|
36
52
|
> Correct: `sections/header.liquid`
|
|
37
53
|
> Wrong: `sections/header_custom_elx.liquid`
|
|
54
|
+
4. Check your work
|
|
55
|
+
- Ensure you have imported the sections in the right way `{% section '<SECTION_NAME>_custom_elx.liquid' %}` (If you used sections)
|
|
38
56
|
|
|
39
57
|
## Defaults
|
|
40
58
|
|
|
@@ -48,6 +66,9 @@ The default files are stored in the `defaults` folder
|
|
|
48
66
|
## Customization
|
|
49
67
|
|
|
50
68
|
- You are not forced to use all the available variables in the templates/sections/layouts, you can use only the variables you need
|
|
69
|
+
- To add custom JS/CSS simply add them as sections, then import them where needed, example to make a main.js file:
|
|
70
|
+
> Create a file `sections/main_js.liquid`
|
|
71
|
+
> Import it in any place as: `{% section 'main_js_custom_elx.liquid' %}`
|
|
51
72
|
|
|
52
73
|
### Layout
|
|
53
74
|
|
|
@@ -75,35 +96,12 @@ The default files are stored in the `defaults` folder
|
|
|
75
96
|
|
|
76
97
|
### Sections
|
|
77
98
|
|
|
78
|
-
- The
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
- `banner_1`
|
|
85
|
-
- `banner_2`
|
|
86
|
-
- `banner_3`
|
|
87
|
-
- `reviews`
|
|
88
|
-
- `menu`
|
|
89
|
-
- `menu_1`
|
|
90
|
-
- `menu_2`
|
|
91
|
-
- `menu_3`
|
|
92
|
-
- `category`
|
|
93
|
-
- `category_related`
|
|
94
|
-
- `categories`
|
|
95
|
-
- `category_element`
|
|
96
|
-
- `course`
|
|
97
|
-
- `course_related`
|
|
98
|
-
- `courses`
|
|
99
|
-
- `course_element`
|
|
100
|
-
- `testimonial`
|
|
101
|
-
- `about`
|
|
102
|
-
- `cta`
|
|
103
|
-
- `cta_1`
|
|
104
|
-
- `cta_2`
|
|
105
|
-
- `cta_3`
|
|
106
|
-
Note: The sections can be loaded using the `section` tag from any template, layout or section, using the syntax: `{% section '<SECTION_NAME>_custom_elx.liquid' %}`, example: `{% section 'header_custom_elx.liquid' %}`
|
|
99
|
+
- The sections can be loaded using the `section` tag from any template, layout or section, using the syntax: `{% section '<SECTION_NAME>_custom_elx.liquid' %}`, example: `{% section 'header_custom_elx.liquid' %}`
|
|
100
|
+
- Examples:
|
|
101
|
+
> **WRONG:** section file `sections/header_custom_elx.liquid`
|
|
102
|
+
> **CORRECT:** section file `sections/header.liquid`
|
|
103
|
+
> **WRONG:** Import section file as `{% section 'header.liquid' %}`
|
|
104
|
+
> **CORRECT:** Import section file as `{% section 'header_custom_elx.liquid' %}`
|
|
107
105
|
|
|
108
106
|
### Templates
|
|
109
107
|
|
|
@@ -119,11 +117,18 @@ Note: The sections can be loaded using the `section` tag from any template, layo
|
|
|
119
117
|
|
|
120
118
|
### Available Liquid Variables
|
|
121
119
|
|
|
120
|
+
- All variables have default values, so use them without setting default values
|
|
121
|
+
|
|
122
122
|
**Global Available vairables:**
|
|
123
123
|
Note: Available in All pages, and configurable from the website administration, recommended to use, so the user can change them from the admin, without the need to edit the code
|
|
124
124
|
- Path to the logo image:
|
|
125
125
|
+ Name: `logo`
|
|
126
|
-
+ Sample:
|
|
126
|
+
+ Sample:
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"path": "https://example.com/logo.png"
|
|
130
|
+
}
|
|
131
|
+
```
|
|
127
132
|
- Primary Color:
|
|
128
133
|
+ Name: `primary`
|
|
129
134
|
+ Sample: `#ff0000`
|
|
@@ -564,4 +569,16 @@ Note: Available in All pages, and configurable from the website administration,
|
|
|
564
569
|
"path": "..."
|
|
565
570
|
}
|
|
566
571
|
}
|
|
567
|
-
```
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
## Website URLs
|
|
575
|
+
|
|
576
|
+
- The website main URL `/` automatically redirects to the home page
|
|
577
|
+
- The Home page URL: `/p/home`
|
|
578
|
+
- The Blogs page URL: `/p/blogs`
|
|
579
|
+
- The Blog page URL: `/p/blog/<ARTICLE_ID>`
|
|
580
|
+
- The Courses page URL: `/p/courses`
|
|
581
|
+
- The Course page URL: `/p/course/<COURSE_ID>`
|
|
582
|
+
- The Contact page URL: `/p/contact`
|
|
583
|
+
- The Category page URL: `/p/categories/<CATEGORY_ID>`
|
|
584
|
+
- The About page URL: `/p/about`
|
package/README.md
CHANGED
package/package.json
CHANGED
package/src/files.js
CHANGED
|
@@ -48,7 +48,11 @@ function readPageFile(type, key, cwd = process.cwd()) {
|
|
|
48
48
|
if (!fs.existsSync(filePath)) {
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
52
|
+
if(content == `<!-- EMPTY FILE -->`) {
|
|
53
|
+
return "";
|
|
54
|
+
}
|
|
55
|
+
return content;
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
function writePageFile(type, key, content, cwd = process.cwd(), isDefault = false) {
|
|
@@ -57,7 +61,11 @@ function writePageFile(type, key, content, cwd = process.cwd(), isDefault = fals
|
|
|
57
61
|
if (!fs.existsSync(dir)) {
|
|
58
62
|
fs.mkdirSync(dir, { recursive: true });
|
|
59
63
|
}
|
|
60
|
-
|
|
64
|
+
if(content) {
|
|
65
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
66
|
+
} else {
|
|
67
|
+
fs.writeFileSync(filePath, `<!-- EMPTY FILE -->`, 'utf-8');
|
|
68
|
+
}
|
|
61
69
|
}
|
|
62
70
|
|
|
63
71
|
function fileExists(type, key, cwd = process.cwd()) {
|
|
@@ -76,7 +84,10 @@ function getLocalPages(cwd = process.cwd()) {
|
|
|
76
84
|
const files = fs.readdirSync(templatesDir).filter(f => f.endsWith('.liquid'));
|
|
77
85
|
for (const file of files) {
|
|
78
86
|
const key = file.replace('.liquid', '');
|
|
79
|
-
|
|
87
|
+
let content = fs.readFileSync(path.join(templatesDir, file), 'utf-8');
|
|
88
|
+
if(content == `<!-- EMPTY FILE -->`) {
|
|
89
|
+
content = "";
|
|
90
|
+
}
|
|
80
91
|
pages.push({ type: 'template', key, content });
|
|
81
92
|
}
|
|
82
93
|
}
|
|
@@ -85,7 +96,10 @@ function getLocalPages(cwd = process.cwd()) {
|
|
|
85
96
|
const files = fs.readdirSync(sectionsDir).filter(f => f.endsWith('.liquid'));
|
|
86
97
|
for (const file of files) {
|
|
87
98
|
const key = file.replace('.liquid', '');
|
|
88
|
-
|
|
99
|
+
let content = fs.readFileSync(path.join(sectionsDir, file), 'utf-8');
|
|
100
|
+
if(content == `<!-- EMPTY FILE -->`) {
|
|
101
|
+
content = "";
|
|
102
|
+
}
|
|
89
103
|
pages.push({ type: 'section', key, content });
|
|
90
104
|
}
|
|
91
105
|
}
|
|
@@ -94,7 +108,10 @@ function getLocalPages(cwd = process.cwd()) {
|
|
|
94
108
|
const files = fs.readdirSync(layoutsDir).filter(f => f.endsWith('.liquid'));
|
|
95
109
|
for (const file of files) {
|
|
96
110
|
const key = file.replace('.liquid', '');
|
|
97
|
-
|
|
111
|
+
let content = fs.readFileSync(path.join(layoutsDir, file), 'utf-8');
|
|
112
|
+
if(content == `<!-- EMPTY FILE -->`) {
|
|
113
|
+
content = "";
|
|
114
|
+
}
|
|
98
115
|
pages.push({ type: 'layout', key, content });
|
|
99
116
|
}
|
|
100
117
|
}
|
package/src/index.js
CHANGED
|
@@ -17,6 +17,7 @@ program
|
|
|
17
17
|
.command('init')
|
|
18
18
|
.description('Initialize configuration and download pages')
|
|
19
19
|
.action(async () => {
|
|
20
|
+
await updateDevDoc();
|
|
20
21
|
try {
|
|
21
22
|
const cwd = process.cwd();
|
|
22
23
|
|
|
@@ -57,6 +58,7 @@ program
|
|
|
57
58
|
.description('Download pages from server')
|
|
58
59
|
.option('-f, --force', 'Force download without confirmation prompts')
|
|
59
60
|
.action(async (options) => {
|
|
61
|
+
await updateDevDoc();
|
|
60
62
|
try {
|
|
61
63
|
const cwd = process.cwd();
|
|
62
64
|
const config = readConfig(cwd);
|
|
@@ -79,6 +81,7 @@ program
|
|
|
79
81
|
.description('Upload pages to server')
|
|
80
82
|
.option('-f, --force', 'Force upload without confirmation prompts')
|
|
81
83
|
.action(async (options) => {
|
|
84
|
+
await updateDevDoc();
|
|
82
85
|
try {
|
|
83
86
|
const cwd = process.cwd();
|
|
84
87
|
const config = readConfig(cwd);
|
|
@@ -208,19 +211,19 @@ async function downloadPages(cwd, config, force = false) {
|
|
|
208
211
|
}
|
|
209
212
|
}
|
|
210
213
|
|
|
211
|
-
if (localContent !== remoteContent) {
|
|
214
|
+
// if (localContent !== remoteContent) {
|
|
212
215
|
writePageFile(type, key, remoteContent, cwd);
|
|
213
216
|
if (remoteTimestamp) {
|
|
214
217
|
setPageTimestamp(cache, type, key, remoteTimestamp);
|
|
215
218
|
}
|
|
216
219
|
console.log(chalk.green(` ✓ ${filePath} (updated)`));
|
|
217
220
|
downloadedCount++;
|
|
218
|
-
} else {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
221
|
+
// } else {
|
|
222
|
+
// if (remoteTimestamp) {
|
|
223
|
+
// setPageTimestamp(cache, type, key, remoteTimestamp);
|
|
224
|
+
// }
|
|
225
|
+
// console.log(chalk.gray(` - ${filePath} (unchanged)`));
|
|
226
|
+
// }
|
|
224
227
|
}
|
|
225
228
|
|
|
226
229
|
writeCache(cache, cwd);
|
|
@@ -273,10 +276,10 @@ async function uploadPages(cwd, config, force = false) {
|
|
|
273
276
|
}
|
|
274
277
|
}
|
|
275
278
|
|
|
276
|
-
if (localPage.content === remotePage.content) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
279
|
+
// if (localPage.content === remotePage.content) {
|
|
280
|
+
// console.log(chalk.gray(` - ${filePath} (unchanged)`));
|
|
281
|
+
// continue;
|
|
282
|
+
// }
|
|
280
283
|
}
|
|
281
284
|
|
|
282
285
|
pagesToUpload.push(localPage);
|
|
@@ -311,4 +314,35 @@ async function uploadPages(cwd, config, force = false) {
|
|
|
311
314
|
}
|
|
312
315
|
}
|
|
313
316
|
|
|
317
|
+
async function updateDevDoc() {
|
|
318
|
+
const devDocDir = path.join(process.cwd(), 'DEV_DOC');
|
|
319
|
+
const configFileExists = fs.existsSync(path.join(process.cwd(), 'cyber-elx.jsonc'));
|
|
320
|
+
|
|
321
|
+
if (configFileExists) {
|
|
322
|
+
if (!fs.existsSync(devDocDir)) {
|
|
323
|
+
fs.mkdirSync(devDocDir, { recursive: true });
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const files = ['ThemeDev.md', 'README.md'];
|
|
327
|
+
|
|
328
|
+
for (const file of files) {
|
|
329
|
+
const sourceContent = fs.readFileSync(path.join(__dirname, '..', 'DEV_DOC', file), 'utf-8');
|
|
330
|
+
const localPath = path.join(devDocDir, file);
|
|
331
|
+
let localContent = '';
|
|
332
|
+
|
|
333
|
+
try {
|
|
334
|
+
localContent = fs.readFileSync(localPath, 'utf-8');
|
|
335
|
+
} catch (err) {
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (sourceContent !== localContent) {
|
|
339
|
+
fs.writeFileSync(localPath, sourceContent);
|
|
340
|
+
console.log(chalk.green(`DEV_DOC/${file} was updated`));
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
314
348
|
program.parse();
|