juxt

Yehonathan Sharvit 2017-04-26T08:05:33.601206Z

@jonpither waiting for your comments…

jonpither 2017-04-26T08:19:52.834543Z

hi @viebel

jonpither 2017-04-26T08:21:55.869053Z

to way to achieve this currently is to make a Mach extension

jonpither 2017-04-26T08:22:29.878423Z

I'll knock up an example for you

Yehonathan Sharvit 2017-04-26T08:27:37.964656Z

thx

jonpither 2017-04-26T08:41:28.216340Z

the target bar is imported from the ext1.mach.edn file, with properties assigned

Yehonathan Sharvit 2017-04-26T09:51:06.437466Z

It works like a charm @jonpither @dominicm 👏

1👍
dominicm 2017-04-26T09:51:48.449125Z

@viebel I'll have to use this myself for our training machfile. Gotta oss that thing 🙂

Yehonathan Sharvit 2017-04-26T09:55:07.505216Z

Definitely

2017-04-26T10:27:19.023236Z

Hi there. I’m using bidi on the frontend (great combo!), and trying to encode a set of routes in a way which would make it easier for me to do i18n. I have a map of routes like {"" :home "about/" :about} etc. and, in front of that, there’s either a [/ :lang /], or just a “/”, which would mean the default language. So, I tried:

(def app-routes
  ["/" [["" common-routes-map]
        [[[keyword :lang] "/"] common-routes-map]
        [true :404]]])
And it works great, the lang is captured in a keyword, and the shared routes show up on the handlers, but in generating routes the :lang -less route is taking precedence wether the :lang keyword is present or not.. I’ve been trying quite a few different workarounds but most feel too clever. Is there a better way to “encode” the route along the lines of what I want to achieve?

dominicm 2017-04-26T10:29:43.058998Z

@minikomi if you move the [[keyword :lang] "/" … before the ["" common-routes…] does that solve your problem?

2017-04-26T10:31:01.079537Z

oh.. will try 🙂

2017-04-26T10:32:05.094955Z

seems like it! nice one hahha

dominicm 2017-04-26T10:33:38.117753Z

@minikomi the reason is that bidi checks in order.

2017-04-26T10:34:28.129989Z

Yep got it! Makes sense. I wonder if there’s a way to restrict the value of the keyword? If not i can just check within the app on navigation.

dominicm 2017-04-26T10:37:32.174708Z

I'm not certain off the top of my head, but you have 2 options: - Use a regex and use a middleware to coerce it to a keyword - Look at how the regex/fn validators are implemented within bidi, most of bidi is extensible, you may be able to just drop your own function in there & return false when it doesn't match.

2017-04-26T10:38:13.184293Z

Yeah, I went down route one for a little while but ended up having too much string / keyword juggling for my liking.

dominicm 2017-04-26T10:43:33.259283Z

Does a middleware like this not solve it:

(defn coerce-lang
  [handler]
  (fn [req]
    (handler (update-in req [:route-params :lang] keyword)))

2017-04-26T10:52:27.386591Z

Oops, just found out that having the [keyword :lang] version first means that not having a :lang keyword throws an exception.

2017-04-26T10:53:51.406540Z

ie. fails fast, rather than keeps looking

dominicm 2017-04-26T10:54:17.412563Z

Hmm, then it should check your second set of routes under ["" common-routes-map]

dominicm 2017-04-26T11:00:31.503526Z

Oh. That makes sense.

dominicm 2017-04-26T11:00:55.510155Z

Yes, I've never considered that. :thinking_face:

2017-04-26T11:03:24.547367Z

The other way around it is use the original order then a fn like:

(defn to [handler &{:keys [lang]
                    :as params}]
  (let [url (b/unmatch-pair i18n-routes {:handler handler
                                         :params (dissoc params :lang)})]
    (if lang (str "/" (name lang) url)
        url)))

2017-04-26T11:04:17.559888Z

A bit tricky, since I want to capture it if it exists, ignore it if it’s not there..

dominicm 2017-04-26T11:05:05.570898Z

I'm not sure what bidi's rules are about duplicate handlers in a route structure tbh.

2017-04-26T11:06:39.593480Z

yeah, seems a bit sketchy but it makes for nice routes / logic throughout - can just check a :lang value to change some things but keep most of the structure of the app the same

dominicm 2017-04-26T12:06:17.460420Z

certainly

Yehonathan Sharvit 2017-04-26T13:35:25.284949Z

@jonpither what is the best way to deploy a clojure web server (catacumba) to aws beanstalk?

Yehonathan Sharvit 2017-04-26T13:35:47.294275Z

Your article is quite old https://juxt.pro/blog/posts/beanstalk.html

Yehonathan Sharvit 2017-04-26T13:36:06.302432Z

May 2015

Yehonathan Sharvit 2017-04-26T13:36:10.303928Z

Is it still relevant?

jonpither 2017-04-26T13:36:40.317636Z

@viebel we have a new approach, I literally 50% through the blog. I can take you through it if you want - it's a bit alpha tho

jonpither 2017-04-26T13:37:05.328266Z

We moved away from Beanstalk

jonpither 2017-04-26T13:37:16.332894Z

and we use Terraform to provision a beanstalk-like environment

Yehonathan Sharvit 2017-04-26T13:37:46.345754Z

My customer requires beanstalk 😬

jonpither 2017-04-26T13:38:29.364725Z

if beanstalk is a hard-fast, then the approach in the blog above should still work

Yehonathan Sharvit 2017-04-26T13:42:38.474019Z

Is there a way to deploy the uberjar directly to beanstalk - without docker?

jonpither 2017-04-26T13:43:29.495926Z

no

dominicm 2017-04-26T13:43:32.497299Z

@viebel I think beanstalk has it's own wrapper.

dominicm 2017-04-26T13:43:36.498670Z

that isn't docker

jonpither 2017-04-26T13:43:42.501363Z

beanstalk takes either a WAR or a Dockerfile

dominicm 2017-04-26T13:43:43.501749Z

but docker is a pretty convenient format in comparison

Yehonathan Sharvit 2017-04-26T13:49:22.653054Z

how do I setup docker on macos?

Yehonathan Sharvit 2017-04-26T13:49:25.654645Z

with brew?

jonpither 2017-04-26T13:54:38.800296Z

yeah should work

jonpither 2017-04-26T13:54:48.804561Z

I had it working well, but I'm on linux now

jonpither 2017-04-26T13:55:08.814096Z

https://docs.docker.com/docker-for-mac/

dominicm 2017-04-26T13:59:15.931136Z

docker for mac is a lot better than it used to be, I hear.

jonpither 2017-04-26T13:59:52.949449Z

my experience was it was changing a lot also