1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Electron: Various tweaks to get PortableApps format to work

This commit is contained in:
Laurent Cozic 2018-04-23 21:50:29 +02:00
parent d4b19f19a1
commit 2bf87655da
24 changed files with 537 additions and 305 deletions

View File

@ -9,9 +9,10 @@ const fs = require('fs-extra');
class ElectronAppWrapper {
constructor(electronApp, env) {
constructor(electronApp, env, profilePath) {
this.electronApp_ = electronApp;
this.env_ = env;
this.profilePath_ = profilePath;
this.win_ = null;
this.willQuitApp_ = false;
this.tray_ = null;
@ -37,12 +38,16 @@ class ElectronAppWrapper {
createWindow() {
const windowStateKeeper = require('electron-window-state');
// Load the previous state with fallback to defaults
const windowState = windowStateKeeper({
const stateOptions = {
defaultWidth: 800,
defaultHeight: 600,
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 = {
x: windowState.x,

View File

@ -568,6 +568,12 @@ class Application extends BaseApplication {
}
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);
AlarmService.setDriver(new AlarmServiceDriverNode({ appName: packageInfo.build.appId }));

View File

@ -24,11 +24,22 @@ function envFromArgs(args) {
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();
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);

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,23 @@
"build/icons/*"
],
"win": {
"icon": "../../Assets/Joplin.ico"
"icon": "../../Assets/Joplin.ico",
"target": [
{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
},
{
"target": "portable",
"arch": [
"x64",
"ia32"
]
}
]
},
"nsis": {
"oneClick": false,
@ -61,6 +77,7 @@
"base-64": "^0.1.0",
"compare-versions": "^3.1.0",
"electron-context-menu": "^0.9.1",
"electron-is-dev": "^0.3.0",
"electron-window-state": "^4.1.1",
"follow-redirects": "^1.2.5",
"form-data": "^2.3.1",

View File

@ -368,11 +368,11 @@ class BaseApplication {
let initArgs = startFlags.matched;
if (argv.length) this.showPromptString_ = false;
if (process.argv[1].indexOf('joplindev') >= 0) {
if (!initArgs.profileDir) initArgs.profileDir = '/mnt/d/Temp/TestNotes2';
initArgs.logLevel = Logger.LEVEL_DEBUG;
initArgs.env = 'dev';
}
// if (process.argv[1].indexOf('joplindev') >= 0) {
// if (!initArgs.profileDir) initArgs.profileDir = '/mnt/d/Temp/TestNotes2';
// initArgs.logLevel = Logger.LEVEL_DEBUG;
// initArgs.env = 'dev';
// }
let appName = initArgs.env == 'dev' ? 'joplindev' : 'joplin';
if (Setting.value('appId').indexOf('-desktop') >= 0) appName += '-desktop';

View File

@ -0,0 +1,5 @@
[Launch]
ProgramExecutable=Joplin\Joplin.exe
DirectoryMoveOK=yes
SupportsUNC=yes
CommandLineArguments=--profile "%PAL:DataDir%"

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View 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

View 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.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

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

View 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.

View 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.