Fork me on GitHub
#beginners
<
2016-11-08
>
seancorfield00:11:27

@dimovich Clojure doesn’t really have “frameworks” like other web dev languages. Instead it focuses on small, composable libraries and you build solutions based on those. So there’s no CMS for Clojure, pretty much by definition.

dimovich07:11:32

@seancorfield So, if the client needs to edit some files on the server, what options are there?

sveri07:11:25

@dimovich There are some CMS that are build with clojure, if you google for it. That said, you can just read and write files from hard drive or the resource path and use a normal formular to edit them

kauko07:11:07

If the client having access to the server is ok, then it's probably pretty straight forward

kauko07:11:17

if not, then you'll need some sort of CMS

sveri08:11:01

Also, please remember, text files dont have any formatting besides tabs and line breaks.

kauko08:11:48

Maybe markdown would be better? Or write the content in edn files, and then parse the edn into your templates.

kauko08:11:33

TBH @dimovich your use case sounds like something I personally wouldn't choose Clojure for. I mean, not that there's something inherent in Clojure that makes it unsuitable for something like this, but based on your description I'd say that there's stuff out there that gives you all you need pretty much from out of the box

kauko08:11:35

Why not just use Wordpress or something? That's not even the only option. I know these techs are not as sexy as Clojure, but I'd say they suit your needs just fine.

kauko08:11:07

Clojure is the golden hammer of god, but for this nail, a regular hammer should do just fine. 😉

dimovich08:11:16

@kauko you're right. Feels like using a bazooka to kill a fly. 🙂 I was planning to use markdown. The thing is, enlive (or any other templating lib) seem so elegant and simple. But I guess in this case, going with Wordpress should be fine.

dimovich08:11:01

thank you all for the answers

dominicm10:11:28

@dimovich Before you move on, there might be a better option

dominicm10:11:04

https://www.contentful.com/ CMS-as-an-API. There's possibly others of these around, but this is the one I know off the top of my head.

dominicm10:11:41

I've heard of people using the wordpress API, to have the "admin panel" of wordpress, but the smooth dev of Clojure.

dominicm10:11:15

A quick google suggests there are loads of these CMS-as-API things now.

dimovich11:11:18

@dominicm thx!

seancorfield16:11:14

@sveri I haven’t been able to turn up any Clojure-based CMS … do you have any pointers?

sveri16:11:45

@seancorfield this one has had some commits this year: https://github.com/emil0r/reverie

pawel.kapala17:11:53

Hey! What do you think I should use to convert this map (that was clojure.set/map-inverted): {[:a :b :c] 1 [:c :d] 2 [:a :c] 3} into {:a [1 3], :b [1], :c [1 2 3] ?

pawel.kapala17:11:11

This looks pretty close, but something is wrong here: (reduce (fn [m e] (update m (key e) (fnil conj []) e)) {} {[:a :b :c] 1 [:c :d] 2 [:a :c] 3})

pawel.kapala17:11:09

got it: (reduce (fn [m e] (update m (key e) (fnil conj []) (val e))) {} {[:a :b :c] 1 [:c :d] 2 [:a :c] 3})

pawel.kapala17:11:58

there must be a "magical" link about asking questions and finding solutions by yourself rubber-duck anyone? thanks!

curlyfry17:11:42

@pawel.kapala Doesn't that just wrap the values of the input map in vectors?

pawel.kapala17:11:35

indeed, too quickly I called it success 😉

pawel.kapala17:11:54

(reduce (fn [m e]
                (reduce (fn [m k]                       
                          (merge-with #(into [] (concat %1 %2)) m {k [(val e)]})) 
                        m (key e)))
                    {} {[:a :b :c] 1 [:c :d] 2 [:a :c] 3})
But I have a feeling, it should be possible to do it simpler..

st18:11:04

(apply merge-with concat
  (map (fn [[ks v]] (zipmap ks (repeat [v]))) {[:a :b :c] 1 [:c :d] 2 [:a :c] 3}))

rauh18:11:38

I'm 2 min late, but similarly:

(apply merge-with into
       (for [[k v] {[:a :b :c] 1 [:c :d] 2 [:a :c] 3}
             kw k]
         {kw [v]}))

st18:11:32

@pawel.kapala @rauh definitely a beginner’s question 😉 !

pawel.kapala18:11:44

@rauh @st Thanks!

pawel.kapala18:11:58

@st isn’t it a beginner’s question?

rauh18:11:44

Btw, if performance is important i'd do a manual nested reduce.

pawel.kapala18:11:01

@rauh like in my example?

rauh18:11:21

Yes, my for and merge-with is probably pretty slow

pawel.kapala18:11:10

I’m still analyzing @st ‘s zipmap version

st18:11:37

@pawel.kapala I was suggesting that this is not a trivial question. very interesting exercice for sure.

rauh18:11:13

@pawel.kapala Yes this is 3x faster:

(reduce-kv
      (fn [m kws v]
        (reduce
          (fn [m kw]
            (update m kw (fnil conj []) v))
          m
          kws))
      {}
      {[:a :b :c] 1 [:c :d] 2 [:a :c] 3})

pawel.kapala18:11:27

@st oh I didn’t get that. I still consider myself clojure newbe, so I wouldn’t go asking this question around other channels 😆

progzilla19:11:20

I am an absolute newbie...where do I start from please?

progzilla19:11:25

@shaun-mahood Thanks off I go!

pawel.kapala20:11:06

@shaun-mahood If you like to learn by example then 4clojure

curlyfry20:11:24

@progzilla I agree with the above posters! When I started out I read Clojure for the Brave and True while doing some 4clojure exercises in parallel. The cheat sheet http://clojure.org/api/cheatsheet also helps in exploring Clojure's huge (and amazing) library of core functions.

curlyfry20:11:19

@progzilla Also, I recommend following some other users on 4clojure to see how more experienced programmers solve the exercises. And sorting by difficulty! 🙂

rodeorockstar23:11:16

quick question about dependencies! i'm writing a library that i want to be included in another project as a dependency. the library's project.clj starts with (defproject abc/library "0.1.0-SNAPSHOT"... and has a main namespace called library.core. i ran lein install in the abc/library project and then added [abc/library "0.1.0-SNAPSHOT"] to my dependencies in my main project, but clojure complains that the library.core namespace can't be found. what am i missing?