klipse

pesterhazy 2017-03-04T17:45:00.001068Z

I'm trying out cljsjs in Klipse, using react-select as an example

pesterhazy 2017-03-04T17:45:20.001069Z

It seems to load fine (window.Select is present when checked in devtools)

pesterhazy 2017-03-04T17:45:36.001070Z

But when I render the component, I get an exception

pesterhazy 2017-03-04T17:46:12.001072Z

The exception is

Uncaught TypeError: (0 , g.default) is not a function
    at t.render (eval at cljs.js.js_eval (klipse.js:74727), <anonymous>:1:29889)
    at p._renderValidatedComponentWithoutOwnerOrContext (klipse.js:1941)
    at p._renderValidatedComponent (klipse.js:1941)
    at performInitialMount (klipse.js:1941)
    at p.mountComponent (klipse.js:1941)
    at Object.mountComponent (klipse.js:1943)
    at performInitialMount (klipse.js:1941)
    at p.mountComponent (klipse.js:1941)
    at Object.mountComponent (klipse.js:1943)
    at h.mountChildren (klipse.js:1942)

pesterhazy 2017-03-04T17:51:18.001073Z

hm the issue seems to be in this line: https://github.com/JedWatson/react-select/blob/5aef30df9dba378886f06684f7128216c0f340f6/src/Select.js#L1070

pesterhazy 2017-03-04T17:51:45.001074Z

looks like the "classnames" dependency isn't properly loaded

Yehonathan Sharvit 2017-03-04T18:03:43.001075Z

Does it work fine on regular cljs?

pesterhazy 2017-03-04T18:05:21.001076Z

hm I think so but I should check

pesterhazy 2017-03-04T18:05:31.001077Z

I just looked at the minified js

pesterhazy 2017-03-04T18:05:43.001078Z

it checks for window.classNames

pesterhazy 2017-03-04T18:06:05.001079Z

and window.classNames is indeed set

pesterhazy 2017-03-04T18:06:13.001080Z

so not sure what's going on there

pesterhazy 2017-03-04T18:14:12.001081Z

window.classNames("a", "b")
"a b"

pesterhazy 2017-03-04T18:14:16.001082Z

also works hm hm

pesterhazy 2017-03-04T18:33:20.001083Z

OK, updated. I rearranged the requires so that cljsjs.classnames gets loaded before cljsjs.react-select

pesterhazy 2017-03-04T18:33:31.001085Z

but I'm getting another error now

Yehonathan Sharvit 2017-03-04T18:36:49.001086Z

I cannot look at it now

Yehonathan Sharvit 2017-03-04T18:37:13.001087Z

I’m preparing the “Essential Klipse” webinar that is starting in 20 minutes

pesterhazy 2017-03-04T18:37:54.001088Z

I'll join in 🙂

Yehonathan Sharvit 2017-03-04T18:43:24.001089Z

Cool

Yehonathan Sharvit 2017-03-04T18:43:40.001090Z

I’m currently testing the webinar connection with Jay

pesterhazy 2017-03-04T19:07:31.001091Z

I can confirm that the react-select gist works when you try it in a lein figwheel environment

clojuregeek 2017-03-04T20:33:41.001096Z

Hi, my blog is based on jekyll (octopress.. old version!) and i tried using klipse ... and got this error

clojuregeek 2017-03-04T20:33:51.001097Z

Pygments can't parse unknown language: language-klipse

clojuregeek 2017-03-04T20:34:28.001098Z

after adding JS to the template and changing a blog post to be like:

16 │ <pre><code class="language-klipse">
  17 │ (defrecord Recipe [name link source])
  18 │ </code></pre>

clojuregeek 2017-03-04T20:35:59.001099Z

i was wondering if anybody knows if this can work while using pygments

Yehonathan Sharvit 2017-03-04T20:47:11.001100Z

Welcome @clojuregeek

Yehonathan Sharvit 2017-03-04T20:47:33.001101Z

Can you share the HTML code of the page that causes the issue

Yehonathan Sharvit 2017-03-04T20:47:41.001102Z

?

Yehonathan Sharvit 2017-03-04T20:47:52.001103Z

It would be helpful if you can host the page somewhere

Yehonathan Sharvit 2017-03-04T20:47:55.001104Z

and send a link

clojuregeek 2017-03-04T20:50:36.001105Z

I get the error when running rake generate so it doens't get as far as to the html

Yehonathan Sharvit 2017-03-04T20:52:17.001106Z

What did you put in your markdown exactly?

clojuregeek 2017-03-04T20:53:50.001107Z

i used html tags in like i posted and trid

clojuregeek 2017-03-04T20:53:55.001108Z

16 │ 
klipse 17 │ (defrecord Recipe [name link source]) 18 │

clojuregeek 2017-03-04T20:54:11.001109Z

three ` for closing too 🙂

Yehonathan Sharvit 2017-03-04T20:55:37.001110Z

The problem is that pygment doesn’t know klipse

Yehonathan Sharvit 2017-03-04T20:55:51.001111Z

and it probably has a close list of languages it supports

Yehonathan Sharvit 2017-03-04T20:56:44.001112Z

the markdown engine I use (kramdown) doesnt have such a limitation

Yehonathan Sharvit 2017-03-04T20:56:44.001113Z

Could you replace klipse by clojure?

clojuregeek 2017-03-04T20:59:26.001115Z

ok no errors... but i am not seeing the js in the page... let me see what is going on

Yehonathan Sharvit 2017-03-04T21:01:30.001116Z

ok.

Yehonathan Sharvit 2017-03-04T21:05:49.001117Z

@pesterhazy could you try to use the non-minified version of react-select?

Yehonathan Sharvit 2017-03-04T21:06:24.001119Z

By including this a script in your html page?

Yehonathan Sharvit 2017-03-04T21:06:43.001120Z

All the cljsjs files are hosted here: https://github.com/viebel/cljsjs-hosted

clojuregeek 2017-03-04T21:11:02.001121Z

@viebel ok no errors, i see the html/css in page .. but it doesn't transform the code snippit

Yehonathan Sharvit 2017-03-04T21:11:33.001122Z

did u update the klipse settings - with language-clojure?

pesterhazy 2017-03-04T21:13:23.001123Z

@viebel, will try that

clojuregeek 2017-03-04T21:13:32.001124Z

I used what the site said for clojure

<script>
    window.klipse_settings = {
        selector: '.language-klipse'// css selector for the html elements you want to klipsify
    };
</script>

Yehonathan Sharvit 2017-03-04T21:14:08.001125Z

you need to modify the selector

Yehonathan Sharvit 2017-03-04T21:14:33.001126Z

the selector contains the CSS selector of the elements you want to klipsify

Yehonathan Sharvit 2017-03-04T21:14:56.001127Z

In your case it should be:

<script>
    window.klipse_settings = {
        selector: '.language-clojure’ // css selector for the html elements you want to klipsify
    };
</script>

clojuregeek 2017-03-04T21:22:52.001128Z

ok i can't get it .. i have the selector as clojure as that is wht the class name is of the div containing my clojure code ... the js link and css link is there

Yehonathan Sharvit 2017-03-04T21:23:49.001129Z

Can you share the html file?

Yehonathan Sharvit 2017-03-04T21:27:25.001131Z

There are a couple of issues here:

Yehonathan Sharvit 2017-03-04T21:28:10.001132Z

1. the url of the js file is not the good one. It should be <https://storage.googleapis.com/app.klipse.tech/plugin/js/klipse_plugin.js>

Yehonathan Sharvit 2017-03-04T21:28:22.001133Z

2. the klipse tag should be at the end of the body

Yehonathan Sharvit 2017-03-04T21:31:18.001134Z

3. it seems that pygment modifies the DOM at render time. Therefore the element with the clojure class is completly rewritten. And klipse cannot find it

clojuregeek 2017-03-04T21:33:32.001136Z

hm so can't use pygment then?

Yehonathan Sharvit 2017-03-04T21:34:13.001137Z

Can u show me the source of your klipse snippet?

clojuregeek 2017-03-04T21:34:41.001138Z

the clojure code in the div?

Yehonathan Sharvit 2017-03-04T21:35:11.001139Z

Including the div as you create it in your source file

clojuregeek 2017-03-04T21:37:33.001140Z

markdown

22 │ 
clojure 23 │ (def tacos (->Recipe "Tacos" "http://www.tacorecipes.com" "mom")) 24 │
generated html:
&lt;figure class="code"&gt;&lt;figcaption&gt;&lt;span&gt;&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class="line-number"&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;pre&gt;&lt;code class="clojure"&gt;&lt;span class="line"&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;defrecord &lt;/span&gt;&lt;span class="nv"&gt;Recipe&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;name &lt;/span&gt;&lt;span class="nv"&gt;link&lt;/span&gt; &lt;span class="nv"&gt;source&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

Yehonathan Sharvit 2017-03-04T21:39:07.001141Z

What happens if you use three backticks without any language?

clojuregeek 2017-03-04T21:40:07.001142Z

looks same without syntax highlighting

Yehonathan Sharvit 2017-03-04T21:41:54.001144Z

and the generate html?

clojuregeek 2017-03-04T21:42:26.001145Z

&lt;figure class="code"&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class="line-number"&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;pre&gt;&lt;code class=""&gt;&lt;span class="line"&gt;(defrecord Recipe [name link source])&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

Yehonathan Sharvit 2017-03-04T21:43:37.001146Z

Let me think...

clojuregeek 2017-03-04T21:44:01.001147Z

ok i need to take a call

clojuregeek 2017-03-04T21:45:54.001148Z

well in 5 mins 🙂

Yehonathan Sharvit 2017-03-04T21:48:18.001149Z

you need to find a way to tell pygment to let you use a language pygment doesn’t know

Yehonathan Sharvit 2017-03-04T21:48:28.001150Z

like klipse or eval-clojure

Yehonathan Sharvit 2017-03-04T21:48:51.001151Z

it should leave the div as is

Yehonathan Sharvit 2017-03-04T21:56:23.001152Z

@clojuregeek there might be a solution

Yehonathan Sharvit 2017-03-04T21:56:25.001153Z

http://octopress.org/docs/plugins/backtick-codeblock/

Yehonathan Sharvit 2017-03-04T21:56:50.001154Z

It is written that "Passing 'plain' disables highlighting"

Yehonathan Sharvit 2017-03-04T21:56:57.001155Z

could you try `plain ?

clojuregeek 2017-03-04T22:15:57.001156Z

ok i will do it now

clojuregeek 2017-03-04T22:18:14.001157Z

ok i did.. doesn't render

Yehonathan Sharvit 2017-03-04T22:18:44.001158Z

you need to find a way to tell pygment to let you use a language it doesn’t know

Yehonathan Sharvit 2017-03-04T22:19:23.001159Z

so that it leaves the &lt;pre&gt;&lt;code&gt; element as is

Yehonathan Sharvit 2017-03-04T22:19:50.001160Z

can you show me the generated html when you used `plain ?

clojuregeek 2017-03-04T22:20:56.001161Z

&lt;figure class="code"&gt;&lt;figcaption&gt;&lt;span&gt;&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class="line-number"&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;pre&gt;&lt;code class=""&gt;&lt;span class="line"&gt;(defrecord Recipe [name link source])&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

clojuregeek 2017-03-04T22:21:29.001162Z

looks the same as when i didn't use anything after the `

clojuregeek 2017-03-04T22:22:56.001163Z

anyways thanks for your help, i don't want to take too much of your time. I'll try again later and see if i can remove pygments .. i might need to update a few things too

Yehonathan Sharvit 2017-03-04T22:23:05.001164Z

last thing

Yehonathan Sharvit 2017-03-04T22:23:20.001165Z

can you try to have the div as is in the markdown

Yehonathan Sharvit 2017-03-04T22:23:28.001166Z

I mean something like:

Yehonathan Sharvit 2017-03-04T22:23:47.001167Z

<div class=”clojure”> (map inc [1 2 3]) </div>

Yehonathan Sharvit 2017-03-04T22:24:23.001168Z

The problem with that approach is that if you have &lt; or &gt; inside your code you need to html-escape those characters

Yehonathan Sharvit 2017-03-04T22:25:57.001169Z

Another option is to try `text

Yehonathan Sharvit 2017-03-04T22:26:11.001170Z

It might live the dom element as is

clojuregeek 2017-03-04T22:27:01.001171Z

yeah i already tried it that way

clojuregeek 2017-03-04T22:27:08.001172Z

so i dunno! 🙂 i give up for now 🙂

Yehonathan Sharvit 2017-03-04T22:27:40.001173Z

maybe after a good night of sleep, things will come up in a nicer way...

clojuregeek 2017-03-04T22:29:37.001174Z

🙂

Yehonathan Sharvit 2017-03-04T22:54:26.001175Z

@clojuregeek I just tried to use pygment instead of rouge in my jekyll blog and it works fine

pesterhazy 2017-03-04T22:54:37.001176Z

wow, I got react-select to work

Yehonathan Sharvit 2017-03-04T22:54:38.001177Z

with ~~~klipse

clojuregeek 2017-03-04T22:55:02.001182Z

@viebel hmm..

Yehonathan Sharvit 2017-03-04T22:57:51.001183Z

@pesterhazy Nice!

Yehonathan Sharvit 2017-03-04T22:58:02.001184Z

So the issue is with the minified js?

pesterhazy 2017-03-04T22:58:11.001185Z

kind of hacky though, I went around cljsjs

pesterhazy 2017-03-04T22:58:27.001186Z

well using the unminified js was definitely helpful in debugging

Yehonathan Sharvit 2017-03-04T22:58:52.001187Z

did you discover the root cause of the issue?

clojuregeek 2017-03-04T22:59:09.001188Z

@viebel i am going to have to look at this another day but thanks for your help 🙂

pesterhazy 2017-03-04T22:59:44.001189Z

I think so

pesterhazy 2017-03-04T23:00:14.001190Z

because react-input-autosize/dist/react-input-autosize.js wasn't loaded

pesterhazy 2017-03-04T23:00:33.001191Z

or not loaded early enough

pesterhazy 2017-03-04T23:02:18.001192Z

YES, that's it, it works with cljsjs too

Yehonathan Sharvit 2017-03-04T23:02:51.001193Z

whne u explicitly loads it?

pesterhazy 2017-03-04T23:03:27.001194Z

exactly

pesterhazy 2017-03-04T23:03:48.001195Z

that really wasn't obvious from the error though

Yehonathan Sharvit 2017-03-04T23:04:20.001196Z

and in regular cljs the bug did not occur?

Yehonathan Sharvit 2017-03-04T23:06:39.001197Z

Can u send the working snippet with cljs

Yehonathan Sharvit 2017-03-04T23:06:55.001198Z

?

pesterhazy 2017-03-04T23:09:32.001201Z

I had to specify classnames and react-input-autosize explicitly

Yehonathan Sharvit 2017-03-04T23:10:31.001202Z

And in regular cljs you don’t need to specify them?

pesterhazy 2017-03-04T23:11:51.001203Z

exactly

pesterhazy 2017-03-04T23:11:59.001204Z

it's specified as a dependency

Yehonathan Sharvit 2017-03-04T23:12:17.001205Z

where?

Yehonathan Sharvit 2017-03-04T23:13:03.001207Z

hmmm

Yehonathan Sharvit 2017-03-04T23:13:11.001208Z

So this is a bug inside klipse

Yehonathan Sharvit 2017-03-04T23:13:14.001209Z

Sorry about that

pesterhazy 2017-03-04T23:14:39.001210Z

not at all

pesterhazy 2017-03-04T23:15:04.001211Z

In debugging this I learned many things

pesterhazy 2017-03-04T23:15:21.001212Z

how to load javascripts files using goog.net.Xhr and eval

pesterhazy 2017-03-04T23:15:27.001213Z

how to load css files

pesterhazy 2017-03-04T23:15:39.001214Z

the fact that unpkg is awesome

Yehonathan Sharvit 2017-03-04T23:16:13.001215Z

🙂

pesterhazy 2017-03-04T23:16:23.001216Z

do you want me to create an issue?

Yehonathan Sharvit 2017-03-04T23:16:36.001217Z

Ye

Yehonathan Sharvit 2017-03-04T23:16:40.001218Z

Yes

Yehonathan Sharvit 2017-03-04T23:16:58.001219Z

And I’d love to see a PR with your load-many function

pesterhazy 2017-03-04T23:17:20.001220Z

hehe 🙂

pesterhazy 2017-03-04T23:17:52.001221Z

it's kind of suboptimal because it loads js/css files sequentially

Yehonathan Sharvit 2017-03-04T23:18:57.001222Z

Don’t worry about that

Yehonathan Sharvit 2017-03-04T23:19:02.001223Z

we can optimize later

pesterhazy 2017-03-04T23:19:53.001224Z

cool

Yehonathan Sharvit 2017-03-04T23:19:58.001225Z

Also, we need to think about the CSS

pesterhazy 2017-03-04T23:20:15.001226Z

yeah I agree

Yehonathan Sharvit 2017-03-04T23:20:18.001227Z

for the klipse plugin, it’s not an issue, you can add them to the page

Yehonathan Sharvit 2017-03-04T23:20:26.001228Z

But the klipse app, it’s a big issue

pesterhazy 2017-03-04T23:20:27.001229Z

plunkr etc have a way to add stylesheets

pesterhazy 2017-03-04T23:20:46.001230Z

but that may be overkill I don't know

Yehonathan Sharvit 2017-03-04T23:21:21.001231Z

Without that you cannot demo react-select at all!

Yehonathan Sharvit 2017-03-04T23:22:46.001232Z

By the way, the css files are uploaded in cljsjs-hosted https://github.com/viebel/cljsjs-hosted/blob/master/cljsjs/react-select/common/react-select.inc.css

Yehonathan Sharvit 2017-03-04T23:22:59.001233Z

It means that you don’t need unpkg at all

pesterhazy 2017-03-04T23:23:23.001234Z

hm yes I can also get it from there

pesterhazy 2017-03-04T23:23:35.001235Z

still need to create a &lt;link&gt; tag

Yehonathan Sharvit 2017-03-04T23:23:37.001236Z

(Why did you write that unpkg is awesome? Is it more than a cdn that hosts js/css)

pesterhazy 2017-03-04T23:23:56.001237Z

well I think it contains everything that is in npm

Yehonathan Sharvit 2017-03-04T23:24:10.001238Z

Oh! That’s great

pesterhazy 2017-03-04T23:24:41.001239Z

Hence, u*npkg*

pesterhazy 2017-03-04T23:24:56.001240Z

hmm that doesn't make as sense as it did in my head 🙂

Yehonathan Sharvit 2017-03-04T23:25:45.001241Z

Wait a minute

Yehonathan Sharvit 2017-03-04T23:25:58.001242Z

This is great news for klipse

Yehonathan Sharvit 2017-03-04T23:26:31.001243Z

Think about the js klipse snippets

Yehonathan Sharvit 2017-03-04T23:26:51.001244Z

We could serve any js package by just getting its name

Yehonathan Sharvit 2017-03-04T23:27:47.001245Z

You could have data-js-package=d3 and boom

Yehonathan Sharvit 2017-03-04T23:27:54.001246Z

d3 on your page!

pesterhazy 2017-03-04T23:28:34.001247Z

yes 🙂

pesterhazy 2017-03-04T23:29:18.001248Z

if they provide a standalone package in their npm bundle? (not sure I know what I'm talking about)

Yehonathan Sharvit 2017-03-04T23:29:43.001249Z

who are “they”?

pesterhazy 2017-03-04T23:30:19.001250Z

the author of the npm package

Yehonathan Sharvit 2017-03-04T23:31:15.001251Z

You’re right

Yehonathan Sharvit 2017-03-04T23:31:37.001252Z

Sometimes the npm package contains only the source and you need to build it

Yehonathan Sharvit 2017-03-04T23:32:29.001253Z

But I think that most of the popular packages include a bundle

Yehonathan Sharvit 2017-03-04T23:32:47.001254Z

And unpkg is smart:

If you omit the file path, unpkg will try to serve the browser bundle if present, the main module otherwise.

Yehonathan Sharvit 2017-03-04T23:33:04.001255Z

from: https://unpkg.com/#/

Yehonathan Sharvit 2017-03-04T23:34:23.001257Z

Going to sleep...

Yehonathan Sharvit 2017-03-04T23:34:59.001258Z

Feel free to open an issue also for this feature (loading js package from unpkg)

pesterhazy 2017-03-04T23:40:20.001259Z

good night