Skip to content

Commit

Permalink
use zd config in api, fix keystore, add margin
Browse files Browse the repository at this point in the history
  • Loading branch information
carbon-hvze committed Jul 20, 2023
1 parent a64bbf1 commit 21628ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
18 changes: 10 additions & 8 deletions src/zd/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
(zen/get-symbol ztx)))

;; ISSUE mw does not work for / request
;; TODO remove this mw
(defmethod web/middleware-in 'zd/append-doc
[ztx _cfg {{id :id} :route-params :as req} & opts]
(when (some? id)
Expand All @@ -39,7 +40,7 @@
uri :uri
hs :headers
doc :doc :as req} & opts]
(let [{r :root ps :paths} (zendoc-config ztx)]
(let [{r :root ps :paths :as config} (zendoc-config ztx)]
(cond
(= uri "/")
{:status 301
Expand All @@ -53,11 +54,11 @@

(get hs "x-body")
{:status 200
:body (hiccup/html (render/render-doc ztx {:request req :paths ps :doc doc :root r} doc))}
:body (hiccup/html (render/render-doc ztx {:request req :paths ps :doc doc :root r :config config} doc))}

:else
{:status 200
:body (render/doc-view ztx {:request req :paths ps :doc doc :root r} doc)})))
:body (render/doc-view ztx {:request req :paths ps :doc doc :root r :config config} doc)})))

(defmethod web/middleware-out 'zd/layout
[ztx config {page :page :as req} {bdy :body :as resp} & args]
Expand Down Expand Up @@ -114,11 +115,12 @@
:body (render/editor ztx {:root r :request req :doc doc} doc)}))

(defmethod zen/op 'zd/render-preview
[ztx _ {{id :id} :route-params r :zd/root :as req} & opts]
{:headers {"Content-Type" "text/html"}
:body (-> (render/preview ztx {:request req :root r} (slurp (:body req)))
(hiccup/html))
:status 200})
[ztx _ {{id :id} :route-params :as req} & opts]
(let [{r :root ps :paths :as config} (zendoc-config ztx)]
{:headers {"Content-Type" "text/html"}
:body (-> (render/preview ztx {:request req :paths ps :config config :root r} (slurp (:body req)))
(hiccup/html))
:status 200}))

(defmethod zen/op 'zd.events/logger
[ztx config {ev-name :ev :as ev} & opts]
Expand Down
2 changes: 1 addition & 1 deletion src/zd/blocks/anns.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(defmethod methods/renderann :title
[ztx {doc :doc} {{title :title} :ann cnt :content k :key :as block}]
[:div {:class (c [:py 4])}
[:h2 {:class (c :flex :items-center [:m 0] [:py 4]) :id k}
[:h2 {:class (c :flex :items-center [:mb 0.8] [:py 4]) :id k}
title]
cnt])

Expand Down
4 changes: 2 additions & 2 deletions src/zd/gitsync.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
{:status :updated}))))))

(defn init-remote [ztx {:keys [from branch keystore to] k :key :as remote}]
(let [ident {:name "pubkey"#_(or k ["id_rsa" "id_dsa" "id_ecdsa" "id_ed25519"])
(let [ident {:name (or k ["id_rsa" "id_dsa" "id_ecdsa" "id_ed25519"])
;; TODO support for other os
:trust-all? true
:key-dir (or keystore "~/.ssh")}]
:key-dir (or keystore (str (System/getProperty "user.home") "/.ssh"))}]
(when (string? to)
(git/with-identity ident
(let [pulled? (.exists (io/file to))
Expand Down

0 comments on commit 21628ba

Please sign in to comment.