summaryrefslogtreecommitdiffstats
path: root/src/view
diff options
context:
space:
mode:
Diffstat (limited to 'src/view')
-rw-r--r--src/view/author.phel14
-rw-r--r--src/view/main.phel18
2 files changed, 22 insertions, 10 deletions
diff --git a/src/view/author.phel b/src/view/author.phel
new file mode 100644
index 0000000..4253941
--- /dev/null
+++ b/src/view/author.phel
@@ -0,0 +1,14 @@
+(ns lezer.view.author
+ (:require phel.html :refer [html doctype]))
+
+(defn author-html [author books]
+ (html
+ (doctype :html5)
+ [:html
+ [:head
+ [:title (str "Author: " author " - Lezer")]]
+ [:body
+ [:h1 (:name author)]
+ [:ul
+ (for [book :in books]
+ [:li (:title book)])]]]))
diff --git a/src/view/main.phel b/src/view/main.phel
index 1be6226..9476591 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.pdo)
(:require phel.string :as str))
(def- head
@@ -22,7 +22,7 @@
[:a {:href "https://github.com/phel-lang/phel-lang"} "GitHub"]
[:a {:href "https://gitter.im/phel-lang/community"} "Community"]])
-(defn content [books]
+(defn content [books router]
(html
(doctype :html5)
[:html
@@ -30,12 +30,10 @@
[:body
[:ul
(for [b :in books]
- (let [authors (:authors b)
- book (:book b)]
- [:li (:title book)
- (if (not (empty? authors))
- (str " by "
- (str/join ", " (map :name authors))))]))]
+ [: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: "]
@@ -45,5 +43,5 @@
[:input {:type "text" :name "author"}]
[:input {:type "submit"}]]]]]))
-(defn index-html [books]
- (content books))
+(defn index-html [books router]
+ (content books router))