diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/app.phel | 15 | ||||
| -rw-r--r-- | src/controller/routes.phel | 13 | ||||
| -rw-r--r-- | src/module/greet.phel | 4 | ||||
| -rw-r--r-- | src/view/main.phel | 30 |
4 files changed, 62 insertions, 0 deletions
diff --git a/src/app.phel b/src/app.phel new file mode 100644 index 0000000..a9d8af3 --- /dev/null +++ b/src/app.phel @@ -0,0 +1,15 @@ +(ns web-skeleton\app + (:require web-skeleton\controller\routes) + (:require phel\router :as r) + (:require phel\http :as h)) + +(def app + (r/handler + (r/router + [["/" {:handler routes/index-handler}] + ["/ping" {:name ::ping + :get {:handler routes/ping-handler} + :post {:handler routes/ping-handler}}]]))) + +(when-not *build-mode* + (h/emit-response (app (h/request-from-globals)))) diff --git a/src/controller/routes.phel b/src/controller/routes.phel new file mode 100644 index 0000000..ae0cdf1 --- /dev/null +++ b/src/controller/routes.phel @@ -0,0 +1,13 @@ +(ns web-skeleton\controller\routes + (:require web-skeleton\view\main :refer [index-html]) + (:require web-skeleton\module\greet :as g) + (:require phel\router :as r) + (:require phel\http :as h)) + +(defn index-handler [req] + (h/response-from-map {:status 200 + :body index-html})) + +(defn ping-handler [req] + (h/response-from-map {:status 200 + :body (g/greet (str "pong - " (rand)))})) diff --git a/src/module/greet.phel b/src/module/greet.phel new file mode 100644 index 0000000..239e425 --- /dev/null +++ b/src/module/greet.phel @@ -0,0 +1,4 @@ +(ns web-skeleton\module\greet) + +(defn greet [name] + (str "Hello, " name))
\ No newline at end of file diff --git a/src/view/main.phel b/src/view/main.phel new file mode 100644 index 0000000..34cb792 --- /dev/null +++ b/src/view/main.phel @@ -0,0 +1,30 @@ +(ns web-skeleton\view\main + (:require phel\html :refer [html doctype])) + +(def- head + [:head + [:meta {:charset "utf-8"}] + [:meta {:name "viewport" :content "width=device-width, initial-scale=1"}] + [:link {:rel "stylesheet" :href "./css/style.css"}] + [:link {:rel "icon" :type "image/png" :href "./images/favicon-32.png"}] + [:title "Phel-lang"]]) + +(def- logo + [:div {:class "logo"} + [:img {:src "./images/logo.svg" :width "360"}]]) + +(def- links + [:div {:class "links"} + [:a {:href "https://phel-lang.org/"} "Homepage"] + [:a {:href "https://phel-lang.org/documentation/getting-started/"} "Getting started"] + [:a {:href "https://github.com/phel-lang/phel-lang"} "GitHub"] + [:a {:href "https://gitter.im/phel-lang/community"} "Community"]]) + +(def- content + [:div {:class "flex-center position-ref full-height"} + [:div {:class "content"} logo links]]) + +(def index-html (html + (doctype :html5) + head + content))
\ No newline at end of file |
