mirror of https://github.com/TriliumNext/Notes
Merge branch 'master' into ckeditor
commit
7ca043ebc6
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
sqlite3 ~/trilium-data/document.db .schema > schema.sql
|
||||
@ -0,0 +1 @@
|
||||
UPDATE options SET opt_name = 'start_note_path' WHERE opt_name = 'start_note_tree_id';
|
||||
@ -0,0 +1,34 @@
|
||||
$("#setup-form").submit(() => {
|
||||
const username = $("#username").val();
|
||||
const password1 = $("#password1").val();
|
||||
const password2 = $("#password2").val();
|
||||
|
||||
if (!username) {
|
||||
showAlert("Username can't be empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!password1) {
|
||||
showAlert("Password can't be empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (password1 !== password2) {
|
||||
showAlert("Both password fields need be identical.");
|
||||
return false;
|
||||
}
|
||||
|
||||
server.post('setup', {
|
||||
username: username,
|
||||
password: password1
|
||||
}).then(() => {
|
||||
window.location.replace("/");
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
function showAlert(message) {
|
||||
$("#alert").html(message);
|
||||
$("#alert").show();
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const auth = require('../../services/auth');
|
||||
const options = require('../../services/options');
|
||||
const sql = require('../../services/sql');
|
||||
const utils = require('../../services/utils');
|
||||
const my_scrypt = require('../../services/my_scrypt');
|
||||
const password_encryption = require('../../services/password_encryption');
|
||||
|
||||
router.post('', auth.checkAppNotInitialized, async (req, res, next) => {
|
||||
const { username, password } = req.body;
|
||||
|
||||
await sql.doInTransaction(async () => {
|
||||
await options.setOption('username', username);
|
||||
|
||||
await options.setOption('password_verification_salt', utils.randomSecureToken(32));
|
||||
await options.setOption('password_derived_key_salt', utils.randomSecureToken(32));
|
||||
|
||||
const passwordVerificationKey = utils.toBase64(await my_scrypt.getVerificationHash(password));
|
||||
await options.setOption('password_verification_hash', passwordVerificationKey);
|
||||
|
||||
await password_encryption.setDataKey(password, utils.randomSecureToken(16));
|
||||
});
|
||||
|
||||
sql.setDbReadyAsResolved();
|
||||
|
||||
res.send({});
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const auth = require('../services/auth');
|
||||
|
||||
router.get('', auth.checkAppNotInitialized, (req, res, next) => {
|
||||
res.render('setup', {});
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@ -0,0 +1,92 @@
|
||||
CREATE TABLE `migrations` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`version` INTEGER NOT NULL,
|
||||
`success` INTEGER NOT NULL,
|
||||
`error` TEXT
|
||||
);
|
||||
CREATE TABLE `sync` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`entity_name` TEXT NOT NULL,
|
||||
`entity_id` TEXT NOT NULL,
|
||||
`sync_date` INTEGER NOT NULL
|
||||
, source_id TEXT);
|
||||
CREATE UNIQUE INDEX `IDX_sync_entity_name_id` ON `sync` (
|
||||
`entity_name`,
|
||||
`entity_id`
|
||||
);
|
||||
CREATE INDEX `IDX_sync_sync_date` ON `sync` (
|
||||
`sync_date`
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS "options" (
|
||||
`opt_name` TEXT NOT NULL PRIMARY KEY,
|
||||
`opt_value` TEXT,
|
||||
`date_modified` INT
|
||||
);
|
||||
CREATE TABLE `event_log` (
|
||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`note_id` TEXT,
|
||||
`comment` TEXT,
|
||||
`date_added` INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX `IDX_event_log_date_added` ON `event_log` (
|
||||
`date_added`
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS "notes" (
|
||||
`note_id` TEXT NOT NULL,
|
||||
`note_title` TEXT,
|
||||
`note_text` TEXT,
|
||||
`date_created` INT,
|
||||
`date_modified` INT,
|
||||
`is_protected` INT NOT NULL DEFAULT 0,
|
||||
`is_deleted` INT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(`note_id`)
|
||||
);
|
||||
CREATE INDEX `IDX_notes_is_deleted` ON `notes` (
|
||||
`is_deleted`
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS "notes_history" (
|
||||
`note_history_id` TEXT NOT NULL PRIMARY KEY,
|
||||
`note_id` TEXT NOT NULL,
|
||||
`note_title` TEXT,
|
||||
`note_text` TEXT,
|
||||
`is_protected` INT,
|
||||
`date_modified_from` INT,
|
||||
`date_modified_to` INT
|
||||
);
|
||||
CREATE INDEX `IDX_notes_history_note_id` ON `notes_history` (
|
||||
`note_id`
|
||||
);
|
||||
CREATE INDEX `IDX_notes_history_note_date_modified_from` ON `notes_history` (
|
||||
`date_modified_from`
|
||||
);
|
||||
CREATE INDEX `IDX_notes_history_note_date_modified_to` ON `notes_history` (
|
||||
`date_modified_to`
|
||||
);
|
||||
CREATE TABLE `source_ids` (
|
||||
`source_id` TEXT NOT NULL,
|
||||
`date_created` INTEGER NOT NULL,
|
||||
PRIMARY KEY(`source_id`)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS "notes_tree" (
|
||||
[note_tree_id] VARCHAR(30) PRIMARY KEY NOT NULL,
|
||||
[note_id] VARCHAR(30) NOT NULL,
|
||||
[note_pid] VARCHAR(30) NOT NULL,
|
||||
[note_pos] INTEGER NOT NULL,
|
||||
[is_expanded] BOOLEAN NULL ,
|
||||
date_modified INTEGER NOT NULL DEFAULT 0,
|
||||
is_deleted INTEGER NOT NULL DEFAULT 0
|
||||
, `prefix` TEXT);
|
||||
CREATE INDEX `IDX_notes_tree_note_tree_id` ON `notes_tree` (
|
||||
`note_tree_id`
|
||||
);
|
||||
CREATE INDEX `IDX_notes_tree_note_id_note_pid` ON `notes_tree` (
|
||||
`note_id`,
|
||||
`note_pid`
|
||||
);
|
||||
CREATE TABLE `recent_notes` (
|
||||
'note_tree_id'TEXT NOT NULL PRIMARY KEY,
|
||||
`note_path` TEXT NOT NULL,
|
||||
`date_accessed` INTEGER NOT NULL ,
|
||||
is_deleted INT
|
||||
);
|
||||
@ -1 +1 @@
|
||||
module.exports = { build_date:"2017-11-30T00:11:04-05:00", build_revision: "719f5530544efa1d7aae16afd8a9e64db04ff206" };
|
||||
module.exports = { build_date:"2017-12-06T21:44:45-05:00", build_revision: "4f47c4d6e919aefd303617ac459cea41a1761385" };
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Setup</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="width: 500px; margin: auto;">
|
||||
<h1>Trilium setup</h1>
|
||||
|
||||
<div class="alert alert-warning" id="alert" style="display: none;">
|
||||
</div>
|
||||
|
||||
<form id="setup-form">
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" class="form-control" id="username" placeholder="Arbitrary string">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password1">Password</label>
|
||||
<input type="password" class="form-control" id="password1" placeholder="Password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password2">Repeat password</label>
|
||||
<input type="password" class="form-control" id="password2" placeholder="Password">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-default">Save</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
const baseApiUrl = 'api/';
|
||||
</script>
|
||||
|
||||
<!-- Required for correct loading of scripts in Electron -->
|
||||
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
|
||||
|
||||
<script src="libraries/jquery.min.js"></script>
|
||||
|
||||
<link href="libraries/bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||
<script src="libraries/bootstrap/js/bootstrap.js"></script>
|
||||
|
||||
<script src="javascripts/setup.js"></script>
|
||||
<script src="javascripts/utils.js"></script>
|
||||
<script src="javascripts/server.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue