Skip to content

Commit

Permalink
prelaunch: Prelaunch routes, switch to hiccup2 ns
Browse files Browse the repository at this point in the history
  • Loading branch information
goshatch committed Sep 30, 2024
1 parent b232f67 commit 9e86725
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 33 deletions.
28 changes: 25 additions & 3 deletions src/tools/ifs/parts.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
14 changes: 6 additions & 8 deletions src/tools/ifs/parts/layouts/main.clj
Original file line number Diff line number Diff line change
@@ -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]]))
42 changes: 20 additions & 22 deletions src/tools/ifs/parts/pages.clj
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
(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]))

(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))))))

0 comments on commit 9e86725

Please sign in to comment.