Fork me on GitHub
#klipse
<
2017-06-06
>
genRaiy08:06:59

I want to add cljs-time to my klipse blog … is this supported? [https://github.com/andrewmcveigh/cljs-time]

genRaiy08:06:16

but cannot see how to bring a CLJS lib in

Yehonathan Sharvit08:06:52

It’s not explained here

genRaiy08:06:16

that’s a relief 😉

Yehonathan Sharvit08:06:40

You need to have a klipse snippet with data-external-libs=

Yehonathan Sharvit08:06:12

And the content of the snippet will something like : require '[cljs-time.core :as t]

Yehonathan Sharvit08:06:28

data-external-libs is like the classpath

genRaiy08:06:33

I’ll give it a go

Yehonathan Sharvit08:06:42

it tells klipse where to resolve the namespaces

genRaiy08:06:45

I saw that

genRaiy08:06:58

but wasn’t sure how to form the URL for the lib

genRaiy08:06:35

I guess I could also use a tag rather than master

Yehonathan Sharvit08:06:52

it might be a better idea

Yehonathan Sharvit08:06:26

I’d appreciate if you could improve the instructions for using external libs

Yehonathan Sharvit08:06:32

it confuses a lot of people

genRaiy08:06:12

sure - if I get it to work, I’ll try to help

genRaiy08:06:50

it’s not working yet so don’t get to excited 😛

genRaiy08:06:08

#error {:message “No such namespace: cljs-time.core, could not locate cljs_time/core.cljs, cljs_time/core.cljc, or Closure namespace \“cljs-time.core\“”, :data {:tag :cljs/analysis-error}}

genRaiy08:06:44

this is the code I have…

Yehonathan Sharvit08:06:29

sorry, I made a mistake in the data-external-libs

Yehonathan Sharvit08:06:42

It has to be: data-external-libs=

Yehonathan Sharvit08:06:57

Notice the src at the end

genRaiy08:06:13

yes, makes no difference

genRaiy08:06:33

maybe it should have /cljs_time also

Yehonathan Sharvit08:06:48

what error do you see now?

genRaiy08:06:14

#error {:message “No such namespace: cljs-time.core, could not locate cljs_time/core.cljs, cljs_time/core.cljc, or Closure namespace \“cljs-time.core\“”, :data {:tag :cljs/analysis-error}}

genRaiy08:06:11

I am doing it within a deckjs presentation

Yehonathan Sharvit08:06:28

It shouldn’t make a difference

genRaiy08:06:48

I thought not but mention it for completeness

Yehonathan Sharvit08:06:04

What’s the topic of your presentation?

genRaiy08:06:39

It’s a bunch of jokes about Clojure and FP, written in Clojure

genRaiy08:06:58

I previously had to swap between keynote and the terminal

genRaiy08:06:15

and I would rather do it all in one 🙂

genRaiy08:06:26

for example I make a macro called joke that can be called with a story and a punchline

genRaiy08:06:48

but it has no side effects

genRaiy08:06:01

and jokes should always have a side effect

genRaiy08:06:20

otherwise it’s a quantum joke

arnaud_bos08:06:31

I'm screenshoting that

arnaud_bos08:06:09

The four sentences, out of context it's hilarious

genRaiy08:06:34

LOL, it’s meant to be a joke so I’m happy about that 🙂

genRaiy08:06:06

I can see I’m going to have t o be careful not to reveal too much here!

arnaud_bos08:06:11

It was last year's EuroClojure where you did a clojure jokes "unsession" or something, right?

genRaiy08:06:34

yes, I’m hoping to do the same this year too

genRaiy08:06:50

I have an unsession booked at least

arnaud_bos08:06:23

Cool, I'll probably book my ticket and flight sometime this week, when are the unsessions?

genRaiy08:06:44

normally on the Thursday evening

arnaud_bos08:06:13

Perfect, I was disappointed not to go to EuroClojure last year, hopefully I'll see your unsession this year.

genRaiy08:06:59

that would be great

Yehonathan Sharvit09:06:02

@raymcdermott I think I found the issue

Yehonathan Sharvit09:06:13

Could you try

(require 'goog.i18n.DateTimeSymbols
         '[cljs-time.core :as t])

genRaiy09:06:52

#error {:message “Could not eval my.klipse”, :data {:tag :cljs/analysis-error}, :cause #error {:message “Only :as alias, :refer (names) and :rename {from to} options supported in :require; offending spec: (quote goog.i18n.DateTimeSymbols) at line 1 “, :data {:file nil, :line 1, :column 1, :tag :cljs/analysis-error}}}

Yehonathan Sharvit09:06:36

can you show me the page source?

genRaiy09:06:52

#error {:message “Could not eval my.klipse”, :data {:tag :cljs/analysis-error}, :cause #error {:message “Only :refer-clojure, :require, :require-macros, :use, :use-macros, and :import libspecs supported. Got (require (quote goog.i18n.DateTimeSymbols) (quote [cljs-time.core :as t])) instead. at line 1 “, :data {:file nil, :line 1, :column 1, :tag :cljs/analysis-error}}}

genRaiy09:06:12

I used :require, not require first

Yehonathan Sharvit09:06:43

That should work also

Yehonathan Sharvit09:06:52

You cannot put (require) inside a ns

Yehonathan Sharvit09:06:59

You have to use :require

Yehonathan Sharvit09:06:05

but without the quotes

genRaiy09:06:22

I had that… but OK let me revert

Yehonathan Sharvit09:06:31

Also it is better to put the require statement in a separate snippet

Yehonathan Sharvit09:06:50

Then it is not re-evaluated when you modify your code

genRaiy09:06:05

#error {:message “No such namespace: cljs-time.core, could not locate cljs_time/core.cljs, cljs_time/core.cljc, or Closure namespace \“cljs-time.core\“”, :data {:tag :cljs/analysis-error}}

Yehonathan Sharvit09:06:08

also, you have a typo

Yehonathan Sharvit09:06:26

<code class="clojure"
              data-external-libs="https://raw.githubusercontent.com/andrewmcveigh/cljs-time/master/src/">

genRaiy09:06:52

LOL yes the typo

genRaiy09:06:59

OK, it’s working now!!

genRaiy09:06:48

does Klipse support macros (I assume yes)

genRaiy09:06:48

OK, let me play with that and I promise to do a little write-up on external libs

Yehonathan Sharvit09:06:38

When using macro, you have to do a special trick with the namespace

Yehonathan Sharvit09:06:14

And be careful not to create more than 1 ns in your presentation

Yehonathan Sharvit09:06:20

otherwise it’s going to be a big mess

Yehonathan Sharvit09:06:30

And I have a surpris for you

Yehonathan Sharvit09:06:48

While we were talking, I have added cljs-time to the analysis cache of Klipse

genRaiy09:06:50

so can I put the ns/require in a snippet at the top and assume it’s going to be usable everywhere?

genRaiy09:06:03

haha, cool

Yehonathan Sharvit09:06:14

Starting from Klipse version 7.1.1

Yehonathan Sharvit09:06:24

you don’t need the data-external-libs

Yehonathan Sharvit09:06:26

in order to use cljs-time

Yehonathan Sharvit09:06:43

and it loads much faster

genRaiy09:06:30

so will that get picked up automagically now?

Yehonathan Sharvit09:06:07

You can check the browser console

Yehonathan Sharvit09:06:12

to see what version you get

genRaiy09:06:03

ok, I’ll give it a shot

genRaiy09:06:25

boom, yes that works

genRaiy11:06:10

something else I’m having an issue with…. hiding code

genRaiy11:06:14

if I do this

genRaiy11:06:58

I get this

Yehonathan Sharvit11:06:39

the snippet is not hidden at all!!

genRaiy11:06:04

you see my problem

genRaiy11:06:09

quite literally

Yehonathan Sharvit11:06:27

You need to create a css rule that hides element with class hidden

genRaiy11:06:44

oh, I thought that was with klipse

Yehonathan Sharvit11:06:45

.hidden {
visibility: hidden
}

Yehonathan Sharvit11:06:55

It’s not part of klipse

genRaiy11:06:49

it’s in the manual

Yehonathan Sharvit11:06:12

is it form the gitbook?

Yehonathan Sharvit11:06:28

that’s because gitbook has such a css rule

Yehonathan Sharvit11:06:44

Probably, I need to make it clearer

genRaiy11:06:27

the css rule does not collapse the space that the code would have occupied

genRaiy11:06:40

I’m not a CSS guru

genRaiy11:06:47

so any clues would be appreciated

genRaiy12:06:45

.hidden { display: none; }

genRaiy12:06:12

does the right thing - the visibility CSS rule is literally bullshit

genRaiy12:06:37

I have the macros working now too - so that’s cool and the gang