Makes the history page use local storage

This commit is contained in:
2023-01-11 13:15:46 -08:00
parent 3a2dc07227
commit 045aa01edc
2 changed files with 20 additions and 14 deletions

View File

@@ -11,6 +11,17 @@
[datomic.api :as d] [datomic.api :as d]
[hiccup2.core :as hiccup])) [hiccup2.core :as hiccup]))
(defn setup-script [request]
(str
"
window.onload = function () {
document.body.addEventListener(\"htmx:configRequest\", function(event) {
event.detail.headers[\"Authorization\"] = \"Token \" + localStorage.getItem(\"jwt\") ;
console.log(event.detail.headers[\"Authorization\"]);
});
}"))
(defn base-page [request contents] (defn base-page [request contents]
[:html.has-navbar-fixed-top [:html.has-navbar-fixed-top
[:head [:head
@@ -32,16 +43,10 @@
[:script {:src "https://unpkg.com/htmx.org@1.8.4" [:script {:src "https://unpkg.com/htmx.org@1.8.4"
:integrity "sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV" :integrity "sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV"
:crossorigin= "anonymous"}] :crossorigin= "anonymous"}]
[:script {:type "text/javascript", :src "https://cdn.yodlee.com/fastlink/v4/initialize.js", :async "async" }]] [:script {:type "text/javascript", :src "https://cdn.yodlee.com/fastlink/v4/initialize.js", :async "async" }]
[:script {:type "text/javascript"} [:script {:type "text/javascript"}
(hiccup/raw (hiccup/raw (setup-script request))]]
(str
"
window.onload = function () {
document.body.addEventListener(\"htmx:configRequest\", function(event) {
event.detail.headers[\"Authorization\"] = \"Token " (get (:query-params request) "jwt")" \" ;
});
}"))]
[:body [:body
[:div {:id "app"} [:div {:id "app"}
@@ -81,6 +86,7 @@ window.onload = function () {
{:status 200 {:status 200
:headers {"Content-Type" "text/html"} :headers {"Content-Type" "text/html"}
:body (str :body (str
"<!DOCTYPE html>"
(hiccup/html (hiccup/html
{} {}
hiccup))}) hiccup))})