-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
97 lines (76 loc) · 2.11 KB
/
index.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
'use strict';
var yaml = require('js-yaml'),
_ = require('underscore'),
path = require('path'),
fs = require('fs');
var newslynx_config_lib = require('newslynx-app-config'),
local_settings,
newslynx_config;
if (_.isEmpty(newslynx_config_lib.config)){
local_settings = yaml.load(fs.readFileSync(path.join(__dirname, '/config.yaml'), 'utf-8'));
newslynx_config = _.extend({}, newslynx_config_lib.config, local_settings);
newslynx_config_lib.save(newslynx_config);
}
var newslynx = require('newslynx'),
port = 3690;
const app = require('app');
const BrowserWindow = require('browser-window');
// report crashes to the Electron project
require('crash-reporter').start();
function createMainWindow () {
const win = new BrowserWindow({
width: 1350,
height: 768,
resizable: true
});
win.loadUrl('http://localhost:'+port);
win.on('closed', onClosed);
return win;
}
var gh_releases = require('electron-gh-releases')
var options = {
repo: 'newslynx/newslynx-electron',
currentVersion: app.getVersion()
}
var update = new gh_releases(options, function (auto_updater) {
// Auto updater event listener
auto_updater.on('update-downloaded', function (e, rNotes, rName, rDate, uUrl, quitAndUpdate) {
// Install the update
quitAndUpdate()
})
})
// Check for updates
update.check(function (err, status) {
if (!err && status) {
update.download()
} else {
console.log('ERROR updating', err)
}
})
function onClosed() {
// deref the window
// for multiple windows store them in an array
mainWindow = null;
}
// prevent window being GC'd
let mainWindow;
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate-with-no-open-windows', function () {
if (!mainWindow) {
mainWindow = createMainWindow();
}
});
app.on('ready', function () {
// Add menu items
var Menu = require('menu');
var menu_template = require('./menus.js')(BrowserWindow)
var menu = Menu.buildFromTemplate(menu_template);
Menu.setApplicationMenu(menu);
newslynx.run(port, null, function(){
mainWindow = createMainWindow();
});
});