mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 22:47:36 +00:00
enhance: add append improvements based on feedback
* For append api call, default to today if app is not in a page context * API relate commands can auth w/ env var
This commit is contained in:
1
deps/cli/CHANGELOG.md
vendored
1
deps/cli/CHANGELOG.md
vendored
@@ -3,6 +3,7 @@
|
||||
* Add append command to add text to current page
|
||||
* Change export-edn command to default to writing to a file, like the export command
|
||||
* Rename --api-query-token options to --api-server-token
|
||||
* API related commands can also authenticate with $LOGSEQ_API_SERVER_TOKEN
|
||||
* Add descriptions for most commands to explain in-depth usage
|
||||
|
||||
## 0.1.0
|
||||
|
||||
3
deps/cli/README.md
vendored
3
deps/cli/README.md
vendored
@@ -61,6 +61,9 @@ Search found 100 results:
|
||||
dev:db-export woot woot.edn && dev:db-create woot2 woot.edn
|
||||
dev:db-diff woot woot2
|
||||
...
|
||||
# Can also authenticate api with $LOGSEQ_API_SERVER_TOKEN
|
||||
$ LOGSEQ_API_SERVER_TOKEN=my-token logseq search woot
|
||||
...
|
||||
|
||||
# Search a local graph
|
||||
$ logseq search woot page
|
||||
|
||||
3
deps/cli/src/logseq/cli/commands/append.cljs
vendored
3
deps/cli/src/logseq/cli/commands/append.cljs
vendored
@@ -11,8 +11,7 @@
|
||||
(if (= 200 (.-status resp))
|
||||
(p/let [body (.json resp)]
|
||||
(if (.-error body)
|
||||
(cli-util/error (str "Failed to append. Ensure the app is in a specific page.\n"
|
||||
"API Response: "
|
||||
(cli-util/error (str "Failed to append.\nAPI Error: "
|
||||
(string/replace (.-error body) "\n" "\\\\n")))
|
||||
(println "Success!")))
|
||||
(cli-util/api-handle-error-response resp)))
|
||||
|
||||
3
deps/cli/src/logseq/cli/util.cljs
vendored
3
deps/cli/src/logseq/cli/util.cljs
vendored
@@ -18,7 +18,8 @@
|
||||
(defn api-fetch [token method args]
|
||||
(js/fetch "http://127.0.0.1:12315/api"
|
||||
(clj->js {:method "POST"
|
||||
:headers {"Authorization" (str "Bearer " token)
|
||||
:headers {"Authorization"
|
||||
(str "Bearer " (or token js/process.env.LOGSEQ_API_SERVER_TOKEN))
|
||||
"Content-Type" "application/json"}
|
||||
:body (js/JSON.stringify
|
||||
(clj->js {:method method
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
[electron.ipc :as ipc]
|
||||
[frontend.commands :as commands]
|
||||
[frontend.config :as config]
|
||||
[frontend.date :as date]
|
||||
[frontend.db :as db]
|
||||
[frontend.db.async :as db-async]
|
||||
[frontend.db.conn :as conn]
|
||||
@@ -1082,8 +1083,9 @@
|
||||
(and (nil? opts) (some->> content (instance? js/Object))))
|
||||
opts (if current-page? content opts)
|
||||
content (if current-page? uuid-or-page-name content)
|
||||
uuid-or-page-name (if current-page? (state/get-current-page)
|
||||
uuid-or-page-name)]
|
||||
uuid-or-page-name (if current-page?
|
||||
(or (state/get-current-page) (date/today))
|
||||
uuid-or-page-name)]
|
||||
(p/let [_ (<ensure-page-loaded uuid-or-page-name)
|
||||
page? (not (util/uuid-string? uuid-or-page-name))
|
||||
page-not-exist? (and page? (nil? (db-model/get-page uuid-or-page-name)))
|
||||
|
||||
Reference in New Issue
Block a user