Electron: Various tweaks to get PortableApps format to work
@ -9,9 +9,10 @@ const fs = require('fs-extra');
|
|||||||
|
|
||||||
class ElectronAppWrapper {
|
class ElectronAppWrapper {
|
||||||
|
|
||||||
constructor(electronApp, env) {
|
constructor(electronApp, env, profilePath) {
|
||||||
this.electronApp_ = electronApp;
|
this.electronApp_ = electronApp;
|
||||||
this.env_ = env;
|
this.env_ = env;
|
||||||
|
this.profilePath_ = profilePath;
|
||||||
this.win_ = null;
|
this.win_ = null;
|
||||||
this.willQuitApp_ = false;
|
this.willQuitApp_ = false;
|
||||||
this.tray_ = null;
|
this.tray_ = null;
|
||||||
@ -37,12 +38,16 @@ class ElectronAppWrapper {
|
|||||||
createWindow() {
|
createWindow() {
|
||||||
const windowStateKeeper = require('electron-window-state');
|
const windowStateKeeper = require('electron-window-state');
|
||||||
|
|
||||||
// Load the previous state with fallback to defaults
|
const stateOptions = {
|
||||||
const windowState = windowStateKeeper({
|
|
||||||
defaultWidth: 800,
|
defaultWidth: 800,
|
||||||
defaultHeight: 600,
|
defaultHeight: 600,
|
||||||
file: 'window-state-' + this.env_ + '.json',
|
file: 'window-state-' + this.env_ + '.json',
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if (this.profilePath_) stateOptions.path = this.profilePath_;
|
||||||
|
|
||||||
|
// Load the previous state with fallback to defaults
|
||||||
|
const windowState = windowStateKeeper(stateOptions);
|
||||||
|
|
||||||
const windowOptions = {
|
const windowOptions = {
|
||||||
x: windowState.x,
|
x: windowState.x,
|
||||||
|
@ -568,6 +568,12 @@ class Application extends BaseApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async start(argv) {
|
async start(argv) {
|
||||||
|
const electronIsDev = require('electron-is-dev');
|
||||||
|
|
||||||
|
// If running inside a package, the command line, instead of being "node.exe <path> <flags>" is "joplin.exe <flags>" so
|
||||||
|
// insert an extra argument so that they can be processed in a consistent way everywhere.
|
||||||
|
if (!electronIsDev) argv.splice(1, 0, '.');
|
||||||
|
|
||||||
argv = await super.start(argv);
|
argv = await super.start(argv);
|
||||||
|
|
||||||
AlarmService.setDriver(new AlarmServiceDriverNode({ appName: packageInfo.build.appId }));
|
AlarmService.setDriver(new AlarmServiceDriverNode({ appName: packageInfo.build.appId }));
|
||||||
|
@ -24,11 +24,22 @@ function envFromArgs(args) {
|
|||||||
return 'prod';
|
return 'prod';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Likewise, we want to know if a profile is specified early, in particular
|
||||||
|
// to save the window state data.
|
||||||
|
function profileFromArgs(args) {
|
||||||
|
if (!args) return null;
|
||||||
|
const profileIndex = args.indexOf('--profile');
|
||||||
|
if (profileIndex <= 0 || profileIndex >= args.length - 1) return null;
|
||||||
|
const profileValue = args[profileIndex + 1];
|
||||||
|
return profileValue ? profileValue : null;
|
||||||
|
}
|
||||||
|
|
||||||
Logger.fsDriver_ = new FsDriverNode();
|
Logger.fsDriver_ = new FsDriverNode();
|
||||||
|
|
||||||
const env = envFromArgs(process.argv);
|
const env = envFromArgs(process.argv);
|
||||||
|
const profilePath = profileFromArgs(process.argv);
|
||||||
|
|
||||||
const wrapper = new ElectronAppWrapper(electronApp, env);
|
const wrapper = new ElectronAppWrapper(electronApp, env, profilePath);
|
||||||
|
|
||||||
initBridge(wrapper);
|
initBridge(wrapper);
|
||||||
|
|
||||||
|
670
ElectronClient/app/package-lock.json
generated
@ -26,7 +26,23 @@
|
|||||||
"build/icons/*"
|
"build/icons/*"
|
||||||
],
|
],
|
||||||
"win": {
|
"win": {
|
||||||
"icon": "../../Assets/Joplin.ico"
|
"icon": "../../Assets/Joplin.ico",
|
||||||
|
"target": [
|
||||||
|
{
|
||||||
|
"target": "nsis",
|
||||||
|
"arch": [
|
||||||
|
"x64",
|
||||||
|
"ia32"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target": "portable",
|
||||||
|
"arch": [
|
||||||
|
"x64",
|
||||||
|
"ia32"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"nsis": {
|
"nsis": {
|
||||||
"oneClick": false,
|
"oneClick": false,
|
||||||
@ -61,6 +77,7 @@
|
|||||||
"base-64": "^0.1.0",
|
"base-64": "^0.1.0",
|
||||||
"compare-versions": "^3.1.0",
|
"compare-versions": "^3.1.0",
|
||||||
"electron-context-menu": "^0.9.1",
|
"electron-context-menu": "^0.9.1",
|
||||||
|
"electron-is-dev": "^0.3.0",
|
||||||
"electron-window-state": "^4.1.1",
|
"electron-window-state": "^4.1.1",
|
||||||
"follow-redirects": "^1.2.5",
|
"follow-redirects": "^1.2.5",
|
||||||
"form-data": "^2.3.1",
|
"form-data": "^2.3.1",
|
||||||
|
@ -368,11 +368,11 @@ class BaseApplication {
|
|||||||
let initArgs = startFlags.matched;
|
let initArgs = startFlags.matched;
|
||||||
if (argv.length) this.showPromptString_ = false;
|
if (argv.length) this.showPromptString_ = false;
|
||||||
|
|
||||||
if (process.argv[1].indexOf('joplindev') >= 0) {
|
// if (process.argv[1].indexOf('joplindev') >= 0) {
|
||||||
if (!initArgs.profileDir) initArgs.profileDir = '/mnt/d/Temp/TestNotes2';
|
// if (!initArgs.profileDir) initArgs.profileDir = '/mnt/d/Temp/TestNotes2';
|
||||||
initArgs.logLevel = Logger.LEVEL_DEBUG;
|
// initArgs.logLevel = Logger.LEVEL_DEBUG;
|
||||||
initArgs.env = 'dev';
|
// initArgs.env = 'dev';
|
||||||
}
|
// }
|
||||||
|
|
||||||
let appName = initArgs.env == 'dev' ? 'joplindev' : 'joplin';
|
let appName = initArgs.env == 'dev' ? 'joplindev' : 'joplin';
|
||||||
if (Setting.value('appId').indexOf('-desktop') >= 0) appName += '-desktop';
|
if (Setting.value('appId').indexOf('-desktop') >= 0) appName += '-desktop';
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
[Launch]
|
||||||
|
ProgramExecutable=Joplin\Joplin.exe
|
||||||
|
DirectoryMoveOK=yes
|
||||||
|
SupportsUNC=yes
|
||||||
|
CommandLineArguments=--profile "%PAL:DataDir%"
|
BIN
Tools/PortableAppsLauncher/App/AppInfo/Launcher/splash.jpg
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
Tools/PortableAppsLauncher/App/AppInfo/appicon.ico
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
Tools/PortableAppsLauncher/App/AppInfo/appicon_128.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
Tools/PortableAppsLauncher/App/AppInfo/appicon_16.png
Normal file
After Width: | Height: | Size: 679 B |
BIN
Tools/PortableAppsLauncher/App/AppInfo/appicon_32.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
Tools/PortableAppsLauncher/App/AppInfo/appicon_75.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
26
Tools/PortableAppsLauncher/App/AppInfo/appinfo.ini
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[Format]
|
||||||
|
Type=PortableApps.comFormat
|
||||||
|
Version=3.3
|
||||||
|
|
||||||
|
[Details]
|
||||||
|
Name=Joplin Portable
|
||||||
|
AppID=JoplinPortable
|
||||||
|
Publisher=Joplin & PortableApps.com
|
||||||
|
Homepage=PortableApps.com/JoplinPortable
|
||||||
|
Category=Office
|
||||||
|
Description=Note taking
|
||||||
|
Language=Multilingual
|
||||||
|
|
||||||
|
[License]
|
||||||
|
Shareable=true
|
||||||
|
OpenSource=true
|
||||||
|
Freeware=true
|
||||||
|
CommercialUse=true
|
||||||
|
|
||||||
|
[Version]
|
||||||
|
PackageVersion=1.0.83
|
||||||
|
DisplayVersion=1.0.83
|
||||||
|
|
||||||
|
[Control]
|
||||||
|
Icons=1
|
||||||
|
Start=JoplinPortable.exe
|
3
Tools/PortableAppsLauncher/App/readme.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
The files in this directory are necessary for the portable application to
|
||||||
|
function. There is normally no need to directly access or alter any of the
|
||||||
|
files within these directories.
|
BIN
Tools/PortableAppsLauncher/JoplinPortable.exe
Normal file
BIN
Tools/PortableAppsLauncher/Other/Help/images/donation_button.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
Tools/PortableAppsLauncher/Other/Help/images/favicon.ico
Normal file
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 168 B |
After Width: | Height: | Size: 269 B |
BIN
Tools/PortableAppsLauncher/Other/Help/images/help_logo_top.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
@ -0,0 +1,6 @@
|
|||||||
|
AdditionalParameters=
|
||||||
|
DisableSplashScreen=false
|
||||||
|
RunLocally=false
|
||||||
|
|
||||||
|
# The above options are explained in the included readme.txt
|
||||||
|
# This INI file is an example only and is not used unless it is placed as described in the included readme.txt
|
21
Tools/PortableAppsLauncher/Other/Source/License.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2016-2018 Laurent Cozic
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
50
Tools/PortableAppsLauncher/Other/Source/Readme.txt
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
The base application's source code is available from the portable app's
|
||||||
|
homepage listed in the help.html file.
|
||||||
|
|
||||||
|
Details of most other things are available there as well.
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
=======
|
||||||
|
|
||||||
|
This package and its launcher are released under the GPL. The launcher is the
|
||||||
|
PortableApps.com Launcher, available with full source and documentation from
|
||||||
|
http://portableapps.com/development. We request that developers using the
|
||||||
|
PortableApps.com Launcher please leave this directory intact and unchanged.
|
||||||
|
|
||||||
|
USER CONFIGURATION
|
||||||
|
==================
|
||||||
|
|
||||||
|
(For this section, AppNamePortable is the executable base file name, normally
|
||||||
|
the App ID of the package.)
|
||||||
|
|
||||||
|
Some configuration in the PortableApps.com Launcher can be overridden by the
|
||||||
|
user in an INI file next to AppNamePortable.exe called AppNamePortable.ini. If
|
||||||
|
you are happy with the default options, it is not necessary, though. There is
|
||||||
|
an example INI included with this package to get you started. To use it, copy
|
||||||
|
PortableApps.comLauncher.ini from this directory to AppNamePortable.ini next to
|
||||||
|
AppNamePortable.exe. The options in the INI file are as follows::
|
||||||
|
|
||||||
|
AdditionalParameters=
|
||||||
|
DisableSplashScreen=false
|
||||||
|
RunLocally=false
|
||||||
|
|
||||||
|
(There is no need for an INI header in this file; if you have one, though, it
|
||||||
|
won't damage anything.)
|
||||||
|
|
||||||
|
The AdditionalParameters entry allows you to pass additional command-line
|
||||||
|
parameters to the application.
|
||||||
|
|
||||||
|
The DisableSplashScreen entry allows you to run the launcher without the splash
|
||||||
|
screen showing up. The default is false.
|
||||||
|
|
||||||
|
The RunLocally entry allows you to run the portable application from a read-
|
||||||
|
only medium. This is known as Live mode. It copies what it needs to to a
|
||||||
|
temporary directory on the host computer, runs the application, and then
|
||||||
|
deletes it afterwards, leaving nothing behind. This can be useful for running
|
||||||
|
the application from a CD or if you work on a computer that may have spyware or
|
||||||
|
viruses and you'd like to keep your device set to read-only. As a consequence
|
||||||
|
of this technique, any changes you make during the Live mode session aren't
|
||||||
|
saved back to your device. The default is false.
|
||||||
|
|
||||||
|
There may be other values also permitted in the user configuration file by the
|
||||||
|
portable application; refer to help.html for any details of them.
|