Fork me on GitHub
#hoplon
<
2017-03-22
>
peterromfeld02:03:50

yeah because its like "us flag" changes to "at flag" and more then 50 cards like this (its a search result)

peterromfeld02:03:26

currently i have this ugly thing here:

(defn country-flag [class]
  (with-let [elem (i)] (with-init! (.addClass (.removeClass (js/$ elem)) class))))

thedavidmeister05:03:45

"Providing a map of classes as keywords with true or false is more verbose but allows us to enforce the existence or absence of a class. "

thedavidmeister05:03:44

@peterromfeld additionally, this might be a use case for a data attribute

thedavidmeister05:03:25

:data-country-flag current-flag

peterromfeld05:03:01

@thedavidmeister we are using semantic-ui, not sure how i would use it with data attribute

thedavidmeister05:03:45

@peterromfeld then set the classes as keys of a map and true/false in the values

thedavidmeister05:03:42

e.g. :class (j/cell {:us-flag true :at-flag false})

peterromfeld05:03:38

for all 250 countries in each of the 50 cards?

thedavidmeister06:03:26

@peterromfeld yeah... the problem with class is that it's kind of "global"

thedavidmeister06:03:26

you could do something with a watch maybe

thedavidmeister06:03:36

like, stick false into everything in the old value

peterromfeld06:03:42

to clarify, i dont propose to change :class its how i use it most of the time.. just in this exception it would be nice to have :class! which acts little different

thedavidmeister06:03:55

you could do something with lenses or a do-watch

thedavidmeister06:03:47

(let [add (j/cell nil)
      remove (j/cell nil)
 (j/cell=
  {add true remove false}
  #(j/dosync
    (reset! remove @add)
    (reset! add %))))

thedavidmeister06:03:49

something like that

thedavidmeister06:03:58

generally though i really use data attributes for anything like this

thedavidmeister06:03:58

i prefer having k/v data that i can control on a per-k basis than a big bucket o' vals

peterromfeld06:03:25

btw i just put my new method into index.cljs.hl and use :class! for this flag exception (dont want to reinvent something that my css framework provides)

peterromfeld06:03:51

works like a charm

thedavidmeister06:03:18

cool, well you can also wrap the above in a defn and get cells for each card

thedavidmeister06:03:25

(defn flag-class-cell
 (let [n (j/cell nil)
       o (j/cell nil)]
  (j/cell=
   {n true o false}
   #(j/dosync
     (reset! o <@U3MG3NJCC>)
     (reset! n %)))))

john_tollison19:03:16

I commented out a couple of things that were obvious problems, hoping it'd work, and then got, "Wrong number of args (1) passed to: cli/argspec->cli-argspec". I'm sure this is just one more thing I need to learn at a deeper level, but I don't know what I'm doing here.

micha19:03:15

can you paste the whole stacktrace?

micha19:03:22

if you have one

john_tollison19:03:43

Retrieving maven-metadata.xml from http://repo1.maven.org/maven2/ (4k) Retrieving maven-metadata.xml from https://repo1.maven.org/maven2/ (4k) Retrieving maven-metadata.xml from https://repo.clojars.org/ (1k) Classpath conflict: org.clojure/clojure version 1.7.0 already loaded, NOT loading version 1.5.1 Boot.main Boot.java: 258 ... boot.App.main App.java: 491 boot.App.runBoot App.java: 399 org.projectodd.shimdandy.impl.ClojureRuntimeShimImpl.invoke ClojureRuntimeShimImpl.java: 150 org.projectodd.shimdandy.impl.ClojureRuntimeShimImpl.invoke ClojureRuntimeShimImpl.java: 159 ... boot.main/-main main.clj: 206 boot.main/-main/fn main.clj: 206 ... clojure.lang.ArityException: Wrong number of args (1) passed to: cli/argspec->cli-argspec clojure.lang.ExceptionInfo: Wrong number of args (1) passed to: cli/argspec->cli-argspec file: "/var/folders/mg/b82_3kcn7bl97_3rfl4klmlw0000gn/T/boot.user5190031215929737070.clj" line: 9

john_tollison19:03:17

that was from the last run... previous errors include java.lang.RuntimeException: No reader function for tag tailrecursion.boot.core/version java.lang.RuntimeException: Unable to resolve symbol: add-sync! in this context clojure.lang.ExceptionInfo: Unable to resolve symbol: add-sync! in this context

micha20:03:14

the java.lang.RuntimeException: No reader function for tag tailrecursion.boot.core/version error

micha20:03:24

that is a boot version 1 file

micha20:03:42

so that boot script won't work with boot2

micha20:03:19

can you paste the build.boot file please?

john_tollison20:03:25

Yes, that was what I was asking. Is there a version for the new boot, by chance?

john_tollison20:03:49

#!/usr/bin/env boot ;#tailrecursion.boot.core/version "2.5.1" (set-env! :dependencies '[ ;tailrecursion.boot.core/version "2.5.1" [tailrecursion/hoplon "5.10.23"] [tailrecursion/boot.task "2.2.4"] [tailrecursion/boot.notify "2.0.2"] [tailrecursion/boot.ring "0.2.1"]] :src-paths #{"src"} :out-path "resources/public" :main-class 'hello-world.core) ;; Static resources synced to output dir ;(add-sync! (get-env :out-path) #{"resources/assets"}) (require '[tailrecursion.hoplon.boot :refer :all] '[tailrecursion.boot.task.notify :refer [hear]] '[tailrecursion.castra.task :refer [castra-dev-server]]) (deftask heroku "Prepare project.clj and Procfile for Heroku deployment." [& [main-class]] (let [jar-name "hoplon-app-standalone.jar" jar-path (format "target/%s" jar-name) main-class (or main-class (get-env :main-class))] (assert main-class "missing :main-class entry in env") (set-env! :src-paths #{"resources"} :lein {:min-lein-version "2.0.0" :uberjar-name jar-name}) (comp (lein-generate) (with-pre-wrap (println "Writing project.clj...") (-> "project.clj" slurp (.replaceAll "(:min-lein-version)\\s+(\"[0-9.]+\")" "$1 $2") ((partial spit "project.clj"))) (println "Writing Procfile...") (-> "web: java $JVM_OPTS -cp %s clojure.main -m %s $PORT" (format jar-path main-class) ((partial spit "Procfile"))))))) (deftask development "Start local dev server." [] (comp (castra-dev-server 'hello-world.api) (watch) (hear) (hoplon {:prerender false}))) (deftask production "Compile application with Google Closure advanced optimizations." [] (hoplon {:optimizations :advanced}))

micha20:03:57

you can do boot -V to see the boot version

micha20:03:08

could you paste into a snippet please?

micha20:03:11

it's hard to read that

john_tollison20:03:22

oh, ok, don't use slack much...

micha20:03:30

the + on the left

micha20:03:42

you can paste in there and it will do monospace fonts and whatnot

john_tollison20:03:34

um, I'm seeing a + by direct messages?

john_tollison20:03:26

give me a second, I'll get there 🙂

john_tollison20:03:52

oh, ok, feeling dumb

micha20:03:39

ah i see a problem

micha20:03:47

(deftask heroku
  "Prepare project.clj and Procfile for Heroku deployment."
  [& [main-class]]

micha20:03:03

that's the issue there

micha20:03:46

you can fix it by doing this instead i think

micha20:03:15

(deftask heroku
  "Prepare project.clj and Procfile for Heroku deployment."
  [m main-class NAME str "The name of the main class."]

john_tollison20:03:14

ok, let me try that. Sorry for being so slow. I use clj for gaming math and systemy things lose me quick.

micha20:03:29

yeah no worries

alandipert22:03:25

@john_tollison I recently updated hoplon-castra template and am aware of people using on heroku

alandipert22:03:18

(different method, jar based deploy, but can help you out if needed)

john_tollison22:03:33

Yes, I found my way to that update. That was exactly what I was asking for initial. Thanks 🙂