Skip to content

Commit

Permalink
Merge branch 'master' into zotero/poc
Browse files Browse the repository at this point in the history
  • Loading branch information
thezjy committed Jul 28, 2021
2 parents f9853a4 + 1581e47 commit 06b80fe
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 153 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"ignore": "^5.1.8",
"is-svg": "4.2.2",
"jszip": "^3.5.0",
"mldoc": "0.9.1",
"mldoc": "0.9.2",
"path": "^0.12.7",
"pixi-graph-fork": "^0.1.3",
"posthog-js": "^1.10.2",
Expand Down
5 changes: 1 addition & 4 deletions src/main/frontend/components/export.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
(t :export-json)]]
[:li.mb-4
[:a.font-medium {:on-click #(export/export-repo-as-roam-json! current-repo)}
(t :export-roam-json)]]
[:li.mb-4
[:a.font-medium {:on-click #(export/convert-repo-markdown-v2! current-repo)}
(t :convert-markdown)]]]
(t :export-roam-json)]]]
[:a#download-as-edn-v2.hidden]
[:a#download-as-json-v2.hidden]
[:a#download-as-roam-json.hidden]
Expand Down
9 changes: 1 addition & 8 deletions src/main/frontend/components/header.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
[frontend.handler.web.nfs :as nfs]
[frontend.mixins :as mixins]
[goog.dom :as gdom]
[goog.object :as gobj]
[frontend.handler.migrate :as migrate]))
[goog.object :as gobj]))

(rum/defc logo < rum/reactive
[{:keys [white? electron-mac?]}]
Expand Down Expand Up @@ -138,12 +137,6 @@
:options {:href (rfe/href :import)}
:icon svg/import-sm})

(when (and current-repo
(not (:markdown/version (state/get-config))))
{:title "Convert to more standard Markdown"
:options {:on-click (fn [] (migrate/show-convert-notification! current-repo))}
:icon svg/import-sm})

{:title [:div.flex-row.flex.justify-between.items-center
[:span (t :join-community)]]
:options {:href "https://discord.gg/KpN4eHY"
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/config.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
(set))]
(set/union
config-formats
#{:gif :svg :jpeg :ico :png :jpg :bmp})))
#{:gif :svg :jpeg :ico :png :jpg :bmp :webp})))

(def html-render-formats
#{:adoc :asciidoc})
Expand Down Expand Up @@ -167,7 +167,7 @@

(defn get-highlight
[format]
"^^")
"==")

(defn get-code
[format]
Expand Down
17 changes: 13 additions & 4 deletions src/main/frontend/date.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
"yyyy年MM月dd日"}
(state/get-date-formatter)))

;; (tf/parse (tf/formatter "dd.MM.yyyy") "2021Q4") => 20040120T000000
(def safe-journal-title-formatters
(set ["yyyy-MM-dd" "yyyy_MM_dd" (state/get-date-formatter)]))

(defn get-date-time-string
([]
(get-date-time-string (t/now)))
Expand Down Expand Up @@ -188,10 +192,15 @@
(defn journal-title->
[journal-title then-fn]
(when-not (string/blank? journal-title)
(when-let [time (try
(tf/parse (tf/formatter (state/get-date-formatter)) (util/capitalize-all journal-title))
(catch js/Error _e
nil))]
(when-let [time (->> (map
(fn [formatter]
(try
(tf/parse (tf/formatter formatter) (util/capitalize-all journal-title))
(catch js/Error _e
nil)))
safe-journal-title-formatters)
(filter some?)
first)]
(then-fn time))))

(defn journal-title->int
Expand Down
6 changes: 1 addition & 5 deletions src/main/frontend/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[frontend.db-schema :as db-schema]
[frontend.db.conn :as conn]
[frontend.db.default :as default-db]
[frontend.db.migrate :as migrate]
[frontend.db.model]
[frontend.db.query-custom]
[frontend.db.query-react]
Expand Down Expand Up @@ -135,9 +134,7 @@

(defn restore!
[{:keys [repos] :as me} old-db-schema restore-config-handler]
(let [logged? (:name me)
;; TODO: switch to use the db version
old-db? (and old-db-schema (not (:block/name old-db-schema)))]
(let [logged? (:name me)]
(doall
(for [{:keys [url]} repos]
(let [repo url]
Expand All @@ -148,7 +145,6 @@
stored (idb/get-item db-name)
_ (if stored
(let [stored-db (string->db stored)
stored-db (if old-db? (migrate/migrate url stored-db) stored-db)
attached-db (d/db-with stored-db (concat
[(me-tx stored-db me)]
default-db/built-in-pages))]
Expand Down
12 changes: 7 additions & 5 deletions src/main/frontend/extensions/srs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,10 @@
;; handlers
(defn make-block-a-card!
[block-id]
(when-let [content (:block/content (db/entity [:block/uuid block-id]))]
(editor-handler/save-block!
(state/get-current-repo)
block-id
(str (string/trim content) " #" card-hash-tag))))
(when-let [block (db/entity [:block/uuid block-id])]
(when-let [content (:block/content block)]
(let [content (property/remove-built-in-properties (:block/format block) content)]
(editor-handler/save-block!
(state/get-current-repo)
block-id
(str (string/trim content) " #" card-hash-tag))))))
6 changes: 3 additions & 3 deletions src/main/frontend/handler/editor.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@
(when-let [sibling-block-id (dom/attr sibling-block "blockid")]
(when-let [block (db/pull repo '[*] [:block/uuid (uuid sibling-block-id)])]
(let [original-content (util/trim-safe (:block/content block))
new-value (str original-content " " (string/triml value))
new-value (str (property/remove-built-in-properties format original-content) " " (string/triml value))
tail-len (count (string/triml value))
pos (max
(if original-content
Expand Down Expand Up @@ -1518,16 +1518,16 @@
"*" "*"
"_" "_"
"^" "^"
"=" "="
;; ":" ":" ; TODO: only properties editing and org mode tag

})

(def reversed-autopair-map
(zipmap (vals autopair-map)
(keys autopair-map)))

(defonce autopair-when-selected
#{"^" "_"})
#{"^" "_" "="})

(def delete-map
(assoc autopair-map
Expand Down
16 changes: 2 additions & 14 deletions src/main/frontend/handler/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
[frontend.components.encryption :as encryption]
[frontend.fs.nfs :as nfs]
[frontend.db.conn :as conn]
[frontend.handler.migrate :as migrate]
[frontend.extensions.srs :as srs]
[frontend.db-schema :as db-schema]
[frontend.db :as db]
Expand Down Expand Up @@ -60,21 +59,10 @@
;; add ast/version to db
(let [conn (conn/get-conn repo false)
ast-version (d/datoms @conn :aevt :ast/version)]
(db/set-key-value repo :ast/version db-schema/ast-version))

;; markdown convert notification
(js/setTimeout
(fn []
(when (not (:markdown/version (state/get-config)))
(migrate/show-convert-notification! repo)))
5000))
(db/set-key-value repo :ast/version db-schema/ast-version)))

(defmethod handle :graph/migrated [[_ repo]]
(js/setTimeout
(fn []
(when (not (:markdown/version (state/get-config)))
(migrate/show-migrated-notification! repo)))
5000))
(js/alert "Graph migrated."))

(defn get-local-repo
[]
Expand Down
15 changes: 0 additions & 15 deletions src/main/frontend/handler/export.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -581,21 +581,6 @@
(.setAttribute anchor "download" path)
(.click anchor))))))))))

(defn convert-repo-markdown-v2!
[repo]
(when repo
(when-let [files (get-md-file-contents repo)]
(let [zip-file-name (-> (string/replace repo config/local-db-prefix "")
(string/replace #"^/+" ""))
zip-file-name (str zip-file-name
"_markdown_"
(quot (util/time-ms) 1000))]
(p/let [zipfile (zip/make-zip zip-file-name files repo)]
(when-let [anchor (gdom/getElement "convert-markdown-to-unordered-list-or-heading")]
(.setAttribute anchor "href" (js/window.URL.createObjectURL zipfile))
(.setAttribute anchor "download" (.-name zipfile))
(.click anchor)))))))

(defn- dissoc-properties [m ks]
(if (:block/properties m)
(update m :block/properties
Expand Down
88 changes: 0 additions & 88 deletions src/main/frontend/handler/migrate.cljs

This file was deleted.

8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6165,10 +6165,10 @@ mkdirp@^0.5.0, mkdirp@^0.5.4, mkdirp@~0.5.1:
dependencies:
minimist "^1.2.5"

[email protected].1:
version "0.9.1"
resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-0.9.1.tgz#dfcdcf52614a27ce83b9318c551246398e13f0e7"
integrity sha512-4BL8Fu6+izd9iJ3JhqEU57K9W8MHUD29V51eOXa/pTpmkXi1GFSy0c9nYLkd8KjAPkI6nFVmjl7A9rcfbGe+/g==
[email protected].2:
version "0.9.2"
resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-0.9.2.tgz#0d88a049bb9564a1567134178b2dea9196f30148"
integrity sha512-e1JFKKkX6IYHFP8XwN0pqcEn2L8biVHWXGUyaUU8RHsCq2poN1fPIAZ5waosS4EffC+CQk68PycEhCobYwbndA==
dependencies:
yargs "^12.0.2"

Expand Down

0 comments on commit 06b80fe

Please sign in to comment.