Skip to content

Commit 8652e48

Browse files
committed
regenerate site
1 parent 8a5e31a commit 8652e48

File tree

4 files changed

+64
-60
lines changed

4 files changed

+64
-60
lines changed

articles/tutorials/basic_web_development/index.html

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,23 @@ <h2>Basic Web Development</h2>
115115
file to specify the libraries we want to use, and a couple of folders: one
116116
for CSS files and one for your source code.</p><p>The <code>deps.edn</code> file should have the following contents:</p><pre><code class="clojure">{:paths ["src" "resources"]
117117
:deps {;; basic Ring and web server:
118-
ring/ring-core {:mvn/version "1.9.6"}
119-
ring/ring-jetty-adapter {:mvn/version "1.9.6"}
118+
ring/ring-core {:mvn/version "1.12.2"}
119+
ring/ring-jetty-adapter {:mvn/version "1.12.2"}
120+
;; logging, required by jetty:
121+
org.slf4j/slf4j-simple {:mvn/version "2.0.13"}
120122

121123
;; routing:
122-
compojure/compojure {:mvn/version "1.7.0"}
124+
compojure/compojure {:mvn/version "1.7.1"}
123125

124126
;; convenient package of "default" middleware:
125-
ring/ring-defaults {:mvn/version "0.3.4"}
127+
ring/ring-defaults {:mvn/version "0.5.0"}
126128

127129
;; to generate HTML:
128130
hiccup/hiccup {:mvn/version "1.0.5"}
129131

130132
;; for the database:
131-
com.github.seancorfield/next.jdbc {:mvn/version "1.3.862"}
132-
com.h2database/h2 {:mvn/version "2.1.214"}}}
133+
com.github.seancorfield/next.jdbc {:mvn/version "1.3.939"}
134+
com.h2database/h2 {:mvn/version "2.2.224"}}}
133135
</code></pre><p>Now we'll create the first version of our source file:</p><pre><code class="clojure">;; this file is: src/my_webapp/handler.clj
134136
(ns my-webapp.handler
135137
(:require [compojure.core :refer [defroutes GET]]
@@ -149,10 +151,10 @@ <h2>Basic Web Development</h2>
149151
(jetty/run-jetty #'app {:port 3000}))
150152
</code></pre><blockquote><p>REPL-friendly code: we use the <code>#'</code> prefix on var names so that we can update the definitions while the program is running, without needing to restart our program -- see <a href="https://clojure.org/guides/repl/enhancing_your_repl_workflow#writing-repl-friendly-programs">writing REPL-friendly programs on clojure.org</a>.</p></blockquote><blockquote><p>Note: the directory has an underscore in it (<code>my_webapp</code>) but the namespace has a hyphen in it (<code>my-webapp</code>). This is important in Clojure: we use lowercase names with hyphens to separate "words" -- often called kebab-case -- but the corresponding directory and filenames should be lowercase with underscores to separate "words" -- often called snake_case. This is due to how Clojure maps code onto names that are acceptable to the underlying JVM ecosystem.</p></blockquote><p>At this point you can run this very basic web application from the command-line:</p><pre><code class="bash">clojure -M -m my-webapp.handler
151153
</code></pre><p>This says we want to run <a href="https://clojure.org/reference/repl_and_main">Clojure's main entry point</a> (<code>-M</code>) and then <code>-m my-webapp.handler</code>
152-
tells Clojure that we want it to run the <code>-main</code> function in that namespace.</p><p>It will output something like this (and then "hang" while the web server is running):</p><pre><code>2023-03-24 14:03:21.305:INFO::main: Logging initialized @2337ms to org.eclipse.jetty.util.log.StdErrLog
153-
2023-03-24 14:03:21.752:INFO:oejs.Server:main: jetty-9.4.48.v20220622; built: 2022-06-21T20:42:25.880Z; git: 6b67c5719d1f4371b33655ff2d047d24e171e49a; jvm 19.0.2+7
154-
2023-03-24 14:03:21.783:INFO:oejs.AbstractConnector:main: Started ServerConnector@43201f84{HTTP/1.1, (http/1.1)}{0.0.0.0:3000}
155-
2023-03-24 14:03:21.783:INFO:oejs.Server:main: Started @2815ms
154+
tells Clojure that we want it to run the <code>-main</code> function in that namespace.</p><p>It will output something like this (and then "hang" while the web server is running):</p><pre><code>[main] INFO org.eclipse.jetty.server.Server - jetty-11.0.21; built: 2024-05-14T03:19:28.958Z; git: 996cd61addad9cb033e0e3eba6fa3f0fa3dc270d; jvm 21.0.1+12-LTS
155+
[main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@677274e7{/,null,AVAILABLE}
156+
[main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@5570ee6d{HTTP/1.1, (http/1.1)}{0.0.0.0:3000}
157+
[main] INFO org.eclipse.jetty.server.Server - Started Server@729d1428{STARTING}[11.0.21,sto=0] @4321ms
156158
</code></pre><blockquote><p>Note: you can stop this program running by pressing <code>^C</code> (control-c) on macOS or Linux, or by pressing <code>^Z</code> (control-z) on Windows.</p></blockquote><p>The only relevant line in that output is <code>Started ServerConnector</code> where it
157159
shows the host and port it is running on -- <code>0.0.0.0:3000</code> -- so you should
158160
be able to open a web browser and go to http://localhost:3000 and you should
@@ -398,28 +400,30 @@ <h2>Basic Web Development</h2>
398400
<a href="https://clojure.org/guides/tools_build"><code>tools.build</code> guide</a> for more details.</p><p>To make your webapp suitable for deployment, make the following
399401
changes:</p><h3 id="changes-in-depsedn">Changes in deps.edn</h3><p>In your <code>dep.edn</code> file add the following, after the <code>:deps</code> hash map:</p><pre><code class="clojure"> :aliases
400402
{;; Run with clj -T:build function-in-build
401-
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.9.4" :git/sha "76b78fe"}}
403+
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.4"}}
402404
:ns-default build}}
403405
</code></pre><p>The whole <code>deps.edn</code> file should now look like this:</p><pre><code class="clojure">{:paths ["src" "resources"]
404406
:deps {;; basic Ring and web server:
405-
ring/ring-core {:mvn/version "1.9.6"}
406-
ring/ring-jetty-adapter {:mvn/version "1.9.6"}
407+
ring/ring-core {:mvn/version "1.12.2"}
408+
ring/ring-jetty-adapter {:mvn/version "1.12.2"}
409+
;; logging, required by jetty:
410+
org.slf4j/slf4j-simple {:mvn/version "2.0.13"}
407411

408412
;; routing:
409-
compojure/compojure {:mvn/version "1.7.0"}
413+
compojure/compojure {:mvn/version "1.7.1"}
410414

411415
;; convenient package of "default" middleware:
412-
ring/ring-defaults {:mvn/version "0.3.4"}
416+
ring/ring-defaults {:mvn/version "0.5.0"}
413417

414418
;; to generate HTML:
415419
hiccup/hiccup {:mvn/version "1.0.5"}
416420

417421
;; for the database:
418-
com.github.seancorfield/next.jdbc {:mvn/version "1.3.862"}
419-
com.h2database/h2 {:mvn/version "2.1.214"}}
422+
com.github.seancorfield/next.jdbc {:mvn/version "1.3.939"}
423+
com.h2database/h2 {:mvn/version "2.2.224"}}
420424
:aliases
421425
{;; Run with clj -T:build function-in-build
422-
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.9.4" :git/sha "76b78fe"}}
426+
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.4"}}
423427
:ns-default build}}}
424428
</code></pre><h3 id="add-a-buildclj-file">Add a build.clj file</h3><p>The <code>tools.build</code> library is intended to be used with a <code>build.clj</code> script
425429
which typically lives in the root of your project and is invoked via the

cryogen.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><atom:link href="https://clojure-doc.org/" rel="self" type="application/rss+xml"/><title>Clojure Guides</title><link>https://clojure-doc.org/</link><description>Clojure Documentation</description><lastBuildDate>Sun, 30 Jun 2024 11:16:36 -0700</lastBuildDate><generator>clj-rss</generator></channel></rss>
1+
<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><atom:link href="https://clojure-doc.org/" rel="self" type="application/rss+xml"/><title>Clojure Guides</title><link>https://clojure-doc.org/</link><description>Clojure Documentation</description><lastBuildDate>Mon, 01 Jul 2024 17:54:03 -0700</lastBuildDate><generator>clj-rss</generator></channel></rss>

feed.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><atom:link href="https://clojure-doc.org/" rel="self" type="application/rss+xml"/><title>Clojure Guides</title><link>https://clojure-doc.org/</link><description>Clojure Documentation</description><lastBuildDate>Sun, 30 Jun 2024 11:16:36 -0700</lastBuildDate><generator>clj-rss</generator></channel></rss>
1+
<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><atom:link href="https://clojure-doc.org/" rel="self" type="application/rss+xml"/><title>Clojure Guides</title><link>https://clojure-doc.org/</link><description>Clojure Documentation</description><lastBuildDate>Mon, 01 Jul 2024 17:54:03 -0700</lastBuildDate><generator>clj-rss</generator></channel></rss>

0 commit comments

Comments
 (0)