Thanks James!

That was it. Changed my original handler to this and it works perfectly....

(defn ring-handler [request]
  {:status 200
   :headers {"Content-Type" "text/html"}
   :body (str "<html><head></head><body>" header "change this text" 
"</body></html>")})

 


On Thursday, February 6, 2014 9:03:25 AM UTC-8, James Reeves wrote:
>
> The :auto-refresh option adds in the ring-refresh middleware, which 
> injects Javascript into HTML pages to automatically refresh the page when 
> notified.
>
> The HTML page needs to be of content-type "text/html", and should be 
> well-formed with a <head> element.
>
> Try checking the source code of the HTML page being served to see if it's 
> correctly injecting the script.
>
> - James
>
>
> On 6 February 2014 16:41, boz <b...@cox.net <javascript:>> wrote:
>
>> I'm starting to think my expectations are wrong and the :auto-refresh? 
>> doesn't make the browser refresh. I've never seen it work so what do I 
>> know. :)
>> I tried making a new project using the compojure template...
>>
>> $ lein new compojure godoggo 
>>
>>
>> I then changed its project.clj to include the :auto-refresh? setting...
>>
>> (defproject godoggo "0.1.0-SNAPSHOT"
>>   :description "FIXME: write description"
>>   :url "http://example.com/FIXME";
>>   :dependencies [[org.clojure/clojure "1.5.1"]
>>                  [compojure "1.1.6"]]
>>   :plugins [[lein-ring "0.8.10"]]
>>   :ring {:handler godoggo.handler/app
>>          *:auto-refresh? true*}
>>   :profiles
>>   {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
>>                         [ring-mock "0.1.5"]]}})  
>>
>>
>>  Ran the server...
>>
>> $ lein ring server 3333 
>>
>>
>> The page pops up in my browser OK. But changes to src/godoggo/handler.clj 
>> do not show p unless I refresh manually. 
>> ... So have I just got it wrong? Does :auto-refresh? do something else?
>>
>> ???
>> boz
>>
>> On Wednesday, February 5, 2014 11:16:21 PM UTC-8, boz wrote:
>>>
>>> Hi,
>>>
>>> I've set up lein-ring with ring :auto-refresh? true but don't see 
>>> updates in the browser unless I refresh manually. It seems I have something 
>>> configured wrong but I can't see it. Does this look right?...
>>>
>>> (defproject mystuff "0.1.0-SNAPSHOT"
>>>   :description "experiment"
>>>   :url "http://example.com/FIXME";
>>>   :license {:name "Eclipse Public License"
>>>             :url "http://www.eclipse.org/legal/epl-v10.html"}
>>>   :dependencies [[org.clojure/clojure "1.5.1"]
>>>                  [hiccup "1.0.5"]]
>>>   :plugins [[lein-ring "0.8.10"]]
>>>    :ring {:handler mystuff.core/ring-handler
>>>          :auto-reload? true
>>>          :auto-refresh? true}
>>>   :target-path "target/%s")
>>>
>>>
>>> My ring-handler function is basically a copy of the hello world one on 
>>> ring's site, but the body comes from a defined value.
>>>
>>> (def x (html [:h1 ("hello")]))
>>>
>>> (defn ring-handler [request]
>>>   {:status 200
>>>    :headers {"Content-Type" "text/html"}
>>>    :body x})
>>>
>>>
>>> The :auto-reload? true works as expected. But not :auto-refresh? true.
>>>
>>> I'm after the live coding experience here. And I want it to be with 
>>> lein-ring if I can. 
>>> (I tried Daniel Szmulewicz's cool emacs way but I think lein-ring will 
>>> fit my needs better.)
>>>
>>> confuzzled,
>>> boz
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com<javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to