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

+2-1
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

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/css/welcome.css

+7
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

+18-2
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

+1-2
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

+74-1
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

+2-1
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

+3-2
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+
}

app/main.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* main.js
3+
*/
14
// This will be fixed when porting functions to modules
25
/* eslint-disable no-use-before-define */
36

@@ -44,18 +47,20 @@ app.on('ready', () => {
4447
// Wake up i18n!
4548
prepareLocalize();
4649

50+
// First run?
4751
if (!(conf.get('general.locale'))) {
4852
welcome();
4953
return;
5054
}
55+
5156
startupRoutine();
5257
});
5358

5459
function welcome() {
5560
// Creates welcome window
5661
welcomeWindow = new BrowserWindow({
5762
title: appName,
58-
height: 580,
63+
height: 620,
5964
width: 680,
6065
center: true,
6166
frame: false,
@@ -99,14 +104,7 @@ function startupRoutine() {
99104
app.quit();
100105
});
101106

102-
// Check if phpPath is already known
103-
if (conf.get('php.default')) {
104-
// Yes! I know where PHP is!
105-
startApp();
106-
} else {
107-
// Nope! Go and find it!
108-
runCheck();
109-
}
107+
startApp();
110108
}
111109

112110
/* In case of all windows are closed */

app/php/osx/php app/php/osx

File renamed without changes.

app/welcome.html

+33-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<title>PHP Assistant: Welcome</title>
88
<link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
99
<link href="css/welcome.css" type="text/css" rel="stylesheet">
10+
<link href="css/pretty.css" type="text/css" rel="stylesheet">
1011
<script>
1112
window.$ = window.jQuery = require('./js/jquery.js');
1213
var isMainWindow = true;
@@ -35,19 +36,48 @@
3536
<div class="row col-xs-offset-0 col-xs-12 well">
3637
<h1>Bem-vindo!</h1>
3738
<p>Seja bem-vindo ao PHP Assistant. Aqui estão as instruções para uso.</p>
38-
<!--p>Para que esta aplicação funcione, você precisa ter o PHP instalado na máquina.</p-->
3939
<p>Esta aplicação já vem com uma versão do PHP disponível internamente.</p>
4040
<p>Caso você tenha alguma outra versão, a aplicação tentará descobrir automaticamente onde o PHP está. Se não for possível, você deverá indicar onde o executável/binário do PHP está localizado.</p>
4141
<p>Se você instalou ferramentas como XAMPP, pode utilizar o PHP que veio junto.</p>
42-
<p>Quando estiver pronto, clique no botão "Iniciar".</p>
42+
<p>Quando estiver pronto, clique no botão "Próximo Passo".</p>
4343
</div>
4444
<div class="row">
45-
<button class="btn btn-default"><span class="glyphicon glyphicon-log-in" aria-hidden="true"></span>&nbsp; Iniciar</button>
45+
<button id="next-step" class="btn btn-default"><span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>&nbsp; Próximo Passo</button>
46+
</div>
47+
</div>
48+
49+
<div id="choose-mode" class="container-fluid">
50+
<div class="row col-xs-offset-0 col-xs-12 well">
51+
<h1>Escolha o modo</h1>
52+
<p>O PHP Assistant funciona de duas maneiras: como uma aplicação comum e como uma aplicação da barra de notificações. Você pode alterar essa opção depois.</p>
53+
<p>Dependendo da distribuição Linux, o modo em barra de notificações pode não funcionar.</p>
54+
<div class="row modes">
55+
<div class="col-xs-6">
56+
<label for="radio-regular"><img src="gfx/presentation/app-regular.png" class="app-modes"></label>
57+
<br>
58+
<div class="pretty inline circle primary">
59+
<input type="radio" id="radio-regular" name="app-mode" value="regular">
60+
<label><i class="default"></i> Aplicação comum</label>
61+
</div>
62+
</div>
63+
<div class="col-xs-6">
64+
<label for="radio-tray"><img src="gfx/presentation/app-tray.png" class="app-modes"></label>
65+
<br>
66+
<div class="pretty inline circle primary">
67+
<input type="radio" id="radio-tray" name="app-mode" value="tray">
68+
<label><i class="default"></i> Aplicação na tray</label>
69+
</div>
70+
</div>
71+
</div>
72+
</div>
73+
<div class="row">
74+
<button id="start-app" class="btn btn-default" disabled><span class="glyphicon glyphicon-log-in" aria-hidden="true"></span>&nbsp; Iniciar Aplicação</button>
4675
</div>
4776
</div>
4877

4978
</body>
5079
<script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
80+
<script src="js/binary.operations.js" type="text/javascript" charset="utf-8"></script>
5181
<script src="js/welcome.js" type="text/javascript" charset="utf-8"></script>
5282

5383
</html>

0 commit comments

Comments
 (0)