aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tau/handler.clj
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2022-12-26 21:49:13 +0100
committerMiguel Ángel Moreno <mail@migalmoreno.com>2022-12-26 21:49:13 +0100
commitdce9e36b352509665887ea1ca2e6f81904038a11 (patch)
tree2ba797188500e2677e3182f38d2334307be3e295 /src/backend/tau/handler.clj
parent9361d6444548748445db1548d0e3a6291d802bd3 (diff)
feat(backend): Modularize components
Diffstat (limited to 'src/backend/tau/handler.clj')
-rw-r--r--src/backend/tau/handler.clj71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/backend/tau/handler.clj b/src/backend/tau/handler.clj
new file mode 100644
index 0000000..3dc5219
--- /dev/null
+++ b/src/backend/tau/handler.clj
@@ -0,0 +1,71 @@
+(ns tau.handler
+ (:require
+ [clojure.string :as str]
+ [hiccup.page :as hiccup]
+ [ring.util.response :refer [response]]
+ [tau.api.stream :as stream]
+ [tau.api.search :as search]
+ [tau.api.channel :as channel]
+ [tau.api.playlist :as playlist]
+ [tau.api.comment :as comment]
+ [tau.api.kiosk :as kiosk]
+ [tau.api.service :as service]))
+
+(defn index
+ [_]
+ (response
+ (hiccup/html5
+ [:head
+ [:meta {:charset "UTF-8"}]
+ [:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]
+ [:title "Tau"]
+ (hiccup/include-css "/css/tau.css")]
+ [:body
+ [:div#app]
+ (hiccup/include-js "/js/main.js")
+ [:script "tau.core.init();"]])))
+
+(defn search
+ [{:keys [parameters] :as req}]
+ (let [{:keys [service-id]} (:path parameters)
+ {:keys [q]} (:query parameters)
+ {:strs [contentFilters sortFilter nextPage]} (:query-params req)
+ content-filters (and contentFilters (str/split contentFilters #","))]
+ (response (if nextPage
+ (search/get-info service-id q contentFilters sortFilter nextPage)
+ (search/get-info service-id q contentFilters sortFilter)))))
+
+(defn channel
+ [{{:keys [url]} :path-params {:strs [nextPage]} :query-params}]
+ (response (if nextPage
+ (channel/get-info url nextPage)
+ (channel/get-info url))))
+
+(defn playlist
+ [{{:keys [url]} :path-params {:strs [nextPage]} :query-params}]
+ (response (if nextPage
+ (playlist/get-info url nextPage)
+ (playlist/get-info url))))
+
+(defn comments
+ [{{:keys [url]} :path-params {:strs [nextPage]} :query-params}]
+ (response (if nextPage
+ (comment/get-info url nextPage)
+ (comment/get-info url))))
+
+(defn services
+ [_]
+ (response (service/get-services)))
+
+(defn kiosks
+ [{{{:keys [service-id]} :path} :parameters}]
+ (response (kiosk/get-kiosks service-id)))
+
+(defn kiosk
+ [{{{:keys [kiosk-id service-id]} :path} :parameters {:strs [nextPage]} :query-params}]
+ (response (if nextPage
+ (kiosk/get-info kiosk-id service-id nextPage)
+ (kiosk/get-info kiosk-id service-id))))
+
+(defn stream [{{:keys [url]} :path-params}]
+ (response (stream/get-info url)))