Fork me on GitHub
#re-frame
<
2016-01-04
>
Pablo Fernandez09:01:12

@darwin, @simax99: I also published blog posts describing how to use pushy with both bidi and silk.

simax9910:01:06

@pupeno: Yes I've read them - very useful. In fact I've now replaced secretary with bidi and pushy in my project. Like your ninja tools project I'm trying to render routes client side but running into this issue: https://groups.google.com/forum/#!searchin/ring-clojure/nested$20routes/ring-clojure/Pbdq0ds5LFg/k2Pt4V0hDgAJ

Pablo Fernandez10:01:15

@simax99: you need your assets to have absolute URLs, as in /assets/whatevs

Pablo Fernandez10:01:24

@simax99: the MIME type error is because you are serving dynamic content before static one, so your route /employees/js/compiled/app.js is probably a html you renderer. You need to serve static assets first, dynamically generated content second. That’s how I do it in NinjaTools.

Pablo Fernandez10:01:45

Actually, I’m not 100% sure about the that.

Pablo Fernandez10:01:18

James is spot on in that you are serving dynamic content instead of your asset.

Pablo Fernandez10:01:34

Look at the contents of the file you just served if in doubt.

Pablo Fernandez10:01:01

And for the client side, I recommend Silk over Bidi: https://carouselapps.com/2015/09/21/bidi-vs-silk/

simax9910:01:05

@pupeno: All the assets are now absolute ... /assets as James suggested.

Pablo Fernandez10:01:25

What’s the contents of http://localhost:3000/employees/js/compiled/app.js as seen by the browser?

simax9910:01:26

@pupeno: I don't understand what you mean I'm serving dynamic content before static.

Pablo Fernandez10:01:52

You can ignore that for a bit. I’m not 100% sure that was correct.

simax9910:01:34

Hmm, http://localhost:3000/employees/js/compiled/app.js actually contains my index.html. Of course http://localhost:3000/employees/js/compiled/app.js is not correct. It should be http://localhost:3000/js/compiled/app.js. This only happens on a sub route. http://localhost:3000/employees renders perfectly. http://localhost:3000/employees/19 displays the problem.

simax9910:01:20

Are you rendering sub routes successfully?

Pablo Fernandez11:01:18

You need to use absolute URLs for javascript as well.

Pablo Fernandez11:01:37

If you don’t use absolute URLs, your page breaks when your path is different.

Pablo Fernandez11:01:50

Use /js/compiled/app.js instead of js/compiled/app.js

simax9912:01:04

Unfortunately I'd already tried that. It produces the following errors: Refused to execute script from 'http://localhost:3000/employees/js/compiled/out/goog/base.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

simax9912:01:12

Refused to execute script from 'http://localhost:3000/employees/js/compiled/out/cljs_deps.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

simax9912:01:37

I notice the cljsbuild sections of our project.clj files are quite different. Mine looks like this

:cljsbuild {
              :builds [{:id           "dev"
                        :source-paths ["src/cljs"]

                        :figwheel     {:on-jsload "metime.client/mount-root"}

                        :compiler     {:main                 metime.client
                                       :asset-path           "js/compiled/out"
                                       :output-to            "resources/public/js/compiled/app.js"
                                       :output-dir           "resources/public/js/compiled/out"
                                       :source-map           "resources/public/js/compiled/app.js.map"
                                       ;:recompile-dependents false
                                       :source-map-timestamp true}}
                       {:id           "min"
                        :source-paths ["src/cljs"]
                        :compiler     {:output-to     "resources/public/js/compiled/app.js"
                                       :main          metime.client
                                       :optimizations :advanced
                                       :pretty-print  false}}]}
I don't know if that's significant.

Pablo Fernandez13:01:40

@simax99: /employees/js/compiled/out/goog/base.js doesn’t exist, it should not be loaded. You need to find where it’s being referred as js/compiled/out/goog/base.js and correct it to /js/compiled/out/goog/base.js. changing :asset-path to start with / might be a good starting point.

simax9914:01:58

@pupeno: Changing the asset-path to /js/compiled/out and the script tag to <script src="/js/compiled/app.js" type="text/javascript"></script> did the trick. Ironically James Reeves just came up with the same solution. Many thanks for your help... I'll go and checkout your post on Bidi v Silk now.simple_smile

simax9915:01:22

@pupeno: Its strange because the ClojureScript wiki for :asset-path https://github.com/clojure/clojurescript/wiki/Compiler-Options#asset-path shows it as: :asset-path "js/compiled/out". That's why I set mine like that.