1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Added demo and improved parsing of markdown URLs

This commit is contained in:
Laurent Cozic 2017-10-28 00:20:03 +01:00
parent e4435a4fb6
commit aefeca66d5
12 changed files with 2176 additions and 20 deletions

3
.gitignore vendored
View File

@ -32,4 +32,5 @@ INFO.md
sync_staging.sh
*.swp
_vieux/
README.md
README.md
_mydocs

View File

@ -347,9 +347,9 @@ class AppGui {
description: null,
action: () => {
const w = this.widget('mainWindow').focusedWidget;
if (w.name == 'folderList') {
if (w.name === 'folderList') {
this.widget('noteList').focus();
} else if (w.name == 'noteList') {
} else if (w.name === 'noteList' || w.name === 'noteText') {
this.processCommand('edit $n');
}
},
@ -612,6 +612,15 @@ class AppGui {
const resourceIdRegex = /^:\/[a-f0-9]+$/i
const noteLinks = {};
const hasProtocol = function(s, protocols) {
if (!s) return false;
s = s.trim().toLowerCase();
for (let i = 0; i < protocols.length; i++) {
if (s.indexOf(protocols[i] + '://') === 0) return true;
}
return false;
}
// By default, before the server is started, only the regular
// URLs appear in blue.
noteTextWidget.markdownRendererOptions = {
@ -620,7 +629,7 @@ class AppGui {
if (resourceIdRegex.test(url)) {
return url;
} else if (url.indexOf('http://') === 0 || url.indexOf('https://') === 0) {
} else if (hasProtocol(url, ['http', 'https'])) {
return linkStyle(url);
} else {
return url;
@ -662,11 +671,15 @@ class AppGui {
type: 'resource',
id: url.substr(2),
};
} else {
} else if (hasProtocol(url, ['http', 'https', 'file', 'ftp'])) {
noteLinks[index] = {
type: 'url',
url: url,
};
} else if (url.indexOf('#') === 0) {
return ''; // Anchors aren't supported for now
} else {
return url;
}
return linkStyle(this.resourceServer_.baseUrl() + '/' + index);

View File

@ -33,18 +33,6 @@ class Command extends BaseCommand {
} else {
await Note.save(newItem);
}
// const folder = await Folder.loadByField('title', destination);
// if (!folder) throw new Error(_('Cannot find "%s".', destination));
// const notes = await app().loadItems(BaseModel.TYPE_NOTE, pattern);
// if (!notes.length) throw new Error(_('Cannot find "%s".', pattern));
// for (let i = 0; i < notes.length; i++) {
// await Note.moveToFolder(notes[i].id, folder.id);
// }
}
}

View File

@ -1,6 +1,6 @@
{
"name": "joplin",
"version": "0.10.57",
"version": "0.10.58",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -18,7 +18,7 @@
],
"owner": "Laurent Cozic"
},
"version": "0.10.57",
"version": "0.10.58",
"bin": {
"joplin": "./main.js"
},

View File

@ -3,4 +3,4 @@ set -e
CLIENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes2 --stack-trace-enabled --log-level debug --env dev "$@"
#bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --stack-trace-enabled --log-level debug "$@"
#bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --stack-trace-enabled --log-level debug "$@"

1
CliClientDemo/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

Binary file not shown.

31
CliClientDemo/index.js Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env node
'use strict';
const spawn = require('child_process').spawn;
const os = require('os');
const fs = require('fs-extra');
const joplinPath = __dirname + '/node_modules/.bin/joplin';
const profileDir = os.homedir() + '/.config/demo-joplin';
const dbFilename = 'database.sqlite';
fs.ensureDirSync(profileDir);
if (!fs.pathExistsSync(profileDir + '/' + dbFilename)) {
fs.copySync(__dirname + '/' + dbFilename, profileDir + '/' + dbFilename);
}
const opt = {
cwd: __dirname,
env: (function() {
process.env.NODE_PATH = '.';
return process.env;
}()),
stdio: [process.stdin, process.stdout, process.stderr]
};
const app = spawn(joplinPath, ['--profile', profileDir], opt);
app.on('close', (code) => {
process.exit(code);
});

2085
CliClientDemo/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
{
"name": "demo-joplin",
"version": "1.0.3",
"description": "Demo for Joplin CLI",
"bin": {
"demo-joplin": "./index.js"
},
"bugs": {
"url": "https://github.com/laurent22/joplin/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/laurent22/joplin"
},
"engines": {
"node": ">=8.7.0"
},
"copyright": {
"title": "Joplin CLI",
"years": [
2016,
2017
],
"owner": "Laurent Cozic"
},
"dependencies": {
"fs-extra": "^4.0.2",
"joplin": "^0.10.58"
},
"author": "Laurent Cozic",
"license": "MIT"
}

5
CliClientDemo/publish.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
npm version patch
npm publish