mirror of https://github.com/logseq/logseq
Merge branch 'master' into fix-IOS-bottom-fixed-position
commit
43740a8e58
36
LICENSE.md
36
LICENSE.md
|
@ -659,3 +659,39 @@ You should also get your employer (if you work as a programmer) or school,
|
|||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permission under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or combining it with any of the below libraries (or a modified version of that library), containing parts covered by the terms of any of the below libraries, the licensors of this Program grant you additional permission to convey the resulting work.
|
||||
|
||||
* cider/cider-nrepl
|
||||
* clojure-complete
|
||||
* com.cemerick/friend
|
||||
* compojure
|
||||
* environ
|
||||
* hiccup
|
||||
* medley
|
||||
* org.clojure/clojure
|
||||
* org.clojure/clojurescript
|
||||
* org.clojure/core.async
|
||||
* org.clojure/core.cache
|
||||
* org.clojure/core.incubator
|
||||
* org.clojure/core.logic
|
||||
* org.clojure/core.match
|
||||
* org.clojure/core.memoize
|
||||
* org.clojure/data.csv
|
||||
* org.clojure/data.json
|
||||
* org.clojure/data.priority-map
|
||||
* org.clojure/java.classpath
|
||||
* org.clojure/java.jdbc
|
||||
* org.clojure/math.numeric-tower
|
||||
* org.clojure/tools.analyzer
|
||||
* org.clojure/tools.analyzer.jvm
|
||||
* org.clojure/tools.logging
|
||||
* org.clojure/tools.macro
|
||||
* org.clojure/tools.namespace
|
||||
* org.clojure/tools.nrepl
|
||||
* org.clojure/tools.reader
|
||||
* org.tcrawley/dynapath
|
||||
* refactor-nrepl
|
||||
* slingshot
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
.dark-theme {
|
||||
--ls-primary-background-color: #002b36;
|
||||
--ls-secondary-background-color: #073642;
|
||||
--ls-tertiary-background-color: var(--ls-secondary-background-color);
|
||||
--ls-tertiary-background-color: #0f4552;
|
||||
--ls-block-properties-background-color: #02222a;
|
||||
--ls-search-background-color: var(--ls-primary-background-color);
|
||||
--ls-border-color: #0e5263;
|
||||
|
@ -32,7 +32,7 @@
|
|||
--ls-page-checkbox-color: #6093a0;
|
||||
--ls-page-checkbox-border-color: var(--ls-primary-background-color);
|
||||
--ls-page-blockquote-color: var(--ls-primary-text-color);
|
||||
--ls-page-blockquote-bg-color: var(--ls-tertiary-background-color);
|
||||
--ls-page-blockquote-bg-color: var(--ls-secondary-background-color);
|
||||
--ls-page-blockquote-border-color: var(--ls-secondary-text-color);
|
||||
--ls-page-inline-code-color: var(--ls-primary-text-color);
|
||||
--ls-page-inline-code-bg-color: #01222a;
|
||||
|
@ -510,7 +510,7 @@ a.nav-item:hover, a.star-page:hover {
|
|||
|
||||
.bg-base-2 {
|
||||
background-color: #f0f8ff;
|
||||
background-color: var(--ls-tertiary-background-color);
|
||||
background-color: var(--ls-secondary-background-color);
|
||||
}
|
||||
|
||||
a.menu-link:hover, button.pull:hover, button.menu:focus {
|
||||
|
@ -548,7 +548,7 @@ button.menu {
|
|||
.form-checkbox {
|
||||
color: #137cbd;
|
||||
color: var(--ls-page-checkbox-color);
|
||||
background-color: none;
|
||||
background-color: transparent;
|
||||
background-color: var(--ls-page-checkbox-color);
|
||||
border: 1px solid;
|
||||
border-color: #808080;
|
||||
|
@ -570,7 +570,7 @@ input {
|
|||
/* } */
|
||||
|
||||
.form-select {
|
||||
background-color: none;
|
||||
background-color: transparent;
|
||||
background-color: var(--ls-primary-background-color);
|
||||
background-repeat: no-repeat;
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3e%3cpath d='M7 7l3-3 3 3m0 6l-3 3-3-3' stroke='%239fa6b2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
|
||||
|
@ -643,10 +643,6 @@ hr {
|
|||
}
|
||||
|
||||
a.button {
|
||||
-webkit-appearance: button;
|
||||
-moz-appearance: button;
|
||||
appearance: button;
|
||||
|
||||
text-decoration: none;
|
||||
color: #FFF;
|
||||
display: inline;
|
||||
|
@ -885,19 +881,19 @@ iframe {
|
|||
padding: 0;
|
||||
overflow: hidden;
|
||||
|
||||
.embed-responsive-item,
|
||||
iframe,
|
||||
embed,
|
||||
object,
|
||||
video {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
}
|
||||
.embed-responsive-item,
|
||||
iframe,
|
||||
embed,
|
||||
object,
|
||||
video {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1409,8 +1405,9 @@ a.tag:hover {
|
|||
border-color: var(--ls-page-checkbox-border-color);
|
||||
}
|
||||
|
||||
.dark-theme #right-sidebar .bg-base-2 {
|
||||
background-color: #0f4552;
|
||||
#right-sidebar .bg-base-2,
|
||||
#right-sidebar blockquote {
|
||||
background-color: var(--ls-tertiary-background-color);
|
||||
}
|
||||
|
||||
.white-theme a.right-sidebar-button {
|
||||
|
@ -1450,3 +1447,14 @@ a.tag:hover {
|
|||
}
|
||||
|
||||
/* endregion */
|
||||
|
||||
/* Hide scrollbar for IE, Edge and Firefox */
|
||||
.hide-scrollbar {
|
||||
-ms-overflow-style: none; /* IE and Edge */
|
||||
scrollbar-width: none; /* Firefox */
|
||||
}
|
||||
|
||||
/* Hide scrollbar for Chrome, Safari and Opera */
|
||||
.hide-scrollbar::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html><head><meta charset="utf-8"><meta content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no" name="viewport"><meta content="Agp2znmEoRKqxMhzbNL2R3UOCNcagP7+fu0KSM+09O21u7EHdJgqhTrslpfyFC/dSt6jvpaDzNiFf2769fLHMAUAAABoeyJvcmlnaW4iOiJodHRwczovL2xvZ3NlcS5jb206NDQzIiwiZmVhdHVyZSI6Ik5hdGl2ZUZpbGVTeXN0ZW0yIiwiZXhwaXJ5IjoxNTk3Mjg5MzY5LCJpc1N1YmRvbWFpbiI6dHJ1ZX0=" http-equiv="origin-trial"><link href="https://asset.logseq.com/static/style.css" rel="stylesheet" type="text/css"><link href="https://asset.logseq.com/static/img/logo.png" rel="shortcut icon" type="image/png"><link href="https://asset.logseq.com/static/img/logo.png" rel="shortcut icon" sizes="192x192"><link href="https://asset.logseq.com/static/img/logo.png" rel="apple-touch-icon"><meta content="summary" name="twitter:card"><meta content="A local-first notes app which uses Git to store and sync your knowledge." name="twitter:description"><meta content="@logseq" name="twitter:site"><meta content="A local-first notes app." name="twitter:title"><meta content="https://asset.logseq.com/static/img/logo.png" name="twitter:image:src"><meta content="A local-first notes app." name="twitter:image:alt"><meta content="A local-first notes app." property="og:title"><meta content="site" property="og:type"><meta content="https://logseq.com" property="og:url"><meta content="https://asset.logseq.com/static/img/logo.png" property="og:image"><meta content="A local-first notes app which uses Git to store and sync your knowledge." property="og:description"><title>Logseq: A local-first notes app</title><meta content="logseq" property="og:site_name"><meta description="A local-first notes app which uses Git to store and sync your knowledge."><script crossorigin="anonymous" defer onload="if (window.location.host != 'localhost:3000') {
|
||||
Sentry.init({dsn: 'https://636e9174ffa148c98d2b9d3369661683@o416451.ingest.sentry.io/5311485'});
|
||||
};" src="https://asset.logseq.com/static/js/sentry.min.js"></script></head><body><div id="root"></div><script>window.user={"name":"tiensonqin","email":"tiensonqin@gmail.com","avatar":"https://avatars3.githubusercontent.com/u/479169?v=4","repos":[{"id":"bc80efff-1420-4eb7-9e07-9506b8d9bbe0","url":"https://github.com/tiensonqin/notes"}],"preferred_format":"org","encrypt_object_key":"snRsaP8r9VG6KsXxu0IfDA"};</script><script src="https://asset.logseq.com/static/js/mldoc.min.js"></script><script src="https://asset.logseq.com/static/js/magic_portal.js"></script><script>let worker = new Worker("/static/js/worker.js");
|
||||
};" src="https://asset.logseq.com/static/js/sentry.min.js"></script></head><body><div id="root"></div><script>window.user={"name":"tiensonqin","email":"tiensonqin@gmail.com","avatar":"https://avatars3.githubusercontent.com/u/479169?v=4","repos":[{"id":"bc80efff-1420-4eb7-9e07-9506b8d9bbe0","url":"https://github.com/tiensonqin/notes"}],"preferred_format":"org","encrypt_object_key":"snRsaP8r9VG6KsXxu0IfDA"};</script><script src="https://asset.logseq.com/static/js/mldoc.min.js"></script><script src="/js/magic_portal.js"></script><script>let worker = new Worker("/js/worker.js");
|
||||
const portal = new MagicPortal(worker);
|
||||
;(async () => {
|
||||
const git = await portal.get('git');
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,2 +0,0 @@
|
|||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.MagicPortal=t()}(this,function(){var e=function(e){var t=this;this.rpc_counter=0,this.channel=e,this.foreign=new Map,this.local=new Map,this.calls=new Map,this.queue=[],this.connectionEstablished=!1,this.channel.addEventListener("message",function(e){var n=e.data;if(n&&"object"==typeof n)switch(n.type){case"MP_INIT":return t.onInit(n);case"MP_SET":return t.onSet(n);case"MP_CALL":return t.onCall(n);case"MP_RETURN":return t.onReturn(n)}}),this.channel.postMessage({type:"MP_INIT",id:1,reply:!0})};e.prototype.onInit=function(e){this.connectionEstablished=!0;var t=this.queue;this.queue=[];for(var n=0,o=t;n<o.length;n+=1){this.channel.postMessage(o[n])}e.reply&&this.channel.postMessage({type:"MP_INIT",reply:!1})},e.prototype.onSet=function(e){for(var t=this,n={},o=e.object,i=function(){var i=r[s],c=!e.void.includes(i);n[i]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return t.rpc_counter=(t.rpc_counter+1)%Number.MAX_SAFE_INTEGER,new Promise(function(n,s){t.postMessage({type:"MP_CALL",object:o,method:i,id:t.rpc_counter,args:e,reply:c}),c?t.calls.set(t.rpc_counter,{resolve:n,reject:s}):n()})}},s=0,r=e.methods;s<r.length;s+=1)i();var c=this.foreign.get(e.object);this.foreign.set(e.object,n),"function"==typeof c&&c(n)},e.prototype.onCall=function(e){var t=this,n=this.local.get(e.object);n&&n[e.method].apply(n,e.args).then(function(n){return e.reply&&t.channel.postMessage({type:"MP_RETURN",id:e.id,result:n})}).catch(function(n){return t.channel.postMessage({type:"MP_RETURN",id:e.id,error:n.message})})},e.prototype.onReturn=function(e){if(this.calls.has(e.id)){var t=this.calls.get(e.id),n=t.resolve,o=t.reject;this.calls.delete(e.id),e.error?o(e.error):n(e.result)}},e.prototype.postMessage=function(e){this.connectionEstablished?this.channel.postMessage(e):this.queue.push(e)},e.prototype.set=function(e,t,n){void 0===n&&(n={}),this.local.set(e,t);var o=Object.entries(t).filter(function(e){return"function"==typeof e[1]}).map(function(e){return e[0]});this.postMessage({type:"MP_SET",object:e,methods:o,void:n.void||[]})},e.prototype.get=function(e){return new Promise(function(t,n){var o=this;return this.foreign.has(e)?t(this.foreign.get(e)):t(new Promise(function(t,n){return o.foreign.set(e,t)}))}.bind(this))};return function(t){var n=new e(t);Object.defineProperties(this,{get:{writable:!1,configurable:!1,value:n.get.bind(n)},set:{writable:!1,configurable:!1,value:n.set.bind(n)}})}});
|
||||
//# sourceMappingURL=index.umd.js.map
|
|
@ -1,303 +0,0 @@
|
|||
importScripts(
|
||||
// Batched optimization
|
||||
"/static/js/lightning-fs.min.js?v=0.0.2.3",
|
||||
"https://cdn.jsdelivr.net/npm/isomorphic-git@1.7.4/index.umd.min.js",
|
||||
"https://cdn.jsdelivr.net/npm/isomorphic-git@1.7.4/http/web/index.umd.js",
|
||||
// Fixed a bug
|
||||
"/static/js/magic_portal.js"
|
||||
);
|
||||
|
||||
const detect = () => {
|
||||
if (typeof window !== 'undefined' && !self.skipWaiting) {
|
||||
return 'window'
|
||||
} else if (typeof self !== 'undefined' && !self.skipWaiting) {
|
||||
return 'Worker'
|
||||
} else if (typeof self !== 'undefined' && self.skipWaiting) {
|
||||
return 'ServiceWorker'
|
||||
}
|
||||
};
|
||||
|
||||
function basicAuth (username, token) {
|
||||
return "Basic " + btoa("tiensonqin:" + token);
|
||||
}
|
||||
|
||||
const fsName = 'logseq';
|
||||
const createFS = () => new LightningFS(fsName);
|
||||
let fs = createFS();
|
||||
let pfs = fs.promises;
|
||||
|
||||
if (detect() === 'Worker') {
|
||||
const portal = new MagicPortal(self);
|
||||
portal.set('git', git);
|
||||
portal.set('fs', fs);
|
||||
portal.set('pfs', pfs);
|
||||
portal.set('gitHttp', GitHttp);
|
||||
portal.set('workerThread', {
|
||||
setConfig: function (dir, path, value) {
|
||||
return git.setConfig ({
|
||||
fs,
|
||||
dir,
|
||||
path,
|
||||
value
|
||||
});
|
||||
},
|
||||
clone: function (dir, url, corsProxy, depth, branch, username, token) {
|
||||
return git.clone ({
|
||||
fs,
|
||||
dir,
|
||||
http: GitHttp,
|
||||
url,
|
||||
corsProxy,
|
||||
ref: branch,
|
||||
singleBranch: true,
|
||||
depth,
|
||||
headers: {
|
||||
"Authorization": basicAuth(username, token)
|
||||
}
|
||||
});
|
||||
},
|
||||
fetch: function (dir, url, corsProxy, depth, branch, username, token) {
|
||||
return git.fetch ({
|
||||
fs,
|
||||
dir,
|
||||
http: GitHttp,
|
||||
url,
|
||||
corsProxy,
|
||||
ref: branch,
|
||||
singleBranch: true,
|
||||
depth,
|
||||
headers: {
|
||||
"Authorization": basicAuth(username, token)
|
||||
}
|
||||
});
|
||||
},
|
||||
pull: function (dir, corsProxy, branch, username, token) {
|
||||
return git.pull ({
|
||||
fs,
|
||||
dir,
|
||||
http: GitHttp,
|
||||
corsProxy,
|
||||
ref: branch,
|
||||
singleBranch: true,
|
||||
// fast: true,
|
||||
headers: {
|
||||
"Authorization": basicAuth(username, token)
|
||||
}
|
||||
});
|
||||
},
|
||||
push: function (dir, corsProxy, branch, force, username, token) {
|
||||
return git.push ({
|
||||
fs,
|
||||
dir,
|
||||
http: GitHttp,
|
||||
ref: branch,
|
||||
corsProxy,
|
||||
remote: "origin",
|
||||
force,
|
||||
headers: {
|
||||
"Authorization": basicAuth(username, token)
|
||||
}
|
||||
});
|
||||
},
|
||||
merge: function (dir, branch) {
|
||||
return git.merge ({
|
||||
fs,
|
||||
dir,
|
||||
ours: branch,
|
||||
theirs: "remotes/origin/" + branch,
|
||||
// fastForwardOnly: true
|
||||
});
|
||||
},
|
||||
checkout: function (dir, branch) {
|
||||
return git.checkout ({
|
||||
fs,
|
||||
dir,
|
||||
ref: branch,
|
||||
});
|
||||
},
|
||||
log: function (dir, branch, depth) {
|
||||
return git.log ({
|
||||
fs,
|
||||
dir,
|
||||
ref: branch,
|
||||
depth,
|
||||
singleBranch: true
|
||||
})
|
||||
},
|
||||
add: function (dir, file) {
|
||||
return git.add ({
|
||||
fs,
|
||||
dir,
|
||||
filepath: file
|
||||
});
|
||||
},
|
||||
remove: function (dir, file) {
|
||||
return git.remove ({
|
||||
fs,
|
||||
dir,
|
||||
filepath: file
|
||||
});
|
||||
},
|
||||
commit: function (dir, message, name, email, parent) {
|
||||
if (parent) {
|
||||
return git.commit ({
|
||||
fs,
|
||||
dir,
|
||||
message,
|
||||
author: {name: name,
|
||||
email: email},
|
||||
parent: parent
|
||||
});
|
||||
} else {
|
||||
return git.commit ({
|
||||
fs,
|
||||
dir,
|
||||
message,
|
||||
author: {name: name,
|
||||
email: email}
|
||||
});
|
||||
}
|
||||
},
|
||||
readCommit: function (dir, oid) {
|
||||
return git.readCommit ({
|
||||
fs,
|
||||
dir,
|
||||
oid
|
||||
});
|
||||
},
|
||||
readBlob: function (dir, oid, path) {
|
||||
return git.readBlob ({
|
||||
fs,
|
||||
dir,
|
||||
oid,
|
||||
path
|
||||
});
|
||||
},
|
||||
writeRef: function (dir, branch, oid) {
|
||||
return git.writeRef ({
|
||||
fs,
|
||||
dir,
|
||||
ref: "refs/heads/" + branch,
|
||||
value: oid,
|
||||
force: true
|
||||
});
|
||||
},
|
||||
resolveRef: function (dir, ref) {
|
||||
return git.resolveRef ({
|
||||
fs,
|
||||
dir,
|
||||
ref
|
||||
});
|
||||
},
|
||||
listFiles: function (dir, branch) {
|
||||
return git.listFiles ({
|
||||
fs,
|
||||
dir,
|
||||
ref: branch
|
||||
});
|
||||
},
|
||||
rimraf: async function (path) {
|
||||
// try {
|
||||
// // First assume path is itself a file
|
||||
// await pfs.unlink(path)
|
||||
// // if that worked we're done
|
||||
// return
|
||||
// } catch (err) {
|
||||
// // Otherwise, path must be a directory
|
||||
// if (err.code !== 'EISDIR') throw err
|
||||
// }
|
||||
// Knowing path is a directory,
|
||||
// first, assume everything inside path is a file.
|
||||
let files = await pfs.readdir(path);
|
||||
for (let file of files) {
|
||||
let child = path + '/' + file
|
||||
try {
|
||||
await pfs.unlink(child)
|
||||
} catch (err) {
|
||||
if (err.code !== 'EISDIR') throw err
|
||||
}
|
||||
}
|
||||
// Assume what's left are directories and recurse.
|
||||
let dirs = await pfs.readdir(path)
|
||||
for (let dir of dirs) {
|
||||
let child = path + '/' + dir
|
||||
await rimraf(child, pfs)
|
||||
}
|
||||
// Finally, delete the empty directory
|
||||
await pfs.rmdir(path)
|
||||
},
|
||||
getFileStateChanges: async function (commitHash1, commitHash2, dir) {
|
||||
return git.walk({
|
||||
fs,
|
||||
dir,
|
||||
trees: [git.TREE({ ref: commitHash1 }), git.TREE({ ref: commitHash2 })],
|
||||
map: async function(filepath, [A, B]) {
|
||||
var type = 'equal';
|
||||
if (A === null) {
|
||||
type = "add";
|
||||
}
|
||||
|
||||
if (B === null) {
|
||||
type = "remove";
|
||||
}
|
||||
|
||||
// ignore directories
|
||||
if (filepath === '.') {
|
||||
return
|
||||
}
|
||||
if ((A !== null && (await A.type()) === 'tree')
|
||||
||
|
||||
(B !== null && (await B.type()) === 'tree')) {
|
||||
return
|
||||
}
|
||||
|
||||
// generate ids
|
||||
const Aoid = A !== null && await A.oid();
|
||||
const Boid = B !== null && await B.oid();
|
||||
|
||||
if (type === "equal") {
|
||||
// determine modification type
|
||||
if (Aoid !== Boid) {
|
||||
type = 'modify'
|
||||
}
|
||||
if (Aoid === undefined) {
|
||||
type = 'add'
|
||||
}
|
||||
if (Boid === undefined) {
|
||||
type = 'remove'
|
||||
}
|
||||
}
|
||||
|
||||
if (Aoid === undefined && Boid === undefined) {
|
||||
console.log('Something weird happened:')
|
||||
console.log(A)
|
||||
console.log(B)
|
||||
}
|
||||
|
||||
return {
|
||||
path: `/${filepath}`,
|
||||
type: type,
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
statusMatrix: async function (dir) {
|
||||
await git.statusMatrix({ fs, dir });
|
||||
},
|
||||
getChangedFiles: async function (dir) {
|
||||
try {
|
||||
const FILE = 0, HEAD = 1, WORKDIR = 2;
|
||||
|
||||
let filenames = (await git.statusMatrix({ fs, dir }))
|
||||
.filter(row => row[HEAD] !== row[WORKDIR])
|
||||
.map(row => row[FILE]);
|
||||
|
||||
return filenames;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
});
|
||||
// self.addEventListener("message", ({ data }) => console.log(data));
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
(ns frontend.commands
|
||||
(:require [frontend.util :as util]
|
||||
[frontend.date :as date]
|
||||
[frontend.text :as text]
|
||||
[frontend.state :as state]
|
||||
[frontend.search :as search]
|
||||
[clojure.string :as string]
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +1,8 @@
|
|||
(ns frontend.components.commit
|
||||
(:require [rum.core :as rum]
|
||||
[frontend.util :as util :refer-macros [profile]]
|
||||
[frontend.handler.git :as git-handler]
|
||||
[frontend.handler.repo :as repo-handler]
|
||||
[frontend.state :as state]
|
||||
[clojure.string :as string]
|
||||
[frontend.db :as db]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.mixins :as mixins]
|
||||
[goog.dom :as gdom]
|
||||
[goog.object :as gobj]))
|
||||
|
|
|
@ -18,10 +18,8 @@
|
|||
[cljs.pprint :as pprint]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.components.editor :as editor]
|
||||
[frontend.components.svg :as svg]
|
||||
[frontend.context.i18n :as i18n]
|
||||
[frontend.text :as text]
|
||||
[frontend.security :as security]))
|
||||
[frontend.text :as text]))
|
||||
|
||||
(defn- set-format-js-loading!
|
||||
[format value]
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
[frontend.components.svg :as svg]
|
||||
[frontend.date :as date]
|
||||
[frontend.state :as state]
|
||||
[frontend.mixins :as mixins]
|
||||
[frontend.handler.repeated :as repeated]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[cljs-time.core :as t]
|
||||
|
|
|
@ -3,14 +3,12 @@
|
|||
[goog.object :as gobj]
|
||||
[frontend.rum :as r]
|
||||
[frontend.util :as util :refer-macros [profile]]
|
||||
[frontend.fs :as fs]
|
||||
[frontend.mixins :as mixins]
|
||||
[frontend.storage :as storage]
|
||||
[frontend.components.svg :as svg]
|
||||
[cljs-bean.core :as bean]
|
||||
[dommy.core :as d]
|
||||
[clojure.string :as string]
|
||||
[frontend.date :as date]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.draw :as draw :refer
|
||||
[*files
|
||||
|
@ -28,7 +26,7 @@
|
|||
[frontend.config :as config]
|
||||
[frontend.state :as state]
|
||||
[frontend.search :as search]
|
||||
[frontend.components.widgets :as widgets]
|
||||
[frontend.components.repo :as repo]
|
||||
[promesa.core :as p]
|
||||
[reitit.frontend.easy :as rfe]))
|
||||
|
||||
|
@ -139,7 +137,7 @@
|
|||
"Please specify a title first!"
|
||||
:error)
|
||||
;; TODO: focus the title input
|
||||
)
|
||||
)
|
||||
|
||||
(= title @*saving-title)
|
||||
nil
|
||||
|
@ -437,10 +435,10 @@
|
|||
(when current-repo
|
||||
[:div.absolute.top-4.right-4.hidden.md:block
|
||||
[:div.flex.flex-row.items-center
|
||||
(widgets/sync-status current-repo)
|
||||
(widgets/repos true
|
||||
(fn [repo]
|
||||
(reset! *current-file (get-last-file repo))))]])]))
|
||||
(repo/sync-status current-repo)
|
||||
(repo/repos-dropdown true
|
||||
(fn [repo]
|
||||
(reset! *current-file (get-last-file repo))))]])]))
|
||||
|
||||
(rum/defcs draw-2 < rum/reactive
|
||||
{:init (fn [state]
|
||||
|
|
|
@ -3,20 +3,16 @@
|
|||
[frontend.components.svg :as svg]
|
||||
[frontend.config :as config]
|
||||
[frontend.handler.editor :as editor-handler :refer [get-state]]
|
||||
[frontend.handler.image :as image-handler]
|
||||
[frontend.util :as util :refer-macros [profile]]
|
||||
[frontend.handler.file :as file]
|
||||
[frontend.handler.page :as page-handler]
|
||||
[frontend.components.datetime :as datetime-comp]
|
||||
[promesa.core :as p]
|
||||
[frontend.date :as date]
|
||||
[frontend.state :as state]
|
||||
[frontend.mixins :as mixins]
|
||||
[frontend.image :as image]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.db :as db]
|
||||
[frontend.config :as config]
|
||||
[frontend.utf8 :as utf8]
|
||||
[dommy.core :as d]
|
||||
[goog.object :as gobj]
|
||||
[goog.dom :as gdom]
|
||||
|
@ -29,12 +25,8 @@
|
|||
*angle-bracket-caret-pos
|
||||
*matched-block-commands
|
||||
*show-block-commands]]
|
||||
[frontend.format.block :as block]
|
||||
[medley.core :as medley]
|
||||
[cljs-time.core :as t]
|
||||
[cljs-time.coerce :as tc]
|
||||
[cljs-drag-n-drop.core :as dnd]
|
||||
[frontend.search :as search]
|
||||
[frontend.text :as text]
|
||||
["/frontend/utils" :as utils]))
|
||||
|
||||
|
@ -640,7 +632,8 @@
|
|||
(not (editor-handler/in-auto-complete? (gdom/getElement id)))))
|
||||
(state/clear-edit!))))))
|
||||
:node (gdom/getElement id)
|
||||
:visibilitychange? true))
|
||||
;; :visibilitychange? true
|
||||
))
|
||||
100)
|
||||
|
||||
(when-let [element (gdom/getElement id)]
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
(set! (.-onload reader)
|
||||
(fn [e]
|
||||
(let [text (.. e -target -result)]
|
||||
(external-handler/import-from-roam-json! text)
|
||||
(reset! *importing? false))))
|
||||
(external-handler/import-from-roam-json! text
|
||||
#(reset! *importing? false)))))
|
||||
(.readAsText reader file)))
|
||||
(notification/show! "Please choose a JSON file."
|
||||
:error))))}]
|
||||
|
|
|
@ -2,24 +2,15 @@
|
|||
(:require [rum.core :as rum]
|
||||
[frontend.util :as util]
|
||||
[frontend.handler.project :as project]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.image :as image-handler]
|
||||
[frontend.handler.file :as file]
|
||||
[frontend.handler.export :as export-handler]
|
||||
[frontend.handler.page :as page-handler]
|
||||
[frontend.config :as config]
|
||||
[frontend.state :as state]
|
||||
[clojure.string :as string]
|
||||
[frontend.db :as db]
|
||||
[frontend.components.hiccup :as hiccup]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.format :as format]
|
||||
[frontend.format.mldoc :as mldoc]
|
||||
[frontend.components.content :as content]
|
||||
[frontend.components.lazy-editor :as lazy-editor]
|
||||
[frontend.config :as config]
|
||||
[frontend.utf8 :as utf8]
|
||||
[goog.dom :as gdom]
|
||||
[goog.object :as gobj]
|
||||
[frontend.date :as date]
|
||||
[cljs-time.coerce :as tc]
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,22 +4,18 @@
|
|||
[frontend.date :as date]
|
||||
[frontend.db-mixins :as db-mixins]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.repo :as repo-handler]
|
||||
[frontend.handler.page :as page-handler]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.db :as db]
|
||||
[frontend.state :as state]
|
||||
[clojure.string :as string]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.format :as format]
|
||||
[frontend.components.content :as content]
|
||||
[frontend.components.hiccup :as hiccup]
|
||||
[frontend.components.block :as block]
|
||||
[frontend.components.editor :as editor]
|
||||
[frontend.components.reference :as reference]
|
||||
[frontend.components.page :as page]
|
||||
[frontend.components.onboarding :as onboarding]
|
||||
[frontend.utf8 :as utf8]
|
||||
[goog.object :as gobj]
|
||||
[clojure.string :as string]))
|
||||
|
||||
|
@ -47,11 +43,11 @@
|
|||
(let [start-level (or (:block/level (first blocks)) 1)]
|
||||
(content/content
|
||||
encoded-page-name
|
||||
{:hiccup (hiccup/->hiccup blocks
|
||||
{:id encoded-page-name
|
||||
:start-level 2
|
||||
:editor-box editor/box}
|
||||
{})})))
|
||||
{:hiccup (block/->hiccup blocks
|
||||
{:id encoded-page-name
|
||||
:start-level 2
|
||||
:editor-box editor/box}
|
||||
{})})))
|
||||
|
||||
(rum/defc blocks-cp < rum/reactive db-mixins/query
|
||||
{}
|
||||
|
|
|
@ -311,12 +311,12 @@
|
|||
[:td.text-right
|
||||
[:a {:href "https://www.example.com"}
|
||||
"label"]]]
|
||||
[:tr [:td "![image](https://logseq.com/static/img/logo.png)"]
|
||||
[:tr [:td "![image](https://asset.logseq.com/static/img/logo.png)"]
|
||||
[:td.text-right
|
||||
[:img {:style {:float "right"
|
||||
:width 64
|
||||
:height 64}
|
||||
:src "https://logseq.com/static/img/logo.png"
|
||||
:src "https://asset.logseq.com/static/img/logo.png"
|
||||
:alt "image"}]]]]]]
|
||||
|
||||
[:li
|
||||
|
@ -342,10 +342,10 @@
|
|||
[:td.text-right
|
||||
[:a {:href "https://www.example.com"}
|
||||
"label"]]]
|
||||
[:tr [:td "[[https://logseq.com/static/img/logo.png][image]]"]
|
||||
[:tr [:td "[[https://asset.logseq.com/static/img/logo.png][image]]"]
|
||||
[:td.text-right
|
||||
[:img {:style {:float "right"
|
||||
:width 64
|
||||
:height 64}
|
||||
:src "https://logseq.com/static/img/logo.png"
|
||||
:src "https://asset.logseq.com/static/img/logo.png"
|
||||
:alt "image"}]]]]]]]]))
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns frontend.components.page
|
||||
(:require [rum.core :as rum]
|
||||
[medley.core :as medley]
|
||||
[frontend.util :as util :refer-macros [profile]]
|
||||
[frontend.handler.file :as file]
|
||||
[frontend.handler.page :as page-handler]
|
||||
|
@ -8,19 +7,16 @@
|
|||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.handler.export :as export-handler]
|
||||
[frontend.state :as state]
|
||||
[clojure.string :as string]
|
||||
[frontend.db :as db]
|
||||
[dommy.core :as d]
|
||||
[frontend.components.hiccup :as hiccup]
|
||||
[frontend.components.editor :as editor]
|
||||
[frontend.components.block :as block]
|
||||
[frontend.components.editor :as editor]
|
||||
[frontend.components.reference :as reference]
|
||||
[frontend.components.svg :as svg]
|
||||
[frontend.extensions.graph-2d :as graph-2d]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.format :as format]
|
||||
[frontend.components.content :as content]
|
||||
[frontend.components.project :as project]
|
||||
[frontend.config :as config]
|
||||
|
@ -73,7 +69,7 @@
|
|||
:sidebar? sidebar?
|
||||
:block? block?
|
||||
:editor-box editor/box}
|
||||
hiccup (hiccup/->hiccup page-blocks hiccup-config {})]
|
||||
hiccup (block/->hiccup page-blocks hiccup-config {})]
|
||||
(rum/with-key
|
||||
(content/content encoded-page-name
|
||||
{:hiccup hiccup
|
||||
|
@ -108,9 +104,9 @@
|
|||
[:div#today-queries.mt-10
|
||||
(for [{:keys [title] :as query} queries]
|
||||
(rum/with-key
|
||||
(hiccup/custom-query {:start-level 2
|
||||
:attr {:class "mt-10"}
|
||||
:editor-box editor/box} query)
|
||||
(block/custom-query {:start-level 2
|
||||
:attr {:class "mt-10"}
|
||||
:editor-box editor/box} query)
|
||||
(str repo "-custom-query-" (:query query))))]))))
|
||||
|
||||
(defn- delete-page!
|
||||
|
@ -340,7 +336,7 @@
|
|||
(if (and (string/includes? page-original-name "[[")
|
||||
(string/includes? page-original-name "]]"))
|
||||
(let [ast (mldoc/->edn page-original-name (mldoc/default-config format))]
|
||||
(hiccup/block-cp {} (ffirst ast)))
|
||||
(block/markup-element-cp {} (ffirst ast)))
|
||||
page-original-name)
|
||||
(or
|
||||
page-name
|
||||
|
@ -454,16 +450,16 @@
|
|||
(let [encoded-page (util/encode-str page)]
|
||||
[:tr {:key encoded-page}
|
||||
[:td [:a {:on-click (fn [e]
|
||||
(util/stop e)
|
||||
(let [repo (state/get-current-repo)
|
||||
page (db/pull repo '[*] [:page/name (string/lower-case page)])]
|
||||
(when (gobj/get e "shiftKey")
|
||||
(state/sidebar-add-block!
|
||||
repo
|
||||
(:db/id page)
|
||||
:page
|
||||
{:page page}))))
|
||||
:href (rfe/href :page {:name encoded-page})}
|
||||
(util/stop e)
|
||||
(let [repo (state/get-current-repo)
|
||||
page (db/pull repo '[*] [:page/name (string/lower-case page)])]
|
||||
(when (gobj/get e "shiftKey")
|
||||
(state/sidebar-add-block!
|
||||
repo
|
||||
(:db/id page)
|
||||
:page
|
||||
{:page page}))))
|
||||
:href (rfe/href :page {:name encoded-page})}
|
||||
page]]
|
||||
[:td [:span.text-gray-500.text-sm
|
||||
(if (zero? modified-at)
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
(ns frontend.components.project
|
||||
(:require [rum.core :as rum]
|
||||
[frontend.util :as util :refer-macros [profile]]
|
||||
[frontend.handler.project :as project-handler]
|
||||
[frontend.state :as state]
|
||||
[clojure.string :as string]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.mixins :as mixins]
|
||||
[goog.dom :as gdom]
|
||||
[goog.object :as gobj]))
|
||||
[frontend.handler.project :as project-handler]))
|
||||
|
||||
(rum/defcs add-project <
|
||||
(rum/local "" ::project)
|
||||
|
|
|
@ -4,17 +4,12 @@
|
|||
[frontend.state :as state]
|
||||
[clojure.string :as string]
|
||||
[frontend.db :as db]
|
||||
[frontend.components.hiccup :as hiccup]
|
||||
[frontend.components.block :as block]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.format :as format]
|
||||
[frontend.components.content :as content]
|
||||
[frontend.config :as config]
|
||||
[frontend.date :as date]
|
||||
[frontend.components.svg :as svg]
|
||||
[frontend.components.editor :as editor]
|
||||
[frontend.handler.page :as page-handler]
|
||||
[frontend.db-mixins :as db-mixins]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(rum/defc references < rum/reactive db-mixins/query
|
||||
|
@ -48,13 +43,13 @@
|
|||
[:h2.font-bold.opacity-50 (let []
|
||||
"SCHEDULED AND DEADLINE")]
|
||||
[:div.references-blocks.mb-6
|
||||
(let [ref-hiccup (hiccup/->hiccup scheduled-or-deadlines
|
||||
{:id (str encoded-page-name "-agenda")
|
||||
:start-level 2
|
||||
:ref? true
|
||||
:group-by-page? true
|
||||
:editor-box editor/box}
|
||||
{})]
|
||||
(let [ref-hiccup (block/->hiccup scheduled-or-deadlines
|
||||
{:id (str encoded-page-name "-agenda")
|
||||
:start-level 2
|
||||
:ref? true
|
||||
:group-by-page? true
|
||||
:editor-box editor/box}
|
||||
{})]
|
||||
(content/content encoded-page-name
|
||||
{:hiccup ref-hiccup}))]))
|
||||
|
||||
|
@ -62,13 +57,14 @@
|
|||
[:h2.font-bold.opacity-50 (let []
|
||||
(str n-ref " Linked References"))]
|
||||
[:div.references-blocks
|
||||
(let [ref-hiccup (hiccup/->hiccup ref-blocks
|
||||
{:id encoded-page-name
|
||||
:start-level 2
|
||||
:ref? true
|
||||
:group-by-page? true
|
||||
:editor-box editor/box}
|
||||
{})]
|
||||
(let [ref-hiccup (block/->hiccup ref-blocks
|
||||
{:id encoded-page-name
|
||||
:start-level 2
|
||||
:ref? true
|
||||
:breadcrumb-show? true
|
||||
:group-by-page? true
|
||||
:editor-box editor/box}
|
||||
{})]
|
||||
(content/content encoded-page-name
|
||||
{:hiccup ref-hiccup}))])]]))))
|
||||
|
||||
|
@ -78,13 +74,13 @@
|
|||
encoded-page-name (util/url-encode page-name)]
|
||||
(reset! n-ref (count ref-blocks))
|
||||
[:div.references-blocks
|
||||
(let [ref-hiccup (hiccup/->hiccup ref-blocks
|
||||
{:id (str encoded-page-name "-unlinked-")
|
||||
:start-level 2
|
||||
:ref? true
|
||||
:group-by-page? true
|
||||
:editor-box editor/box}
|
||||
{})]
|
||||
(let [ref-hiccup (block/->hiccup ref-blocks
|
||||
{:id (str encoded-page-name "-unlinked-")
|
||||
:start-level 2
|
||||
:ref? true
|
||||
:group-by-page? true
|
||||
:editor-box editor/box}
|
||||
{})]
|
||||
(content/content encoded-page-name
|
||||
{:hiccup ref-hiccup}))]))
|
||||
|
||||
|
|
|
@ -5,10 +5,16 @@
|
|||
[frontend.state :as state]
|
||||
[frontend.db :as db]
|
||||
[frontend.handler.repo :as repo-handler]
|
||||
[frontend.handler.common :as common-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.export :as export-handler]
|
||||
[frontend.util :as util]
|
||||
[reitit.frontend.easy :as rfe]))
|
||||
[frontend.config :as config]
|
||||
[reitit.frontend.easy :as rfe]
|
||||
[frontend.version :as version]
|
||||
[frontend.components.commit :as commit]
|
||||
[frontend.context.i18n :as i18n]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(rum/defc add-repo
|
||||
[]
|
||||
|
@ -25,8 +31,8 @@
|
|||
[:div.pl-1.content
|
||||
[:div.flex.my-4 {:key "add-button"}
|
||||
(ui/button
|
||||
"Add another repo"
|
||||
:href (rfe/href :repo-add))]
|
||||
"Add another repo"
|
||||
:href (rfe/href :repo-add))]
|
||||
|
||||
(for [{:keys [id url] :as repo} repos]
|
||||
[:div.flex.justify-between.mb-1 {:key id}
|
||||
|
@ -52,3 +58,106 @@
|
|||
|
||||
[:a#download-as-json.hidden]]
|
||||
(widgets/add-repo))))
|
||||
|
||||
(rum/defc sync-status < rum/reactive
|
||||
{:did-mount (fn [state]
|
||||
(js/setTimeout common-handler/check-changed-files-status 1000)
|
||||
state)}
|
||||
[]
|
||||
(let [repo (state/get-current-repo)]
|
||||
(when-not (= repo config/local-repo)
|
||||
(let [changed-files (state/sub [:repo/changed-files repo])
|
||||
should-push? (seq changed-files)
|
||||
git-status (state/sub [:git/status repo])
|
||||
pushing? (= :pushing git-status)
|
||||
pulling? (= :pulling git-status)
|
||||
last-pulled-at (db/sub-key-value repo :git/last-pulled-at)]
|
||||
[:div.flex-row.flex.items-center
|
||||
(when pushing?
|
||||
[:span.lds-dual-ring.mt-1])
|
||||
(ui/dropdown
|
||||
(fn [{:keys [toggle-fn]}]
|
||||
[:div.cursor.w-2.h-2.sync-status.mr-2
|
||||
{:class (if (or should-push? pushing?) "bg-orange-400" "bg-green-600")
|
||||
:style {:border-radius "50%"
|
||||
:margin-top 2}
|
||||
:on-mouse-over
|
||||
(fn [e]
|
||||
(toggle-fn)
|
||||
(js/setTimeout common-handler/check-changed-files-status 0))}])
|
||||
(fn [{:keys [toggle-fn]}]
|
||||
(rum/with-context [[t] i18n/*tongue-context*]
|
||||
[:div.p-2.rounded-md.shadow-xs.bg-base-3.flex.flex-col.sync-content
|
||||
{:on-mouse-leave toggle-fn}
|
||||
[:div
|
||||
[:div
|
||||
(if (and should-push? (seq changed-files))
|
||||
[:div.changes
|
||||
[:ul
|
||||
(for [file changed-files]
|
||||
[:li {:key (str "sync-" file)}
|
||||
[:div.flex.flex-row.justify-between.align-items
|
||||
[:a {:href (rfe/href :file {:path file})}
|
||||
file]
|
||||
[:a.ml-4.text-sm.mt-1
|
||||
{:on-click (fn [e]
|
||||
(export-handler/download-file! file))}
|
||||
[:span (t :download)]]]])]]
|
||||
[:p (t :git/local-changes-synced)])]
|
||||
;; [:a.text-sm.font-bold {:href "/diff"} "Check diff"]
|
||||
[:div.flex.flex-row.justify-between.align-items.mt-2
|
||||
(ui/button (t :git/push)
|
||||
:on-click (fn [] (state/set-modal! commit/add-commit-message)))
|
||||
(if pushing?
|
||||
[:span.lds-dual-ring.mt-1])]]
|
||||
[:hr]
|
||||
[:div
|
||||
(when-not (string/blank? last-pulled-at)
|
||||
[:p {:style {:font-size 12}} (t :git/last-pull)
|
||||
(str ": " last-pulled-at)])
|
||||
[:div.flex.flex-row.justify-between.align-items
|
||||
(ui/button (t :git/pull)
|
||||
:on-click (fn [] (repo-handler/pull-current-repo)))
|
||||
(if pulling?
|
||||
[:span.lds-dual-ring.mt-1])]
|
||||
[:p.pt-2.text-sm.opacity-50
|
||||
(t :git/version) (str " " version/version)]]])))]))))
|
||||
|
||||
(rum/defc repos-dropdown < rum/reactive
|
||||
[head? on-click]
|
||||
(let [current-repo (state/sub :git/current-repo)
|
||||
logged? (state/logged?)
|
||||
local-repo? (= current-repo config/local-repo)
|
||||
get-repo-name (fn [repo]
|
||||
(if head?
|
||||
(db/get-repo-path repo)
|
||||
(util/take-at-most (db/get-repo-name repo) 20)))]
|
||||
(when logged?
|
||||
(if current-repo
|
||||
(let [repos (state/sub [:me :repos])]
|
||||
(if (> (count repos) 1)
|
||||
(ui/dropdown-with-links
|
||||
(fn [{:keys [toggle-fn]}]
|
||||
[:a#repo-switch {:on-click toggle-fn}
|
||||
[:span (get-repo-name current-repo)]
|
||||
[:span.dropdown-caret.ml-1 {:style {:border-top-color "#6b7280"}}]])
|
||||
(mapv
|
||||
(fn [{:keys [id url]}]
|
||||
{:title (get-repo-name url)
|
||||
:options {:on-click (fn []
|
||||
(state/set-current-repo! url)
|
||||
(when-not (= :draw (state/get-current-route))
|
||||
(route-handler/redirect-to-home!))
|
||||
(when on-click
|
||||
(on-click url)))}})
|
||||
(remove (fn [repo]
|
||||
(= current-repo (:url repo)))
|
||||
repos))
|
||||
{:modal-class (util/hiccup->class
|
||||
"origin-top-right.absolute.left-0.mt-2.w-48.rounded-md.shadow-lg ")})
|
||||
(if local-repo?
|
||||
[:span (get-repo-name current-repo)]
|
||||
[:a
|
||||
{:href current-repo
|
||||
:target "_blank"}
|
||||
(get-repo-name current-repo)])))))))
|
||||
|
|
|
@ -3,12 +3,10 @@
|
|||
[frontend.ui :as ui]
|
||||
[frontend.components.svg :as svg]
|
||||
[frontend.components.page :as page]
|
||||
[frontend.components.hiccup :as hiccup]
|
||||
[frontend.components.block :as block]
|
||||
[frontend.extensions.graph-2d :as graph-2d]
|
||||
[frontend.components.onboarding :as onboarding]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.handler.page :as page-handler]
|
||||
[frontend.state :as state]
|
||||
[frontend.db :as db]
|
||||
|
@ -150,10 +148,10 @@
|
|||
blocks (if journal?
|
||||
(rest blocks)
|
||||
blocks)
|
||||
sections (hiccup/build-slide-sections blocks {:id "slide-reveal-js"
|
||||
:start-level 2
|
||||
:slide? true
|
||||
:sidebar? true})]
|
||||
sections (block/build-slide-sections blocks {:id "slide-reveal-js"
|
||||
:start-level 2
|
||||
:slide? true
|
||||
:sidebar? true})]
|
||||
[[:a {:href (str "/page/" (util/url-encode page-name))}
|
||||
(util/capitalize-all page-name)]
|
||||
[:div.ml-2.slide.mt-2
|
||||
|
@ -228,22 +226,21 @@
|
|||
"1 0 40%"
|
||||
"0 0 0px")}}
|
||||
(if sidebar-open?
|
||||
[:div {:style {:flex "1 1 auto"
|
||||
[:div.hide-scrollbar {:style {:flex "1 1 auto"
|
||||
:padding 12
|
||||
:height "100%"
|
||||
:overflow-y "scroll"
|
||||
:overflow-y "auto"
|
||||
:overflow-x "hidden"
|
||||
:box-sizing "content-box"
|
||||
:margin-right -17}}
|
||||
:box-sizing "content-box"}}
|
||||
[:div.flex.flex-row.mb-2 {:key "right-sidebar-settings"}
|
||||
[:div.mr-4.text-sm
|
||||
[:a.right-sidebar-button {:on-click (fn [e]
|
||||
(state/sidebar-add-block! repo "contents" :contents nil))}
|
||||
(state/sidebar-add-block! repo "contents" :contents nil))}
|
||||
(t :right-side-bar/contents)]]
|
||||
|
||||
[:div.mr-4.text-sm
|
||||
[:a.right-sidebar-button {:on-click (fn [_e]
|
||||
(state/sidebar-add-block! repo "recent" :recent nil))}
|
||||
(state/sidebar-add-block! repo "recent" :recent nil))}
|
||||
(t :right-side-bar/recent)]]
|
||||
|
||||
(when config/publishing?
|
||||
|
@ -253,25 +250,25 @@
|
|||
|
||||
[:div.mr-4.text-sm
|
||||
[:a.right-sidebar-button {:on-click (fn []
|
||||
(when-let [page (get-current-page)]
|
||||
(state/sidebar-add-block!
|
||||
repo
|
||||
(str "page-graph-" page)
|
||||
:page-graph
|
||||
page)))}
|
||||
(when-let [page (get-current-page)]
|
||||
(state/sidebar-add-block!
|
||||
repo
|
||||
(str "page-graph-" page)
|
||||
:page-graph
|
||||
page)))}
|
||||
(t :right-side-bar/page)]]
|
||||
|
||||
[:div.mr-4.text-sm
|
||||
(let [theme (if dark? "white" "dark")]
|
||||
[:a.right-sidebar-button {:title (t :right-side-bar/switch-theme theme)
|
||||
:on-click (fn []
|
||||
(state/set-theme! theme))}
|
||||
:on-click (fn []
|
||||
(state/set-theme! theme))}
|
||||
(t :right-side-bar/theme (t (keyword theme)))])]
|
||||
|
||||
(when-not config/publishing?
|
||||
[:div.mr-4.text-sm
|
||||
[:a.right-sidebar-button {:on-click (fn [_e]
|
||||
(state/sidebar-add-block! repo "help" :help nil))}
|
||||
(state/sidebar-add-block! repo "help" :help nil))}
|
||||
(t :right-side-bar/help)]])]
|
||||
|
||||
(for [[idx [repo db-id block-type block-data]] (medley/indexed blocks)]
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
(:require [rum.core :as rum]
|
||||
[frontend.util :as util]
|
||||
[frontend.handler.route :as route]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.handler.page :as page-handler]
|
||||
[frontend.db :as db]
|
||||
[frontend.handler.search :as search-handler]
|
||||
|
@ -12,8 +11,6 @@
|
|||
[frontend.config :as config]
|
||||
[frontend.search :as search]
|
||||
[clojure.string :as string]
|
||||
[goog.crypt.base64 :as b64]
|
||||
[goog.object :as gobj]
|
||||
[goog.dom :as gdom]
|
||||
[frontend.context.i18n :as i18n]))
|
||||
|
||||
|
|
|
@ -10,18 +10,14 @@
|
|||
[frontend.components.page :as page]
|
||||
[frontend.components.settings :as settings]
|
||||
[frontend.components.svg :as svg]
|
||||
[frontend.components.project :as project]
|
||||
[frontend.components.repo :as repo]
|
||||
[frontend.components.commit :as commit]
|
||||
[frontend.components.right-sidebar :as right-sidebar]
|
||||
[frontend.storage :as storage]
|
||||
[goog.crypt.base64 :as b64]
|
||||
[frontend.util :as util]
|
||||
[frontend.state :as state]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.user :as user-handler]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.handler.repo :as repo-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.export :as export]
|
||||
[frontend.config :as config]
|
||||
|
@ -236,13 +232,9 @@
|
|||
(not (gobj/get e "altKey"))
|
||||
(not (gobj/get e "metaKey")))
|
||||
(when-let [repo-url (state/get-current-repo)]
|
||||
(if (and
|
||||
(not (state/get-edit-input-id))
|
||||
(seq (state/get-changed-files repo-url)))
|
||||
(do
|
||||
(util/stop e)
|
||||
(state/set-modal! commit/add-commit-message))
|
||||
(notification/show! "No changed files yet!" :warning)))))}
|
||||
(when-not (state/get-edit-input-id)
|
||||
(util/stop e)
|
||||
(state/set-modal! commit/add-commit-message)))))}
|
||||
(fn [e key-code]
|
||||
nil))))
|
||||
{:did-mount (fn [state]
|
||||
|
@ -295,7 +287,7 @@
|
|||
:stroke-linejoin "round"
|
||||
:stroke-linecap "round"}]]]])
|
||||
[:div.flex-shrink-0.flex.items-center.px-4.h-16 {:style {:background-color "#002b36"}}
|
||||
(widgets/repos false)]
|
||||
(repo/repos-dropdown false)]
|
||||
[:div.flex-1.h-0.overflow-y-auto
|
||||
(sidebar-nav route-match close-fn)]]]
|
||||
[:div.flex.flex-col.w-0.flex-1.overflow-hidden
|
||||
|
@ -326,10 +318,10 @@
|
|||
(storage/remove :git/current-repo))}
|
||||
(t :login-github)])
|
||||
|
||||
(widgets/sync-status)
|
||||
(repo/sync-status)
|
||||
|
||||
[:div.repos.hidden.md:block
|
||||
(widgets/repos true)]
|
||||
(repo/repos-dropdown true)]
|
||||
|
||||
(when-let [project (and current-repo (state/get-current-project))]
|
||||
[:a.opacity-70.hover:opacity-100.ml-4
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
(:require [rum.core :as rum]
|
||||
[frontend.util :as util]
|
||||
[frontend.handler.user :as user-handler]
|
||||
[frontend.handler.git :as git-handler]
|
||||
[frontend.handler.repo :as repo-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.export :as export-handler]
|
||||
|
@ -13,9 +12,7 @@
|
|||
[frontend.ui :as ui]
|
||||
[frontend.db :as db]
|
||||
[frontend.version :as version]
|
||||
[frontend.components.svg :as svg]
|
||||
[frontend.components.commit :as commit]
|
||||
[clojure.set :as set]
|
||||
[frontend.context.i18n :as i18n]
|
||||
[reitit.frontend.easy :as rfe]))
|
||||
|
||||
|
@ -39,104 +36,6 @@
|
|||
:on-click
|
||||
#(user-handler/set-preferred-format! :org))]]))
|
||||
|
||||
(rum/defc sync-status < rum/reactive
|
||||
[]
|
||||
(let [repo (state/get-current-repo)]
|
||||
(when-not (= repo config/local-repo)
|
||||
(let [git-status (state/sub [:git/status repo])
|
||||
pulling? (= :pulling git-status)
|
||||
pushing? (= :pushing git-status)
|
||||
last-pulled-at (db/sub-key-value repo :git/last-pulled-at)
|
||||
changed-files (state/sub [:repo/changed-files repo])
|
||||
should-push? (seq changed-files)]
|
||||
(rum/with-context [[t] i18n/*tongue-context*]
|
||||
[:div.flex-row.flex.items-center
|
||||
(when pushing?
|
||||
[:span.lds-dual-ring.mt-1])
|
||||
(ui/dropdown
|
||||
(fn [{:keys [toggle-fn]}]
|
||||
[:div.cursor.w-2.h-2.sync-status.mr-2
|
||||
{:class (if (or should-push? pushing?) "bg-orange-400" "bg-green-600")
|
||||
:style {:border-radius "50%"
|
||||
:margin-top 2}
|
||||
:on-mouse-over
|
||||
(fn [e]
|
||||
(toggle-fn)
|
||||
(js/setTimeout repo-handler/check-changed-files-status 0))}])
|
||||
(fn [{:keys [toggle-fn]}]
|
||||
[:div.p-2.rounded-md.shadow-xs.bg-base-3.flex.flex-col.sync-content
|
||||
{:on-mouse-leave toggle-fn}
|
||||
(if (and should-push? (seq changed-files))
|
||||
[:div
|
||||
[:div.changes
|
||||
[:ul
|
||||
(for [file changed-files]
|
||||
[:li {:key (str "sync-" file)}
|
||||
[:div.flex.flex-row.justify-between.align-items
|
||||
[:a {:href (rfe/href :file {:path file})}
|
||||
file]
|
||||
[:a.ml-4.text-sm.mt-1
|
||||
{:on-click (fn [e]
|
||||
(export-handler/download-file! file))}
|
||||
[:span (t :download)]]]])]]
|
||||
;; [:a.text-sm.font-bold {:href "/diff"} "Check diff"]
|
||||
[:div.flex.flex-row.justify-between.align-items.mt-2
|
||||
(ui/button (t :git/push)
|
||||
:on-click (fn [] (state/set-modal! commit/add-commit-message)))
|
||||
(if pushing?
|
||||
[:span.lds-dual-ring.mt-1])]]
|
||||
[:p (t :git/local-changes-synced)])
|
||||
[:hr]
|
||||
[:div
|
||||
[:p {:style {:font-size 12}} (t :git/last-pull)
|
||||
last-pulled-at]
|
||||
[:div.flex.flex-row.justify-between.align-items
|
||||
(ui/button (t :git/pull)
|
||||
:on-click (fn [] (repo-handler/pull-current-repo)))
|
||||
(if pulling?
|
||||
[:span.lds-dual-ring.mt-1])]
|
||||
[:p.pt-2.text-sm.opacity-50
|
||||
(t :git/version) (str " " version/version)]]]))])))))
|
||||
|
||||
(rum/defc repos < rum/reactive
|
||||
[head? on-click]
|
||||
(let [current-repo (state/sub :git/current-repo)
|
||||
logged? (state/logged?)
|
||||
local-repo? (= current-repo config/local-repo)
|
||||
get-repo-name-f (fn [repo]
|
||||
(if head?
|
||||
(db/get-repo-path repo)
|
||||
(util/take-at-most (db/get-repo-name repo) 20)))]
|
||||
(when logged?
|
||||
(if current-repo
|
||||
(let [repos (state/sub [:me :repos])]
|
||||
(if (> (count repos) 1)
|
||||
(ui/dropdown-with-links
|
||||
(fn [{:keys [toggle-fn]}]
|
||||
[:a#repo-switch {:on-click toggle-fn}
|
||||
[:span (get-repo-name-f current-repo)]
|
||||
[:span.dropdown-caret.ml-1 {:style {:border-top-color "#6b7280"}}]])
|
||||
(mapv
|
||||
(fn [{:keys [id url]}]
|
||||
{:title (get-repo-name-f url)
|
||||
:options {:on-click (fn []
|
||||
(state/set-current-repo! url)
|
||||
(when-not (= :draw (state/get-current-route))
|
||||
(route-handler/redirect-to-home!))
|
||||
(when on-click
|
||||
(on-click url)))}})
|
||||
(remove (fn [repo]
|
||||
(= current-repo (:url repo)))
|
||||
repos))
|
||||
{:modal-class (util/hiccup->class
|
||||
"origin-top-right.absolute.left-0.mt-2.w-48.rounded-md.shadow-lg ")})
|
||||
(if local-repo?
|
||||
[:span (get-repo-name-f current-repo)]
|
||||
[:a
|
||||
{:href current-repo
|
||||
:target "_blank"}
|
||||
(get-repo-name-f current-repo)])))))))
|
||||
|
||||
(rum/defcs add-repo <
|
||||
(rum/local "" ::repo)
|
||||
(rum/local "" ::branch)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
[frontend.handler.route :as route]
|
||||
[frontend.page :as page]
|
||||
[frontend.routes :as routes]
|
||||
[frontend.util :as util]
|
||||
[reitit.frontend :as rf]
|
||||
[reitit.frontend.easy :as rfe]))
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
[frontend.utf8 :as utf8]
|
||||
[cljs-bean.core :as bean]
|
||||
[frontend.config :as config]
|
||||
[rum.core :as rum]
|
||||
[goog.object :as gobj]
|
||||
["localforage" :as localforage]
|
||||
[promesa.core :as p]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns frontend.db-mixins
|
||||
(:require [frontend.db :as db]
|
||||
[rum.core :as rum]))
|
||||
(:require [frontend.db :as db]))
|
||||
|
||||
(def query
|
||||
{:wrap-render
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
(ns frontend.dicts
|
||||
(:require [tongue.core :as tongue]
|
||||
[frontend.state :as state]
|
||||
[clojure.string :as string]
|
||||
[frontend.config :as config]))
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
(ns frontend.extensions.code
|
||||
(:require [rum.core :as rum]
|
||||
[frontend.config :as config]
|
||||
[frontend.util :as util]
|
||||
[frontend.mixins :as mixins]
|
||||
[goog.dom :as gdom]
|
||||
[goog.object :as gobj]
|
||||
[frontend.db :as db]
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
.extensions__code {
|
||||
@apply relative
|
||||
@apply relative;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.extensions__code-lang {
|
||||
@apply absolute top-0 right-0 p-1 text-sm text-gray-500;
|
||||
z-index: 2;
|
||||
z-index: 1;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.extensions__code > .CodeMirror {
|
||||
z-index: 0;
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
(ns frontend.extensions.sci
|
||||
(:require [rum.core :as rum]
|
||||
[frontend.config :as config]
|
||||
[frontend.ui :as ui]
|
||||
[goog.object :as gobj]
|
||||
[cljs-bean.core :as bean]
|
||||
[sci.core :as sci]))
|
||||
(:require [sci.core :as sci]))
|
||||
|
||||
(defn eval-string
|
||||
[s]
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
(:require [rum.core :as rum]
|
||||
[medley.core :as medley]
|
||||
[cljs-bean.core :as bean]
|
||||
[promesa.core :as p]
|
||||
[frontend.loader :as loader]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.config :as config]))
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
;; TODO: 5. Roam attributes -> properties
|
||||
;; TODO: 6. hiccup
|
||||
|
||||
(defonce uid-pattern #"\(\(([a-zA-Z0-9_\\-]{10})\)\)")
|
||||
(defonce uid-pattern #"\(\(([a-zA-Z0-9_\\-]{6,24})\)\)")
|
||||
(defonce macro-pattern #"\{\{([^{}]+)\}\}")
|
||||
|
||||
(defn uid-transform
|
||||
|
@ -55,7 +55,9 @@
|
|||
(map last)
|
||||
(distinct)
|
||||
(set))]
|
||||
(reset! all-refed-uids uids))))
|
||||
(reset! all-refed-uids uids)
|
||||
(doseq [uid uids]
|
||||
(swap! uid->uuid assoc uid (medley/random-uuid))))))
|
||||
|
||||
(defn transform
|
||||
[text]
|
||||
|
@ -65,7 +67,6 @@
|
|||
(uid-transform)
|
||||
(macro-transform)))
|
||||
|
||||
;; #"(([a-zA-Z0-9_\\-]{9}))"
|
||||
(declare children->text)
|
||||
(defn child->text
|
||||
[{:keys [uid string children] :as child} level]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns frontend.format.adoc
|
||||
(:require [frontend.format.protocol :as protocol]
|
||||
[frontend.config :as config]
|
||||
[frontend.loader :as loader]))
|
||||
|
||||
(defn loaded? []
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
[medley.core :as medley]
|
||||
[frontend.config :as config]
|
||||
[datascript.core :as d]
|
||||
[clojure.set :as set]
|
||||
[frontend.date :as date]
|
||||
[frontend.format.mldoc :as mldoc]
|
||||
[medley.core :as medley]))
|
||||
|
||||
(defn heading-block?
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
(ns frontend.format.mldoc
|
||||
(:require [frontend.format.protocol :as protocol]
|
||||
[frontend.util :as util]
|
||||
[frontend.config :as config]
|
||||
[clojure.string :as string]
|
||||
[frontend.loader :as loader]
|
||||
[cljs-bean.core :as bean]
|
||||
[medley.core :as medley]
|
||||
[cljs.core.match :refer-macros [match]]))
|
||||
|
||||
(defn default-config
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
(ns frontend.fs
|
||||
(:require [frontend.util :as util]
|
||||
[promesa.core :as p]
|
||||
[clojure.string :as string]))
|
||||
(:require [frontend.util :as util]))
|
||||
|
||||
(defn mkdir
|
||||
[dir]
|
||||
|
|
|
@ -5,10 +5,7 @@
|
|||
[clojure.string :as string]
|
||||
[clojure.set :as set]
|
||||
[frontend.state :as state]
|
||||
[goog.object :as gobj]
|
||||
[cljs-bean.core :as bean]
|
||||
[cljs-time.coerce :as tc]
|
||||
[cljs-time.core :as t]))
|
||||
[cljs-bean.core :as bean]))
|
||||
|
||||
;; only support Github now
|
||||
(defn get-username
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
(ns frontend.graph
|
||||
(:require [frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.util :as util]
|
||||
(:require [frontend.handler.route :as route-handler]
|
||||
[clojure.string :as string]
|
||||
[cljs-bean.core :as bean]
|
||||
[goog.object :as gobj]
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.migration :as migration-handler]
|
||||
[frontend.handler.repo :as repo-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.file :as file-handler]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.ui :as ui]))
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
(ns frontend.handler.common
|
||||
(:require [goog.object :as gobj]
|
||||
[frontend.state :as state]
|
||||
[cljs-bean.core :as bean]
|
||||
[promesa.core :as p]
|
||||
[frontend.util :as util]))
|
||||
|
||||
(defn check-changed-files-status
|
||||
[]
|
||||
(when-let [repo (state/get-current-repo)]
|
||||
(when (and
|
||||
(gobj/get js/window "workerThread")
|
||||
(gobj/get js/window.workerThread "getChangedFiles"))
|
||||
(->
|
||||
(p/let [files (js/window.workerThread.getChangedFiles (util/get-repo-dir repo))]
|
||||
(let [files (bean/->clj files)]
|
||||
(state/set-changed-files! repo files)))
|
||||
(p/catch (fn [error]
|
||||
(js/console.dir error)))))))
|
|
@ -511,8 +511,7 @@
|
|||
:else
|
||||
(move-block-in-different-repos target-block-repo to-block-repo target-block to-block top-block bottom-block nested? top? target-child? direction target-content target-file original-top-block-start-pos block-changes))
|
||||
|
||||
;; (when (state/git-auto-push?)
|
||||
;; (doseq [repo (->> #{target-block-repo to-block-repo}
|
||||
;; (remove nil?))]
|
||||
;; (repo-handler/push repo nil)))
|
||||
))))
|
||||
(when (state/git-auto-push?)
|
||||
(doseq [repo (->> #{target-block-repo to-block-repo}
|
||||
(remove nil?))]
|
||||
(repo-handler/push repo nil)))))))
|
||||
|
|
|
@ -5,18 +5,12 @@
|
|||
[promesa.core :as p]
|
||||
[frontend.state :as state]
|
||||
[frontend.db :as db]
|
||||
[frontend.git :as git]
|
||||
[frontend.github :as github]
|
||||
[frontend.handler.file :as file-handler]
|
||||
[frontend.handler.git :as git-handler]
|
||||
[cljs-bean.core :as bean]
|
||||
[frontend.date :as date]
|
||||
[frontend.config :as config]
|
||||
[frontend.format :as format]
|
||||
[frontend.format.protocol :as protocol]
|
||||
[frontend.storage :as storage]
|
||||
[clojure.string :as string]
|
||||
[cljs-time.local :as tl]
|
||||
[cljs-time.core :as t]
|
||||
[cljs-time.coerce :as tc]))
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
[frontend.format :as format]
|
||||
[frontend.format.block :as block]
|
||||
[frontend.image :as image]
|
||||
[cljs-time.local :as tl]
|
||||
[cljs-time.core :as t]
|
||||
[cljs-time.coerce :as tc]
|
||||
[frontend.db :as db]
|
||||
|
@ -423,7 +422,8 @@
|
|||
|
||||
:else
|
||||
value)]
|
||||
(when (not= (string/trim content) (string/trim value)) ; block content changed
|
||||
(cond
|
||||
(not= (string/trim content) (string/trim value)) ; block content changed
|
||||
(let [file (db/entity repo (:db/id file))]
|
||||
(cond
|
||||
;; Page was referenced but no related file
|
||||
|
@ -545,12 +545,16 @@
|
|||
(when (or (seq retract-refs) pre-block?)
|
||||
(ui-handler/re-render-root!))
|
||||
|
||||
;; (when (state/git-auto-push?)
|
||||
;; (repo-handler/push repo nil))
|
||||
)
|
||||
(repo-handler/push-if-auto-enabled! repo))
|
||||
|
||||
:else
|
||||
nil))))))
|
||||
nil))
|
||||
|
||||
(seq (state/get-changed-files))
|
||||
(repo-handler/push-if-auto-enabled! repo)
|
||||
|
||||
:else
|
||||
nil))))
|
||||
|
||||
(defn insert-new-block-aux!
|
||||
[{:block/keys [uuid content meta file dummy? level repo page format properties collapsed?] :as block}
|
||||
|
@ -566,22 +570,22 @@
|
|||
repo (or repo (state/get-current-repo))
|
||||
;; block-has-children? (seq children) ; not working for now
|
||||
block-has-children? (db/block-has-children? repo block)
|
||||
v1 (subs value 0 pos)
|
||||
v2 (string/triml (subs value pos))
|
||||
v1 (string/trim (if with-level? v1 (block/with-levels v1 format block)))
|
||||
v2-level (cond
|
||||
new-level
|
||||
new-level
|
||||
(or block-self? block-has-children?)
|
||||
(inc level)
|
||||
:else
|
||||
level)
|
||||
v2 (if (and v2
|
||||
(re-find (re-pattern (util/format "^[%s]+\\s+" (config/get-block-pattern format))) v2))
|
||||
v2
|
||||
(rebuild-block-content
|
||||
(str (config/default-empty-block format v2-level) " " v2)
|
||||
format))
|
||||
fst-block-text (subs value 0 pos)
|
||||
snd-block-text (string/triml (subs value pos))
|
||||
fst-block-text (string/trim (if with-level? fst-block-text (block/with-levels fst-block-text format block)))
|
||||
snd-block-text-level (cond
|
||||
new-level
|
||||
new-level
|
||||
(or block-self? block-has-children?)
|
||||
(inc level)
|
||||
:else
|
||||
level)
|
||||
snd-block-text (if (and snd-block-text
|
||||
(re-find (re-pattern (util/format "^[%s]+\\s+" (config/get-block-pattern format))) snd-block-text))
|
||||
snd-block-text
|
||||
(rebuild-block-content
|
||||
(str (config/default-empty-block format snd-block-text-level) " " snd-block-text)
|
||||
format))
|
||||
block (with-block-meta repo block)
|
||||
original-id (:block/uuid block)
|
||||
format (:block/format block)
|
||||
|
@ -589,7 +593,7 @@
|
|||
file (db/entity repo (:db/id file))
|
||||
insert-block (fn [block file-path file-content]
|
||||
(let [value (if create-new-block?
|
||||
(str v1 "\n" v2)
|
||||
(str fst-block-text "\n" snd-block-text)
|
||||
value)
|
||||
value (text/re-construct-block-properties block value properties)
|
||||
value (rebuild-block-content value format)
|
||||
|
@ -652,7 +656,7 @@
|
|||
(when ok-handler
|
||||
(let [first-block (first blocks)
|
||||
last-block (last blocks)]
|
||||
(ok-handler [first-block last-block v2]))))))]
|
||||
(ok-handler [first-block last-block snd-block-text]))))))]
|
||||
(cond
|
||||
(and (not file) page)
|
||||
;; TODO: replace with handler.page/create!
|
||||
|
@ -686,7 +690,7 @@
|
|||
(str content
|
||||
(text/remove-level-spaces value (keyword format))
|
||||
"\n"
|
||||
v2))
|
||||
snd-block-text))
|
||||
(git-handler/git-add repo path)
|
||||
(ui-handler/re-render-root!)
|
||||
|
||||
|
@ -1008,7 +1012,8 @@
|
|||
(when top-block?
|
||||
(route-handler/redirect! {:to :page
|
||||
:path-params {:name (:page/name page)}})
|
||||
(ui-handler/re-render-root!))))))
|
||||
(ui-handler/re-render-root!))
|
||||
(repo-handler/push-if-auto-enabled! repo)))))
|
||||
|
||||
(defn remove-block-property!
|
||||
[block-id key]
|
||||
|
@ -1065,7 +1070,7 @@
|
|||
(if (string/starts-with? (string/lower-case line) key)
|
||||
new-line
|
||||
line))
|
||||
(rest lines))]
|
||||
(rest lines))]
|
||||
(->> (cons (first lines) body)
|
||||
(string/join "\n")))
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
[goog.dom :as gdom]
|
||||
[goog.object :as gobj]
|
||||
[frontend.util :as util]
|
||||
[clojure.string :as string]
|
||||
[medley.core :as medley]
|
||||
[frontend.state :as state]
|
||||
[frontend.db :as db]))
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns frontend.handler.external
|
||||
(:require [frontend.external :as external]
|
||||
[frontend.handler.file :as file-handler]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.common :as common-handler]
|
||||
[frontend.state :as state]
|
||||
[frontend.date :as date]
|
||||
[frontend.config :as config]
|
||||
|
@ -9,37 +9,46 @@
|
|||
[frontend.db :as db]))
|
||||
|
||||
(defn index-files!
|
||||
[repo files error-files]
|
||||
(doseq [file files]
|
||||
(let [title (:title file)
|
||||
journal? (date/valid-journal-title? title)]
|
||||
(try
|
||||
(when-let [text (:text file)]
|
||||
(let [path (str (if journal?
|
||||
config/default-journals-directory
|
||||
config/default-pages-directory)
|
||||
"/"
|
||||
(if journal?
|
||||
(date/journal-title->default title)
|
||||
(string/replace title "/" "-"))
|
||||
".md")]
|
||||
(file-handler/alter-file repo path text {})
|
||||
(when journal?
|
||||
(let [page-name (string/lower-case title)]
|
||||
(db/transact! repo
|
||||
[{:page/name page-name
|
||||
:page/journal? true
|
||||
:page/journal-day (date/journal-title->int title)}])))))
|
||||
(catch js/Error e
|
||||
(swap! error-files conj file))))))
|
||||
[repo files git-add-cb]
|
||||
(let [titles (->> files
|
||||
(map :title)
|
||||
(map :text)
|
||||
(remove nil?))
|
||||
files (map (fn [file]
|
||||
(let [title (:title file)
|
||||
journal? (date/valid-journal-title? title)]
|
||||
(when-let [text (:text file)]
|
||||
(let [path (str (if journal?
|
||||
config/default-journals-directory
|
||||
config/default-pages-directory)
|
||||
"/"
|
||||
(if journal?
|
||||
(date/journal-title->default title)
|
||||
(string/replace title "/" "-"))
|
||||
".md")]
|
||||
[path text]))))
|
||||
files)]
|
||||
;; TODO: git add is quite slow
|
||||
(file-handler/alter-files repo files {:add-history? false
|
||||
:update-status? false
|
||||
:reset? true
|
||||
:git-add-cb git-add-cb})
|
||||
(let [journal-pages-tx (let [titles (filter date/valid-journal-title? titles)]
|
||||
(map
|
||||
(fn [title]
|
||||
(let [page-name (string/lower-case title)]
|
||||
{:page/name page-name
|
||||
:page/journal? true
|
||||
:page/journal-day (date/journal-title->int title)}))
|
||||
titles))]
|
||||
(when (seq journal-pages-tx)
|
||||
(db/transact! repo journal-pages-tx)))))
|
||||
|
||||
;; TODO: compute the dependencies
|
||||
;; TODO: Should it merge the roam daily notes with the month journals
|
||||
(defn import-from-roam-json!
|
||||
[data]
|
||||
[data finished-ok-handler]
|
||||
(when-let [repo (state/get-current-repo)]
|
||||
(let [files (external/to-markdown-files :roam data {})
|
||||
error-files (atom #{})]
|
||||
(index-files! repo files error-files)
|
||||
(when (seq @error-files)
|
||||
(index-files! repo @error-files (atom nil))))))
|
||||
(let [files (external/to-markdown-files :roam data {})]
|
||||
(index-files! repo files
|
||||
(fn []
|
||||
(common-handler/check-changed-files-status)
|
||||
(finished-ok-handler))))))
|
||||
|
|
|
@ -6,15 +6,12 @@
|
|||
[frontend.state :as state]
|
||||
[frontend.db :as db]
|
||||
[frontend.git :as git]
|
||||
[frontend.handler.common :as common-handler]
|
||||
[frontend.handler.git :as git-handler]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[datascript.core :as d]
|
||||
[frontend.github :as github]
|
||||
[cljs-bean.core :as bean]
|
||||
[frontend.date :as date]
|
||||
[frontend.config :as config]
|
||||
[frontend.format :as format]
|
||||
[frontend.format.protocol :as protocol]
|
||||
[clojure.string :as string]
|
||||
[frontend.history :as history]
|
||||
[frontend.handler.project :as project-handler]))
|
||||
|
@ -107,10 +104,11 @@
|
|||
(js/console.dir error))))))
|
||||
|
||||
(defn alter-file
|
||||
[repo path content {:keys [reset? re-render-root? add-history?]
|
||||
[repo path content {:keys [reset? re-render-root? add-history? update-status?]
|
||||
:or {reset? true
|
||||
re-render-root? false
|
||||
add-history? true}}]
|
||||
add-history? true
|
||||
update-status? false}}]
|
||||
(let [original-content (db/get-file-no-sub repo path)]
|
||||
(if reset?
|
||||
(db/reset-file! repo path content)
|
||||
|
@ -118,7 +116,7 @@
|
|||
(util/p-handle
|
||||
(fs/write-file (util/get-repo-dir repo) path content)
|
||||
(fn [_]
|
||||
(git-handler/git-add repo path)
|
||||
(git-handler/git-add repo path update-status?)
|
||||
(when (= path (str config/app-name "/" config/config-file))
|
||||
(restore-config! repo true))
|
||||
(when (= path (str config/app-name "/" config/custom-css-file))
|
||||
|
@ -131,26 +129,48 @@
|
|||
(js/console.error error)))))
|
||||
|
||||
(defn alter-files
|
||||
[repo files]
|
||||
(let [files-tx (mapv (fn [[path content]]
|
||||
(let [original-content (db/get-file-no-sub repo path)]
|
||||
[path original-content content])) files)]
|
||||
(-> (p/all
|
||||
(doall
|
||||
(map
|
||||
(fn [[path content]]
|
||||
(db/set-file-content! repo path content)
|
||||
(util/p-handle
|
||||
(fs/write-file (util/get-repo-dir repo) path content)
|
||||
(fn [_]
|
||||
(git-handler/git-add repo path))
|
||||
(fn [error]
|
||||
(println "Write file failed, path: " path ", content: " content)
|
||||
(js/console.error error))))
|
||||
files)))
|
||||
(p/then (fn [_result]
|
||||
(ui-handler/re-render-file!)
|
||||
(history/add-history! repo files-tx))))))
|
||||
([repo files]
|
||||
(alter-files repo files {}))
|
||||
([repo files {:keys [add-history? update-status? git-add-cb reset?]
|
||||
:or {add-history? true
|
||||
update-status? true
|
||||
reset? false}}]
|
||||
(let [files-tx (mapv (fn [[path content]]
|
||||
(let [original-content (db/get-file-no-sub repo path)]
|
||||
[path original-content content])) files)
|
||||
write-file-f (fn [[path content]]
|
||||
(if reset?
|
||||
(db/reset-file! repo path content)
|
||||
(db/set-file-content! repo path content))
|
||||
(util/p-handle
|
||||
(fs/write-file (util/get-repo-dir repo) path content)
|
||||
(fn [_])
|
||||
(fn [error]
|
||||
(println "Write file failed, path: " path ", content: " content)
|
||||
(js/console.error error))))
|
||||
git-add-f (fn [_result]
|
||||
(let [add-helper
|
||||
(fn []
|
||||
(doall
|
||||
(map
|
||||
(fn [[path content]]
|
||||
(git-handler/git-add repo path update-status?))
|
||||
files)))]
|
||||
(-> (p/all (add-helper))
|
||||
(p/then (fn [_]
|
||||
(when git-add-cb
|
||||
(git-add-cb))))
|
||||
(p/catch (fn [error]
|
||||
(println "Git add failed:")
|
||||
(js/console.error error)))))
|
||||
(ui-handler/re-render-file!)
|
||||
(when add-history?
|
||||
(history/add-history! repo files-tx)))]
|
||||
(-> (p/all (doall (map write-file-f files)))
|
||||
(p/then git-add-f)
|
||||
(p/catch (fn [error]
|
||||
(println "Alter files failed:")
|
||||
(js/console.error error)))))))
|
||||
|
||||
(defn remove-file!
|
||||
[repo file]
|
||||
|
@ -161,8 +181,8 @@
|
|||
"/"
|
||||
file)
|
||||
nil)]
|
||||
(state/git-add! repo (str "- " file))
|
||||
(when-let [file (db/entity repo [:file/path file])]
|
||||
(common-handler/check-changed-files-status)
|
||||
(let [file-id (:db/id file)
|
||||
page-id (db/get-file-page-id (:file/path file))
|
||||
tx-data (map
|
||||
|
|
|
@ -1,24 +1,16 @@
|
|||
(ns frontend.handler.git
|
||||
(:refer-clojure :exclude [clone load-file])
|
||||
(:require [frontend.util :as util :refer-macros [profile]]
|
||||
[frontend.fs :as fs]
|
||||
[promesa.core :as p]
|
||||
[frontend.state :as state]
|
||||
[frontend.db :as db]
|
||||
[frontend.git :as git]
|
||||
[frontend.github :as github]
|
||||
[cljs-bean.core :as bean]
|
||||
[frontend.date :as date]
|
||||
[frontend.config :as config]
|
||||
[frontend.format :as format]
|
||||
[frontend.format.protocol :as protocol]
|
||||
[goog.object :as gobj]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[clojure.string :as string]
|
||||
[cljs-time.local :as tl]
|
||||
[cljs-time.core :as t]
|
||||
[cljs-time.coerce :as tc]))
|
||||
[frontend.handler.common :as common-handler]
|
||||
[cljs-time.local :as tl]))
|
||||
|
||||
(defn- set-latest-commit!
|
||||
[repo-url hash]
|
||||
|
@ -43,10 +35,15 @@
|
|||
(db/set-key-value repo-url :git/error (if value (str value))))
|
||||
|
||||
(defn git-add
|
||||
[repo-url file]
|
||||
(p/let [result (git/add repo-url file)]
|
||||
(state/git-add! repo-url file)))
|
||||
|
||||
([repo-url file]
|
||||
(git-add repo-url file true))
|
||||
([repo-url file update-status?]
|
||||
(-> (p/let [result (git/add repo-url file)]
|
||||
(when update-status?
|
||||
(common-handler/check-changed-files-status)))
|
||||
(p/catch (fn [error]
|
||||
(println "git add '" file "' failed: " error)
|
||||
(js/console.error error))))))
|
||||
(defn get-latest-commit
|
||||
([repo-url handler]
|
||||
(get-latest-commit repo-url handler 1))
|
||||
|
@ -86,7 +83,6 @@
|
|||
(state/get-github-token repo)
|
||||
true)]
|
||||
(reset! pushing? false)
|
||||
(state/clear-changed-files! repo)
|
||||
(notification/clear! nil)
|
||||
(route-handler/redirect! {:to :home})))))
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
(ns frontend.handler.history
|
||||
(:require [frontend.state :as state]
|
||||
[frontend.history :as history]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.file :as file]))
|
||||
|
||||
(defn- default-undo
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
[frontend.ui :as ui]
|
||||
[promesa.core :as p]
|
||||
[frontend.util :as util]
|
||||
[frontend.git :as git]
|
||||
[clojure.string :as str]
|
||||
[frontend.date :as date]
|
||||
[frontend.config :as config]
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
[frontend.util :as util :refer-macros [profile]]
|
||||
[frontend.tools.html-export :as html-export]
|
||||
[frontend.config :as config]
|
||||
[frontend.handler.common :as common-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.file :as file-handler]
|
||||
[frontend.handler.repo :as repo-handler]
|
||||
[frontend.handler.git :as git-handler]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.handler.project :as project-handler]
|
||||
|
@ -250,11 +252,12 @@
|
|||
;; remove file
|
||||
(->
|
||||
(p/let [_ (git/remove-file repo file-path)
|
||||
_result (fs/unlink (str (util/get-repo-dir repo)
|
||||
"/"
|
||||
file-path)
|
||||
nil)]
|
||||
(state/git-add! repo (str "- " file-path)))
|
||||
_ (fs/unlink (str (util/get-repo-dir repo)
|
||||
"/"
|
||||
file-path)
|
||||
nil)]
|
||||
(common-handler/check-changed-files-status)
|
||||
(repo-handler/push-if-auto-enabled! repo))
|
||||
(p/catch (fn [err]
|
||||
(prn "error: " err))))))
|
||||
|
||||
|
@ -300,6 +303,8 @@
|
|||
|
||||
(notification/show! "Page renamed successfully!" :success)
|
||||
|
||||
(repo-handler/push-if-auto-enabled! repo)
|
||||
|
||||
(ui-handler/re-render-root!)))))
|
||||
|
||||
(defn rename-when-alter-title-propertiy!
|
||||
|
|
|
@ -3,28 +3,22 @@
|
|||
(:require [frontend.util :as util :refer-macros [profile]]
|
||||
[frontend.fs :as fs]
|
||||
[promesa.core :as p]
|
||||
[datascript.core :as d]
|
||||
[frontend.state :as state]
|
||||
[frontend.db :as db]
|
||||
[frontend.git :as git]
|
||||
[frontend.github :as github]
|
||||
[cljs-bean.core :as bean]
|
||||
[frontend.date :as date]
|
||||
[frontend.config :as config]
|
||||
[frontend.format :as format]
|
||||
[frontend.format.protocol :as protocol]
|
||||
[goog.object :as gobj]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.git :as git-handler]
|
||||
[frontend.handler.file :as file-handler]
|
||||
[frontend.handler.migration :as migration-handler]
|
||||
[frontend.handler.project :as project-handler]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.user :as user-handler]
|
||||
[frontend.handler.common :as common-handler]
|
||||
[frontend.ui :as ui]
|
||||
[cljs-time.local :as tl]
|
||||
[cljs-time.core :as t]
|
||||
[cljs.reader :as reader]
|
||||
[clojure.string :as string]
|
||||
[frontend.dicts :as dicts]
|
||||
|
@ -103,18 +97,6 @@
|
|||
:error
|
||||
false))
|
||||
|
||||
(defn show-diff-error!
|
||||
[_repo-url]
|
||||
(notification/show!
|
||||
[:p
|
||||
[:span.text-gray-700.font-bold.mr-2
|
||||
"Please resolve the diffs if any."]
|
||||
(ui/button
|
||||
"Go to diff"
|
||||
:href "/diff")]
|
||||
:error
|
||||
false))
|
||||
|
||||
(defn get-new-token
|
||||
[repo]
|
||||
(when-let [installation-id (-> (filter
|
||||
|
@ -317,88 +299,90 @@
|
|||
(db/get-conn repo-url true)
|
||||
(db/cloned? repo-url)
|
||||
token)
|
||||
(let [status (db/get-key-value repo-url :git/status)]
|
||||
(when (or
|
||||
force-pull?
|
||||
(and
|
||||
;; (not= status :push-failed)
|
||||
(not= status :pushing)
|
||||
(empty? (state/get-changed-files repo-url))
|
||||
(not (state/get-edit-input-id))
|
||||
(not (state/in-draw-mode?))))
|
||||
(git-handler/set-git-status! repo-url :pulling)
|
||||
(let [latest-commit (db/get-key-value repo-url :git/latest-commit)]
|
||||
(->
|
||||
(p/let [result (git/fetch repo-url token)]
|
||||
(let [{:keys [fetchHead]} (bean/->clj result)]
|
||||
(when fetchHead
|
||||
(git-handler/set-remote-latest-commit! repo-url fetchHead))
|
||||
(-> (git/merge repo-url)
|
||||
(p/then (fn [result]
|
||||
(-> (git/checkout repo-url)
|
||||
(p/then (fn [result]
|
||||
(git-handler/set-git-status! repo-url nil)
|
||||
(git-handler/set-git-last-pulled-at! repo-url)
|
||||
(when (and latest-commit fetchHead
|
||||
(not= latest-commit fetchHead))
|
||||
(p/let [diffs (git/get-diffs repo-url latest-commit fetchHead)]
|
||||
(when (seq diffs)
|
||||
(load-db-and-journals! repo-url diffs false)
|
||||
(git-handler/set-latest-commit! repo-url fetchHead)
|
||||
(when (seq (state/get-changed-files repo-url))
|
||||
;; FIXME: no need to create a new commit
|
||||
(push repo-url {:diff-push? true})))))))
|
||||
(p/catch (fn [error]
|
||||
(git-handler/set-git-status! repo-url :checkout-failed)
|
||||
(git-handler/set-git-error! repo-url error))))))
|
||||
(p/catch (fn [error]
|
||||
(git-handler/set-git-status! repo-url :merge-failed)
|
||||
(git-handler/set-git-error! repo-url error)
|
||||
(notification/show!
|
||||
[:p.content
|
||||
"Failed to merge, please "
|
||||
[:span.text-gray-700.font-bold
|
||||
"resolve any diffs first."]]
|
||||
:error)
|
||||
(route-handler/redirect! {:to :diff}))))))
|
||||
(p/catch (fn [error]
|
||||
(println "Pull error:" (str error))
|
||||
(js/console.error error)
|
||||
;; token might be expired, request new token
|
||||
(p/let [files (js/window.workerThread.getChangedFiles (util/get-repo-dir repo-url))]
|
||||
(when (empty? files)
|
||||
(let [status (db/get-key-value repo-url :git/status)]
|
||||
(when (or
|
||||
force-pull?
|
||||
(and
|
||||
;; (not= status :push-failed)
|
||||
(not= status :pushing)
|
||||
(not (state/get-edit-input-id))
|
||||
(not (state/in-draw-mode?))))
|
||||
(git-handler/set-git-status! repo-url :pulling)
|
||||
(let [latest-commit (db/get-key-value repo-url :git/latest-commit)]
|
||||
(->
|
||||
(p/let [result (git/fetch repo-url token)]
|
||||
(let [{:keys [fetchHead]} (bean/->clj result)]
|
||||
(when fetchHead
|
||||
(git-handler/set-remote-latest-commit! repo-url fetchHead))
|
||||
(-> (git/merge repo-url)
|
||||
(p/then (fn [result]
|
||||
(-> (git/checkout repo-url)
|
||||
(p/then (fn [result]
|
||||
(git-handler/set-git-status! repo-url nil)
|
||||
(git-handler/set-git-last-pulled-at! repo-url)
|
||||
(when (and latest-commit fetchHead
|
||||
(not= latest-commit fetchHead))
|
||||
(p/let [diffs (git/get-diffs repo-url latest-commit fetchHead)]
|
||||
(when (seq diffs)
|
||||
(load-db-and-journals! repo-url diffs false)
|
||||
(git-handler/set-latest-commit! repo-url fetchHead))))))
|
||||
(p/catch (fn [error]
|
||||
(git-handler/set-git-status! repo-url :checkout-failed)
|
||||
(git-handler/set-git-error! repo-url error))))
|
||||
(state/set-changed-files! repo-url nil)))
|
||||
(p/catch (fn [error]
|
||||
(println "Git pull error:")
|
||||
(js/console.error error)
|
||||
(git-handler/set-git-status! repo-url :merge-failed)
|
||||
(git-handler/set-git-error! repo-url error)
|
||||
(git-handler/get-latest-commit
|
||||
repo-url
|
||||
(fn [commit]
|
||||
(let [local-oid (gobj/get commit "oid")
|
||||
remote-oid (db/get-key-value repo-url
|
||||
:git/remote-latest-commit)]
|
||||
(p/let [result (git/get-local-diffs repo-url local-oid remote-oid)]
|
||||
(if (seq result)
|
||||
(do
|
||||
(notification/show!
|
||||
[:p.content
|
||||
"Failed to merge, please "
|
||||
[:span.text-gray-700.font-bold
|
||||
"resolve any diffs first."]]
|
||||
:error)
|
||||
(route-handler/redirect! {:to :diff}))
|
||||
(push repo-url {:commit-push? true
|
||||
:force? true
|
||||
:commit-message "Merge push without diffed files"})))))))))))
|
||||
(p/catch (fn [error]
|
||||
(println "Pull error:" (str error))
|
||||
(js/console.error error)
|
||||
;; token might be expired, request new token
|
||||
|
||||
(cond
|
||||
(and (or (string/includes? (str error) "401")
|
||||
(string/includes? (str error) "404"))
|
||||
(not fallback?))
|
||||
(request-app-tokens!
|
||||
(fn []
|
||||
(pull repo-url (state/get-github-token repo-url) {:fallback? true}))
|
||||
nil)
|
||||
(cond
|
||||
(and (or (string/includes? (str error) "401")
|
||||
(string/includes? (str error) "404"))
|
||||
(not fallback?))
|
||||
(request-app-tokens!
|
||||
(fn []
|
||||
(pull repo-url (state/get-github-token repo-url) {:fallback? true}))
|
||||
nil)
|
||||
|
||||
(or (string/includes? (str error) "401")
|
||||
(string/includes? (str error) "404"))
|
||||
(show-install-error! repo-url (util/format "Failed to fetch %s." repo-url))
|
||||
(or (string/includes? (str error) "401")
|
||||
(string/includes? (str error) "404"))
|
||||
(show-install-error! repo-url (util/format "Failed to fetch %s." repo-url))
|
||||
|
||||
:else
|
||||
nil)))))))))
|
||||
|
||||
(defn check-changed-files-status
|
||||
[f]
|
||||
(when (gobj/get js/window.workerThread "getChangedFiles")
|
||||
(->
|
||||
(p/let [files (js/window.workerThread.getChangedFiles (util/get-repo-dir (state/get-current-repo)))]
|
||||
(let [files (bean/->clj files)]
|
||||
(when (empty? files)
|
||||
;; FIXME: getChangedFiles not return right result
|
||||
(state/reset-changed-files! files))))
|
||||
(p/catch (fn [error]
|
||||
(js/console.dir error))))))
|
||||
:else
|
||||
nil)))))))))))
|
||||
|
||||
(defn push
|
||||
[repo-url {:keys [commit-message fallback? diff-push? force?]
|
||||
[repo-url {:keys [commit-message fallback? diff-push? commit-push? force?]
|
||||
:or {commit-message "Logseq auto save"
|
||||
fallback? false
|
||||
diff-push? false
|
||||
commit-push? false
|
||||
force? false}}]
|
||||
(let [status (db/get-key-value repo-url :git/status)]
|
||||
(when (and
|
||||
|
@ -406,10 +390,8 @@
|
|||
(not (state/get-edit-input-id)))
|
||||
(-> (p/let [files (js/window.workerThread.getChangedFiles (util/get-repo-dir (state/get-current-repo)))]
|
||||
(when (or
|
||||
force?
|
||||
(and
|
||||
(seq (state/get-changed-files repo-url))
|
||||
(seq files))
|
||||
commit-push?
|
||||
(seq files)
|
||||
fallback?
|
||||
diff-push?)
|
||||
;; auto commit if there are any un-committed changes
|
||||
|
@ -421,13 +403,15 @@
|
|||
(git-handler/set-git-status! repo-url :pushing)
|
||||
(when-let [token (state/get-github-token repo-url)]
|
||||
(util/p-handle
|
||||
(git/push repo-url token)
|
||||
(git/push repo-url token force?)
|
||||
(fn [result]
|
||||
(git-handler/set-git-status! repo-url nil)
|
||||
(git-handler/set-git-error! repo-url nil)
|
||||
(state/clear-changed-files! repo-url))
|
||||
(state/set-changed-files! repo-url nil))
|
||||
(fn [error]
|
||||
(println "Git push error: ")
|
||||
(js/console.error error)
|
||||
(common-handler/check-changed-files-status)
|
||||
(let [permission? (or (string/includes? (str error) "401")
|
||||
(string/includes? (str error) "404"))]
|
||||
(cond
|
||||
|
@ -450,6 +434,11 @@
|
|||
(println "Git push error: ")
|
||||
(js/console.dir error)))))))
|
||||
|
||||
(defn push-if-auto-enabled!
|
||||
[repo]
|
||||
(when (state/git-auto-push?)
|
||||
(push repo nil)))
|
||||
|
||||
(defn pull-current-repo
|
||||
[]
|
||||
(when-let [repo (state/get-current-repo)]
|
||||
|
@ -519,8 +508,7 @@
|
|||
(db/remove-db! url)
|
||||
(db/remove-files-db! url)
|
||||
(fs/rmdir (util/get-repo-dir url))
|
||||
(state/delete-repo! repo)
|
||||
(state/clear-changed-files! repo))
|
||||
(state/delete-repo! repo))
|
||||
(fn [error]
|
||||
(prn "Delete repo failed, error: " error))))
|
||||
|
||||
|
@ -617,7 +605,6 @@
|
|||
[{:keys [id url] :as repo}]
|
||||
(db/remove-conn! url)
|
||||
(db/clear-query-state!)
|
||||
(state/clear-changed-files! url)
|
||||
(-> (p/let [_ (db/remove-db! url)
|
||||
_ (db/remove-files-db! url)]
|
||||
(fs/rmdir (util/get-repo-dir url)))
|
||||
|
@ -631,7 +618,7 @@
|
|||
(when-let [repo (state/get-current-repo)]
|
||||
(push repo {:commit-message commit-message
|
||||
:fallback? false
|
||||
:force? true})))
|
||||
:commit-push? true})))
|
||||
|
||||
(defn read-repair-journals!
|
||||
[repo-url]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
(ns frontend.history
|
||||
(:require [frontend.db :as db]))
|
||||
(ns frontend.history)
|
||||
|
||||
;; Undo && Redo that works with files
|
||||
;; TODO:
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns frontend.image
|
||||
(:require [goog.object :as gobj]
|
||||
[frontend.blob :as blob]
|
||||
["/frontend/exif" :as exif]
|
||||
[frontend.util :as util]
|
||||
[frontend.date :as date]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
(ns frontend.keyboard
|
||||
(:require [goog.events :as events]
|
||||
[goog.ui.KeyboardShortcutHandler.EventType :as EventType]
|
||||
[goog.events.KeyCodes :as KeyCodes])
|
||||
[goog.ui.KeyboardShortcutHandler.EventType :as EventType])
|
||||
(:import [goog.ui KeyboardShortcutHandler]))
|
||||
|
||||
;; Copy from https://github.com/tonsky/rum/blob/gh-pages/doc/useful-mixins.md#keyboard-shortcut
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.state :as state]
|
||||
[goog.events.KeyCodes :as codes]
|
||||
[frontend.util :as util]
|
||||
[medley.core :as medley]
|
||||
["mousetrap" :as mousetrap]
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
(:require [rum.core :as rum]
|
||||
[frontend.state :as state]
|
||||
[frontend.components.sidebar :as sidebar]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.context.i18n :as i18n]))
|
||||
|
||||
(rum/defc route-view
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
[frontend.handler.route :as route]
|
||||
[frontend.page :as page]
|
||||
[frontend.routes :as routes]
|
||||
[frontend.util :as util]
|
||||
[reitit.frontend :as rf]
|
||||
[reitit.frontend.easy :as rfe]
|
||||
[cljs.reader :as reader]))
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
(ns frontend.publishing.html
|
||||
(:require-macros [hiccups.core])
|
||||
(:require [frontend.config :as config]
|
||||
[frontend.state :as state]
|
||||
(:require [frontend.state :as state]
|
||||
[hiccups.runtime]))
|
||||
|
||||
(defn publishing-html
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
(ns frontend.routes
|
||||
(:require [frontend.components.home :as home]
|
||||
[frontend.components.repo :as repo]
|
||||
[frontend.components.sidebar :as sidebar]
|
||||
[frontend.components.file :as file]
|
||||
[frontend.components.page :as page]
|
||||
[frontend.components.diff :as diff]
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
(:require [frontend.db :as db]
|
||||
[frontend.config :as config]
|
||||
[frontend.state :as state]
|
||||
[medley.core :as medley]
|
||||
[frontend.util :as util]
|
||||
[cljs-bean.core :as bean]
|
||||
[clojure.string :as string]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns frontend.security
|
||||
(:require [clojure.walk :as walk]
|
||||
[clojure.string :as string]))
|
||||
(:require [clojure.walk :as walk]))
|
||||
|
||||
;; To prevent from cross-site scripting vulnerability, we should add security checks for both hiccup and raw html.
|
||||
;; Hiccup: [:a {:href "javascript:alert('hei')"} "click me"]
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
[goog.object :as gobj]
|
||||
[goog.dom :as gdom]
|
||||
[dommy.core :as dom]
|
||||
[cljs-time.core :as t]
|
||||
[cljs-time.coerce :as tc]
|
||||
[clojure.core.async :as async]))
|
||||
[cljs.core.async :as async]))
|
||||
|
||||
(defonce state
|
||||
(atom
|
||||
|
@ -23,9 +21,7 @@
|
|||
:repo/loading-files? nil
|
||||
:repo/importing-to-db? nil
|
||||
:repo/sync-status {}
|
||||
:repo/changed-files (or
|
||||
(storage/get "git-changed-files")
|
||||
{})
|
||||
:repo/changed-files nil
|
||||
:indexeddb/support? true
|
||||
;; TODO: save in local storage so that if :changed? is true when user
|
||||
;; reloads the browser, the app should re-index the repo (another way
|
||||
|
@ -718,27 +714,6 @@
|
|||
[value]
|
||||
(set-state! :indexeddb/support? value))
|
||||
|
||||
(defn git-add!
|
||||
[repo file]
|
||||
(update-state! [:repo/changed-files repo]
|
||||
(fn [files] (distinct (conj files file))))
|
||||
(storage/set "git-changed-files" (:repo/changed-files @state)))
|
||||
|
||||
(defn reset-changed-files!
|
||||
[files]
|
||||
(when-let [repo (get-current-repo)]
|
||||
(swap! state assoc-in [:repo/changed-files repo] files)))
|
||||
|
||||
(defn clear-changed-files!
|
||||
[repo]
|
||||
(set-state! [:repo/changed-files repo] nil)
|
||||
(set-state! [:git/status repo] nil)
|
||||
(storage/set "git-changed-files" (:repo/changed-files @state)))
|
||||
|
||||
(defn get-changed-files
|
||||
[repo]
|
||||
(get-in @state [:repo/changed-files repo]))
|
||||
|
||||
(defn set-modal!
|
||||
[modal-panel-content]
|
||||
(swap! state assoc
|
||||
|
@ -838,3 +813,11 @@
|
|||
(defn git-auto-push?
|
||||
[]
|
||||
(true? (:git-auto-push (get-config (get-current-repo)))))
|
||||
|
||||
(defn set-changed-files!
|
||||
[repo changed-files]
|
||||
(set-state! [:repo/changed-files repo] changed-files))
|
||||
|
||||
(defn get-changed-files
|
||||
[]
|
||||
(get-in @state [:repo/changed-files (get-current-repo)]))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns frontend.tools.html-export
|
||||
(:require-macros [hiccups.core :as hiccups :refer [html]])
|
||||
(:require [frontend.db :as db]
|
||||
[frontend.components.hiccup :as hiccup]
|
||||
[frontend.components.block :as block]
|
||||
[frontend.extensions.slide :as slide]
|
||||
[hiccups.runtime :as hiccupsrt]
|
||||
[clojure.walk :as walk]
|
||||
|
@ -18,13 +18,13 @@
|
|||
(defn- build-block
|
||||
[config block]
|
||||
(let [body (:block/body block)
|
||||
block (hiccup/build-block-part config block)]
|
||||
block (block/build-block-part config block)]
|
||||
[:div.block
|
||||
block
|
||||
(when (seq body)
|
||||
(for [child body]
|
||||
(do
|
||||
(hiccup/block-cp config child))))]))
|
||||
(block/markup-element-cp config child))))]))
|
||||
|
||||
(defn export-page
|
||||
[page-name blocks show-notification!]
|
||||
|
@ -36,12 +36,12 @@
|
|||
(if (seq blocks)
|
||||
(let [config {:html-export? true :slide? slide?}
|
||||
hiccup (if slide?
|
||||
(let [sections (hiccup/build-slide-sections blocks
|
||||
(merge
|
||||
config
|
||||
{:id "slide"
|
||||
:start-level 2})
|
||||
build-block)]
|
||||
(let [sections (block/build-slide-sections blocks
|
||||
(merge
|
||||
config
|
||||
{:id "slide"
|
||||
:start-level 2})
|
||||
build-block)]
|
||||
(slide/slide-content false "" sections))
|
||||
[:div.page
|
||||
(for [block blocks]
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
(ns frontend.version)
|
||||
|
||||
(defonce version "0.0.4.3-2")
|
||||
(defonce version "0.0.4.3-5")
|
||||
|
|
Loading…
Reference in New Issue