Fork me on GitHub
#hoplon
<
2015-10-26
>
thedavidmeister08:10:22

@alandipert: I have no idea how to make a war work. I get servlet errors every time. I'm coming from a PHP background, not Java, so while the programming concepts in clojure are not too hard to pick up, the specifics on deploying and the JVM are taking me aaages to nut out

thedavidmeister08:10:05

actually, i don't even really know the differences/pros/cons between ring handlers, serving a directory, pom, war, jar, etc...

thedavidmeister08:10:14

i'm trying to reverse engineer all that >.<

thedavidmeister08:10:59

also, philosophically, I'd imagine hoplon would want to be free-tier compatible for heroku

thedavidmeister08:10:14

in order to encourage uptake and generally keep the barrier to entry low

thedavidmeister08:10:39

from what i saw, you can't get a dyno with more than 512mb RAM on heroku for under $50USD per month

thedavidmeister08:10:21

which, when the AUS$ is like 0.75c, is pretty hard on the pocket for something i'm just trialling

thedavidmeister08:10:35

especially when the pure client-side stuff compiles so nicely simple_smile

dm309:10:17

can't you tweak the JVM options on Heroku?

alandipert11:10:53

@thedavidmeister: i'll try and get a minimal war example working today

alandipert11:10:16

hoplon actually was born of PHP

alandipert11:10:23

the first hoplon backend was php, that is

thedavidmeister11:10:00

well i’m happy learning

thedavidmeister11:10:28

also, i just installed cursive because it was recommended in a different chat room

thedavidmeister11:10:50

i thiiiink that .hl files aren’t detected

thedavidmeister11:10:56

does that sound right?

thedavidmeister11:10:17

also, @alandipert i think the stuff i want to do on the server will work better in threads, so kind of glad it’s no longer PHP

thedavidmeister12:10:36

does hoplon work with the cursive IDE?

alandipert12:10:01

cursive is a fine editor of .hl files, supports only Leiningen projects atm (hoplon is boot-only)

alandipert12:10:29

i don't know much else, as i haven't tried it myself

alandipert13:10:16

btw re: heroku and ram... it's kind of an antipattern to compile cljs on the server, which the existing heroku tools apparently encourage you to do

alandipert13:10:29

for our production stuff we compile cljs during a build and then deploy the static JS to CDN

alandipert13:10:59

that's why the .war deployment option on heroku is appealing... it's a way to upload what amounts to a zip file of pre-compiled cljs to them to serve out, while still having the ability to run a clj backend on them

thedavidmeister13:10:20

@alandipert: yeah, i got that far, at least, figuring out what a war is

thedavidmeister13:10:26

and that it probably does what i think needs to happen

thedavidmeister13:10:34

but not far enough for it to actually work 😞

thedavidmeister13:10:44

@alandipert: i just went back to sublime, all good simple_smile

alandipert14:10:20

@thedavidmeister: good news! making a war is really easy. first, make a new hoplon app with a backend: lein new hoplon-castra my-app. Then cd my-app. Then boot make-war, which makes target/project.war

alandipert14:10:35

then you can deploy the project.war file as per https://devcenter.heroku.com/articles/war-deployment

onetom15:10:29

@alandipert: awesome news! i might use it for experimentation and teaching. (the css took awhile (~0.6s) to arrive simple_smile FOUC again)

alandipert15:10:15

oh yeah, i don't prerender

alandipert15:10:09

don't want to demand phantomjs

onetom15:10:29

im just looking at the contents of the .war (because it's 21MB) and i see WEB-INF/lib/boot-cljs-1.7.48-6.jar which seems unnecessary. is it a matter of specifying :scope "test" to exclude it from the war?

micha15:10:33

we should fallback to prerender in htmlunit

micha15:10:43

i have some code that does it, i used it for testing

onetom15:10:44

micha: that would be great because on el capitan i was just fighting w phantomjs the other day. it's segfaulting because they are using the upx exe packer on the default distribution file...

micha15:10:04

it was like 5 lines of clojure to get htmlunit working

micha15:10:14

i wish i could remember where that code is

onetom15:10:37

and what would run the javascript in that case, nashorn?

micha15:10:56

whatever htmlunit uses, i think maybe rhino

esp115:10:54

@micha fyi I made a trivial little macro to be able to define elements in html/hlisp:

(defmacro html-elem
  [{:keys [name]} kids]
  (let [n (symbol name)]
    `(defelem ~n [_ _] ~kids)))

esp115:10:29

it’s trivial because it doesn’t have any facilities for doing let bindings

esp115:10:30

it looks like there are already some ways in hlisp to incorporate bound variables into content generation - e.g. attrs with values surrounded in {{…}} get evaluated

esp115:10:08

i don’t know if there is a similar mechanism to eval text node content? or if there is an <eval>...</eval> element?

micha15:10:46

there is no eval in clojurescript unfortunately

micha15:10:09

i think you want to do your code in <script> tags

micha15:10:15

and just refer to them in the html

micha15:10:51

<script type="hoplon">
  (defn my-func [x]
    (+ x 1))
</script>

esp115:10:14

yes, but how to do something like:

<html-elem name="my-head">
    <head>
        <title>Main Title{{(when subtitle (str “ - “ subtitle))}}</title>
        <link href="/css/styles.css" rel="stylesheet" type="text/css">
    </head>
</html-elem>

esp115:10:28

i don’t think you can do inline eval like in the title above.. maybe something like this would be possible tho:

<title>Main Title<eval expr=“{{(when subtitle (str “ - “ subtitle))}}”/></title>

esp115:10:26

just some thoughts. this is kind of a lark because i’m really fine w/just doing everything in clojurescript, but it’d be nice to have some of these facilities on the hlisp side too.

onetom15:10:32

Probably u have to do

<title>Main Title{{opt-subtitle}}</title>
and calculate the opt-subtitle outside, where u define subtitle itself

micha15:10:07

esp: i think you want to use cells and attributes

micha15:10:24

you're not using attributes for what their real purpose is

micha15:10:35

the state is defined in cells

micha15:10:47

and elements have attributes set to those cells

micha15:10:19

that's how you separate the programmy part from the artistic part

micha15:10:40

for the title thing you can do:

micha15:10:12

<title><text>Main Title ~(when subtitle (str “ - “ subtitle))</text></title>

micha15:10:29

the text macro is already a thing in hoplon

esp115:10:47

so the ways to access programmatic/cell state in hlisp is either attr=“{{xyz}}” or <text>something ~(xyz)</text>?

micha15:10:13

well text is a macro

micha15:10:19

it does string interpolation

micha15:10:42

(text "Main Title ~(when foo (str bar baz))")

micha15:10:53

that expands to something like

micha15:10:17

(str "Main Title " (when foo (str bar baz)))

micha15:10:04

(.createTextNode js/document (str "Main Title " (when foo (str bar baz))))

micha15:10:09

but it also is reactive

micha15:10:25

so any of the things can be cells and the text node will update when they change

micha15:10:32

i wonder if hlisp mode should just automatically wrap all text in <text>

esp116:10:59

not a bad idea. btw is there a reason that the string interpolation syntax is different for attrs vs. text nodes?

levitanong18:10:42

@esp1: I’m guessing text nodes have a lot of other strings you want to include like “Hello, my name is…”, whereas in attrs, it’s usually just the cell you want to refer to.