Skip to content

Commit

Permalink
stylofixes
Browse files Browse the repository at this point in the history
  • Loading branch information
niquola committed Aug 30, 2023
1 parent d0fde1c commit 7b7fa19
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 22 deletions.
8 changes: 8 additions & 0 deletions src/zd/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@
{:status 200
:body (str (store/parent-name docname))}))

(defmethod zen/op 'zd/re-validate
[ztx _cfg _req & opts]
(store/re-validate ztx)
{:status 301
:headers {"Location" "/errors"
"Cache-Control" "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"}})


(defmethod zen/start 'zd/zendoc
[ztx config & opts]
Expand Down Expand Up @@ -200,6 +207,7 @@

(def ztx (start))


(stop ztx)

(:zd/backlinks @ztx)
Expand Down
9 changes: 7 additions & 2 deletions src/zd/view/menu.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@
[:div "Search"]]

(let [cnt (count (or (store/errors ztx) []))]
(when (> cnt 0)
(if (> cnt 0)
[:div#errors-link {:class (c :flex [:py 1.5] [:space-x 2] :items-center [:text :red-500])}
[:div {:class (c :flex-1)} (utils/menu-link ztx 'errors)] [:b#errors-count {:class (c :text-sm)} cnt]]))
[:div {:class (c :flex-1)} (utils/menu-link ztx 'errors)] [:b#errors-count {:class (c :text-sm)} cnt]]
[:form {:method "POST"
:class (c [:py 0] :flex :items-center [:space-x 2] {:margin-block-end 0 :font-size "inherited"})
:action "/_revalidate"}
[:div {:class utils/menu-icon-c} [:i.fa-solid.fa-check]]
[:button {:class (c [:py 1] :text-base)} "Validate"]]))

[:a {:class utils/menu-link-c :href "/git"}
[:div {:class utils/menu-icon-c} [:i.fa-solid.fa-timeline]]
Expand Down
51 changes: 31 additions & 20 deletions src/zd/view/timeline.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
[zd.view.utils :as utils :refer [btn-c]]
[clojure.string :as str]))

(defn file-to-link [ztx f]
(when (str/starts-with? f "docs/")
(utils/symbol-link ztx
(-> (str/replace f #"^docs/" "")
(str/replace #"\.zd$" "")
(str/replace #"/" ".")
(symbol)))))

(defn changes-view [ztx changes]
[:form {:action "/git" :method "POST"}
[:div {:class (c :font-bold :text-lg :border-b :flex [:space-x 4] [:py 0.5] :divide-y)}
Expand All @@ -22,33 +30,36 @@
(get {:deleted [:i.fa-solid.fa-trash]
:new [:i.fa-solid.fa-square-plus]
:modified [:i.fa-solid.fa-pen-to-square]} m (str m))]
[:div f]])))]
[:div f]
(file-to-link ztx f)])))]
[:div {:class (c [:my 2] [:py 2] :border-t)}
[:button {:class btn-c} "Commit"]]])

(defn history-view [ztx history]
[:div {:class (c [:mt 4])}
[:div {:class (c :font-bold :text-lg :border-b)} "History"]
(->> history
(map (fn [{date :date commits :commits}]
[:details {:class (c [:my 4])}
[:summary {:class (c :block :border-b [:pt 1] [:pb 0.5] :font-bold [:text :gray-600] :cursor-pointer [:hover [:bg :gray-100]])} date]
[:div
(->> commits
(map (fn [com]
[:details {:class (c [:py 1])}
[:summary {:class (c :border-b [:space-x 4] :cursor-pointer [:hover [:bg :gray-100]])}
[:span {:class (c [:w 8] [:text :gray-600])}
(last (str/split (:time com) #"\s"))]
[:span (:user com)]
[:span "-"]
[:span (:comment com)]]
[:div {:class (c [:pt 2])}
(->> (:files com)
(map (fn [f]
[:div {:class (c [:ml 4] [:py 0.5] :flex :items-center [:space-x 2])}
[:i.fa-regular.fa-file {:class (str (c [:gray-400]))}]
[:space f]])))]])))]])))])
(map-indexed
(fn [i {date :date commits :commits}]
[:details {:class (c [:my 4]) :open (> 10 i)}
[:summary {:class (c :block :border-b [:pt 1] [:pb 0.5] :font-bold [:text :gray-600] :cursor-pointer [:hover [:bg :gray-100]])} date]
[:div
(->> commits
(map-indexed (fn [j com]
[:details {:class (c [:py 0]) :open (> 3 i)}
[:summary {:class (c [:px 2] [:bg :gray-100] :border-b [:space-x 4] :cursor-pointer [:hover [:bg :gray-100]])}
[:span {:class (c [:w 8] [:text :gray-600])}
(last (str/split (:time com) #"\s"))]
[:span (:user com)]
[:span "-"]
[:span (:comment com)]]
[:div {:class (c [:pt 2] [:pb 4] :border-b)}
(->> (:files com)
(map (fn [f]
[:div {:class (c [:ml 4] [:py 0.5] :flex :items-center [:space-x 2])}
[:i.fa-regular.fa-file {:class (str (c [:gray-400]))}]
[:space f]
(file-to-link ztx f)])))]])))]])))])

(defn view [ztx {changes :changes history :history}]
[:div {:class (c [:w 200])}
Expand Down
4 changes: 4 additions & 0 deletions zrc/zd.edn
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,17 @@
search-page
{:zen/tags #{zen-web/op zen/op}}

re-validate
{:zen/tags #{zen-web/op zen/op}}

api
{:zen/tags #{zen-web/api}
:engine zen-web/routemap
;; TODO move zen web defaults to zen web core
;; :mw [zen-web/defaults]
"_errors" {:GET check-errors}
"_search" {:GET search-page}
"_revalidate" {:POST re-validate}
"git" {:GET git-changes
:POST git-commit}
"new" {:GET new-doc
Expand Down

0 comments on commit 7b7fa19

Please sign in to comment.