Fix config content

This commit is contained in:
Tienson Qin
2020-07-23 08:19:56 +08:00
parent 58f2416599
commit 1b5c8cd36a
3 changed files with 14 additions and 74 deletions

View File

@@ -207,75 +207,5 @@
(def config-file "config.edn")
(def metadata-file "metadata.edn")
(defonce config-default-content
"{:project {
;; Selected public notes can be published to https://logseq.com/your-project-or-your-username.
:name \"\"
:alias \"\"
;; your twitter handle
:twitter \"\"
;; description supports both hiccup and html
:description []}
;; Git settings
:git-pull-secs 60
:git-push-secs 10
:git-auto-push true
;; The app will ignore those directories or files.
;; E.g. \"/archived\" \"/test.md\"
:hidden []
;; When creating the new journal page, the app will use your template content here.
;; Example for Markdown users: \"## [[Work]]\n###\n## [[Family]]\n###\n\"
;; Example for Org mode users: \"** [[Work]]\n***\n** [[Family]]\n***\n\"
{:journals \"\"}
;; The app will show those queries in today's journal page,
;; the \"NOW\" query asks the tasks which need to be finished \"now\",
;; the \"NEXT\" query asks the future tasks.
:default-queries
{:journals
[{:title \"🔨 NOW\"
:query [:find (pull ?h [*])
:in $ ?start ?today
:where
[?h :heading/marker ?marker]
[?h :heading/page ?p]
[?p :page/journal? true]
[?p :page/journal-day ?d]
[(>= ?d ?start)]
[(<= ?d ?today)]
[(= ?marker \"NOW\")]]
:inputs [:14d :today]
:result-transform (fn [result]
(sort-by (fn [h]
(get h :heading/priority \"Z\")) result))}
{:title \"📅 NEXT\"
:query [:find (pull ?h [*])
:in $ ?start ?next
:where
[?h :heading/marker ?marker]
[?h :heading/ref-pages ?p]
[?p :page/journal? true]
[?p :page/journal-day ?d]
[(> ?d ?start)]
[(< ?d ?next)]
[(contains? #{\"NOW\" \"LATER\"} ?marker)]]
:inputs [:today :7d-after]
:default-collapsed? true}]}
;; Add your own commands to speedup.
;; E.g. [[\"js\" \"Javascript\"]]
:commands
[[\"Think\" \"[[Think]]\"]]
;; Macros replace texts and will make you more productive.
;; For example:
;; Add this to the macros below:
;; {\"poem\" \"Rose is $1, violet's $2. Life's ordered: Org assists you.\"}
;; input \"{{{poem(red,blue)}}}\"
;; becomes
;; Rose is red, violet's blue. Life's ordered: Org assists you.
:macros {}}
")
(def config-default-content
"{:project {\n ;; Selected public notes can be published to https://logseq.com/your-project-or-your-username.\n :name \"\"\n :alias \"\"\n ;; your twitter handle\n :twitter \"\"\n ;; description supports both hiccup and html\n :description []}\n\n ;; Git settings\n :git-pull-secs 60\n :git-push-secs 10\n :git-auto-push true\n\n ;; The app will ignore those directories or files.\n ;; E.g. \"/archived\" \"/test.md\"\n :hidden []\n\n ;; When creating the new journal page, the app will use your template content here.\n ;; Example for Markdown users: \"## [[Work]]\\n###\\n## [[Family]]\\n###\\n\"\n ;; Example for Org mode users: \"** [[Work]]\\n***\\n** [[Family]]\\n***\\n\"\n :default-templates\n {:journals \"\"}\n\n ;; The app will show those queries in today's journal page,\n ;; the \"NOW\" query asks the tasks which need to be finished \"now\",\n ;; the \"NEXT\" query asks the future tasks.\n :default-queries\n {:journals\n [{:title \"🔨 NOW\"\n :query [:find (pull ?h [*])\n :in $ ?start ?today\n :where\n [?h :heading/marker ?marker]\n [?h :heading/page ?p]\n [?p :page/journal? true]\n [?p :page/journal-day ?d]\n [(>= ?d ?start)]\n [(<= ?d ?today)]\n [(= ?marker \"NOW\")]]\n :inputs [:14d :today]\n :result-transform (fn [result]\n (sort-by (fn [h]\n (get h :heading/priority \"Z\")) result))}\n {:title \"📅 NEXT\"\n :query [:find (pull ?h [*])\n :in $ ?start ?next\n :where\n [?h :heading/marker ?marker]\n [?h :heading/ref-pages ?p]\n [?p :page/journal? true]\n [?p :page/journal-day ?d]\n [(> ?d ?start)]\n [(< ?d ?next)]\n [(contains? #{\"NOW\" \"LATER\"} ?marker)]]\n :inputs [:today :7d-after]\n :default-collapsed? true}]}\n\n ;; Add your own commands to speedup.\n ;; E.g. [[\"js\" \"Javascript\"]]\n :commands\n [[\"Think\" \"[[Think]]\"]]\n\n ;; Macros replace texts and will make you more productive.\n ;; For example:\n ;; Add this to the macros below:\n ;; {\"poem\" \"Rose is $1, violet's $2. Life's ordered: Org assists you.\"}\n ;; input \"{{{poem(red,blue)}}}\"\n ;; becomes\n ;; Rose is red, violet's blue. Life's ordered: Org assists you.\n :macros {}}\n")

View File

@@ -1585,7 +1585,12 @@
(defn reset-config!
[repo-url content]
(when-let [content (or content (get-file repo-url (str config/app-name "/" config/config-file)))]
(let [config (reader/read-string content)]
(let [config (try
(reader/read-string content)
(catch js/Error e
(println "Parsing config file failed: ")
(js/console.dir e)
{}))]
(state/set-config! repo-url config)
config)))

View File

@@ -1352,7 +1352,12 @@
(when-let [repo (state/get-current-repo)]
(let [path (str config/app-name "/" config/config-file)]
(when-let [config (db/get-file path)]
(let [config (reader/read-string config)
(let [config (try
(reader/read-string config)
(catch js/Error e
(println "Parsing config file failed: ")
(js/console.dir e)
{}))
ks (if (vector? k) k [k])
new-config (assoc-in config ks v)]
(state/set-config! repo new-config)