sharing WIP

This commit is contained in:
zadam 2021-12-21 16:12:59 +01:00
parent 8b56fb10fd
commit e7faebfac3
10 changed files with 11396 additions and 132 deletions

View File

@ -0,0 +1 @@
UPDATE branches SET branchId = 'hidden' where parentNoteId = 'root' AND noteId = 'hidden';

11450
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -78,7 +78,7 @@
"tmp": "^0.2.1", "tmp": "^0.2.1",
"turndown": "7.1.1", "turndown": "7.1.1",
"unescape": "1.0.1", "unescape": "1.0.1",
"ws": "8.3.0", "ws": "8.4.0",
"yauzl": "2.10.0" "yauzl": "2.10.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -75,7 +75,9 @@ async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logEr
if (logErrors) { if (logErrors) {
const parent = froca.getNoteFromCache(parentNoteId); const parent = froca.getNoteFromCache(parentNoteId);
console.debug(utils.now(), `Did not find parent ${parentNoteId} (${parent ? parent.title : 'n/a'}) for child ${childNoteId} (${child.title}), available parents: ${parents.map(p => `${p.noteId} (${p.title})`)}. You can ignore this message as it is mostly harmless.`); console.debug(utils.now(), `Did not find parent ${parentNoteId} (${parent ? parent.title : 'n/a'})
for child ${childNoteId} (${child.title}), available parents: ${parents.map(p => `${p.noteId} (${p.title})`)}.
You can ignore this message as it is mostly harmless.`);
} }
const someNotePath = getSomeNotePath(child, hoistedNoteId); const someNotePath = getSomeNotePath(child, hoistedNoteId);
@ -83,6 +85,10 @@ async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logEr
if (someNotePath) { // in case it's root the path may be empty if (someNotePath) { // in case it's root the path may be empty
const pathToRoot = someNotePath.split("/").reverse().slice(1); const pathToRoot = someNotePath.split("/").reverse().slice(1);
if (!pathToRoot.includes("root")) {
pathToRoot.push('root');
}
for (const noteId of pathToRoot) { for (const noteId of pathToRoot) {
effectivePathSegments.push(noteId); effectivePathSegments.push(noteId);
} }

View File

@ -1,5 +1,4 @@
import SwitchWidget from "./switch.js"; import SwitchWidget from "./switch.js";
import froca from "../services/froca.js";
import branchService from "../services/branches.js"; import branchService from "../services/branches.js";
import server from "../services/server.js"; import server from "../services/server.js";
import utils from "../services/utils.js"; import utils from "../services/utils.js";
@ -39,7 +38,7 @@ export default class SharedSwitchWidget extends SwitchWidget {
} }
} }
await server.remove(`branches/${shareBranch.branchId}`); await server.remove(`branches/${shareBranch.branchId}?taskId=no-progress-reporting`);
} }
async refreshWithNote(note) { async refreshWithNote(note) {

View File

@ -1,3 +1,7 @@
body {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
}
#layout { #layout {
max-width: 1200px; max-width: 1200px;
margin: 0 auto; margin: 0 auto;
@ -32,7 +36,7 @@
#title { #title {
margin: 0; margin: 0;
padding: 10px 20px 0 20px; padding: 20px 20px 0 20px;
} }
#content { #content {
@ -48,40 +52,54 @@ pre {
word-wrap: anywhere; word-wrap: anywhere;
} }
#menuLink { #menuButton {
display: none;
position: fixed; position: fixed;
display: block; top: 8px;
top: 0; left: 5px;
left: 0;
width: 1.4em; width: 1.4em;
background: #000; border-radius: 5px;
background: rgba(0,0,0,0.7); border: 1px solid #aaa;
font-size: 2rem; font-size: 2rem;
z-index: 10; z-index: 10;
height: auto; height: auto;
color: white; color: black;
border: none;
cursor: pointer; cursor: pointer;
} }
#menuButton::after {
position: relative;
top: -2px;
left: 1px;
}
@media (max-width: 48em) { @media (max-width: 48em) {
#layout.active #menu { #layout.active #menu {
display: block; display: block;
margin-top: 40px;
}
#menuButton {
display: block;
} }
#layout.active #main { #layout.active #main {
display: none; display: none;
} }
#layout.active #menuLink::after { #title {
padding-left: 60px;
}
#layout.active #menuButton::after {
content: "«"; content: "«";
} }
#menuButton::after {
content: "»";
}
#menu { #menu {
display: none; display: none;
} }
#menuLink::after {
content: "»";
}
} }

View File

@ -4,7 +4,7 @@ const build = require('./build');
const packageJson = require('../../package'); const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir'); const {TRILIUM_DATA_DIR} = require('./data_dir');
const APP_DB_VERSION = 187; const APP_DB_VERSION = 188;
const SYNC_VERSION = 23; const SYNC_VERSION = 23;
const CLIPPER_PROTOCOL_VERSION = "1.0"; const CLIPPER_PROTOCOL_VERSION = "1.0";

View File

@ -94,7 +94,7 @@ async function createInitialDatabase(username, password, theme) {
log.info("Importing demo content ..."); log.info("Importing demo content ...");
const dummyTaskContext = new TaskContext("initial-demo-import", 'import', false); const dummyTaskContext = new TaskContext("no-progress-reporting", 'import', false);
const zipImportService = require("./import/zip"); const zipImportService = require("./import/zip");
await zipImportService.importZip(dummyTaskContext, demoFile, rootNote); await zipImportService.importZip(dummyTaskContext, demoFile, rootNote);

View File

@ -34,7 +34,7 @@ class TaskContext {
increaseProgressCount() { increaseProgressCount() {
this.progressCount++; this.progressCount++;
if (Date.now() - this.lastSentCountTs >= 300 && this.taskId !== 'initial-demo-import') { if (Date.now() - this.lastSentCountTs >= 300 && this.taskId !== 'no-progress-reporting') {
this.lastSentCountTs = Date.now(); this.lastSentCountTs = Date.now();
ws.sendMessageToAllClients({ ws.sendMessageToAllClients({

View File

@ -12,11 +12,13 @@
</head> </head>
<body> <body>
<div id="layout"> <div id="layout">
<button id="menuLink"></button> <% if (subRoot.hasChildren()) { %>
<button id="menuButton"></button>
<div id="menu"> <div id="menu">
<%- include('share-tree-item', {note: subRoot, activeNote: note}) %> <%- include('share-tree-item', {note: subRoot, activeNote: note}) %>
</div> </div>
<% } %>
<div id="main"> <div id="main">
<h1 id="title"><%= note.title %></h1> <h1 id="title"><%= note.title %></h1>
@ -36,7 +38,7 @@
return { return {
layout: document.getElementById('layout'), layout: document.getElementById('layout'),
menu: document.getElementById('menu'), menu: document.getElementById('menu'),
menuLink: document.getElementById('menuLink') menuButton: document.getElementById('menuButton')
}; };
} }
@ -65,13 +67,13 @@
toggleClass(elements.layout, active); toggleClass(elements.layout, active);
toggleClass(elements.menu, active); toggleClass(elements.menu, active);
toggleClass(elements.menuLink, active); toggleClass(elements.menuButton, active);
} }
function handleEvent(e) { function handleEvent(e) {
var elements = getElements(); var elements = getElements();
if (e.target.id === elements.menuLink.id) { if (e.target.id === elements.menuButton.id) {
toggleAll(); toggleAll();
e.preventDefault(); e.preventDefault();
} else if (elements.menu.className.indexOf('active') !== -1) { } else if (elements.menu.className.indexOf('active') !== -1) {