forked from CinemaPress/CinemaPress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
optimal.js
232 lines (210 loc) · 7.69 KB
/
optimal.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
const fs = require('fs');
const os = require('os');
const path = require('path');
let config_file = path.join(__dirname, 'config', 'production', 'config.js');
let modules_file = path.join(__dirname, 'config', 'production', 'modules.js');
let process_file = path.join(__dirname, 'process.json');
let config = require(config_file);
let modules = require(modules_file);
let process_json = require(process_file);
var d = new Date();
d.setDate(d.getDate() - 31);
config.index.year.keys = d.getFullYear() + '';
config.index.year.sorting = 'premiere-up';
config.index.year.order = 9;
config.index.count.type = 'year';
config.index.count.key = d.getFullYear() + '';
config.index.count.sorting = 'premiere-up';
let theme =
process && process.argv && process.argv[2] ? process.argv[2] : config.theme;
if (['arya'].indexOf(theme) + 1) {
config.default.count = 12;
config.index.year.count = 12;
modules.content.data.index.count = 12;
modules.episode.data.index.count = 12;
modules.related.data.types.year.count = 6;
modules.content.data.news.count = 3;
modules.comments.data.fast.recent.display = ['index'];
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#14181c'
);
modules.slider.data.movies = modules.slider.data.movies.slice(0, 6);
}
if (['bran'].indexOf(theme) + 1) {
modules.comments.data.hypercomments.recent.display = [];
modules.comments.data.fast.recent.display = [];
modules.comments.data.disqus.recent.display = [];
modules.comments.data.fast.recent.num_items = 0;
modules.comments.data.fast.recent.display = ['index'];
modules.comments.data.disqus.recent.num_items = 0;
modules.comments.data.hypercomments.recent.num_items = 0;
config.default.count = 12;
config.index.year.count = 12;
modules.content.data.index.count = 12;
modules.episode.data.index.count = 12;
modules.related.data.types.year.count = 6;
modules.content.data.news.count = 3;
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#101010'
);
}
if (['cersei'].indexOf(theme) + 1) {
config.default.count = 15;
config.index.year.count = 10;
modules.content.data.index.count = 10;
modules.episode.data.index.count = 20;
modules.related.data.types.year.count = 5;
modules.comments.data.fast.recent.display = ['index'];
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#393939'
);
}
if (['robb', 'sansa', 'tyrion'].indexOf(theme) + 1) {
config.default.count = 10;
config.index.year.count = 10;
modules.content.data.index.count = 10;
modules.episode.data.index.count = 12;
modules.related.data.types.year.count = 5;
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#7e8594'
);
}
if (['joffrey'].indexOf(theme) + 1) {
modules.related.data.types.year.count = 7;
modules.comments.data.fast.recent.display = ['index'];
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#5e81a8'
);
modules.slider.data.movies = modules.slider.data.movies.slice(0, 10);
}
if (['hodor'].indexOf(theme) + 1) {
modules.comments.data.hypercomments.recent.display = [];
modules.comments.data.fast.recent.display = [];
modules.comments.data.disqus.recent.display = [];
modules.comments.data.fast.recent.num_items = 0;
modules.comments.data.disqus.recent.num_items = 0;
modules.comments.data.hypercomments.recent.num_items = 0;
config.default.count = 10;
config.index.year.count = 10;
modules.content.data.index.count = 10;
modules.episode.data.index.count = 25;
modules.related.data.types.year.count = 5;
modules.content.data.news.count = 3;
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#1f2123'
);
modules.slider.data.movies = modules.slider.data.movies.slice(0, 3);
}
if (['daenerys'].indexOf(theme) + 1) {
config.default.count = 12;
config.index.year.count = 12;
modules.content.data.index.count = 12;
modules.episode.data.index.count = 24;
modules.related.data.types.year.count = 5;
modules.content.data.news.count = 3;
modules.comments.data.fast.recent.display = ['index'];
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#282350'
);
modules.slider.data.movies = modules.slider.data.movies.slice(0, 3);
}
if (['tarly'].indexOf(theme) + 1) {
config.default.count = 12;
config.index.year.count = 12;
modules.content.data.index.count = 12;
modules.episode.data.index.count = 5;
modules.related.data.types.year.count = 12;
modules.top.data.count = 5;
modules.comments.data.fast.recent.num_items = 5;
modules.comments.data.disqus.recent.num_items = 0;
modules.comments.data.hypercomments.recent.num_items = 0;
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#333333'
);
modules.slider.data.movies = modules.slider.data.movies.slice(0, 3);
}
if (['mormont'].indexOf(theme) + 1) {
config.default.count = 12;
config.index.year.count = 12;
modules.content.data.index.count = 12;
modules.episode.data.index.count = 16;
modules.related.data.types.year.count = 12;
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#262626'
);
}
if (['ramsay'].indexOf(theme) + 1) {
modules.episode.data.index.count = 24;
modules.comments.data.fast.recent.display = ['index'];
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#333333'
);
}
if (['dustin'].indexOf(theme) + 1) {
config.default.count = 12;
config.index.year.count = 12;
modules.content.data.index.count = 12;
modules.episode.data.index.count = 24;
modules.related.data.types.year.count = 4;
modules.viewed.data.width = '90px';
modules.viewed.data.height = '120px';
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#44475a'
);
}
if (['tormund'].indexOf(theme) + 1) {
config.default.count = 12;
config.index.year.count = 12;
modules.content.data.index.count = 12;
modules.episode.data.index.count = 32;
modules.related.data.types.year.count = 10;
modules.content.data.news.count = 4;
modules.comments.data.fast.recent.display = ['index'];
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#111216'
);
modules.slider.data.movies = modules.slider.data.movies.slice(0, 6);
}
if (['snow'].indexOf(theme) + 1) {
config.default.count = 20;
config.index.year.count = 20;
modules.content.data.index.count = 20;
modules.episode.data.index.count = 12;
modules.related.data.types.year.count = 10;
modules.content.data.news.count = 2;
modules.comments.data.fast.recent.display = [];
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
'#21202a'
);
modules.slider.data.movies = modules.slider.data.movies.slice(0, 5);
modules.soon.data.count = 5;
modules.viewed.data.count = 18;
}
let mem = parseInt('' + os.totalmem() / 1000000);
let cpu = os.cpus() ? os.cpus().length : 1;
let max = parseInt('' + mem / (cpu > 1 ? cpu : 2));
//process_json.apps[0].node_args = '--max-old-space-size=' + max;
//process_json.apps[0].max_memory_restart = max + 'M';
//process_json.apps[0].instances = cpu + '';
fs.writeFileSync(
config_file,
'module.exports = ' + JSON.stringify(config, null, '\t') + ';'
);
fs.writeFileSync(
modules_file,
'module.exports = ' + JSON.stringify(modules, null, '\t') + ';'
);
fs.writeFileSync(process_file, JSON.stringify(process_json, null, '\t'));