This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-22
Channels
- # beginners (24)
- # boot (80)
- # braid-chat (11)
- # cider (89)
- # clara (11)
- # cljsfiddle (5)
- # cljsjs (9)
- # cljsrn (63)
- # clojure (114)
- # clojure-austin (1)
- # clojure-berlin (5)
- # clojure-brasil (4)
- # clojure-dusseldorf (5)
- # clojure-hamburg (17)
- # clojure-india (1)
- # clojure-new-zealand (3)
- # clojure-poland (1)
- # clojure-russia (91)
- # clojure-taiwan (1)
- # clojure-uk (54)
- # clojurebridge (3)
- # clojurescript (170)
- # core-matrix (1)
- # cursive (14)
- # datomic (8)
- # emacs (13)
- # hoplon (96)
- # immutant (20)
- # jobs (9)
- # jobs-rus (13)
- # kosmos (3)
- # off-topic (8)
- # om (111)
- # onyx (41)
- # parinfer (116)
- # pedestal (2)
- # proton (4)
- # re-frame (46)
- # reagent (7)
- # ring-swagger (24)
- # slack-help (2)
- # testing (1)
- # untangled (8)
how do I tell compojure to serve files out of ‘node_modules’ folder? I don’t want to copy it inside resources/public
@ag: http://weavejester.github.io/compojure/compojure.route.html#var-files maybe?
I'm going to guess that resources
can only grab files that are in the classpath?
have you tried the :root
option?
@bostonaholic: yeah but what :root ’s gotta be? ../..
or just “” or nil? I’m trying all sorts of things
I added to my page
[:link {:href "/font-awesome/css/font-awesome.css" :rel "stylesheet" :type "text/css"}]
(files "node_modules" {:root "../.."})
would be my best guess
root will have to be in relation to your resources directory
also will depend on your web server configuration and probably a whole host of other things
depending on your web server, you may need to restart it when changing compojure routes
any other stuff works beautifully when it’s in resources/public folder. I want to serve things right from node_modules
if you add node_modules to the classpath, you could reference it probably with resources
resources
will serve files from the classpath
So if the resources
directory is on the classpath
Then public
on the classpath would be equivalent to resources/public
If you add node_modules
to :resource-paths
, then the subdirectories of node_modules
will be on the classpath.
@weavejester: so what exactly it’s has to be to work?
:resource-paths ["node_modules”]
use resources
instead of files
since you're adding node_modules to the classpath
what web server are you using?
those aren't web servers. jetty, immutant, etc.
that will mean that every file in your classpath is accessible
I think you’re wrong… everything in node_modules is accessible, yes… everything in resources/public accessible yes. but nothing else seem to be
Yeah, it seems to be working now as I wanted. I’m slightly concerned that I was able to access project.clj
- I think something was broken here even before I started
I figured that wasn't your intended behavior
Is there any effort to provide a 100% pure javascript implementation of clojurescript compilation?
what’s a good way to hook into mouse and keyboard events without interfering with existing handlers? i.e. looking for a translation of this:
var idleTime = 0;
$(document).ready(function () {
//Zero the idle timer on mouse movement.
$(this).mousemove(function (e) {
idleTime = 0;
});
$(this).keypress(function (e) {
idleTime = 0;
});
});
@urbanslug: They're translated into React.createElement
calls.
@wei: https://github.com/netpyoung/mudbox/blob/a824529a193f4aeb5da80f97bb3f8f915a1a8783/test/backup/input/mouse.cljs
@urbanslug: Just like JSX: The JSX compiler rewrites <div>
into React.createElement("div", null)
. Sablono does the exact same thing
@urbanslug: It's noteworthy that this happens at compile time (so html
is a macro) and it's not interpreted (like reagent).
Well... kinda, unless it can't transform it at compile time, then it gets intrpeted as a fallback
@urbanslug: Yeah, learning React is super easy and quick. It's worth it. You can learn it from CLJS though.
@rauh: How though? I’m finding very little info on react from cljs they assume some level of knowledge of react.
here’s my original version for comparison: https://gist.github.com/yayitswei/c1efdce6bfa2fc16b548
@rauh: getting Uncaught AssertionError: Assertion failed: Listener can not be null
trying out your solution on this line:
(goog.events/listen (array goog.events.EventType.MOUSEMOVE goog.events.EventType.KEYPRESS)
#(handler %))
When I use map to go over a nested structure, how can I prevent, that nil values are stored?
@danielgrosse: keep
should do that
I found a solution which uses postwalk
(clojure.walk/postwalk #(if (coll? %) (into (empty %) (remove nil? %)) %) (build-tree menu-data-structure))
Unfortunately it only works when I call it this way. When I use it inside a function and call the function with the same data, it doesn't remove the nils. How could this be?
(defn remove-nils
[coll]
(clojure.walk/postwalk #(if (coll? %) (into (empty %) (remove nil? %)) %)
coll)
(remove-nils (build-tree menu-data-structure))
build-tree returns a map function which goes over a nested structure
It was a failure in my file. 😩
@vinodg Isn't really a reagent specific question . If you used something from cljsjs (http://cljsjs.github.io/) , then:
(ns my-ns
(:require [cljsjs.js-lib]))
Otherwise, you can just include it in your html header, as without cljs.
For both methods, to access the js libs stuff, use interop:
(js/my-lib-foo)
@vinodg: If I understood "external javascript file" correctly.. Maybe I misunderstood?
@not-much-io: I have a javascript file containing code for generating a "captcha". now i have to include that file in clojurescript code
@vinodg: If you are using reagent, then you have a regular html file, where reagent is mounted onto a div with id "app"? Example: https://github.com/Day8/re-frame-template/blob/master/src/leiningen/new/re_frame/resources/public/index.html Just add the usual js include tag there. And then you can use your lib with interop: (js/gen_captcha)
@vinodg: What I mean by "usual js include":
<script src="js/captcha.js"></script>
@vinodg: Do you want to 'on-demand' load the captcha library? Or are you asking how to call the functions provided by it?
i am getting the <script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6Lcpy9YSAAAAAKPK5T8tdO5WbiRPkKENziunk0c2"></script> .now i have to include that in clojurescript
@vinodg: It should already be there, clojurescript is just compiled into js and thrown into your page, together with your other js. There is no extra step to include it.
@vinodg: Try:
(.log js/console js/RecaptchaState)
Edit: Sorry, forgot to log the var.@not-much-io: see when i make a jax request to the server , i will get "<script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6Lcpy9YSAAAAAKPK5T8tdO5WbiRPkKENziunk0c2"></script>" from server . now ,I at clientside should include it in my hiccup code
@vinodg Aaa, dynamically... This is the equivalent markup:
[:script {:type .. :src ..}]
So if you add it to your markup before you actually use functions from there, it should work? Maybe? 😄Anyone ever seen: Exception in thread "main" java.lang.RuntimeException: No dispatch macro for: =, compiling:(core.clj:39:1)
@slotkenov: do you have a stray #=
somewhere in your code?
@slotkenov: #=
is not a valid cljs reader macro
@vinodg: (js/goog.dom.htmlToDocumentFragment "<script src=....></script>")
then append with (goog.dom.appendChild js/document.body the-fragment)
should work.
@slotkenov: Had this issue recently with environ
plugin from https://github.com/heroku/clojure-getting-started/blob/master/project.clj project. Fixed it by replacing it with string from official page.
@slotkenov, do you know what's in core.clj
on line 39?
@slotkenov: not sure i remember how it fixed but first of all i replaced [environ/environ.lein "0.3.1"]
with [lein-environ "1.0.2"]
@slotkenov: if you have aot compilation - try to disable it (see here https://github.com/technomancy/leiningen/issues/2096)
what’s the advanced compilation-compatible way of writing this? (set! js/document.location "logout”)
I try to follow modern-cljs tutorial (boot version), but when I type « boot cljs », the console prints the compilation but I don’t have any new file. Any clue ?
@wei: (aset js/document "location" "logout")
should work
I keep getting this error in my browser’s console Uncaught Error: Assert failed: Could not find ReactDOMServer server(anonymous function) @ server.cljs?rel=1458656519107:12 dom.cljs?rel=1458656519142:13Uncaught Error: Assert failed: Could not find ReactDOM dom(anonymous function) @ dom.cljs?rel=1458656519142:13
@wei that should probably be js/window.location
? - Google Closure has externs for standard browser things
I'm seeing certain protocol methods give an "undeclared Var" warning in advanced compilation, when I use them in a macro
has anyone seen this before?
I am using github API to search repos with cljs-http lib, the code for call looks like following: ` (http/get api-url {:with-credentials? false :basic-auth {:username “someuser" :password “somekey"} :query-params {:q params}}) `
@zilvinask: CORS preflight request
@mfikes: tried to use the approach you describe here https://groups.google.com/d/msg/clojure/34luqPyg6L4/ksSrvXOiWdIJ without success
has something changed in the meantime?
@anmonteiro: Not that I’m aware of. You suspect a regression?
@mfikes: haven't investigated enough to suspect a regression
but using ^:export
in a protocol method doesn't seem to solve my undeclared var warnings
Undeclared var is from the analyzer… I wouldn’t expect ^:export
would affect that anyway.
There are some tickets related to needing to qualify protocol symbols when from another namespace...
I think this only happens when I call the method from a macro
yep, only happens when calling a protocol method inside a macro
and only in advanced compilation
@dnolen: maybe you have some insight into this? this is related to OM-643, and I've tracked it down to calling ident
inside the defui
macro
it seems that it only happens when calling a protocol method from the "same" namespace. In a macro
calling a protocol method from another namespace does not produce a compilation warning
@anmonteiro: If you are in native code for everything, no need to mess with ^:export
, right?
@mfikes: I'm not sure I understand
@anmonteiro: would like to see a minimal example, non-Om - would greatly clarify the problem if there is one
let me try and create a minimal thing
Well, in that mailing list post you referenced, the point of using ^:export
was so that foreign code (not-ClojureScript) could call the protocol method, even under :advanced
@mfikes: ah yes, you're right. This seems like a whole other issue
working on it!
if I defrecord
or deftype
in the macro instead of defn
the bug goes away, so I'm not entirely sure if this is a real issue or not
@anmonteiro: Curious if the bug persists if you drop the bug.core
qualification here https://gist.github.com/anmonteiro/3a8fdc5ba085e3895254#file-bug-clj-L9
almost certain it does. confirming
@mfikes: yep, it does
@anmonteiro: Cool. Was worth eliminating, as there have been tickets surrounding that aspect.
@anmonteiro: If you macroexpand and see what is generated and the generated stuff looks legit, then maybe it really is a bug
@mfikes: macroexpansion:
(do (clojure.core/defn MyBug [])
(cljs.core/specify! (. MyBug -prototype)
Object
(bar [this]
(bug.core/bug this 3))
(foo [this] "foo")))
I guess that looks legit. I’m not an expert on specify!
. Especially if that code works in expanded form, then it sounds like a bug.
@mfikes: right, but this only happens in advanced compilation, so I'm not sure if there's something else I should be doing
hey guys, I’m new to cljs. can someone tell me if I’m doing anything wrong. I want to use third-party react component, for example this one: http://react-components.com/component/react-datepicker I got it via npm, now just adding this to project.clj won’t do, would it?
:foreign-libs [{:file "node_modules/react-datepicker/dist/react-datepicker.js"
:provides ["react-datepicker"]}]