Fork me on GitHub
#luminus
<
2018-10-12
>
jcb13:10:37

Is there a clean way to define where the resources folder will be once a luminus app is jarred? Other than setting all my paths to "../etc"

Azzurite15:10:57

What do you mean with "where it will be"? In JVM programs, the resources folders are contained inside of the .jar, and you will generally not have to worry about "where" exactly they are as everything's managed. If you want to load external files (outside of the jar) those have nothing to do with the "resources" or resource paths you define in your project. You simply use (slurp <FILEPATH>) (or whatever) to read external files.

Azzurite15:10:34

also I like that you called it "jarred" 😄

jcb15:10:06

complijarred?

jcb15:10:27

I've tried to follow this example from yogthos however there are now MIME type problems which I don't understand

jcb15:10:33

Azzurite, I'd like to be able to update the media resources but not compile each time

Azzurite15:10:10

You have to remember that Luminus is not its own thing, but simply a collection of different libraries. For example, your HTML templates are handled by selmer (https://github.com/yogthos/Selmer#resource-path), so if you set selmer's resource path, that's where the HTML template files will come from. However, media resources are served by a ring middleware (you should be familiar with https://github.com/ring-clojure/ring/wiki/Concepts as Ring is the basis for every Clojure webapp). I'm not absolutely familiar with if Luminus uses the same libraries with all parameters, but the reagent template I have here uses https://github.com/ring-clojure/ring-defaults which by extension uses ring.middleware.resource and ring.middleware.file. You can see in the ring-defaults documentation that you have to change the :static->`:files` configuration parameter to serve static files from the file system.

Azzurite15:10:11

and yeah, the example from yogthos only changes the Selmer template path, but you're talking about "media resources", so I imagine you mean stuff like images

Azzurite15:10:20

for which you'd have to change the ring-defaults middleware options so that they're loaded from the file system

jcb16:10:21

ok thanks for the detailed answer!

Azzurite16:10:48

let me know if it helps, I've actually never used this stuff before 😄

jcb16:10:03

ok, ideally, the whole folder would sit outside the jar as the logic will stay the same but styling/images will change

jcb16:10:37

I'll give it a go, cheers 👍