diff options
| author | 2026-08-27 00:07:02 -0700 | |
|---|---|---|
| committer | 2026-08-27 00:07:02 -0700 | |
| commit | 1cf05f45874fca19706d66bbcd8d80ec851a959d (patch) | |
| tree | ab484150cbadac8d0a48f7e6b5d0c3d05e9282da /src/view/main.phel | |
| parent | 9d4733413c791c8e4f589a197a0da91dad279740 (diff) | |
| download | lezer-1cf05f45874fca19706d66bbcd8d80ec851a959d.tar.gz lezer-1cf05f45874fca19706d66bbcd8d80ec851a959d.zip | |
Clean up Authors
Diffstat (limited to 'src/view/main.phel')
| -rw-r--r-- | src/view/main.phel | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/view/main.phel b/src/view/main.phel index 9476591..f7a0190 100644 --- a/src/view/main.phel +++ b/src/view/main.phel @@ -1,6 +1,6 @@ (ns lezer.view.main (:require phel.router :as r) - (:require phel.html :refer [html doctype]) + (:require phel.html :refer [html doctype raw-string]) (:require phel.string :as str)) (def- head @@ -22,26 +22,39 @@ [:a {:href "https://github.com/phel-lang/phel-lang"} "GitHub"] [:a {:href "https://gitter.im/phel-lang/community"} "Community"]]) +(defn- authors-list [authors router] + (raw-string (html [:span + (let [a (first authors)] + (if a + [:a {:href (r/generate router :author {:id (:id (first authors))})} (:name (first authors))])) + (for [a :in (rest authors)] + [:span ", " + [:a {:href (r/generate router :author {:id (:id a)})} (:name a)]])]))) + (defn content [books router] (html (doctype :html5) [:html head [:body - [:ul - (for [b :in books] - [:li (:title (:book b)) - " by " - (for [a :in (:authors b)] - [:a {:href (r/generate router :author {:id (:id a)})} (:name a)])])] - [:div {:class "flex-center position-ref full-height"} - [:form {:action "/book" :method "POST"} - [:label {:for "title"} "Title: "] - [:input {:type "text" :name "title"}] - [:br] - [:label {:for "author"} "Author: "] - [:input {:type "text" :name "author"}] - [:input {:type "submit"}]]]]])) + [:header + [:h1 "Lezer"]] + [:main + [:ul + (for [b :in books] + [:li (:title (:book b)) + " by " + (authors-list (:authors b) router)])]] + [:aside + [:h2 "Add new book"] + [:div {:class "flex-center position-ref full-height"} + [:form {:action "/book" :method "POST"} + [:label {:for "title"} "Title: "] + [:input {:type "text" :name "title"}] + [:br] + [:label {:for "author"} "Author: "] + [:input {:type "text" :name "author"}] + [:input {:type "submit"}]]]]]])) (defn index-html [books router] (content books router)) |
