Fork me on GitHub
#arachne
<
2017-01-21
>
luke02:01:36

Have at it!

jfntn03:01:48

Congrats!

defndaines18:01:18

This is maybe more of a #leiningen question, but I stumbled on it when working through the “Creating a project” tutorial.... Is there something you need to do so that

(def w (->Widget))
works out of the box after starting with lein repl?

defndaines18:01:04

Maybe I goofed some set-up, because I thought I’ve had this kind of thing work before (i.e., lein loading you into the project namespace, vs. needing to explicitly load things).

luke18:01:44

You need to lead the namespace first, and then make sure that that namespace is “current” in your repl.

luke18:01:27

So, if you just started with lein repl, you could do (require '[myproj.core]) and then (in-ns myproj.core)

luke18:01:53

Or use the fully qualified name, (def w (myproj.core/->Widget))

defndaines18:01:10

Thanks. I ended up doing the require approach, since for some reason the qualified namespace didn’t work. (That’s why I was wondering if I haven’t goofed my lein config somehow, unrelated to arachne.)

luke18:01:48

Well you have to require it just to cause that NS to load... the functions in it aren't available until something such as a require has caused it to be loaded

defndaines18:01:40

I see the difference now. If I lein repl for my other projects, by default I’m going into proj.core and have immediate qualified access to proj.core/ ns functions. But with the arachne config, I’m going into arachne.run, and my proj.core isn’t immediately available. Different from my usual workflow, since the require is implicit.

defndaines19:01:58

BtW, I’m assembling typo fixes as I work through the tutorial. Is fork and pull request the best way to submit those?

luke19:01:54

Yes, thank you! I know there's probably a lot of them :)

anmonteiro19:01:59

@luke (really) off-topic, but I'd love it if you could expand on your workflow for writing and building the docs website

anmonteiro19:01:35

I need to get around to building a docs website for Lumo and I liked Arachne's layout & organization

luke19:01:52

@anmonteiro It’s pretty straightforward. I write the docs in markdown, then use a tool called “mkdocs” to build them into a static html site. I use the “codox” Clojure lib to generate API documentation (also static HTML). I have a script (which you can see at https://github.com/arachne-framework/arachne-docs/blob/master/deploy.sh), to merge the results of the two builds together and deploy them using Github Pages.

luke19:01:20

took me like a day to get set up, would recommend :thumbsup:

anmonteiro19:01:29

awesome, I'll explore. thanks!

madstap20:01:19

An observation on the http tutorial: The way the greet handler is written makes me believe that localhost:8000/greet/ will return "Who's there?", but it seems that with a path of "/greet/:name" there needs to be something in :name, or it won't match.

luke20:01:02

@madstap ah, great point. I forgot to put an example URL in there to make that clear. I’ll fix that in my next update. Thanks!

madstap21:01:02

@luke I don't think I explained it very well...

(defn greeter
  [req]
  (let [name (get-in req [:path-params :name])]
    {:status 200
     :body (if (empty? name)

             "Who's there!?" ; This branch is never taken.

             (str "Hello, " name "!"))}))

(h/endpoint :get "/greet/:name" (h/handler 'myproj.core/greeter))

;; Because "/greet/:name" matches urls like site/greet/aleks,
;; but doesn't match site/greet or site/greet/
;; So :name can never be an empty string, nor nil