summaryrefslogtreecommitdiffstats
path: root/src/view
diff options
context:
space:
mode:
Diffstat (limited to 'src/view')
-rw-r--r--src/view/main.phel43
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))