summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chef/core.clj8
-rw-r--r--src/chef/pages/admin.clj10
-rw-r--r--src/chef/pages/home.clj10
-rw-r--r--src/chef/pages/utils.clj8
-rw-r--r--src/chef/routes.clj13
5 files changed, 49 insertions, 0 deletions
diff --git a/src/chef/core.clj b/src/chef/core.clj
new file mode 100644
index 0000000..86aeb17
--- /dev/null
+++ b/src/chef/core.clj
@@ -0,0 +1,8 @@
+(ns chef.core
+ (:require [org.httpkit.server :as http-server]
+ [chef.routes :as croutes])
+ (:gen-class))
+
+(defn -main [& args]
+ (println "Starting http server...")
+ (http-server/run-server croutes/ring-handler {:port 8080}))
diff --git a/src/chef/pages/admin.clj b/src/chef/pages/admin.clj
new file mode 100644
index 0000000..c06b475
--- /dev/null
+++ b/src/chef/pages/admin.clj
@@ -0,0 +1,10 @@
+(ns chef.pages.admin
+ (:require [chef.pages.utils :as cputils]
+ [hiccup2.core :as html]
+ [ring.util.response :as ruresp]))
+
+(defn handler [req]
+ (-> (cputils/gen-page "chef - Dashboard" [:i "Coming soon..."])
+ html/html
+ str
+ ruresp/response))
diff --git a/src/chef/pages/home.clj b/src/chef/pages/home.clj
new file mode 100644
index 0000000..725ba2b
--- /dev/null
+++ b/src/chef/pages/home.clj
@@ -0,0 +1,10 @@
+(ns chef.pages.home
+ (:require [hiccup2.core :as html]
+ [ring.util.response :as ruresp]
+ [chef.pages.utils :as cputils]))
+
+(defn handler [req]
+ (-> (cputils/gen-page "chef" [:i "Coming soon..."])
+ html/html
+ str
+ ruresp/response))
diff --git a/src/chef/pages/utils.clj b/src/chef/pages/utils.clj
new file mode 100644
index 0000000..72d33fd
--- /dev/null
+++ b/src/chef/pages/utils.clj
@@ -0,0 +1,8 @@
+(ns chef.pages.utils)
+
+(defn gen-page [title & content]
+ [:html
+ [:head
+ [:meta {:name "viewport" :content "width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"}]
+ [:title title]]
+ (apply conj [:body] content [[:script {:src "/static/htmx.js"}]])])
diff --git a/src/chef/routes.clj b/src/chef/routes.clj
new file mode 100644
index 0000000..51c721a
--- /dev/null
+++ b/src/chef/routes.clj
@@ -0,0 +1,13 @@
+(ns chef.routes
+ (:require [reitit.ring :as rring]
+
+ [chef.pages.home :as cphome]
+ [chef.pages.admin :as cpadmin]))
+
+(def router [["/" {:get {:handler cphome/handler}}]
+ ["/admin/" {:get {:handler cpadmin/handler}}]
+ ["/static/*" (rring/create-resource-handler)]])
+
+(def ring-handler (-> router
+ rring/router
+ (rring/ring-handler (rring/redirect-trailing-slash-handler))))