-
Notifications
You must be signed in to change notification settings - Fork 0
/
combine.js
99 lines (73 loc) · 2.17 KB
/
combine.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Importing the Required Modules
const fs = require('fs');
const readline = require('readline');
const path = require('path');
const {EOL} = require('os');
// VARIABLE
var delays = 0;
// jsfunc
const create_file = require('./jsfunc/create_file');
const split_file = require('./jsfunc/split_file');
const append_to_file = require('./jsfunc/append_to_file');
// const project_path = '.';
const project_path = '../data/';
const slide_config_path = project_path + 'event/2021/4developers/';
const config_filename = 'slides.json';
var cfg = require(slide_config_path + config_filename);
console.log(cfg);
// PAGE
var header = '';
fs.readFile(slide_config_path + cfg.template.page.header, "utf8", function (err, data) {
header = data;
});
var footer = '';
fs.readFile(slide_config_path + cfg.template.page.footer, "utf8", function (err, data) {
footer = data;
});
// SLIDE
var before = '';
fs.readFile(slide_config_path + cfg.template.slide.header, "utf8", function (err, data) {
before = data;
});
var after = '';
fs.readFile(slide_config_path + cfg.template.slide.footer, "utf8", function (err, data) {
after = data;
});
// console.log(header + before + after +footer);
var file_list = cfg.slides;
var output = project_path + cfg.output;
var prefix = '# ';
function prepareTemplate() {
create_file('', output);
append_to_file(header, output);
}
/**
* read only selected files
* split content
* combine to index.html
*/
function readSelectedFiles() {
var delays = 0;
// console.log(file_list);
// return;
file_list.forEach(function (item, index, array) {
console.log('item:', item, index);
var filePath = project_path + item;
delays += 100;
console.log(filePath);
setTimeout(function () {
console.log(delays);
split_file(filePath, prefix, function (content) {
// console.log(content);
append_to_file(before + content + after, output);
});
}, delays);
});
}
function end() {
append_to_file(footer, output);
}
setTimeout(prepareTemplate, 200);
// setTimeout(readAllFiles, 600);
setTimeout(readSelectedFiles, 800);
setTimeout(end, 12000);