1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-09-16 08:56:40 +02:00

Various changes

This commit is contained in:
Laurent Cozic
2017-08-22 19:57:35 +02:00
parent 67b812cab0
commit d9c85a7275
17 changed files with 157 additions and 59 deletions

View File

@@ -402,7 +402,7 @@ class Application {
if (this.autocompletion_.active) { if (this.autocompletion_.active) {
if (this.autocompletion_.install) { if (this.autocompletion_.install) {
try { try {
installAutocompletionFile(Setting.value('appName'), Setting.value('profileDir')); await installAutocompletionFile(Setting.value('appName'), Setting.value('profileDir'));
} catch (error) { } catch (error) {
if (error.code == 'shellNotSupported') { if (error.code == 'shellNotSupported') {
console.info(error.message); console.info(error.message);

View File

@@ -8,21 +8,31 @@ import fs from 'fs-extra';
import os from 'os'; import os from 'os';
import yargParser from 'yargs-parser'; import yargParser from 'yargs-parser';
function autocompletionFileContent(appName) { function autocompletionFileContent(appName, alias) {
let content = fs.readFileSync(__dirname + '/autocompletion_template.txt', 'utf8'); let content = fs.readFileSync(__dirname + '/autocompletion_template.txt', 'utf8');
content = content.replace(/\|__APPNAME__\|/g, appName); content = content.replace(/\|__APPNAME__\|/g, appName);
if (!alias) alias = 'joplin_alias_support_is_disabled';
content = content.replace(/\|__APPALIAS__\|/g, alias);
return content; return content;
} }
function installAutocompletionFile(appName, profileDir) { function autocompletionScriptPath(profileDir) {
return profileDir + '/autocompletion.sh';
}
async function installAutocompletionFile(appName, profileDir) {
if (process.env.SHELL.indexOf('bash') < 0) { if (process.env.SHELL.indexOf('bash') < 0) {
let error = new Error(_('Only Bash is currently supported for autocompletion.')); let error = new Error(_('Only Bash is currently supported for autocompletion.'));
error.code = 'shellNotSupported'; error.code = 'shellNotSupported';
throw error; throw error;
} }
const content = autocompletionFileContent(appName); const alias = await cliUtils.promptInput(_('Autocompletion can be made to work with an alias too (such as a one-letter command like "j").\nIf you would like to enable this, please type the alias now (leave it empty for no alias):'));
const filePath = profileDir + '/autocompletion.sh';
const content = autocompletionFileContent(appName, alias);
const filePath = autocompletionScriptPath(profileDir);
fs.writeFileSync(filePath, content); fs.writeFileSync(filePath, content);
console.info(_('Created autocompletion script "%s".', filePath)); console.info(_('Created autocompletion script "%s".', filePath));
@@ -41,10 +51,18 @@ function installAutocompletionFile(appName, profileDir) {
console.info(_('Added autocompletion to "%s".', bashProfilePath)); console.info(_('Added autocompletion to "%s".', bashProfilePath));
} }
console.info(_('Sourcing "%s"...', filePath)); if (alias) {
if (bashrcContent.indexOf('alias ' + alias + '=') >= 0) {
console.info(_('Alias is already set in "%s".', bashProfilePath));
} else {
const l = 'alias ' + alias + '=' + appName;
bashrcContent += "\n" + l + "\n";
fs.writeFileSync(bashProfilePath, bashrcContent);
console.info(_('Added alias to "%s".', bashProfilePath));
}
}
const spawnSync = require('child_process').spawnSync; console.info(_("IMPORTANT: run the following command to initialise autocompletion in the current shell:\nsource '%s'", filePath));
spawnSync('source', [filePath]);
} }
async function handleAutocompletion(autocompletion) { async function handleAutocompletion(autocompletion) {
@@ -154,4 +172,4 @@ function filterList(list, currentWord) {
return output; return output;
} }
export { handleAutocompletion, installAutocompletionFile }; export { handleAutocompletion, installAutocompletionFile, autocompletionScriptPath };

View File

@@ -41,3 +41,4 @@ _|__APPNAME__|_completion() {
} }
complete -o default -F _|__APPNAME__|_completion |__APPNAME__| complete -o default -F _|__APPNAME__|_completion |__APPNAME__|
complete -o default -F _|__APPNAME__|_completion |__APPALIAS__|

View File

@@ -147,6 +147,22 @@ cliUtils.promptConfirm = function(message, answers = null) {
}); });
} }
cliUtils.promptInput = function(message) {
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
return new Promise((resolve, reject) => {
rl.question(message + ' ', (answer) => {
rl.close();
resolve(answer);
});
});
}
let redrawStarted_ = false; let redrawStarted_ = false;
let redrawLastLog_ = null; let redrawLastLog_ = null;
let redrawLastUpdateTime_ = 0; let redrawLastUpdateTime_ = 0;

View File

@@ -15,24 +15,27 @@ class Command extends BaseCommand {
options() { options() {
return [ return [
['-v, --verbose', _('Also displays hidden config variables.')], ['-v, --verbose', _('Also displays unset and hidden config variables.')],
]; ];
} }
async action(args) { async action(args) {
const verbose = args.options.verbose;
const renderKeyValue = (name) => { const renderKeyValue = (name) => {
const value = Setting.value(name); const value = Setting.value(name);
if (Setting.isEnum(name)) { if (Setting.isEnum(name)) {
return _('%s = %s (%s)', name, value, Setting.enumOptionLabel(name, value)); return _('%s = %s (%s)', name, value, Setting.enumOptionsDoc(name));
} else { } else {
return _('%s = %s', name, value); return _('%s = %s', name, value);
} }
} }
if (!args.name && !args.value) { if (!args.name && !args.value) {
let keys = args.options.verbose ? Setting.keys() : Setting.publicKeys(); let keys = Setting.keys(!verbose, 'cli');
for (let i = 0; i < keys.length; i++) { for (let i = 0; i < keys.length; i++) {
const value = Setting.value(keys[i]);
if (!verbose && !value) continue;
this.log(renderKeyValue(keys[i])); this.log(renderKeyValue(keys[i]));
} }
return; return;

View File

@@ -76,6 +76,7 @@ class Command extends BaseCommand {
updatedNote = await Note.unserializeForEdit(updatedNote); updatedNote = await Note.unserializeForEdit(updatedNote);
updatedNote.id = note.id; updatedNote.id = note.id;
await Note.save(updatedNote); await Note.save(updatedNote);
process.stdout.write('.');
watchTimeout = null; watchTimeout = null;
}, 200); }, 200);
}); });

View File

@@ -3,11 +3,5 @@ set -e
CLIENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CLIENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
npm version patch npm version patch
bash $CLIENT_DIR/build.sh $CLIENT_DIR/build.sh
cp "$CLIENT_DIR/package.json" build/ sudo rsync -aP "$CLIENT_DIR/build/" "/usr/lib/node_modules/joplin/"
cp "$CLIENT_DIR/../ReactNativeClient/lib/package.json" build/lib
#cp "$CLIENT_DIR/app/main.sh" build/
cd "$CLIENT_DIR/build"
sudo npm install -g --save
#sudo yarn global add
cd -

View File

@@ -44,6 +44,13 @@ msgstr ""
msgid "Only Bash is currently supported for autocompletion." msgid "Only Bash is currently supported for autocompletion."
msgstr "" msgstr ""
msgid ""
"Autocompletion can be made to work with an alias too (such as a one-letter "
"command like \"j\").\n"
"If you would like to enable this, please type the alias now (leave it empty "
"for no alias):"
msgstr ""
#, javascript-format #, javascript-format
msgid "Created autocompletion script \"%s\"." msgid "Created autocompletion script \"%s\"."
msgstr "" msgstr ""
@@ -57,7 +64,18 @@ msgid "Added autocompletion to \"%s\"."
msgstr "" msgstr ""
#, javascript-format #, javascript-format
msgid "Sourcing \"%s\"..." msgid "Alias is already set in \"%s\"."
msgstr ""
#, javascript-format
msgid "Added alias to \"%s\"."
msgstr ""
#, javascript-format
msgid ""
"IMPORTANT: run the following command to initialise autocompletion in the "
"current shell:\n"
"source '%s'"
msgstr "" msgstr ""
#, javascript-format #, javascript-format
@@ -86,7 +104,7 @@ msgid ""
"current configuration." "current configuration."
msgstr "" msgstr ""
msgid "Also displays hidden config variables." msgid "Also displays unset and hidden config variables."
msgstr "" msgstr ""
#, javascript-format #, javascript-format
@@ -418,7 +436,7 @@ msgid "Invalid option value: \"%s\". Possible values are: %s."
msgstr "" msgstr ""
#, javascript-format #, javascript-format
msgid "%s (%s)" msgid "%s: %s"
msgstr "" msgstr ""
msgid "Synchronisation target" msgid "Synchronisation target"

View File

@@ -46,6 +46,13 @@ msgstr "Quitter le logiciel."
msgid "Only Bash is currently supported for autocompletion." msgid "Only Bash is currently supported for autocompletion."
msgstr "" msgstr ""
msgid ""
"Autocompletion can be made to work with an alias too (such as a one-letter "
"command like \"j\").\n"
"If you would like to enable this, please type the alias now (leave it empty "
"for no alias):"
msgstr ""
#, javascript-format #, javascript-format
msgid "Created autocompletion script \"%s\"." msgid "Created autocompletion script \"%s\"."
msgstr "" msgstr ""
@@ -59,7 +66,18 @@ msgid "Added autocompletion to \"%s\"."
msgstr "" msgstr ""
#, javascript-format #, javascript-format
msgid "Sourcing \"%s\"..." msgid "Alias is already set in \"%s\"."
msgstr ""
#, javascript-format
msgid "Added alias to \"%s\"."
msgstr ""
#, javascript-format
msgid ""
"IMPORTANT: run the following command to initialise autocompletion in the "
"current shell:\n"
"source '%s'"
msgstr "" msgstr ""
#, javascript-format #, javascript-format
@@ -91,7 +109,8 @@ msgstr ""
"fournie, la valeur de [nom] est affichée. Si ni le [nom] ni la [valeur] ne " "fournie, la valeur de [nom] est affichée. Si ni le [nom] ni la [valeur] ne "
"sont fournis, la configuration complète est affichée." "sont fournis, la configuration complète est affichée."
msgid "Also displays hidden config variables." #, fuzzy
msgid "Also displays unset and hidden config variables."
msgstr "Afficher également les variables cachées." msgstr "Afficher également les variables cachées."
#, javascript-format #, javascript-format
@@ -464,9 +483,9 @@ msgstr "Impossible de déplacer la note vers le carnet \"%s\""
msgid "Invalid option value: \"%s\". Possible values are: %s." msgid "Invalid option value: \"%s\". Possible values are: %s."
msgstr "Option invalide: \"%s\". Les valeurs possibles sont : %s." msgstr "Option invalide: \"%s\". Les valeurs possibles sont : %s."
#, javascript-format #, fuzzy, javascript-format
msgid "%s (%s)" msgid "%s: %s"
msgstr "%s (%s)" msgstr "%s: %d/%d"
msgid "Synchronisation target" msgid "Synchronisation target"
msgstr "Cible de la synchronisation" msgstr "Cible de la synchronisation"
@@ -644,6 +663,9 @@ msgstr ""
msgid "Welcome" msgid "Welcome"
msgstr "Bienvenue" msgstr "Bienvenue"
#~ msgid "%s (%s)"
#~ msgstr "%s (%s)"
#~ msgid "Last error: %s (stacktrace in log)." #~ msgid "Last error: %s (stacktrace in log)."
#~ msgstr "Dernière erreur : %s (Plus d'information dans le journal d'erreurs)" #~ msgstr "Dernière erreur : %s (Plus d'information dans le journal d'erreurs)"

View File

@@ -44,6 +44,13 @@ msgstr ""
msgid "Only Bash is currently supported for autocompletion." msgid "Only Bash is currently supported for autocompletion."
msgstr "" msgstr ""
msgid ""
"Autocompletion can be made to work with an alias too (such as a one-letter "
"command like \"j\").\n"
"If you would like to enable this, please type the alias now (leave it empty "
"for no alias):"
msgstr ""
#, javascript-format #, javascript-format
msgid "Created autocompletion script \"%s\"." msgid "Created autocompletion script \"%s\"."
msgstr "" msgstr ""
@@ -57,7 +64,18 @@ msgid "Added autocompletion to \"%s\"."
msgstr "" msgstr ""
#, javascript-format #, javascript-format
msgid "Sourcing \"%s\"..." msgid "Alias is already set in \"%s\"."
msgstr ""
#, javascript-format
msgid "Added alias to \"%s\"."
msgstr ""
#, javascript-format
msgid ""
"IMPORTANT: run the following command to initialise autocompletion in the "
"current shell:\n"
"source '%s'"
msgstr "" msgstr ""
#, javascript-format #, javascript-format
@@ -86,7 +104,7 @@ msgid ""
"current configuration." "current configuration."
msgstr "" msgstr ""
msgid "Also displays hidden config variables." msgid "Also displays unset and hidden config variables."
msgstr "" msgstr ""
#, javascript-format #, javascript-format
@@ -418,7 +436,7 @@ msgid "Invalid option value: \"%s\". Possible values are: %s."
msgstr "" msgstr ""
#, javascript-format #, javascript-format
msgid "%s (%s)" msgid "%s: %s"
msgstr "" msgstr ""
msgid "Synchronisation target" msgid "Synchronisation target"

View File

@@ -7,7 +7,7 @@
"url": "https://github.com/laurent22/joplin" "url": "https://github.com/laurent22/joplin"
}, },
"url": "git://github.com/laurent22/joplin.git", "url": "git://github.com/laurent22/joplin.git",
"version": "0.9.11", "version": "0.9.16",
"bin": { "bin": {
"joplin": "./main.js" "joplin": "./main.js"
}, },
@@ -57,6 +57,7 @@
"babelbuild": "babel app -d build", "babelbuild": "babel app -d build",
"build": "babel-changed app -d build --source-maps && babel-changed app/lib/models -d build/lib/models --source-maps && babel-changed app/lib/services -d build/lib/services --source-maps", "build": "babel-changed app -d build --source-maps && babel-changed app/lib/models -d build/lib/models --source-maps && babel-changed app/lib/services -d build/lib/services --source-maps",
"clean": "babel-changed --reset", "clean": "babel-changed --reset",
"test": "babel-changed tests -d tests-build --source-maps && jasmine" "test": "babel-changed tests -d tests-build --source-maps && jasmine",
"postinstall": "joplin --autocompletion --ac-install"
} }
} }

View File

@@ -1 +1 @@
7863f7005a6fd4ec83c3b2a8df8a5f60 320eb753be882e5509e873e2b5f624e3

View File

@@ -90,8 +90,8 @@ android {
applicationId "net.cozic.joplin" applicationId "net.cozic.joplin"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 22 targetSdkVersion 22
versionCode 45 versionCode 46
versionName "0.9.32" versionName "0.9.33"
ndk { ndk {
abiFilters "armeabi-v7a", "x86" abiFilters "armeabi-v7a", "x86"
} }

View File

@@ -180,9 +180,8 @@ class NoteBodyViewer extends Component {
// the content is displayed. // the content is displayed.
setTimeout(() => { setTimeout(() => {
if (!this.isMounted_) return; if (!this.isMounted_) return;
this.setState({ webViewLoaded: true }); this.setState({ webViewLoaded: true });
}, 100); }, 200);
} }
render() { render() {

View File

@@ -195,9 +195,11 @@ class SideMenuContentComponent extends Component {
} }
if (this.props.tags.length) { if (this.props.tags.length) {
let tags = this.props.tags.slice();
tags.sort((a, b) => { return a.title < b.title ? -1 : +1; });
let tagItems = []; let tagItems = [];
for (let i = 0; i < this.props.tags.length; i++) { for (let i = 0; i < tags.length; i++) {
const tag = this.props.tags[i]; const tag = tags[i];
tagItems.push(this.tagItem(tag, this.props.selectedTagId == tag.id && this.props.notesParentType == 'Tag')); tagItems.push(this.tagItem(tag, this.props.selectedTagId == tag.id && this.props.notesParentType == 'Tag'));
} }

View File

@@ -20,27 +20,32 @@ class Setting extends BaseModel {
return output; return output;
} }
static keys() { static keys(publicOnly = false, appType = null) {
if (this.keys_) return this.keys_; if (!this.keys_) {
this.keys_ = []; this.keys_ = [];
for (let n in this.metadata_) { for (let n in this.metadata_) {
if (!this.metadata_.hasOwnProperty(n)) continue; if (!this.metadata_.hasOwnProperty(n)) continue;
this.keys_.push(n); this.keys_.push(n);
} }
return this.keys_; this.keys_.sort();
} }
static publicKeys() { if (appType || publicOnly) {
let output = []; let output = [];
for (let n in this.metadata_) { for (let i = 0; i < this.keys_.length; i++) {
if (!this.metadata_.hasOwnProperty(n)) continue; const md = this.settingMetadata(this.keys_[i]);
if (this.metadata_[n].public) output.push(n); if (publicOnly && !md.public) continue;
if (appType && md.appTypes && md.appTypes.indexOf(appType) < 0) continue;
output.push(md.key);
} }
return output; return output;
} else {
return this.keys_;
}
} }
static isPublic(key) { static isPublic(key) {
return this.publicKeys().indexOf(key) >= 0; return this.keys(true).indexOf(key) >= 0;
} }
static load() { static load() {
@@ -205,7 +210,7 @@ class Setting extends BaseModel {
let output = []; let output = [];
for (let n in options) { for (let n in options) {
if (!options.hasOwnProperty(n)) continue; if (!options.hasOwnProperty(n)) continue;
output.push(_('%s (%s)', n, options[n])); output.push(_('%s: %s', n, options[n]));
} }
return output.join(', '); return output.join(', ');
} }
@@ -330,7 +335,7 @@ Setting.metadata_ = {
})}, })},
'uncompletedTodosOnTop': { value: true, type: Setting.TYPE_BOOL, public: true, label: () => _('Show uncompleted todos on top of the lists') }, 'uncompletedTodosOnTop': { value: true, type: Setting.TYPE_BOOL, public: true, label: () => _('Show uncompleted todos on top of the lists') },
'trackLocation': { value: true, type: Setting.TYPE_BOOL, public: true, label: () => _('Save location with notes') }, 'trackLocation': { value: true, type: Setting.TYPE_BOOL, public: true, label: () => _('Save location with notes') },
'sync.interval': { value: 300, type: Setting.TYPE_INT, isEnum: true, public: true, label: () => _('Synchronisation interval'), options: () => { 'sync.interval': { value: 300, type: Setting.TYPE_INT, isEnum: true, public: true, appTypes: ['mobile'], label: () => _('Synchronisation interval'), options: () => {
return { return {
0: _('Disabled'), 0: _('Disabled'),
300: _('%d minutes', 5), 300: _('%d minutes', 5),

View File

@@ -18,7 +18,7 @@ reg.initSynchronizerStates_ = {};
reg.logger = () => { reg.logger = () => {
if (!reg.logger_) { if (!reg.logger_) {
console.warn('Calling logger before it is initialized'); //console.warn('Calling logger before it is initialized');
return new Logger(); return new Logger();
} }