diff --git a/src/tools/ifs/parts.clj b/src/tools/ifs/parts.clj index 7e8c6cd..bd9ac86 100644 --- a/src/tools/ifs/parts.clj +++ b/src/tools/ifs/parts.clj @@ -19,11 +19,34 @@ [tools.ifs.parts.db :as db] [tools.ifs.parts.pages :as pages] [tools.ifs.parts.api.auth :as auth] - [tools.ifs.parts.api.account :as account])) + [tools.ifs.parts.api.account :as account] + [tools.ifs.parts.waitlist :as waitlist])) ;; --------------------------------------------------------- ;; Application +(def prelaunch-app + (middleware/wrap-default-middlewares + (ring/ring-handler + (ring/router + [["/" {:get {:handler #(pages/home-page %)}}] + ["/waitlist-signup" {:post {:handler #(waitlist/signup %)}}]] + {:data {:middleware [wrap-params + middleware/exception + middleware/logging + middleware/wrap-html-response]}})))) + +;; TODO: We need to later figure out a way to combine HTML routes and API +;; routes. +;; +;; Currently, the main issue is that I cannot figure out a way to combine API +;; namespaces with different sets of middleware for each. +;; +;; For example, I want the /api namespace to have JSON-related middlewares, but +;; not the root namespace, which serves text/html instead. +;; +;; It is also entirely possible that API routes will be removed, and only HTML +;; routes will remain. (def app (middleware/wrap-default-middlewares (ring/ring-handler @@ -69,8 +92,7 @@ "Starts the web server" [port] (mulog/log ::starting-server :port port) - (server/run-server #'app {:port port})) - + (server/run-server #'prelaunch-app {:port port})) (defn -main "Entry point into the application via clojure.main -M" diff --git a/src/tools/ifs/parts/layouts/main.clj b/src/tools/ifs/parts/layouts/main.clj index a425aaf..cd42fd5 100644 --- a/src/tools/ifs/parts/layouts/main.clj +++ b/src/tools/ifs/parts/layouts/main.clj @@ -1,20 +1,18 @@ (ns tools.ifs.parts.layouts.main - (:require [hiccup.page :refer [html5 include-css include-js]])) + (:require [hiccup2.core :refer [html]])) (defn layout "Fundamental application layout" [title & content] - (html5 + (html [:head [:meta {:charset "utf-8"}] [:meta {:name "viewport" :content "width=device-width, initial-scale=1"}] [:meta {:name "description" :content "Toolkit for IFS practitioners and their clients"}] [:link {:rel "icon" :sizes "192x192" :href "/images/icons/favicon.png"}] [:link {:rel "apple-touch-icon" :href "/images/icons/favicon.png"}] - [:title title] - (include-css "/css/style.css") - (include-js "/js/main.js")] + [:title (str title " — Parts")] + [:link {:rel "stylesheet" :href "/css/style.css"}] + [:script {:src "/js/main.js"}]] [:body - [:secton#container content] - [:script - "window.addEventListener('load', function () { tools.ifs.parts.core.init(); });"]])) + [:secton#container content]])) diff --git a/src/tools/ifs/parts/pages.clj b/src/tools/ifs/parts/pages.clj index 9a14a4d..39ad6a6 100644 --- a/src/tools/ifs/parts/pages.clj +++ b/src/tools/ifs/parts/pages.clj @@ -1,5 +1,5 @@ (ns tools.ifs.parts.pages - (:require [hiccup.core :refer [html]] + (:require [hiccup2.core :refer [html]] [tools.ifs.parts.layouts.main :refer [layout]] [tools.ifs.parts.layouts.partials :refer [header footer]] [ring.util.response :as response])) @@ -7,30 +7,28 @@ (defn system-graph "Page rendering the graph of a system" [system-id] - (-> (response/response - (html - (layout "System" - (header) - [:div - [:h2 "System"]] - [:div#chart] - (footer)))) - (response/content-type "text/html"))) + (response/response + (html + (layout "System" + (header) + [:div [:h2 "System"]] + [:div#chart] + (footer))))) (defn home-page "Page rendered for GET /" [_] (-> (response/response (html - (layout "Home Page" - (header) - [:div#home - [:h1 - {:align "center"} - "Understand your client's parts and their relationships"] - [:h3.hook - {:align "center"} - [:strong "Parts"] - " is a tool for IFS practitioners to keep track of, visualise, and explore the relationships between their clients’ parts."]] - (footer)))) - (response/content-type "text/html"))) + (layout + "Home Page" + (header) + [:div#home + [:h1 + {:align "center"} + "Understand your client's parts and their relationships"] + [:h3.hook + {:align "center"} + [:strong "Parts"] + " is a tool for IFS practitioners to keep track of, visualise, and explore the relationships between their clients’ parts."]] + (footer))))))