Skip to content

Commit 96b642c

Browse files
committed
Making some progress in laboratory stuff
1 parent b30b2b3 commit 96b642c

File tree

13 files changed

+148
-21
lines changed

13 files changed

+148
-21
lines changed

CREDITS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Atom Electron
1717
NodeJS
1818

1919
[Icons]
20-
Presentation icons made by EpicCoders and Freepik from www.flaticon.com
20+
Presentation, notification and menu icons made by EpicCoders and Freepik
21+
from www.flaticon.com
2122

2223
[HTML/CSS/JS]
2324
Twitter Bootstrap

app/css/pretty.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/css/welcome.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,10 @@ div{
2929
margin-top: 0;
3030
margin-bottom: 20px;
3131
}
32+
.app-modes{
33+
width: 110px;
34+
margin-bottom: 15px;
35+
}
36+
.modes{
37+
margin-top: 20px;
38+
}

app/gfx/presentation/app-regular.png

2.14 KB
Loading

app/gfx/presentation/app-tray.png

2.52 KB
Loading

app/js/binary.operations.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ function binaryConvertVersionToShow(version) {
1818
return version.replace(/:/g, '.');
1919
}
2020

21+
/* Gets the path of bundled PHP binary */
22+
function getBundledPhpPath() {
23+
return Path.join(__dirname, 'php', conf.get('system.os'));
24+
}
2125
/**
2226
* Gets version of a binary
2327
* @param {string} path - path to php binary
@@ -81,6 +85,10 @@ function binaryUpdateList() {
8185
const versions = conf.get('php.versions');
8286
const inUse = conf.get('php.default');
8387

88+
// Adds bundled version manually
89+
versions['bundled'] = 'Integrated version';
90+
91+
// Rewrites PHP versions list
8492
Object.keys(versions).forEach((v) => {
8593
$('#binary-list').append(binaryLineGetTemplate(v, versions[v], (inUse === v)));
8694
});
@@ -101,8 +109,12 @@ function phpGetCurrVersion() {
101109

102110
/* Updates binary path used by the runner */
103111
function updatePhpPath() {
104-
// Change phpPath for runner
105-
phpPath = conf.get('php.versions.' + conf.get('php.default'));
112+
// Are we using bundled version?
113+
if (conf.get('php.default') === 'bundled') {
114+
phpPath = getBundledPhpPath();
115+
} else {
116+
phpPath = conf.get('php.versions.' + conf.get('php.default'));
117+
}
106118

107119
// Change PHP version number shown in app
108120
$('#run-version').html(phpGetCurrVersion());
@@ -134,6 +146,10 @@ function binaryAdd(path) {
134146
return false;
135147
}
136148
} catch (e) {
149+
/* eslint-disable no-console */
150+
console.log(e);
151+
/* eslint-enable no-console */
152+
137153
// I couldn't even find the file!!!
138154
return false;
139155
}

app/js/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,11 @@ editor.$blockScrolling = Infinity;
5353

5454
/* Startup routine */
5555
$(() => {
56+
// We need these shortcuts...
5657
editorUnbind(['cmd+,', 'ctrl+t', 'ctrl+p']);
5758

5859
if (isMainWindow) {
5960
updatePhpPath();
60-
/* @@@@@@ this is a test */
61-
phpPath = Path.join(__dirname, 'php/osx/php');
6261
}
6362

6463
// Set missing settings to default

app/js/welcome.js

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
1+
/**
2+
* welcome.js
3+
* First time run check routines
4+
*/
15
const i18n = require('electron').remote.getGlobal('i18n');
26
const app = require('electron').remote.app;
7+
const Configstore = require('configstore');
8+
const pkg = require('./package.json');
9+
const conf = new Configstore(pkg.name);
10+
const fs = require('fs');
11+
const runner = require('child_process');
12+
13+
const unixPaths = [
14+
'/usr/sbin/php',
15+
'/etc/php',
16+
'/usr/lib/php',
17+
'/usr/bin/php',
18+
'/usr/local/bin/php',
19+
'/usr/share/php'
20+
];
21+
22+
const winPaths = [
23+
'C:\\php\\php.exe',
24+
'C:\\xampp\\php\\php.exe'
25+
];
326

427
// Hide instructions div
5-
$('#instructions').hide();
28+
$('#instructions,#choose-mode').hide();
629

730
/* Fills language options */
831
$.each(i18n.fullLocaleList, (i, v) => {
@@ -20,8 +43,58 @@ $('#go').click(() => {
2043
$('#logo img').attr('width', '70');
2144
});
2245

46+
/* Next step action */
47+
$('#next-step').click(() => {
48+
$('#instructions').hide();
49+
$('#choose-mode').show();
50+
});
51+
52+
/* Enable start button */
53+
$('#radio-regular,#radio-tray').click(() => {
54+
$('#start-app').prop("disabled", false);
55+
});
56+
57+
/* Let's get it started in here! :) */
58+
$('#start-app').click(() => {
59+
// Saving configs
60+
// Mode (regular/tray)
61+
conf.set('general.mode', $('input[name=app-mode]:checked').val());
62+
63+
// Locale
64+
conf.set('general.locale', $('#locales-list').val());
65+
66+
// Check OS and searches for PHP binaries in known paths
67+
if (process.platform === 'win32') {
68+
conf.set('system.os', 'win');
69+
checkPhpPath(winPaths);
70+
} else if (process.platform === 'darwin') {
71+
conf.set('system.os', 'osx');
72+
checkPhpPath(unixPaths);
73+
} else {
74+
conf.set('system.os', 'linux');
75+
checkPhpPath(unixPaths);
76+
}
77+
78+
// Set bundled PHP version as default
79+
conf.set('php.default', 'bundled');
80+
81+
// Restarts the app to finish setup
82+
app.relaunch();
83+
app.exit(0);
84+
85+
});
2386

2487
/* Close button action */
2588
$('#close-button button').click(() => {
2689
app.quit();
2790
});
91+
92+
/* Checks automatically for php binaries in known paths */
93+
function checkPhpPath(list) {
94+
// Try to find a binary in every known path
95+
list.every((path) => {
96+
binaryAdd(path);
97+
return true;
98+
});
99+
return true;
100+
}

app/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,6 @@
9393
"File": "File",
9494
"Don't change": "Don't change",
9595
"Updates": "Updates",
96-
"Update presentation code as you type": "Update presentation code as you type"
96+
"Update presentation code as you type": "Update presentation code as you type",
97+
"": ""
9798
}

app/locales/pt-BR.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,6 @@
9393
"File": "Arquivo",
9494
"Don't change": "Não mudar",
9595
"Updates": "Atualizações",
96-
"Update presentation code as you type": "Atualizar código da apresentação conforme você digita"
97-
}
96+
"Update presentation code as you type": "Atualizar código da apresentação conforme você digita",
97+
"": ""
98+
}

0 commit comments

Comments
 (0)