This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-11
Channels
- # admin-announcements (10)
- # arachne (2)
- # beginners (74)
- # boot (302)
- # cider (49)
- # cljs-dev (11)
- # cljs-edn (7)
- # cljsjs (13)
- # cljsrn (1)
- # clojure (164)
- # clojure-austin (1)
- # clojure-brasil (3)
- # clojure-finland (2)
- # clojure-greece (4)
- # clojure-russia (48)
- # clojure-uk (11)
- # clojurescript (138)
- # community-development (1)
- # cursive (13)
- # datascript (1)
- # datomic (19)
- # emacs (4)
- # events (1)
- # garden (1)
- # hoplon (123)
- # jobs-discuss (9)
- # keechma (5)
- # lein-figwheel (4)
- # leiningen (2)
- # luminus (15)
- # mount (1)
- # off-topic (8)
- # om (66)
- # on (1)
- # onyx (28)
- # other-languages (2)
- # planck (1)
- # proton (5)
- # re-frame (18)
- # reagent (15)
- # untangled (15)
Hi guys! So I'd like to read a config file from clj file. hoplon-castra template creates an assets
folder to store resources and nomally I would do (clojure.java.ìo/resource file.ext)
but going to localhost:8000/file.ext
I can see the file. How can I store the file so it is not visible/reachable by the browser and that I can still do ìo/resource
on it? Thanks!
@leontalbot: there's resource serving ring middleware that's serving the classpath
you could either remove it, or make your own middleware that 404s for files you don't want to expose
what is the simplest? are there examples?
Thanks for answering btw @alandipert
maybe the exclusion middleware, if there are only a few files you don't want to expose
i'm not aware of an example tho, sorry
In the lein world, I often see resources/public
where only public is exposed to the web
so you could call (io/resource "private/file.ext")
I think...
where private
is in resources
folder.
ok so :
(use 'ring.middleware.resource)
(def app
(-> your-handler
(wrap-resource "public"))
it seems to work man!
With this, I could read anything else in resources folder from my code, and only resources/public
get exposed to the web
Kind of surprised this is not used by default...
Maybe I am the only one who needs this but I'd be surprised
I find that useful for reading any static config files
Maybe there are better practices??
@leontalbot: seems like a really good way to do it to me
if you want to make a PR to the template, i would happily merge
@alandipert: Good night!
hey, so i’m using sente instead of castra, just calling reset!
in the callbacks that sente provides
are there any known gotchas when not using castra?
or should I be all good, as long as I’m careful to use cells to handle all the data propagation as it comes back from sente?
@leontalbot: thanks for the PRs - merged & pushed a new version of the hoplon-castra template
@thedavidmeister: should be fine, castra doesn't do anything special to cell behavior
@thedavidmeister: you may find dosync
useful if you are integrating state from multiple places at the same time
it tends to be useful in situations when you're doing a series of reset!
calls
like not over time, but within the same code block
@alandipert excellent
Thanks
no prob. would you be interested in helping maintain the templates? merging the occasional PR etc
Of course!
cool i'll add you as a collaborator
Thanks!
@leontalbot: you should have an invite to a github team that can admin the template repos. i also added you to the hoplon-castra and hoplon groups on clojars, so you can deploy to both groupids
thanks a lot for helping out!
No prob. Be ready for some questions for the first deployment to clojars etc.
keeping the templates in good shape is important, as thats most peoples first interaction w/ hoplon
oh yeah, to deploy etc - update +version+
in build.boot
and then boot build-jar push-release
note: after editing build.boot, commit the change
then, git push --tags
err i'll put in readme
ok i added a bit about deploying, let me know if you have issues
@alandipert: I recall you had problems with Hoplon + CodeMirror - have you solved them?
@dm3: no, i never got it working
i think i got close though
@dm3: https://gist.github.com/alandipert/537ea806516c93e037c2069b3642226f is as far as i got
fortunately hoplon doesnt' do enough for anything to be unsurmountable lol
iirc the problem was a browser lifecycle thing
the with-init! was crucial, but i think after running codemirror might need an explicit repaint or something
i was going off examples of people creating textarea nodes dynamically and codemirroring them
I've been away from the front end for a long time, but I'm interested in Electron, just not the javascript part of it.
From the docs and demos I noticed that the pattern is to establish some global cells for result, errors and loading and plug into them in your application code to get the data as it changes
and each widget gets the data from the same server endpoint but with some different parameters (let’s say date ranges)
having a global cell for results from an endpoint like get-widget-data
won’t work for me
is it possible to use castra in a more rq-async-rs mode where I could pass my result/errors/loading cells every time to my get-widget-data
function on the client side?
I was thinking about using mkremote
every time in my client side function with result/errors/loading cells passed to my function instead of using global cells
but I am not sure if mkremote
is a costly operation and it shouldn’t be used like that
@piotrek: i’m not expert but it seems to me that what you’re proposing should work legally. Afaik mkremote just returns a function that binds the results of the RPC call to the cells you provide
@raywillig: thanks, I will try that
and maybe in the meantime @micha or @alandipert will have some suggestions too
the parameters that you want to pass to the castra endpoint are not cast in stone at the time you call mkremote
so each of your widgets could call the function returned from mkremote and the results will be bound to the state cell
I would like to create a client local function like get-widget-data [date-from date-to result-cell errors-cell loading-cell]
@piotrek: when you have a rpc stub in the client, like for example (def f (mkremote ...))
so I have a function which creates those cells, calls my function with them and pass the cells as attributes to my elem
then I can easily manage the elem by showing loaders based on loading cell, errors and finally the data
I want to have a plain function which gets my function params (like entity id etc.) plus my cells trio
right now I don’t have any castra calls (working on this right now) but I just mock the server by using with-timeout
to simulate network latency 😉