Merge branch 'master' into feat/google-login

pull/1009/head
Tienson Qin 2020-12-29 14:08:57 +08:00
commit 80e4619774
9 changed files with 102 additions and 141 deletions

View File

@ -157,21 +157,20 @@
(not config/publishing?))
(ui/dropdown-with-links
(fn [{:keys [toggle-fn]}]
[:a {:on-click toggle-fn}
[:span.ml-1 "Login"]
[:span.ml-1 {:style {:border-top-color "#6b7280"}}]])
(let [list [{:title (t :login-github)
:url "/login/github"}
{:title (t :login-google)
:url "/login/google"}]]
(fn [{:keys [toggle-fn]}]
[:a {:on-click toggle-fn}
[:span.ml-1.text-sm (t :login)]])
(let [list [{:title (t :login-google)
:url "/login/google"}
{:title (t :login-github)
:url "/login/github"}]]
(mapv
(fn [{:keys [title url]}]
{:title title
:options
{:on-click
(fn [_] (set! (.-href js/window.location) url))}})
list))))
(fn [{:keys [title url]}]
{:title title
:options
{:on-click
(fn [_] (set! (.-href js/window.location) url))}})
list))))
(repo/sync-status)
@ -179,17 +178,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)}

View File

@ -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-graph))
(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]

View File

@ -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
{}

View File

@ -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}

View File

@ -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;

View File

@ -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]
@ -41,68 +42,54 @@
(rum/defcs add-graph <
(rum/local "" ::repo)
(rum/local "master" ::branch)
[state]
(let [repo (get state ::repo)
branch (get state ::branch)
login-source (state/get-login-source)]
github-authed? (:github-authed? (state/get-me))]
(rum/with-context [[t] i18n/*tongue-context*]
(if (= "github" login-source)
[:div.p-8.flex.items-center.justify-center
[:div.w-full.mx-auto
[:div
[:div.p-8.flex.flex-col
[:h1.title "Add a graph"]
(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})
[: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 "
[: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 github-authed?
[:div.w-full.mx-auto.mt-10
[:h1.title "Or"]
[: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
[: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)))}]]]]
[: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)))}]]]]
(ui/button
(ui/button
(t :git/add-repo-prompt-confirm)
:on-click
(fn []
(let [branch (string/trim @branch)]
(if (string/blank? branch)
(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 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))
(notification/show!
[:p "Please input a valid repo url, e.g. https://github.com/username/repo"]
:error
false)))))))]]
(if-not (nfs-handler/supported?)
[:div (t :help/select-nfs-browser)]
[:div.p-8.flex.items-center.justify-center
[:div.w-full.mx-auto
[:div
[:div
[:h1.title.mb-1
"Please open a local directory : "]]
[:a.text-lg.font-medium.opacity-70.hover:opacity-100.ml-3.block
{:on-click (fn [] (nfs/ls-dir-files))}
[:div.flex.flex-row
[:span.inline-block svg/folder-add-large]
(when-not config/mobile?
[:span.ml-1.inline-block {:style {:margin-top "20px"}}
(t :open)])]]]]])))))
[:p "Please input a valid repo url, e.g. https://github.com/username/repo"]
:error
false)))))])])))

View File

@ -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;
}
}
}

View File

@ -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"
@ -334,6 +324,7 @@ title: How to take dummy notes?
:loading-files "Loading files"
:login-github "Login with Github"
:login-google "Login with Google"
:login "Login"
:go-to "Go to "
:or "or"
:download "Download"
@ -575,7 +566,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 "块嵌入"
@ -795,8 +785,8 @@ title: How to take dummy notes?
:graph "图谱"
:publishing "发布"
:export "导出公开页面"
:all-graphs "所有库"
:all-repos "所有库"
:all-graphs "所有库"
:all-pages "所有页面"
:all-files "所有文件"
:my-publishing "我的发布"
@ -813,6 +803,7 @@ title: How to take dummy notes?
:loading-files "正在加载文件"
:login-github "用 Github 登录"
:login-google "用 Google 登录"
:login "登录"
:go-to "转到"
:or "或"
:download "下载"
@ -843,7 +834,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 "塊嵌入"
@ -1097,7 +1087,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"

View File

@ -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))