From 0559f03840a5a218530150edadb3fa75e4ae886b Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 28 Dec 2020 23:46:14 +0800 Subject: [PATCH 1/2] feat(native-fs): mark native fs as stable --- src/main/frontend/components/header.cljs | 21 ++--- src/main/frontend/components/journal.cljs | 6 +- src/main/frontend/components/onboarding.cljs | 18 ---- src/main/frontend/components/repo.cljs | 20 ++--- src/main/frontend/components/sidebar.css | 2 +- src/main/frontend/components/widgets.cljs | 87 ++++++++++---------- src/main/frontend/components/widgets.css | 10 +++ src/main/frontend/dicts.cljs | 29 ++----- src/main/frontend/handler/repo.cljs | 11 ++- 9 files changed, 89 insertions(+), 115 deletions(-) create mode 100644 src/main/frontend/components/widgets.css diff --git a/src/main/frontend/components/header.cljs b/src/main/frontend/components/header.cljs index bf41f0d41..f5eff3edd 100644 --- a/src/main/frontend/components/header.cljs +++ b/src/main/frontend/components/header.cljs @@ -66,7 +66,7 @@ :icon svg/graph-sm}) (when (or logged? (and (nfs/supported?) current-repo)) - {:title (t :all-graphs) + {:title (t :all-repos) :options {:href (rfe/href :repos)} :icon svg/repos-sm}) @@ -167,17 +167,14 @@ (repo/repos-dropdown true)] (when (and (nfs/supported?) (empty? repos)) - (ui/tooltip - "Warning: this is an experimental feature, please only use it for testing purpose." - [:a.text-sm.font-medium.opacity-70.hover:opacity-100.ml-3.block - {:on-click (fn [] - (nfs/ls-dir-files))} - [:div.flex.flex-row.text-center - [:span.inline-block svg/folder-add] - (when-not config/mobile? - [:span.ml-1 {:style {:margin-top 2}} - (t :open)])]] - {:label-style {:width 200}})) + [:a.text-sm.font-medium.opacity-70.hover:opacity-100.ml-3.block + {:on-click (fn [] + (nfs/ls-dir-files))} + [:div.flex.flex-row.text-center + [:span.inline-block svg/folder-add] + (when-not config/mobile? + [:span.ml-1 {:style {:margin-top 2}} + (t :open)])]]) (if config/publishing? [:a.text-sm.font-medium.ml-3 {:href (rfe/href :graph)} diff --git a/src/main/frontend/components/journal.cljs b/src/main/frontend/components/journal.cljs index ae3a64d4c..1e031a6ca 100644 --- a/src/main/frontend/components/journal.cljs +++ b/src/main/frontend/components/journal.cljs @@ -16,6 +16,7 @@ [frontend.components.editor :as editor] [frontend.components.reference :as reference] [frontend.components.page :as page] + [frontend.components.widgets :as widgets] [frontend.components.onboarding :as onboarding] [goog.object :as gobj] [clojure.string :as string] @@ -92,12 +93,13 @@ (blocks-cp repo page format)) + (when intro? (widgets/add-repo)) + (page/today-queries repo today? false) (reference/references title false) - (when intro? - (onboarding/intro))])) + (when intro? (onboarding/intro))])) (rum/defc journals < {:did-mount (fn [state] diff --git a/src/main/frontend/components/onboarding.cljs b/src/main/frontend/components/onboarding.cljs index cef8f380f..093972c45 100644 --- a/src/main/frontend/components/onboarding.cljs +++ b/src/main/frontend/components/onboarding.cljs @@ -47,24 +47,6 @@ :alt "screenshot"}] [:div.flex.flex-col.ls-block.intro-docs - [:h2 {} (t :on-boarding/where-are-my-notes-saved)] - [:p - {} - (t :on-boarding/storage) - [:a {:href "https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API" - :target "_blank"} - "IndexedDB"] - "."] - [:h2 {} (t :on-boarding/how-do-i-use-it)] - [:h3 {} (t :on-boarding/use-1)] - [:p - {} - (t :on-boarding/use-1-desc)] - - [:h3 {} (t :on-boarding/use-2)] - [:p - {} - (t :on-boarding/use-2-desc)] [:h2 {} (t :on-boarding/features)] [:ul {} diff --git a/src/main/frontend/components/repo.cljs b/src/main/frontend/components/repo.cljs index 0fa8c07b0..5d55bf673 100644 --- a/src/main/frontend/components/repo.cljs +++ b/src/main/frontend/components/repo.cljs @@ -30,23 +30,19 @@ (rum/with-context [[t] i18n/*tongue-context*] (if (seq repos) [:div#repos - [:h1.title "All Graphs"] + [:h1.title "All Repos"] [:div.pl-1.content [:div.flex.flex-row.my-4 - (when (state/logged?) + (when (nfs-handler/supported?) [:div.mr-8 (ui/button - "Add another git repo" - :href (rfe/href :repo-add))]) - (when (nfs-handler/supported?) - [:div.flex.flex-col - [:div (ui/button - (t :open-a-directory) - :on-click nfs-handler/ls-dir-files)] - [:span.warning.mt-2.text-sm "Warning: this is an experimental feature," - [:br] - "please only use it for testing purpose."]])] + (t :open-a-directory) + :on-click nfs-handler/ls-dir-files)]) + (when (state/logged?) + (ui/button + "Add another git repo" + :href (rfe/href :repo-add)))] (for [{:keys [id url] :as repo} repos] (let [local? (config/local-db? url)] [:div.flex.justify-between.mb-1 {:key id} diff --git a/src/main/frontend/components/sidebar.css b/src/main/frontend/components/sidebar.css index b37e85c3d..eec101292 100644 --- a/src/main/frontend/components/sidebar.css +++ b/src/main/frontend/components/sidebar.css @@ -71,7 +71,7 @@ } .cp__sidebar-main-content { - padding: 3rem 1.5rem; + padding: 6rem 1.5rem; max-width: var(--ls-main-content-max-width); min-height: 100vh; flex: 1; diff --git a/src/main/frontend/components/widgets.cljs b/src/main/frontend/components/widgets.cljs index a736ba29a..099c2acd6 100644 --- a/src/main/frontend/components/widgets.cljs +++ b/src/main/frontend/components/widgets.cljs @@ -6,6 +6,7 @@ [frontend.handler.route :as route-handler] [frontend.handler.export :as export-handler] [frontend.handler.notification :as notification] + [frontend.handler.web.nfs :as nfs] [frontend.state :as state] [frontend.config :as config] [clojure.string :as string] @@ -38,50 +39,52 @@ (rum/defcs add-repo < (rum/local "" ::repo) - (rum/local "master" ::branch) [state] - (let [repo (get state ::repo) - branch (get state ::branch)] + (let [repo (get state ::repo)] (rum/with-context [[t] i18n/*tongue-context*] - [:div.p-8.flex.items-center.justify-center - [:div.w-full.mx-auto - [:div - [:div - [:h1.title.mb-1 - (t :git/add-repo-prompt)] - (ui/admonition :warning - [:p "Make sure that you've created this repo on GitHub."]) - [:div.mt-4.mb-4.relative.rounded-md.shadow-sm.max-w-xs - [:input#repo.form-input.block.w-full.sm:text-sm.sm:leading-5 - {:autoFocus true - :placeholder "https://github.com/username/repo" - :on-change (fn [e] - (reset! repo (util/evalue e)))}]] + [:div.p-8.flex.items-center.justify-center.flex-col + (let [nfs-supported? (nfs/supported?)] + [:div.cp__widgets-open-local-directory + [:div.select-file-wrap.cursor + (when nfs-supported? + {:on-click nfs/ls-dir-files}) - [:label.font-medium "Default Branch (make sure it's matched with your setting on Github): "] - [:div.mt-2.mb-4.relative.rounded-md.shadow-sm.max-w-xs - [:input#branch.form-input.block.w-full.sm:text-sm.sm:leading-5 - {:value @branch - :placeholder "master" - :on-change (fn [e] - (reset! branch (util/evalue e)))}]]]] + [:div + [:h1.title "Open a local directory"] + [:p.text-sm + "Your data will be stored only in your device."] + (when-not nfs-supported? + (ui/admonition :warning + [:p "It seems that your browser doesn't support the " - (ui/button - (t :git/add-repo-prompt-confirm) - :on-click - (fn [] - (let [branch (string/trim @branch)] - (if (string/blank? branch) - (notification/show! - [:p "Please input a branch, make sure it's matched with your setting on Github."] - :error - false) - (let [repo (util/lowercase-first @repo)] - (if (util/starts-with? repo "https://github.com/") - (let [repo (string/replace repo ".git" "")] - (repo-handler/create-repo! repo branch)) + [:a {:href "https://web.dev/file-system-access/" + :target "_blank"} + "new native filesystem API"] + [:span ", please use any chromium 86+ browser like Chrome, Vivaldi, Edge, Brave, etc."]]))]]]) + (when (state/logged?) + [:div.w-full.mx-auto.mt-10 + [:h1.title "Or you can"] + [:div + [:div + [:h1.title.mb-1 + (t :git/add-repo-prompt)] + [:div.mt-4.mb-4.relative.rounded-md.shadow-sm.max-w-xs + [:input#repo.form-input.block.w-full.sm:text-sm.sm:leading-5 + {:autoFocus true + :placeholder "https://github.com/username/repo" + :on-change (fn [e] + (reset! repo (util/evalue e)))}]]]] - (notification/show! - [:p "Please input a valid repo url, e.g. https://github.com/username/repo"] - :error - false)))))))]]))) + (ui/button + (t :git/add-repo-prompt-confirm) + :on-click + (fn [] + (let [repo (util/lowercase-first @repo)] + (if (util/starts-with? repo "https://github.com/") + (let [repo (string/replace repo ".git" "")] + (repo-handler/create-repo! repo)) + + (notification/show! + [:p "Please input a valid repo url, e.g. https://github.com/username/repo"] + :error + false)))))])]))) diff --git a/src/main/frontend/components/widgets.css b/src/main/frontend/components/widgets.css new file mode 100644 index 000000000..0c12de473 --- /dev/null +++ b/src/main/frontend/components/widgets.css @@ -0,0 +1,10 @@ +.cp__widgets { + &-open-local-directory { + .select-file-wrap { + padding: 50px; + border: dashed 2px; + border-radius: var(--border-radius-m); + justify-content: center; + } + } +} diff --git a/src/main/frontend/dicts.cljs b/src/main/frontend/dicts.cljs index 3b6a4a35e..586d94db8 100644 --- a/src/main/frontend/dicts.cljs +++ b/src/main/frontend/dicts.cljs @@ -17,34 +17,25 @@ title: $today :heading: true :END: ## Logseq is a _privacy-first_, _open-source_ platform for _knowledge_ sharing and management. -## This is a 10 minutes tutorial on how to use Logseq. Let's get started! +## This is a 3 minutes tutorial on how to use Logseq. Let's get started! ## Here are some tips might be useful. #+BEGIN_TIP Click to edit any block. Type `Enter` to create a new block. Type `Shift+Enter` to create a new line. Type `/` to show all the commands. -Type `[[` to reference or create a new page. -Type `((` to reference a block on any page. -Type `Tab` to indent and `Shift+Tab` to unindent block. -Type `/Draw` for free drawing. -Click the help button at the bottom right to see more keybindings. #+END_TIP ## 1. Let's create a page called [[How to take dummy notes?]]. You can click it to go to that page, or you can `Shift+Click` to open it in the right sidebar! Now you should see both _Linked References_ and _Unlinked References_. ## 2. Let's reference some blocks on [[How to take dummy notes?]], you can `Shift+Click` any block reference to open it in the right sidebar. Try making some changes on the right sidebar, those referenced blocks will be changed too! ### ((5f713e91-8a3c-4b04-a33a-c39482428e2d)) : This is a block reference. ### ((5f713ea8-8cba-403d-ac00-9964b1ec7190)) : This is another block reference. -## 3. I don't want to reference the block title, how about embedding the whole block with its children? -### {{{embed ((5f713e91-8a3c-4b04-a33a-c39482428e2d)) }}} -## 4. What if I want to embed the whole page? Here you go: -### {{{embed [[How to take dummy notes?]] }}} -## 5. Do you support tags? +## 3. Do you support tags? ### Of course, this is a #dummy tag. -## 6. Do you support tasks like todo/doing/done and priorities? +## 4. Do you support tasks like todo/doing/done and priorities? ### Yes, type `/` and pick your favorite todo keyword or priority (A/B/C). ### NOW [#A] A dummy tutorial on \"How to take dummy notes?\" -### LATER [#A] Check out this awesome video by [:a {:href \"https://twitter.com/EdTravelling\" :target \"_blank\"} \"@EdTravelling\"], which shows how to install logseq app on your GitHub repo and other cool features like graph view. +### LATER [#A] Check out this awesome video by [:a {:href \"https://twitter.com/EdTravelling\" :target \"_blank\"} \"@EdTravelling\"], which shows how to use logseq to open your local directory. [:div.video-wrapper.mb-4 [:iframe @@ -52,12 +43,12 @@ some changes on the right sidebar, those referenced blocks will be changed too! :allow \"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" :frameBorder \"0\" - :src \"https://www.youtube.com/embed/Vw-x7yTTO0s\" + :src \"https://www.youtube.com/embed/Afmqowr0qEQ\" :height \"367\" :width \"653\"}]] ### DONE Create a page ### CANCELED [#C] Write a page with more than 1000 blocks -## That's it! Thanks for your time and having fun! +## That's it! You can create more bullets or open a local directory to import some notes now! ## " :tutorial/dummy-notes "--- @@ -84,7 +75,7 @@ title: How to take dummy notes? :on-boarding/outliner "outliner" :on-boarding/notebook-for-organizing-and " notebook for organizing and " :on-boarding/your-personal-knowledge-base " your personal knowledge base." - :on-boarding/notice "Notice that this project is in its early days and under quick development, files might be corrupted." + :on-boarding/notice "Notice that this project is in its alpha testing and under quick development, files might be corrupted." :on-boarding/features-desc "Use it to organize your todo list, to write your journals, or to record your unique life." :on-boarding/privacy "The server will never store or analyze your private notes. Your data are plain text files, we support both Markdown and Emacs Org mode for the time being. Even if the website is down or can't be maintained, your data is always yours." :on-boarding/inspired-by " is hugely inspired by " @@ -95,7 +86,6 @@ title: How to take dummy notes? :on-boarding/use-1-desc "Currently, we only support syncing through Github, more options (Self-host git, WebDAV, Google Drive, etc.) will be added soon." :on-boarding/use-1-video "Check out this awesome video by " :on-boarding/use-2 "2. Use it locally (no need to login)" - :on-boarding/use-2-desc "It's only for the testing purpose now, please don't write any serious notes without login." :on-boarding/features "Features" :on-boarding/features-backlinks "Backlinks between [[Page]]s" :on-boarding/features-block-embed "Block embed" @@ -315,7 +305,6 @@ title: How to take dummy notes? :publishing "Publishing" :export "Export public pages" :all-repos "All repos" - :all-graphs "All graphs" :all-pages "All pages" :all-files "All files" :all-journals "All journals" @@ -571,7 +560,6 @@ title: How to take dummy notes? :on-boarding/use-1-desc "目前,我们只支持通过 Github 进行同步,将很快添加更多选项 (Self-host git、WebDAV、Google Drive等)。" :on-boarding/use-1-video "看看这个很棒的视频,创作者 " :on-boarding/use-2 "2. 在本地使用 (无需登录)" - :on-boarding/use-2-desc "暂时这个只为了测试演示,请登录来确保你的数据不会丢失!" :on-boarding/features "功能" :on-boarding/features-backlinks "[[页面]] 之间的双向链接" :on-boarding/features-block-embed "块嵌入" @@ -790,7 +778,6 @@ title: How to take dummy notes? :graph "图谱" :publishing "发布" :export "导出公开页面" - :all-graphs "所有库" :all-repos "所有库" :all-pages "所有页面" :all-files "所有文件" @@ -837,7 +824,6 @@ title: How to take dummy notes? :on-boarding/use-1-desc "目前,我們只支持通過 Github 進行同步,將很快添加更多選項 (Self-host git、WebDAV、Google Drive等)。" :on-boarding/use-1-video "看看這個很棒的視頻,創作者 " :on-boarding/use-2 "2. 在本地使用 (無需登錄)" - :on-boarding/use-2-desc "暫時這個只為了測試演示,請登錄來確保你的數據不會丟失!" :on-boarding/features "功能" :on-boarding/features-backlinks "[[頁面]] 之間的雙向鏈接" :on-boarding/features-block-embed "塊嵌入" @@ -1089,7 +1075,6 @@ title: How to take dummy notes? :on-boarding/use-1-desc "Tans, ondersteun ons sinkronisering met Github, meer opsies (eie bediener git, WebDAV, Google Drive ensovoorts) sal binnekort bygevoeg word. " :on-boarding/use-1-video "Gaan loer gerus na hierdie lekker video by " :on-boarding/use-2 "2. Gebruik dit plaaslik (geen aantekening benodig)" - :on-boarding/use-2-desc "Onthou om jou persoonlike notas nou en dan te rugsteun!" :on-boarding/features "Kenmerke" :on-boarding/features-backlinks "Terugskakels tussen [[Blaaie]]" :on-boarding/features-block-embed "Blok insluiting" diff --git a/src/main/frontend/handler/repo.cljs b/src/main/frontend/handler/repo.cljs index 2370a30ea..ff7c23042 100644 --- a/src/main/frontend/handler/repo.cljs +++ b/src/main/frontend/handler/repo.cljs @@ -554,12 +554,11 @@ (* (config/git-push-secs) 1000))) (defn create-repo! - [repo-url branch] + [repo-url] (spec/validate :repos/url repo-url) - (spec/validate :repos/branch branch) (util/post (str config/api "repos") {:url repo-url - :branch branch} + :branch "main"} (fn [result] (if (:installation_id result) (set! (.-href js/window.location) config/website) @@ -591,10 +590,10 @@ (if (and config-exists? (db/cloned? repo)) (p/do! - (git-handler/git-set-username-email! repo me) - (pull repo nil)) + (git-handler/git-set-username-email! repo me) + (pull repo nil)) (p/do! - (clone-and-load-db repo)))))) + (clone-and-load-db repo)))))) (periodically-pull-current-repo) (periodically-push-current-repo)) From 88a894ad9323eca22cfb467ff4decf593e929b1c Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Tue, 29 Dec 2020 11:53:19 +0800 Subject: [PATCH 2/2] fix: rename back to all graphs --- src/main/frontend/components/header.cljs | 2 +- src/main/frontend/dicts.cljs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/frontend/components/header.cljs b/src/main/frontend/components/header.cljs index f5eff3edd..dc7dd7785 100644 --- a/src/main/frontend/components/header.cljs +++ b/src/main/frontend/components/header.cljs @@ -66,7 +66,7 @@ :icon svg/graph-sm}) (when (or logged? (and (nfs/supported?) current-repo)) - {:title (t :all-repos) + {:title (t :all-graphs) :options {:href (rfe/href :repos)} :icon svg/repos-sm}) diff --git a/src/main/frontend/dicts.cljs b/src/main/frontend/dicts.cljs index 586d94db8..006e89977 100644 --- a/src/main/frontend/dicts.cljs +++ b/src/main/frontend/dicts.cljs @@ -305,6 +305,7 @@ title: How to take dummy notes? :publishing "Publishing" :export "Export public pages" :all-repos "All repos" + :all-graphs "All graphs" :all-pages "All pages" :all-files "All files" :all-journals "All journals" @@ -779,6 +780,7 @@ title: How to take dummy notes? :publishing "发布" :export "导出公开页面" :all-repos "所有库" + :all-graphs "所有库" :all-pages "所有页面" :all-files "所有文件" :my-publishing "我的发布"