CinemaPress/optimal.js

233 lines
7.7 KiB
JavaScript
Raw Permalink Normal View History

2020-01-07 00:04:18 +01:00
const fs = require('fs');
const os = require('os');
const path = require('path');
2020-01-17 04:37:27 +01:00
let config_file = path.join(__dirname, 'config', 'production', 'config.js');
let modules_file = path.join(__dirname, 'config', 'production', 'modules.js');
2020-01-07 00:04:18 +01:00
let process_file = path.join(__dirname, 'process.json');
let config = require(config_file);
let modules = require(modules_file);
2020-01-07 05:38:07 +01:00
let process_json = require(process_file);
2020-01-07 00:04:18 +01:00
2020-01-08 03:45:50 +01:00
var d = new Date();
2020-01-17 04:37:27 +01:00
d.setDate(d.getDate() - 31);
2020-01-08 03:45:50 +01:00
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;
2020-01-07 00:04:18 +01:00
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;
2020-01-07 00:04:18 +01:00
modules.related.data.types.year.count = 6;
modules.content.data.news.count = 3;
2020-12-06 00:43:22 +01:00
modules.comments.data.fast.recent.display = ['index'];
modules.player.data.script = modules.player.data.script.replace(
2020-03-20 02:18:03 +01:00
/#[a-z0-9]{6}/i,
'#14181c'
);
2020-12-08 01:16:37 +01:00
modules.slider.data.movies = modules.slider.data.movies.slice(0, 6);
2020-01-07 00:04:18 +01:00
}
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;
2020-12-06 00:43:22 +01:00
modules.comments.data.fast.recent.display = ['index'];
modules.comments.data.disqus.recent.num_items = 0;
modules.comments.data.hypercomments.recent.num_items = 0;
2020-01-07 00:04:18 +01:00
config.default.count = 12;
config.index.year.count = 12;
modules.content.data.index.count = 12;
modules.episode.data.index.count = 12;
2020-01-07 00:04:18 +01:00
modules.related.data.types.year.count = 6;
modules.content.data.news.count = 3;
modules.player.data.script = modules.player.data.script.replace(
2020-03-20 02:18:03 +01:00
/#[a-z0-9]{6}/i,
'#101010'
);
2020-01-07 00:04:18 +01:00
}
if (['cersei'].indexOf(theme) + 1) {
2021-01-05 00:13:32 +01:00
config.default.count = 15;
config.index.year.count = 10;
modules.content.data.index.count = 10;
modules.episode.data.index.count = 20;
2020-01-07 00:04:18 +01:00
modules.related.data.types.year.count = 5;
2020-03-16 05:04:01 +01:00
modules.comments.data.fast.recent.display = ['index'];
modules.player.data.script = modules.player.data.script.replace(
2020-03-20 02:18:03 +01:00
/#[a-z0-9]{6}/i,
'#393939'
);
2020-01-07 00:04:18 +01:00
}
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;
2020-01-07 00:04:18 +01:00
modules.related.data.types.year.count = 5;
modules.player.data.script = modules.player.data.script.replace(
2020-03-20 02:18:03 +01:00
/#[a-z0-9]{6}/i,
2020-09-28 03:57:37 +02:00
'#7e8594'
);
2020-01-07 00:04:18 +01:00
}
if (['joffrey'].indexOf(theme) + 1) {
modules.related.data.types.year.count = 7;
2020-12-06 00:43:22 +01:00
modules.comments.data.fast.recent.display = ['index'];
modules.player.data.script = modules.player.data.script.replace(
2020-03-20 02:18:03 +01:00
/#[a-z0-9]{6}/i,
2020-09-28 03:57:37 +02:00
'#5e81a8'
);
2020-12-08 01:16:37 +01:00
modules.slider.data.movies = modules.slider.data.movies.slice(0, 10);
2020-01-07 00:04:18 +01:00
}
if (['hodor'].indexOf(theme) + 1) {
modules.comments.data.hypercomments.recent.display = [];
modules.comments.data.fast.recent.display = [];
2020-01-07 00:04:18 +01:00
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;
2020-01-07 00:04:18 +01:00
config.default.count = 10;
config.index.year.count = 10;
modules.content.data.index.count = 10;
modules.episode.data.index.count = 25;
2020-01-07 00:04:18 +01:00
modules.related.data.types.year.count = 5;
modules.content.data.news.count = 3;
modules.player.data.script = modules.player.data.script.replace(
2020-03-20 02:18:03 +01:00
/#[a-z0-9]{6}/i,
'#1f2123'
);
2020-12-08 01:16:37 +01:00
modules.slider.data.movies = modules.slider.data.movies.slice(0, 3);
2020-01-07 00:04:18 +01:00
}
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;
2020-01-07 00:04:18 +01:00
modules.related.data.types.year.count = 5;
modules.content.data.news.count = 3;
2020-02-20 02:34:17 +01:00
modules.comments.data.fast.recent.display = ['index'];
modules.player.data.script = modules.player.data.script.replace(
2020-03-20 02:18:03 +01:00
/#[a-z0-9]{6}/i,
'#282350'
);
2020-12-08 01:16:37 +01:00
modules.slider.data.movies = modules.slider.data.movies.slice(0, 3);
2020-01-07 00:04:18 +01:00
}
if (['tarly'].indexOf(theme) + 1) {
config.default.count = 12;
config.index.year.count = 12;
2020-03-12 05:08:55 +01:00
modules.content.data.index.count = 12;
2020-02-20 00:59:52 +01:00
modules.episode.data.index.count = 5;
2020-01-07 00:04:18 +01:00
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(
2020-03-20 02:18:03 +01:00
/#[a-z0-9]{6}/i,
'#333333'
);
2020-12-08 01:16:37 +01:00
modules.slider.data.movies = modules.slider.data.movies.slice(0, 3);
2020-01-07 00:04:18 +01:00
}
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(
2020-03-20 02:18:03 +01:00
/#[a-z0-9]{6}/i,
'#262626'
);
2020-01-07 00:04:18 +01:00
}
2020-02-20 00:59:52 +01:00
if (['ramsay'].indexOf(theme) + 1) {
modules.episode.data.index.count = 24;
2020-12-06 00:43:22 +01:00
modules.comments.data.fast.recent.display = ['index'];
modules.player.data.script = modules.player.data.script.replace(
2020-03-20 02:18:03 +01:00
/#[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(
2020-03-20 02:18:03 +01:00
/#[a-z0-9]{6}/i,
'#44475a'
);
2020-02-20 00:59:52 +01:00
}
2020-09-14 03:31:25 +02:00
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'
);
2020-12-08 01:16:37 +01:00
modules.slider.data.movies = modules.slider.data.movies.slice(0, 6);
2020-09-14 03:31:25 +02:00
}
2021-03-07 20:34:14 +01:00
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;
2021-03-08 08:21:36 +01:00
modules.content.data.news.count = 2;
2021-03-07 20:34:14 +01:00
modules.comments.data.fast.recent.display = [];
modules.player.data.script = modules.player.data.script.replace(
/#[a-z0-9]{6}/i,
2021-03-07 21:10:29 +01:00
'#21202a'
2021-03-07 20:34:14 +01:00
);
modules.slider.data.movies = modules.slider.data.movies.slice(0, 5);
modules.soon.data.count = 5;
modules.viewed.data.count = 18;
}
2020-01-07 00:04:18 +01:00
let mem = parseInt('' + os.totalmem() / 1000000);
let cpu = os.cpus() ? os.cpus().length : 1;
2020-01-17 04:37:27 +01:00
let max = parseInt('' + mem / (cpu > 1 ? cpu : 2));
2020-01-07 00:04:18 +01:00
//process_json.apps[0].node_args = '--max-old-space-size=' + max;
//process_json.apps[0].max_memory_restart = max + 'M';
2020-01-07 05:38:07 +01:00
//process_json.apps[0].instances = cpu + '';
2020-01-07 00:04:18 +01:00
fs.writeFileSync(
config_file,
'module.exports = ' + JSON.stringify(config, null, '\t') + ';'
);
fs.writeFileSync(
modules_file,
'module.exports = ' + JSON.stringify(modules, null, '\t') + ';'
);
2020-01-07 05:38:07 +01:00
fs.writeFileSync(process_file, JSON.stringify(process_json, null, '\t'));