This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-12
Channels
- # admin-announcements (56)
- # beginners (67)
- # boot (159)
- # cider (5)
- # cljs-dev (16)
- # cljsjs (7)
- # clojure (142)
- # clojure-dev (15)
- # clojure-japan (1)
- # clojure-poland (1)
- # clojure-russia (33)
- # clojurebridge (2)
- # clojurecup (1)
- # clojurescript (56)
- # cursive (3)
- # datavis (2)
- # datomic (29)
- # devops (6)
- # editors (1)
- # emacs (3)
- # hoplon (95)
- # ldnclj (15)
- # leiningen (18)
- # off-topic (10)
- # om (12)
- # onyx (7)
- # parinfer (6)
- # proton (1)
- # spacemacs (3)
- # yada (2)
I'd like some advice about compojure-api. I began with a routes list like this:
(context* "/api" []
(context* "/users" []
<many routes>)
(context* "/videos" []
<many routes>))
But over time, that form got so huge that vim start to give up on highlighting and indenting it. Yes, that's an editor issue, but I took it as a sign that I should split the file up into namespaces... now I discovered that if I put the subcontexts into defs, I can do this:
(context* "/api" []
users-context
videos-context)
...but the API no longer has Swagger-UI documentation. This is probably some macro processing issue. It's a long shot, but if anyone knows what's going on here...@amacdougall instead of def + context*, try defroutes*. plan in to move swagger-doc generation from compile time to runtime soon, so the the def + context* would work too. There is a #C06GSN6R2 if you'd like to chat more. cheers.
@sveri: looks nice, if I only want to use selmer and the login , autherisation part without reagent. Do I have to use only the clj directory in src ?
@roelof yes, the backend stuff is in clj folder and the templates are in resources/templates
Starting with an empty leiningen template or adapting an existing one like closp or luminus
So I will start with just clojure , my first goal is to set up the login part and the templates
However, there is one thing that will speed up development much more, especially when learning things
By using component or mount you will be able to reload code without restarting the repl everytime
you might as well take a look at mount:https://github.com/tolitius/mount might be easier to get
of course this is always subjective, but getting component to work was one of the hardest parts of all for me starting with clj / cljs and compared to that mount looks easier to understand, but, like I siad, that's just my point of view
I have this :
` (ns clcommerce.routes.home
(:require [compojure.core :refer [defroutes GET]]
[clcommerce.layout :as layout]
[ring.util.response :refer [response]]))
(defn home-page []
(layout/render "home/index.html"))
(defn contact-page []
(layout/render "home/contact.html"))
(defroutes home-routes
(GET "/" [] (home-page))
(GET "/contact" [] (contact-page)))
The require looks fine to me. If it was wrong, I would expect you to get an error there or something like “No such namespace: layout”.
What does clcommerce.layout
look like. Are you sure there’s a render
in it? Or maybe you haven’t loaded the latest changes in that file?
That one has this into it :
(ns clcommerce.layout
(:require [selmer.parser :as parser]
)
)
(parser/set-resource-path! ( "templates"))
Selmer seems to have its own render function. So I’m not sure if you would need to define your own like this in layout
. Can’t you use Selmer’s render
directly?
There's an example here:
https://github.com/yogthos/Selmer#templates
So Selmer has a render-file
function which seems to be the one you want.
oke, I will experiment with it but still adding (ns clcommerce.layout (:require [selmer.parser :as parser] does not solve it. Still render-file cannot be resolved
In the example, it shows you can pass variables to the template. So it looks like it’s not overloaded. You can pass an empty map to it.
Eventually, I’m assuming you’ll put stuff in that map, like:
(parser/render-file "home/base.html" {:name "Whatever”})
now next problem : find out how I can tell the css files are in the resources directory
Does the end of Prismatic also mean a big change in Prismatic/Schema being maintained?
@roelof: check it out here. basically structural validation: https://github.com/Prismatic/schema
@martintrojer: Hi, since joplin 0.3 do I understand it correct that I have to define some code to execute migrations? Up to 0.3 I could just define some configuration and then run the migration with the leiningen plugin without one line of clojure code. Is that still possible?
The very least you have to do is to define aliases I think - https://github.com/juxt/joplin/blob/master/example/project.clj#L14-L19
@sveri if you want to run migration / seeds from the command-line you need to implement the aliases
I tend to only use the ‘joplin repl’ nowadays
@martintrojer: I already commented in one of the issues, pre 0.3 it was possible to run a migration without a line of clj code only by configuration.Now I have to write some helper code. Is there a reason to do it like this?
yeah, lein plugins are no good. But like you said in GH#71 some of the boiler plate could be moved into core
PR welcome
I am curious, why you think that lein plugins are no good? Because they are coupling leiningen to your project?
Since joplin potentially brings loads of dependencies, I had various hacks in the plugin only to require the databases you were using.
Also, I really wanted to move the config out of project.clj
I looked a few minutes into the code and my first understanding of joplin.repl/migrate was that the conf param takes a filename where the configuration resides in the classpath. Later I realized it expects the config map. Would it be ok to accept both? the config map or a filename where the config is inside?
joplin.repl/load-config
its the edn reader with support for the tagged literals
The problem with taking the filename is that I want you to control where its coming from, resources / file-path etc
Yeah, but if we write a helper that take the filename, next week there will be a GH issue that somebody wants to load it from resources rather than filesystem path.
And what if we make it like this that the migrate functions calls load-config if conf is a filename or just executes the existing code if it is a map?
so repl/load-config doesn’t take a filename either.
I dont understad that part: https://github.com/juxt/joplin/blob/master/example/src/alias.clj#L9 Why do you add some extra config into the existing one? Is this just an example? Or required everytime?
Yeah, only for this particular example
Ok, would you consider a PR where I just grab that example alias.clj and change the functions to parameterize "joplin.edn"?
I’m here to please
Let's see if I get ready before my family calls. They are still working on the christmas cookies^^
figwheel provides a webserver when you don’t have one, but now I need one, because I want to serve many URLs. What’s the best way to add one that plays nicely with figwheel? Is it possible to not have to run both figwheel and the web server at the same time?
@martintrojer: Hm, I wanted to test the alias namespace and ran this snippet in a repl where I installed joplin.core and joplin.jdbc 0.3.5-Snapshot
@martintrojer: I have the same problem when I try to add the alias.clj to my project using joplin 0.3.4
@martintrojer: Ok, it's a ragtime problem only occurring in windows due to the fileseparator
@martintrojer: I opened this issue: https://github.com/weavejester/ragtime/issues/91 for it. Will have to wait until this is fix so I can try out my PR
@roelof: I do sparingly, I think, but never took much care of them, as they are project specific in my opinion
oke, I try to convert a template where a lot of javascript , meta and javascript is used
I try to convert this ; https://laboutique.lemonstand.com/ with selmer
Hey!… I am having a hard time trying to understand how to apply coercion on one of my REST API end point. What I want is to coerce some query parameters based on a schema definition. For example, if I receive a request with some query parameters like “…/foo?status=0&name=“rcanepa”, I would like to transform the status value to an integer and pass to my handler a map like {“status” 0 “name” “rcanepa”}.
The objective behind all of this, is to provide filtering, pagination and sorting features, so the query params may vary.
If test it, I will get an error for trying to pass a string as the value of the status keyword.
In summary, 1) coercion is not working, and 2) I don’t know how to correctly specify the schema for the :query-params on the endpoint.
@rcanepa: try either: :query-params [status :- s/Int name s/Str]
, binds status
and name
for the body.
@rcanepa: or if you want the whole map: :query [params {:status s/Int, :name s/Str}]
; binds params
for the body.
I wrote about Two Cool Tools in Clojure: http://www.clojuregeek.com/2015/12/12/two-cool-tools-for-clojure-development/