From 8b9f09d718336fc33420525b1ca0fb7311a73003 Mon Sep 17 00:00:00 2001 From: Jose Aviles Date: Sat, 19 Oct 2024 00:20:35 -0400 Subject: [PATCH 1/3] update docs --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index be146d2..9c1edbc 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,40 @@ But it can be customized to include other directories: ["src" "resources" "checkouts/foo/src"])) ``` +Do note this library will only refresh the browser and nothing else. This means updates on the code will trigger a browser refresh, but the code itself won't be reloaded. + +This is good when the assets you are modifying reside in `resources/` such as html, css and JS files. However, sometimes you might reach for tools such as (hiccup)[https://github.com/weavejester/hiccup] for HTML templating. Under these scenarios, `ring-refresh` needs something else to reload the code for it. + +The following is an example using `ring.middleware.reload` to reload the code when you modify the `hiccup` template. You can alternatively reload with the REPL. + +```clojure +(ns test.core + (:require [ring.adapter.jetty :refer [run-jetty]] + [ring.middleware.reload :refer [wrap-reload]] + [ring.middleware.refresh :refer [wrap-refresh]] + [hiccup.page :refer [html5]])) + +(defn home-page [] + (html5 + [:head + [:title "Ring Refresh Example"]] + [:body + [:p "This page will auto-refresh when you change the source code."] + [:p "Try changing something and saving the file, and you'll see the update automatically."]])) + +(defn handler [request] + {:status 200 + :headers {"Content-Type" "text/html"} + :body (home-page)}) + +(def app + (-> handler + wrap-refresh)) + +(defn -main [] + (run-jetty (wrap-reload #'app) {:port 3000})) +``` + ## License Copyright © 2024 James Reeves From 05de2875d65d61ecf654f088e0c0ef9079bfe399 Mon Sep 17 00:00:00 2001 From: Jose Aviles Date: Sat, 19 Oct 2024 00:24:17 -0400 Subject: [PATCH 2/3] update link and headline --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c1edbc..9debeed 100644 --- a/README.md +++ b/README.md @@ -33,10 +33,11 @@ But it can be customized to include other directories: your-handler ["src" "resources" "checkouts/foo/src"])) ``` +### Caveats Do note this library will only refresh the browser and nothing else. This means updates on the code will trigger a browser refresh, but the code itself won't be reloaded. -This is good when the assets you are modifying reside in `resources/` such as html, css and JS files. However, sometimes you might reach for tools such as (hiccup)[https://github.com/weavejester/hiccup] for HTML templating. Under these scenarios, `ring-refresh` needs something else to reload the code for it. +This is good when the assets you are modifying reside in `resources/` such as html, css and JS files. However, sometimes you might reach for tools such as [hiccup](https://github.com/weavejester/hiccup) for HTML templating. Under these scenarios, `ring-refresh` needs something else to reload the code for it. The following is an example using `ring.middleware.reload` to reload the code when you modify the `hiccup` template. You can alternatively reload with the REPL. From a19a76c78e837f224e6fb270c55e81b5498eece8 Mon Sep 17 00:00:00 2001 From: Jose Aviles Date: Sat, 19 Oct 2024 00:24:45 -0400 Subject: [PATCH 3/3] lowercase --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9debeed..36a176f 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ But it can be customized to include other directories: Do note this library will only refresh the browser and nothing else. This means updates on the code will trigger a browser refresh, but the code itself won't be reloaded. -This is good when the assets you are modifying reside in `resources/` such as html, css and JS files. However, sometimes you might reach for tools such as [hiccup](https://github.com/weavejester/hiccup) for HTML templating. Under these scenarios, `ring-refresh` needs something else to reload the code for it. +This is good when the assets you are modifying reside in `resources/` such as html, css and js files. However, sometimes you might reach for tools such as [hiccup](https://github.com/weavejester/hiccup) for HTML templating. Under these scenarios, `ring-refresh` needs something else to reload the code for it. The following is an example using `ring.middleware.reload` to reload the code when you modify the `hiccup` template. You can alternatively reload with the REPL.