Skip to content

Commit

Permalink
Merge branch 'master' of github.com:logseq/logseq
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed Jan 31, 2021
2 parents d9bca05 + 6147d0c commit 0c6064b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 52 deletions.
12 changes: 4 additions & 8 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,24 @@
org.clojure/core.async {:mvn/version "1.3.610"}
thheller/shadow-cljs {:mvn/version "2.11.14"}
expound/expound {:mvn/version "0.8.6"}
lambdaisland/glogi {:mvn/version "1.0.74"}}
lambdaisland/glogi {:mvn/version "1.0.74"}
binaryage/devtools {:mvn/version "1.0.2"}}

:aliases {:cljs {:extra-paths ["src/dev-cljs/" "src/test/" "src/electron/"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.764"}
binaryage/devtools {:mvn/version "1.0.2"}
org.clojure/tools.namespace {:mvn/version "0.2.11"}
cider/cider-nrepl {:mvn/version "0.25.5"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
:test
{:extra-paths ["src/test/"]
:extra-deps {
org.clojure/clojurescript {:mvn/version "1.10.764"}
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.764"}
org.clojure/test.check {:mvn/version "RELEASE"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}

:test-clj
{:extra-paths ["src/test/"]
:extra-deps
{
com.cognitect/test-runner
{com.cognitect/test-runner
{:git/url "https://github.com/cognitect-labs/test-runner",
:sha "76568540e7f40268ad2b646110f237a60295fa3c"}},
:main-opts ["-m" "cognitect.test-runner" "-d" "src/test"]}}}


63 changes: 32 additions & 31 deletions src/main/frontend/components/block.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
[lambdaisland.glogi :as log]
[frontend.context.i18n :as i18n]))

;; TODO: remove rum/with-context because it'll make reactive queries not working

(defn safe-read-string
([s]
(safe-read-string s true))
Expand Down Expand Up @@ -468,36 +470,35 @@
(util/format "{{{%s}}}" name)))

(declare block-content)
(defn block-reference
(rum/defc block-reference < rum/reactive
[config id]
(rum/with-context [[t] i18n/*tongue-context*]
(when-not (string/blank? id)
(let [block (and (util/uuid-string? id)
(db/pull-block (uuid id)))]
(if block
[:span
[:div.block-ref-wrap
{:on-click (fn [e]
(util/stop e)
(if (gobj/get e "shiftKey")
(state/sidebar-add-block!
(state/get-current-repo)
(:db/id block)
:block-ref
{:block block})
(route-handler/redirect! {:to :page
:path-params {:name id}})))}

(let [title (:block/title block)]
(if (empty? title)
;; display the content
[:div.block-ref
(block-content config block nil (:block/uuid block) (:slide? config))]
(->elem
:span.block-ref
(map-inline config title))))]]
[:span.warning.mr-1 {:title "Block ref invalid"}
(util/format "((%s))" id)])))))
(when-not (string/blank? id)
(let [block (and (util/uuid-string? id)
(db/pull-block (uuid id)))]
(if block
[:span
[:div.block-ref-wrap
{:on-click (fn [e]
(util/stop e)
(if (gobj/get e "shiftKey")
(state/sidebar-add-block!
(state/get-current-repo)
(:db/id block)
:block-ref
{:block block})
(route-handler/redirect! {:to :page
:path-params {:name id}})))}

(let [title (:block/title block)]
(if (empty? title)
;; display the content
[:div.block-ref
(block-content config block nil (:block/uuid block) (:slide? config))]
(->elem
:span.block-ref
(map-inline config title))))]]
[:span.warning.mr-1 {:title "Block ref invalid"}
(util/format "((%s))" id)]))))

(defn inline-text
[format v]
Expand Down Expand Up @@ -563,15 +564,15 @@
(if (and s (util/tag-valid? s))
[:a.tag {:href (rfe/href :page {:name s})
:on-click (fn [e]
(.preventDefault e)
(let [repo (state/get-current-repo)
page (db/pull repo '[*] [:page/name (string/lower-case (util/url-decode s))])]
(when (gobj/get e "shiftKey")
(state/sidebar-add-block!
repo
(:db/id page)
:page
{:page page}))))}
{:page page})
(.preventDefault e))))}
(str "#" s)]
[:span.warning.mr-1 {:title "Invalid tag, tags only accept alphanumeric characters, \"-\", \"_\", \"@\" and \"%\"."}
(str "#" s)])
Expand Down
10 changes: 5 additions & 5 deletions src/main/frontend/components/header.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@

(if config/publishing?
[:a.text-sm.font-medium.ml-3 {:href (rfe/href :graph)}
(t :graph)]
(t :graph)])

(dropdown-menu {:me me
:t t
:current-repo current-repo
:default-home default-home}))
(dropdown-menu {:me me
:t t
:current-repo current-repo
:default-home default-home})

[:a#download-as-html.hidden]
[:a#download-as-zip.hidden]])))
4 changes: 2 additions & 2 deletions src/main/frontend/components/right_sidebar.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
[:a.mb-1 {:key (str "recent-page-" page)
:href (rfe/href :page {:name page})
:on-click (fn [e]
(.preventDefault e)
(when (gobj/get e "shiftKey")
(when-let [page (db/pull [:page/name (string/lower-case page)])]
(state/sidebar-add-block!
(state/get-current-repo)
(:db/id page)
:page
{:page page}))))}
{:page page}))
(.preventDefault e)))}
page]))]))

(rum/defc contents < rum/reactive db-mixins/query
Expand Down
15 changes: 9 additions & 6 deletions src/main/frontend/db/model.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,15 @@
[repo]
(when-let [conn (conn/get-conn repo)]
(->> (d/q
'[:find ?path ?modified-at
'[:find ?path
;; ?modified-at
:where
[?file :file/path ?path]
[?file :file/last-modified-at ?modified-at]]
;; [?file :file/last-modified-at ?modified-at]
]
conn)
(seq)
(sort-by last)
;; (sort-by last)
(reverse))))

(defn get-files-blocks
Expand Down Expand Up @@ -703,9 +705,10 @@
property-name (when (and (= "Properties" (ffirst ast))
(not (string/blank? (:title (last (first ast))))))
(:title (last (first ast))))
first-block-name (and first-block
;; FIXME:
(str (last (first (:title first-block)))))
first-block-name (let [title (last (first (:title first-block)))]
(and first-block
(string? title)
title))
file-name (when-let [file-name (last (string/split file #"/"))]
(when-let [file-name (first (util/split-last "." file-name))]
(-> file-name
Expand Down

0 comments on commit 0c6064b

Please sign in to comment.