Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
54dd1b3e
Commit
54dd1b3e
authored
Sep 04, 2015
by
carlosperate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract Electron server code to locate project root into own module.
parent
e8771137
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
41 deletions
+64
-41
package/electron/app/main.js
package/electron/app/main.js
+6
-4
package/electron/app/rootlocator.js
package/electron/app/rootlocator.js
+56
-0
package/electron/app/servermgr.js
package/electron/app/servermgr.js
+2
-37
No files found.
package/electron/app/main.js
View file @
54dd1b3e
...
...
@@ -14,6 +14,7 @@ var winston = require('winston');
var
appMenu
=
require
(
'
./appmenu.js
'
);
var
server
=
require
(
'
./servermgr.js
'
);
var
BrowserWindow
=
require
(
'
browser-window
'
);
var
projectRootLocator
=
require
(
'
./rootlocator.js
'
);
var
env
=
require
(
'
./vendor/electron_boilerplate/env_config
'
);
var
windowStateKeeper
=
require
(
'
./vendor/electron_boilerplate/window_state
'
);
...
...
@@ -21,7 +22,6 @@ var windowStateKeeper = require('./vendor/electron_boilerplate/window_state');
// be closed automatically when the JavaScript object is garbage collected.
var
mainWindow
=
null
;
var
splashWindow
=
null
;
var
projectJetPath
=
null
;
// Preserver of the window size and position between app launches.
var
mainWindowState
=
windowStateKeeper
(
'
main
'
,
{
...
...
@@ -31,14 +31,15 @@ var mainWindowState = windowStateKeeper('main', {
app
.
on
(
'
ready
'
,
function
()
{
// Finding project path
projectJetPath
=
server
.
getProjectJetpack
();
var
projectRootPath
=
projectRootLocator
.
getProjectRootPath
();
// Setting up logging system
winston
.
add
(
winston
.
transports
.
File
,
{
json
:
false
,
filename
:
project
JetPath
.
path
()
+
'
/ardublockly.log
'
,
filename
:
project
RootPath
+
'
/ardublockly.log
'
,
maxsize
:
10485760
,
maxFiles
:
2
});
maxFiles
:
2
});
createSplashWindow
();
...
...
@@ -112,6 +113,7 @@ app.on('window-all-closed', function () {
function
createSplashWindow
()
{
if
(
splashWindow
===
null
)
{
var
projectJetPath
=
projectRootLocator
.
getProjectRootJetpack
();
var
imagePath
=
'
file://
'
+
projectJetPath
.
path
(
'
ardublockly
'
,
'
img
'
,
'
ardublockly_splash.png
'
);
...
...
package/electron/app/rootlocator.js
0 → 100644
View file @
54dd1b3e
/**
* @author carlosperate
* @copyright 2015 carlosperate https://github.com/carlosperate
* @license Licensed under the The MIT License (MIT), a copy can be found in
* the electron project directory LICENSE file.
*
* @fileoverview Finds the Ardublockly root directory path.
*/
'
use strict
'
;
var
winston
=
require
(
'
winston
'
);
var
jetpack
=
require
(
'
fs-jetpack
'
);
var
env
=
require
(
'
./vendor/electron_boilerplate/env_config
'
);
var
tag
=
'
[Project Root Locator]
'
var
ardublocklyRootDir
=
null
;
module
.
exports
.
getProjectRootJetpack
=
function
()
{
if
(
ardublocklyRootDir
===
null
)
{
// First, work out the project root directory
if
(
env
.
name
===
'
development
'
)
{
// In dev mode the file cwd is on the project/package/electron dir
ardublocklyRootDir
=
jetpack
.
dir
(
'
../../
'
);
}
else
{
// Cannot use relative paths in build, so let's try to find the
// ardublockly folder in a node from the executable file path tree
ardublocklyRootDir
=
jetpack
.
dir
(
__dirname
);
var
oldArdublocklyRootDir
=
''
;
while
(
ardublocklyRootDir
.
path
()
!=
oldArdublocklyRootDir
)
{
//winston.log('info', tag + 'Search for Ardublockly project ' +
// 'dir: ' + ardublocklyRootDir.cwd());
// Check if /ardublokly/index.html exists within current path
if
(
jetpack
.
exists
(
ardublocklyRootDir
.
path
(
'
ardublockly
'
,
'
index.html
'
)))
{
// Found the right folder, break with this dir loaded
break
;
}
oldArdublocklyRootDir
=
ardublocklyRootDir
.
path
();
ardublocklyRootDir
=
ardublocklyRootDir
.
dir
(
'
../
'
);
}
if
(
ardublocklyRootDir
.
path
()
==
oldArdublocklyRootDir
)
{
ardublocklyRootDir
=
jetpack
.
dir
(
'
.
'
);
ardublocklyNotFound
(
ardublocklyRootDir
.
path
(
'
.
'
));
}
}
winston
.
info
(
tag
+
'
Ardublockly root dir:
'
+
ardublocklyRootDir
.
cwd
());
}
return
ardublocklyRootDir
;
};
module
.
exports
.
getProjectRootPath
=
function
()
{
return
module
.
exports
.
getProjectRootJetpack
().
path
();
};
package/electron/app/servermgr.js
View file @
54dd1b3e
...
...
@@ -13,53 +13,18 @@ var dialog = require('dialog');
var
winston
=
require
(
'
winston
'
);
var
jetpack
=
require
(
'
fs-jetpack
'
);
var
childProcess
=
require
(
'
child_process
'
);
var
projectRootLocator
=
require
(
'
./rootlocator.js
'
);
var
env
=
require
(
'
./vendor/electron_boilerplate/env_config
'
);
var
tag
=
'
[Server mgr]
'
var
serverProcess
=
null
;
var
ardublocklyRootDir
=
null
;
module
.
exports
.
getProjectJetpack
=
function
()
{
if
(
ardublocklyRootDir
==
null
)
{
// First, work out the project root directory
if
(
env
.
name
===
'
development
'
)
{
// In dev mode the file cwd is on the project/package/electron dir
ardublocklyRootDir
=
jetpack
.
dir
(
'
../../
'
);
}
else
{
// Cannot use relative paths in build, so let's try to find the
// ardublockly folder in a node from the executable file path tree
var
ardublocklyRootDir
=
jetpack
.
dir
(
__dirname
);
var
oldArdublocklyRootDir
=
''
;
while
(
ardublocklyRootDir
.
path
()
!=
oldArdublocklyRootDir
)
{
//winston.log('info', tag + 'Search for Ardublockly project ' +
// 'dir: ' + ardublocklyRootDir.cwd());
// Check if /ardublokly/index.html exists within current path
if
(
jetpack
.
exists
(
ardublocklyRootDir
.
path
(
'
ardublockly
'
,
'
index.html
'
)))
{
// Found the right folder, break with this dir loaded
break
;
}
oldArdublocklyRootDir
=
ardublocklyRootDir
.
path
();
ardublocklyRootDir
=
ardublocklyRootDir
.
dir
(
'
../
'
);
}
if
(
ardublocklyRootDir
.
path
()
==
oldArdublocklyRootDir
)
{
ardublocklyRootDir
=
jetpack
.
dir
(
'
.
'
);
ardublocklyNotFound
(
ardublocklyRootDir
.
path
(
'
.
'
));
}
}
winston
.
info
(
tag
+
'
Ardublockly root dir:
'
+
ardublocklyRootDir
.
cwd
());
}
return
ardublocklyRootDir
;
};
function
getServerExecLocation
()
{
// Relevant OS could be win32, linux, darwin
winston
.
info
(
tag
+
'
OS detected:
'
+
process
.
platform
);
var
ardublocklyProjRootDir
=
module
.
exports
.
getProjec
tJetpack
();
var
ardublocklyProjRootDir
=
projectRootLocator
.
getProjectRoo
tJetpack
();
// Then, work out the location of the python executable files
if
(
process
.
platform
==
"
darwin
"
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment