mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
Better org display
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,5 @@
|
||||
node_modules/
|
||||
public/js
|
||||
public/static/js
|
||||
|
||||
/.cpcache
|
||||
/target
|
||||
|
||||
7
now.json
7
now.json
@@ -12,8 +12,9 @@
|
||||
{ "src": "/public/**", "use": "@now/static"}
|
||||
],
|
||||
"routes": [
|
||||
{ "src": "/api(.*)", "dest": "api/index.js" },
|
||||
{ "src": "/(.+js|.+css|.+png|.+svg|.+jpg|.+ico|robots.txt|.+map)", "dest": "/public/$1" },
|
||||
{ "src": "/(.*)", "dest": "/public/index.html" }
|
||||
{ "src": "/api(.*)", "dest": "api/index.js" },
|
||||
{ "src": "/static/(.*)", "dest": "/public/static/$1" },
|
||||
{ "src": "/(.+js|.+css|.+png|.+svg|.+jpg|.+ico|robots.txt|.+map)", "dest": "/public/$1" },
|
||||
{ "src": "/(.*)", "dest": "/public/index.html" }
|
||||
]
|
||||
}
|
||||
|
||||
6
web/.gitignore
vendored
6
web/.gitignore
vendored
@@ -1,7 +1,7 @@
|
||||
node_modules/
|
||||
public/js/cljs-runtime
|
||||
public/js/main.js
|
||||
public/js/manifest.edn
|
||||
public/static/js/cljs-runtime
|
||||
public/static/js/main.js
|
||||
public/static/js/manifest.edn
|
||||
|
||||
/.cpcache
|
||||
/target
|
||||
|
||||
@@ -9,15 +9,13 @@
|
||||
"watch": "npx shadow-cljs watch app",
|
||||
"release": "npx shadow-cljs release app",
|
||||
"server": "npx shadow-cljs server;",
|
||||
"clean": "rm -rf target; rm -rf public/js/compiled; rm -rf public/js/cljs-runtime"
|
||||
"clean": "rm -rf target; rm -rf public/static/js/compiled; rm -rf public/static/js/cljs-runtime"
|
||||
},
|
||||
"dependencies": {
|
||||
"@material-ui/core": "^4.7.2",
|
||||
"@material-ui/icons": "^4.5.1",
|
||||
"browserfs": "^1.4.3",
|
||||
"dev": "^0.1.3",
|
||||
"isomorphic-git": "^1.1.2",
|
||||
"mldoc_org": "^0.1.8",
|
||||
"mldoc_org": "^0.2.0",
|
||||
"purgecss": "^2.1.0",
|
||||
"react": "^16.12.0",
|
||||
"react-dom": "^16.12.0",
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no" name="viewport">
|
||||
<link href="/css/tailwind.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="/css/org.css" rel="stylesheet">
|
||||
<link href="/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link href="/static/css/tailwind.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="/static/css/org.css" rel="stylesheet">
|
||||
<link href="/static/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet">
|
||||
<link href="/css/highlight.css" rel="stylesheet">
|
||||
<link href="/static/css/highlight.css" rel="stylesheet">
|
||||
<title>Gitnotes</title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -20,7 +20,7 @@
|
||||
git.plugins.set('fs', window.fs);
|
||||
window.pfs = window.fs.promises;
|
||||
</script>
|
||||
<script src="/js/main.js"></script>
|
||||
<script src="/js/highlight.pack.js"></script>
|
||||
<script src="/static/js/main.js"></script>
|
||||
<script src="/static/js/highlight.pack.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -30,13 +30,10 @@
|
||||
font-size: medium;
|
||||
font-weight: bold;
|
||||
margin-top:0; }
|
||||
.todo { font-family: monospace; color: red; }
|
||||
.done { font-family: monospace; color: green; }
|
||||
.priority { font-family: monospace; color: orange; }
|
||||
.tag { background-color: #eee; font-family: monospace;
|
||||
padding: 2px; font-size: 80%; font-weight: normal; }
|
||||
.timestamp { color: #bebebe; }
|
||||
.timestamp-kwd { color: #5f9ea0; }
|
||||
.timestamp { color: #bebebe; margin-left: 6px; }
|
||||
.timestamp-kwd { color: #5f9ea0; margin-left: 6px; }
|
||||
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
|
||||
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
|
||||
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
|
||||
|
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 396 KiB After Width: | Height: | Size: 396 KiB |
1
web/public/static/js/manifest.edn
Normal file
1
web/public/static/js/manifest.edn
Normal file
File diff suppressed because one or more lines are too long
@@ -20,13 +20,16 @@
|
||||
{:target :browser
|
||||
:modules {:main {:init-fn frontend.core/init}}
|
||||
|
||||
:output-dir "public/static/js"
|
||||
:asset-path "/static/js"
|
||||
|
||||
:compiler-options {:infer-externs :auto
|
||||
:externs ["datascript/externs.js"]}
|
||||
;; TODO: purge-css not working properly
|
||||
;; :build-hooks [(shadow.hooks/purge-css
|
||||
;; {:css-source "node_modules/tailwindcss/dist/tailwind.min.css"
|
||||
;; :js-globs ["public/js/*.js"]
|
||||
;; :public-dir "public/css"})]
|
||||
;; :js-globs ["public/static/js/*.js"]
|
||||
;; :public-dir "public/static/css"})]
|
||||
:devtools
|
||||
;; before live-reloading any code call this function
|
||||
{:before-load frontend.core/stop
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
(sidebar/sidebar
|
||||
(if (and suffix (contains? #{"md" "markdown" "org"} suffix))
|
||||
[:div#content.flex.justify-center
|
||||
[:div.m-6.flex-1 {:style {:max-width 900}}
|
||||
[:a {:style {:float "right"}
|
||||
:href (str "/file/" encoded-path "/edit")}
|
||||
[:div.m-6.flex-1 {:style {:position "relative"
|
||||
:max-width 800}}
|
||||
[:a {:href (str "/file/" encoded-path "/edit")}
|
||||
"edit"]
|
||||
(if content
|
||||
(util/raw-html (format/to-html content suffix))
|
||||
@@ -75,5 +75,4 @@
|
||||
(let [commit-message (if (string/blank? @commit-message)
|
||||
(str "Update " path)
|
||||
@commit-message)]
|
||||
(prn "commit!")
|
||||
(handler/alter-file path commit-message @content)))))]])))
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
(for [url repos]
|
||||
[:li {:key url}
|
||||
[:button {:on-click (fn []
|
||||
(prn "set current repo: " url)
|
||||
;; (handler/set-current-repo url)
|
||||
)}
|
||||
(string/replace url "https://github.com/" "")]])]])))
|
||||
@@ -27,8 +26,8 @@
|
||||
[:div
|
||||
[:label.block.text-sm.font-medium.leading-5.text-gray-700
|
||||
{:for "Repo"}
|
||||
"Repo"]
|
||||
[:div.mt-1.relative.rounded-md.shadow-sm
|
||||
"Specify your repo: "]
|
||||
[:div.mt-2.mb-2.relative.rounded-md.shadow-sm
|
||||
[:input.form-input.block.w-full.sm:text-sm.sm:leading-5
|
||||
{:auto-focus true
|
||||
:placeholder "https://github.com/yourname/repo"
|
||||
|
||||
@@ -46,13 +46,7 @@
|
||||
true)
|
||||
(nav-item "Agenda" "#"
|
||||
"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z")
|
||||
(nav-item "Budgets" "#"
|
||||
"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z")
|
||||
(nav-item "Files" "#"
|
||||
"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z")
|
||||
|
||||
(files-list)
|
||||
])
|
||||
(files-list)])
|
||||
|
||||
(rum/defq main-content <
|
||||
{:q (fn [_state] (db/sub-repos))}
|
||||
@@ -152,6 +146,6 @@
|
||||
main-content
|
||||
[:div.max-w-7xl.mx-auto.px-4.sm:px-6.md:px-8
|
||||
[:div.py-4
|
||||
[:div.border-4.border-dashed.border-gray-200.rounded-lg.h-96]]]
|
||||
]
|
||||
]]))
|
||||
[:div.border-4.border-dashed.border-gray-200.rounded-lg.h-96]]]]
|
||||
|
||||
(ui/notification)]]))
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
;; TODO: don't persistent :github/token
|
||||
|
||||
(def datascript-db "gitnotes/DB")
|
||||
(def schema
|
||||
{:db/ident {:db/unique :db.unique/identity}
|
||||
:github/token {}
|
||||
@@ -27,7 +28,7 @@
|
||||
;; heading
|
||||
:heading/uuid {:db/unique :db.unique/identity}
|
||||
:heading/repo {:db/valueType :db.type/ref}
|
||||
:heading/file {}
|
||||
:heading/file {:db/valueType :db.type/ref}
|
||||
:heading/anchor {}
|
||||
:heading/marker {}
|
||||
:heading/priority {}
|
||||
@@ -59,8 +60,7 @@
|
||||
|
||||
;; persisting DB between page reloads
|
||||
(defn persist [db]
|
||||
(prn "DB size: " (count (db->string db)))
|
||||
(js/localStorage.setItem "gitnotes/DB" (db->string db)))
|
||||
(js/localStorage.setItem datascript-db (db->string db)))
|
||||
|
||||
(defn reset-conn! [db]
|
||||
(reset! conn db)
|
||||
@@ -73,8 +73,15 @@
|
||||
(when-let [db (:db-after tx-report)]
|
||||
(js/setTimeout #(persist db) 0))))
|
||||
|
||||
;; (new TextEncoder().encode('foo')).length
|
||||
(defn db-size
|
||||
[]
|
||||
(when-let [store (js/localStorage.getItem datascript-db)]
|
||||
(let [bytes (.-length (.encode (js/TextEncoder.) store))]
|
||||
(/ bytes 1000))))
|
||||
|
||||
(defn restore! []
|
||||
(when-let [stored (js/localStorage.getItem "gitnotes/DB")]
|
||||
(when-let [stored (js/localStorage.getItem datascript-db)]
|
||||
(let [stored-db (string->db stored)]
|
||||
(when (= (:schema stored-db) schema) ;; check for code update
|
||||
(reset-conn! stored-db)))))
|
||||
@@ -132,16 +139,6 @@
|
||||
heading)))
|
||||
headings))
|
||||
|
||||
(defn delete-headings!
|
||||
[]
|
||||
)
|
||||
|
||||
;; transactions
|
||||
(defn reset-headings!
|
||||
[headings]
|
||||
(let [headings (safe-headings headings)]
|
||||
(d/transact! conn headings)))
|
||||
|
||||
;; queries
|
||||
|
||||
(defn- distinct-result
|
||||
@@ -161,6 +158,29 @@
|
||||
[?h :heading/tags ?tags]]
|
||||
@conn)))
|
||||
|
||||
(defn get-repo-headings
|
||||
[repo-url]
|
||||
(-> (d/q '[:find ?heading
|
||||
:in $ ?repo-url
|
||||
:where
|
||||
[?repo :repo/url ?repo-url]
|
||||
[?heading :heading/repo ?repo]]
|
||||
@conn repo-url)
|
||||
seq-flatten))
|
||||
|
||||
(defn delete-headings!
|
||||
[repo-url]
|
||||
(let [headings (get-repo-headings repo-url)
|
||||
headings (mapv (fn [eid] [:db.fn/retractEntity eid]) headings)]
|
||||
(d/transact! conn headings)))
|
||||
|
||||
;; transactions
|
||||
(defn reset-headings!
|
||||
[repo-url headings]
|
||||
(delete-headings! repo-url)
|
||||
(let [headings (safe-headings headings)]
|
||||
(d/transact! conn headings)))
|
||||
|
||||
(defn get-all-headings
|
||||
[]
|
||||
(seq-flatten
|
||||
@@ -365,6 +385,4 @@
|
||||
:heading/marker "TODO"
|
||||
:heading/priority "A"
|
||||
:heading/level "10"
|
||||
:heading/title "hello world"}
|
||||
]))
|
||||
)
|
||||
:heading/title "hello world"}])))
|
||||
|
||||
@@ -5,25 +5,16 @@
|
||||
(defrecord OrgMode [content]
|
||||
protocol/Format
|
||||
(toHtml [this]
|
||||
(.parseHtml (.-MldocOrg org) content)))
|
||||
(.parseHtml (.-MldocOrg org)
|
||||
content
|
||||
(js/JSON.stringify
|
||||
#js {:toc false
|
||||
:heading_number false}))))
|
||||
|
||||
(defn parse-json
|
||||
[content]
|
||||
(.parseJson (.-MldocOrg org) content))
|
||||
|
||||
(defn json->ast
|
||||
[json]
|
||||
(.jsonToAst (.-MldocOrg org) json))
|
||||
|
||||
(defn json->html
|
||||
[json]
|
||||
(.jsonToHtmlStr (.-MldocOrg org) json))
|
||||
|
||||
(defn inline-list->html
|
||||
[json]
|
||||
(.inlineListToHtmlStr (.-MldocOrg org) json))
|
||||
|
||||
(comment
|
||||
(let [text "*** TODO /*great*/ [[https://personal.utdallas.edu/~gupta/courses/acl/papers/datalog-paper.pdf][What You Always Wanted to Know About Datalog]] :datalog:"
|
||||
blocks-json (parse-json text)]
|
||||
(json->html blocks-json)))
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
(when-let [token (db/get-github-token)]
|
||||
(pull repo-url token)
|
||||
(js/setInterval #(pull repo-url token)
|
||||
(* 10 1000))))
|
||||
(* 60 1000))))
|
||||
|
||||
(defn add-transaction
|
||||
[tx]
|
||||
@@ -107,7 +107,6 @@
|
||||
(let [token (db/get-github-token)]
|
||||
(util/p-handle
|
||||
(do
|
||||
(prn "Debug: cloning " repo)
|
||||
(db/set-repo-cloning repo true)
|
||||
(git/clone repo token))
|
||||
(fn []
|
||||
@@ -162,15 +161,20 @@
|
||||
(notify-fn)
|
||||
(js/setInterval notify-fn (* 1000 60)))))
|
||||
|
||||
(defn show-notification!
|
||||
[text]
|
||||
(swap! state/state assoc
|
||||
:notification/show? true
|
||||
:notification/text text)
|
||||
(js/setTimeout #(swap! state/state assoc
|
||||
:notification/show? false
|
||||
:notification/text nil)
|
||||
3000))
|
||||
|
||||
(defn alter-file
|
||||
[path commit-message content]
|
||||
(let [token (db/get-github-token)
|
||||
repo-url (db/get-current-repo)]
|
||||
(prn {:repo-url repo-url
|
||||
:token token
|
||||
:path path
|
||||
:content content
|
||||
:commit-message commit-message})
|
||||
(util/p-handle
|
||||
(fs/write-file (git/get-repo-dir repo-url) path content)
|
||||
(fn [_]
|
||||
@@ -180,8 +184,7 @@
|
||||
token
|
||||
(fn []
|
||||
(db/set-file-content! repo-url path content)
|
||||
;; (show-snackbar "File updated!")
|
||||
)
|
||||
(show-notification! "File updated!"))
|
||||
(fn [error]
|
||||
(prn "Failed to update file, error: " error)))))))
|
||||
|
||||
@@ -228,8 +231,8 @@
|
||||
headings (block/extract-headings headings)]
|
||||
(map (fn [heading]
|
||||
(assoc heading
|
||||
:repo [:repo/url repo-url]
|
||||
:file file))
|
||||
:heading/repo [:repo/url repo-url]
|
||||
:heading/file [:file/path file]))
|
||||
headings)))
|
||||
|
||||
(defn load-all-contents!
|
||||
@@ -241,7 +244,6 @@
|
||||
(db/set-file-content! repo-url file content)))))
|
||||
(p/then
|
||||
(fn [_]
|
||||
(prn "Files are loaded!")
|
||||
(ok-handler))))))
|
||||
|
||||
(defn extract-all-headings
|
||||
@@ -261,7 +263,7 @@
|
||||
(fn []
|
||||
(let [headings (extract-all-headings repo-url)]
|
||||
(reset! headings-atom headings)
|
||||
(db/reset-headings! headings)))))
|
||||
(db/reset-headings! repo-url headings)))))
|
||||
|
||||
|
||||
;; (defn sync
|
||||
@@ -313,7 +315,6 @@
|
||||
[]
|
||||
(db/restore!)
|
||||
(when-let [first-repo (first (db/get-repos))]
|
||||
(prn "first-repo: " first-repo)
|
||||
(db/set-current-repo! first-repo))
|
||||
(let [repos (db/get-repos)]
|
||||
(doseq [repo repos]
|
||||
|
||||
@@ -101,13 +101,10 @@
|
||||
(assoc state
|
||||
k open?
|
||||
:close-fn (fn []
|
||||
(prn "close-fn on " @open?)
|
||||
(reset! open? false))
|
||||
:open-fn (fn []
|
||||
(prn "open-fn on " @open?)
|
||||
(reset! open? true))
|
||||
:toggle-fn (fn []
|
||||
(prn "toggle-fn on " @open?)
|
||||
(swap! open? not))))))))
|
||||
|
||||
(defn will-mount-effect
|
||||
|
||||
@@ -4,4 +4,6 @@
|
||||
(def state (atom
|
||||
{:route-match nil
|
||||
:tasks {}
|
||||
:notification/show? false
|
||||
:notification/text nil
|
||||
}))
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
[frontend.rum :as r]
|
||||
["react-transition-group" :refer [TransitionGroup CSSTransition]]
|
||||
[frontend.util :as util]
|
||||
[frontend.mixins :as mixins]))
|
||||
[frontend.mixins :as mixins]
|
||||
[frontend.state :as state]))
|
||||
|
||||
(defonce transition-group (r/adapt-class TransitionGroup))
|
||||
(defonce css-transition (r/adapt-class CSSTransition))
|
||||
@@ -49,3 +50,46 @@
|
||||
{:type "button"
|
||||
:on-click on-click}
|
||||
text])
|
||||
|
||||
(rum/defc notification-content
|
||||
[state text]
|
||||
[:div.fixed.inset-0.flex.items-end.justify-center.px-4.py-6.pointer-events-none.sm:p-6.sm:items-start.sm:justify-end
|
||||
[:div.max-w-sm.w-full.bg-white.shadow-lg.rounded-lg.pointer-events-auto
|
||||
{:class (case state
|
||||
"entering" "transition ease-out duration-300 transform opacity-0 translate-y-2 sm:translate-x-0"
|
||||
"entered" "transition ease-out duration-300 transform translate-y-0 opacity-100 sm:translate-x-0"
|
||||
"exiting" "transition ease-in duration-100 opacity-100"
|
||||
"exited" "transition ease-in duration-100 opacity-0")}
|
||||
[:div.rounded-lg.shadow-xs.overflow-hidden
|
||||
[:div.p-4
|
||||
[:div.flex.items-start
|
||||
[:div.flex-shrink-0
|
||||
[:svg.h-6.w-6.text-green-400
|
||||
{:stroke "currentColor", :viewbox "0 0 24 24", :fill "none"}
|
||||
[:path
|
||||
{:d "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z",
|
||||
:stroke-width "2",
|
||||
:stroke-linejoin "round",
|
||||
:stroke-linecap "round"}]]]
|
||||
[:div.ml-3.w-0.flex-1.pt-0.5
|
||||
[:p.text-sm.leading-5.font-medium.text-gray-900
|
||||
text]]
|
||||
[:div.ml-4.flex-shrink-0.flex
|
||||
[:button.inline-flex.text-gray-400.focus:outline-none.focus:text-gray-500.transition.ease-in-out.duration-150
|
||||
{:on-click (fn []
|
||||
(swap! state/state assoc :notification/show? false))}
|
||||
[:svg.h-5.w-5
|
||||
{:fill "currentColor", :viewbox "0 0 20 20"}
|
||||
[:path
|
||||
{:clip-rule "evenodd",
|
||||
:d
|
||||
"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",
|
||||
:fill-rule "evenodd"}]]]]]]]]])
|
||||
|
||||
(rum/defc notification < rum/reactive
|
||||
[]
|
||||
(let [{:keys [:notification/show? :notification/text]} (rum/react state/state)]
|
||||
(css-transition
|
||||
{:in show? :timeout 100}
|
||||
(fn [state]
|
||||
(notification-content state text)))))
|
||||
|
||||
@@ -1126,10 +1126,10 @@ mkdirp@^0.5.1:
|
||||
dependencies:
|
||||
minimist "0.0.8"
|
||||
|
||||
mldoc_org@^0.1.8:
|
||||
version "0.1.8"
|
||||
resolved "https://registry.yarnpkg.com/mldoc_org/-/mldoc_org-0.1.8.tgz#f3241a308a11319d948a20ae5e6401c375301b6c"
|
||||
integrity sha512-xaV4pbCV6eumQ4tS/TD40EnsGKN8tZhfKk0llxO+TcNaVEdLAIoilUyJJMiCRwq8esJlMjq53v+ULlC3cQeU6w==
|
||||
mldoc_org@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/mldoc_org/-/mldoc_org-0.2.0.tgz#b9643333939dbddf6b38e76ec130c4b2cc72d6ab"
|
||||
integrity sha512-s5QuzNWRX8XuAV6ymrBB43qwqvxjsCfUZX6/3AuCJ/dka3+jPxcQVjjOfueTFdzbQdPOBMxAhutV+AX9oQnv1A==
|
||||
dependencies:
|
||||
yargs "^12.0.2"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user