Skip to content

Commit

Permalink
fix: only write config.edn when it doesn't exists
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed Feb 24, 2021
1 parent 3edc9d9 commit fca063f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
4 changes: 1 addition & 3 deletions resources/css/common.css
Expand Up @@ -731,10 +731,8 @@ a.fade-link:hover {

/* < > buttons */

a[title="Go Back"],
a[title="Go Forward"] {
a.navigation {
border-radius: 3px;
opacity: 1;
transition: .3s;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/components/header.cljs
Expand Up @@ -168,12 +168,12 @@
(logo {:white? white?})

(when (util/electron?)
[:a.mr-1.opacity-50.hover:opacity-100.it
[:a.mr-1.opacity-30.hover:opacity-100.it.navigation
{:style {:margin-left -10}
:title "Go Back" :on-click #(js/window.history.back)} (svg/arrow-left)])

(when (util/electron?)
[:a.opacity-50.hover:opacity-100.it
[:a.opacity-30.hover:opacity-100.it.navigation
{:style {:margin-right 15}
:title "Go Forward" :on-click #(js/window.history.forward)} (svg/arrow-right)])

Expand Down
3 changes: 1 addition & 2 deletions src/main/frontend/config.cljs
Expand Up @@ -276,8 +276,7 @@
(def metadata-file "metadata.edn")

(def config-default-content
"
{:journal-basis \"daily\" \n\n :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 ;; Currently, we support either \"Markdown\" or \"Org\".\n ;; This can overwrite your global preference so that\n ;; maybe your personal preferred format is Org but you'd\n ;; need to use Markdown for some projects.\n ;; :preferred-format \"\"\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 :block/marker ?marker]\n [?h :block/page ?p]\n [?p :page/journal? true]\n [?p :page/journal-day ?d]\n [(>= ?d ?start)]\n [(<= ?d ?today)]\n [(contains? #{\"NOW\" \"DOING\"} ?marker)]]\n :inputs [:14d :today]\n :result-transform (fn [result]\n (sort-by (fn [h]\n (get h :block/priority \"Z\")) result))\n :collapsed? false}\n {:title \"📅 NEXT\"\n :query [:find (pull ?h [*])\n :in $ ?start ?next\n :where\n [?h :block/marker ?marker]\n [?h :block/ref-pages ?p]\n [?p :page/journal? true]\n [?p :page/journal-day ?d]\n [(> ?d ?start)]\n [(< ?d ?next)]\n [(contains? #{\"NOW\" \"LATER\" \"TODO\"} ?marker)]]\n :inputs [:today :7d-after]\n :collapsed? false}]}\n\n ;; Add your own commands to speedup.\n ;; E.g. [[\"js\" \"Javascript\"]]\n :commands\n []\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")
"{: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 ;; Currently, we support either \"Markdown\" or \"Org\".\n ;; This can overwrite your global preference so that\n ;; maybe your personal preferred format is Org but you'd\n ;; need to use Markdown for some projects.\n ;; :preferred-format \"\"\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 :block/marker ?marker]\n [?h :block/page ?p]\n [?p :page/journal? true]\n [?p :page/journal-day ?d]\n [(>= ?d ?start)]\n [(<= ?d ?today)]\n [(contains? #{\"NOW\" \"DOING\"} ?marker)]]\n :inputs [:14d :today]\n :result-transform (fn [result]\n (sort-by (fn [h]\n (get h :block/priority \"Z\")) result))\n :collapsed? false}\n {:title \"📅 NEXT\"\n :query [:find (pull ?h [*])\n :in $ ?start ?next\n :where\n [?h :block/marker ?marker]\n [?h :block/ref-pages ?p]\n [?p :page/journal? true]\n [?p :page/journal-day ?d]\n [(> ?d ?start)]\n [(< ?d ?next)]\n [(contains? #{\"NOW\" \"LATER\" \"TODO\"} ?marker)]]\n :inputs [:today :7d-after]\n :collapsed? false}]}\n\n ;; Add your own commands to speedup.\n ;; E.g. [[\"js\" \"Javascript\"]]\n :commands\n []\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")

(def markers
#{"now" "later" "todo" "doing" "done" "wait" "waiting"
Expand Down
15 changes: 6 additions & 9 deletions src/main/frontend/handler/repo.cljs
Expand Up @@ -59,16 +59,13 @@
app-dir config/app-name
dir (str repo-dir "/" app-dir)]
(p/let [_ (fs/mkdir-if-not-exists dir)]
(let [default-content config/config-default-content]
(let [default-content config/config-default-content
path (str app-dir "/" config/config-file)]
(p/let [file-exists? (fs/create-if-not-exists repo-url repo-dir (str app-dir "/" config/config-file) default-content)]
(let [path (str app-dir "/" config/config-file)
old-content (when file-exists?
(db/get-file repo-url path))
content (or old-content default-content)]
(file-handler/reset-file! repo-url path content)
(common-handler/reset-config! repo-url content)
(when-not (= content old-content)
(git-handler/git-add repo-url path))))))))
(when-not file-exists?
(file-handler/reset-file! repo-url path default-content)
(common-handler/reset-config! repo-url default-content)
(git-handler/git-add repo-url path)))))))

(defn create-contents-file
[repo-url]
Expand Down

0 comments on commit fca063f

Please sign in to comment.