This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-04
Channels
- # announcements (9)
- # babashka (5)
- # beginners (50)
- # calva (13)
- # clj-kondo (11)
- # clojure (30)
- # clojure-australia (1)
- # clojure-china (1)
- # clojure-europe (4)
- # clojure-filipino (1)
- # clojure-hk (1)
- # clojure-indonesia (1)
- # clojure-japan (1)
- # clojure-korea (1)
- # clojure-my (1)
- # clojure-norway (2)
- # clojure-sg (1)
- # clojure-taiwan (1)
- # clojurescript (32)
- # conjure (2)
- # honeysql (1)
- # hyperfiddle (8)
- # jobs-discuss (9)
- # leiningen (2)
- # malli (3)
- # off-topic (21)
- # reitit (4)
- # shadow-cljs (10)
- # sql (3)
- # squint (17)
- # tools-deps (14)
I've learned the basics of clojure and now I'm going through the documentation of http-kit to understand how clojure does web requests and responses
I'm a bit over whelmed 😓
Maybe https://github.com/ring-clojure/ring/wiki will help?
hey thanks for the suggestion
lemme check it out
I was making simple to-do app with friend, so it is basic's with Reagent and im exhausted. 😄 I know what you mean, but never give up 😉
If you want a more "batteries included" kind of approach, you can check out https://kit-clj.github.io/ or https://biffweb.com/
I recommend to start simple. you can play with this basic example Babashka + http-kit + basic routing https://github.com/prestancedesign/babashka-htmx-todoapp
"Simple" is an interesting term in this context. I share @U03VC5CUADR's feeling of being overwhelmed when starting a simple web app. I've been using Clojure for a couple of years now, and while I haven't started a ton of web apps, it's certainly overwhelming to get started each time. Which server? Which router? What middleware do I need? Which templating language? How do I coordinate and configure each of those to work together? Of course one learns the answers over time, but 1. it's inefficient to have to remember and type out all of those answers each time, and 2. why do I need to care about any of that, when all I want is to serve up some HTML? I understand the community's arguments against web frameworks, but it still leaves newcomers with that feeling of dread, having to become familiar with all of the various components (as good as they may be) before being able to do anything. I'm working on a solution for a "dissolving framwork" which allows you take over parts (or all) of the default web app setup, as and when you need/want to. This (excessively Spartan) demo task list app is 25 lines of Clojure (sans HTML template):
(ns walterl.botter-test
(:require [botter :as b]))
(defonce todos (atom []))
(defn- list-items
[_request & [templ-data]]
(b/render-template "list.html" (assoc templ-data :items @todos)))
(defn- add-item
[{{:keys [text]} :params, :as _request}]
(swap! todos #(conj % {:id (str (random-uuid)), :text text}))
(list-items nil {:flash (format "Added item: \"%s\"" text)}))
(defn- toggle-item
[{{:keys [id]} :params, :as _request}]
(swap! todos
(fn [items]
(map #(cond-> % (= (:id %) id) (update :done? not)) items)))
(list-items nil {:flash (format "Item toggled.")}))
(def routes
[["/" {:get list-items
:post add-item}]
["/toggle" {:post toggle-item}]])
I'm completely new to making any kind of web related programming. I just know how requests and responses work since I started out learning web app exploitation. So idk how a web server function to start with.
Can someone suggest a resource which teach how a web server app works (in clojure).
ik using libraries instead of frameworks is daunting to learn for new comers I don't mind that as long as the resources are in-depth and explains all the details
https://practical.li/ has a wealth of information, like https://practical.li/clojure-web-services/ and https://practical.li/clojurescript/
This book might help out: https://pragprog.com/titles/dswdcloj3/web-development-with-clojure-third-edition/
I've also found this yt channel beginner friendly: https://youtube.com/c/onthecodeagain
I agree that the best bet is to start with Ring. Explore that library and go from there. It basically handles web requests and responses (using clojure maps for both). So it turns a web request into a clojure map, you do what you want with that, then you return a response (to the client’s browser for example) as a clojure map as well. It handles receiving and returning those maps into the relevant http requests and responses.
This guy is also pretty beginner friendly: https://youtu.be/3AWXM8CN6FA
Thanks a lot @U9J50BY4C i'll check it out
Hi everyone, I'm working with IntelliJ IDEA as my editor, and I tried to install LSP Support plugin and configure it as mentioned here: https://clojure-lsp.io/clients/ Now whenever I open a project, I get this error message. Any ideas?
Thanks for the reply! 1. I have cursive plugin already installed. Is there any reason to have both plugins? 2. As for the second question, how can I check it? I'm trying to figure it out on my own but can't seem to find a proper answer.
1. Cursive should come with clojure-lsp installed? Or at least be using it under the hood, I'd be very surprised if it didn't. I'd ask in #cursive 2. https://github.com/clojure/java.classpath at a quick google to give you a full list of the classpath contents
I’m almost certain cursive doesn’t use lsp, I think it has it’s own engine for static analysis (disclaimer: it’s been a while since I’ve used cursive).
Scratch my number 1 then. Actually @U040FH3EFPV, do you have lein
installed on your system?
Yes, I have lein
installed, and as for my java.classpath, I don't see lein
there.
I do remember that when I installed LSP Support plugin, it required Cursive installed.
https://clojure-lsp.io/settings/#classpath-scan some documentation regarding what clojure-lsp does when starting, which should explain why it's trying to run leiningen
are you sure lein
is available in your PATH? the clojure-lsp
binary will attempt to run lein classpath [some options]
but that error indicates that it can't find the lein
command
Thanks @U0178V2SLAY, I now understand the situation better. As for my PATH, I installed lein
via Homebrew. Now, when I run lein
in my IntelliJ terminal, it runs fine. That means lein
is in my PATH, isn't it?
> I do remember that when I installed LSP Support plugin, it required Cursive installed.
That's a bit strange.
The LSP support plugin for Intellij IDEA acts as the language-agnostic LSP client (that is, it doesn't know anything about different programming languages or their specifics but knows how IDEA works) while another program (in this case clojure-lsp
) acts as the LSP server (it knows about clojure, but not about IDEA) and these two use the LSP protocol to communicate with each other.
you might want to try the normal macos Terminal app to check it, just to rule out IDEA doing something strange with the environment
Tried that also, runs fine.
you might be able to explicitly configure the classpath scanning options by creating a file .lsp/config.edn
within your project (if it doesn't already exits) and add:
{:project-specs [{:project-path "project.clj"
:classpath-cmd ["/the/full/absolute/path/to/lein" "with-profile" "+test,+dev" "classpath"]}]}
and replace /the/full/absolute/path/to/lein
with the appropriate path to lein
I'm not sure why clojure-lsp
is not resolving the path automatically, I assume the process is not inheriting the same PATH as your terminal but I don't know how to resolve this in macos.
Dumb question: did you install lein
after opening intellij? Or have you restarted your machine recently? I hate asking the "have you tried rebooting" but it might be a fixer here
and if all else fails you can just fallback to using cursive. I think cursive and lsp have a lot of overlap so I imagine you only need one or the other but not both at the same time :man-shrugging:
@U24QP2D4J Installed lein
before opening IntelliJ. Anyways, tried a reboot and it doesn't seem to work.
@U0178V2SLAY As for your solution, it doesn't seem to work either. I didn't have the dir nor the file in my project dir, and after creating them it still didn't resolve the issue. I think I'll pass for now and I'll update here if anything will come up.
EDIT: @U8SJSCFN3 your solution did work! My IntelliJ doesn't seem to know the my lein
location, and only after configuring it correctly in the .lsp/config.edn (which wasn't created automatically), the problem seemed to resolve. Any idea how to make this process work automatically when creating a new project? Maybe something I missed during the installation process?
Thank you all for your help!
the problem might have something to do with the LSP plugin for IDEA. There's a couple of issues like https://github.com/gtache/intellij-lsp/issues/147 which look similar to your issue
if you use leiningen for all your projects, you might be able to move that project-specs configuration to the https://clojure-lsp.io/settings/#global so that it applies to all clojure lsp projects
Yeah, unfortunatelly the LSP plugin for intellij Is way outdated, but I have plans to have a new plugin in the future 🤞

Hi! I am going through the https://www.learn-clojurescript.com/section-2/lesson-13-interacting-with-javascript-data/ section. I have reached this exercise where I need to get the grade for the Math course from a student.
(def student #js {"locker" 212
"grades" {"Math" "A",
"Physics" "B",
"English" "A+"}})
I tried (.. student -grades -Math)
and I always got nil
. After some googling I noticed that by changing the declaration of the student to
(def student #js {"locker" 212
"grades" #js {"Math" "A",
"Physics" "B",
"English" "A+"}})
the initial attempt worked. Did the first declaration of the student contain a syntax error? Would it be possible to retrieve the Math grade from the first declaration of the student?