### Installing MkDocs Plugins (Shell)
Source: https://github.com/practicalli/clojurescript/blob/main/README.md
Installs a collection of essential MkDocs plugins required for the Practicalli site, including `mkdocs-material`, `mkdocs-callouts`, and `pillow`. These plugins are also installed in the GitHub Action workflow to maintain consistent environments.
```shell
pip3 install mkdocs-material mkdocs-callouts mkdocs-glightbox mkdocs-git-revision-date-localized-plugin mkdocs-redirects pillow cairosvg
```
--------------------------------
### Running ClojureScript Project with Leiningen and Figwheel-main
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-main-projects/simple.md
This command starts the ClojureScript project using Leiningen, utilizing the `:fig` alias for Figwheel-main and the `:build` task. It launches a connected browser REPL.
```Shell
lein fig:build
```
--------------------------------
### Running Local MkDocs Server (Shell)
Source: https://github.com/practicalli/clojurescript/blob/main/README.md
Starts a local development server for the MkDocs documentation from the root of the cloned project. The website will typically be accessible at `http://localhost:8000` after execution, allowing for real-time preview of changes.
```shell
make docs
```
--------------------------------
### Starting ClojureScript REPL from Command Line
Source: https://github.com/practicalli/clojurescript/blob/main/docs/om-project-clojurex/start-the-repl.md
These Clojure function calls are executed in a terminal-based REPL to initiate the development environment. `(run)` starts the Figwheel server at port 3449, providing live reloading, while `(browser-repl)` connects the browser-based ClojureScript REPL for interactive code evaluation.
```clojure
(run)
(browser-repl)
```
--------------------------------
### Installing MkDocs Material v9 (Shell)
Source: https://github.com/practicalli/clojurescript/blob/main/README.md
Installs a specific version of MkDocs Material (version 9) using the `pip` package manager. This ensures compatibility with the project's documentation setup and is a prerequisite for local development.
```shell
pip install mkdocs-material=="9.*"
```
--------------------------------
### Running a Clojure CLI Figwheel-main Project
Source: https://github.com/practicalli/clojurescript/blob/main/docs/install/clojurescript-project.md
This command uses Clojure CLI tools to start the ClojureScript project. It leverages the `:fig` alias for Figwheel-main and the `:build` task to compile and serve the application, typically launching a browser REPL for development.
```Shell
clojure -M:fig:build
```
--------------------------------
### Starting Figwheel Server - Bash
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-project/run-figwheel-again.md
This command initiates the Figwheel development server, which compiles ClojureScript code and provides live reloading capabilities. It also starts a REPL connected to the browser.
```Bash
lein figwheel
```
--------------------------------
### Starting Figwheel and Browser REPL from Clojure REPL
Source: https://github.com/practicalli/clojurescript/blob/main/docs/reagent-project-clojurex/start-the-repl.md
These Clojure commands are executed within a REPL to initialize the development environment. `(run)` starts the Figwheel server on port 3449, enabling live reloading of ClojureScript and CSS, and serving as the application server. `(browser-repl)` then initiates the ClojureScript REPL, which becomes active once the web page is loaded in the browser and connects to Figwheel.
```Clojure
(run)
(browser-repl)
```
--------------------------------
### Running ClojureScript Project with Clojure CLI and Figwheel-main
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-main-projects/simple.md
This command starts the ClojureScript project using Clojure CLI, leveraging the `:fig` alias for Figwheel-main and the `:build` task. It also integrates `rebel readline` for an enhanced REPL experience.
```Shell
clojure -M:fig:build
```
--------------------------------
### Running a Leiningen Figwheel-main Project
Source: https://github.com/practicalli/clojurescript/blob/main/docs/install/clojurescript-project.md
This command uses Leiningen to start the ClojureScript project. It utilizes the `:fig` alias for Figwheel-main and the `:build` task to compile and serve the application, which typically opens a connected browser REPL.
```Shell
lein fig:build
```
--------------------------------
### Starting a Clojure Webserver with Leiningen
Source: https://github.com/practicalli/clojurescript/blob/main/docs/create-a-project/run-webserver.md
This command starts a Jetty web server on http://localhost:8000 using Leiningen, the Clojure build automation tool. It's executed from the root directory of a Clojure project containing `project.clj`.
```bash
lein run 8000
```
--------------------------------
### Verifying Leiningen Installation
Source: https://github.com/practicalli/clojurescript/blob/main/docs/install/leiningen.md
This command is used to verify that Leiningen has been successfully installed and is accessible from the command line. It outputs the installed Leiningen version along with the Java runtime environment details, confirming the setup.
```bash
lein version
```
--------------------------------
### Example Om Root Initialization - ClojureScript
Source: https://github.com/practicalli/clojurescript/blob/main/docs/om/overview.md
This example demonstrates how to initialize an Om application using `om.core/root`. It defines a root component that renders an `
` tag with text from the application state, initializes the state with `{:text "Hello world!"}`, and targets the DOM element with ID 'my-app'.
```ClojureScript
(om.core/root
(fn [app-state owner]
(reify
om.core/IRender
(render [_]
(dom/h1 nil (:text app-state)))))
{:text "Hello world!"}
{:target (. js/document getElementById "my-app")})
```
--------------------------------
### Cloning Clojure Webapps Example Repository
Source: https://github.com/practicalli/clojurescript/blob/main/docs/create-a-project/run-webserver.md
This Git command clones the `clojure-webapps-example` repository from GitHub into the current directory. This is useful for quickly setting up the project if something is not working or to speed up development.
```bash
git clone https://github.com/practicalli/clojure-webapps-example
```
--------------------------------
### Setting up a Leiningen Project
Source: https://github.com/practicalli/clojurescript/blob/main/docs/introduction/writing-tips.md
This shell command creates a new Clojure project using Leiningen. It utilizes the `app` template and names the project `practicalli/gameboard`, offering an alternative setup method for Clojure development.
```shell
lein new app practicalli/gameboard
```
--------------------------------
### Creating a ClojureScript Project with Leiningen
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-main-projects/simple.md
This command initializes a new ClojureScript project using Leiningen and the `figwheel-main` template. It creates a `project.clj` based project named `practicalli/landing-page`.
```Shell
lein new figwheel-main practicalli/landing-page
```
--------------------------------
### Setting up a Clojure CLI Project
Source: https://github.com/practicalli/clojurescript/blob/main/docs/introduction/writing-tips.md
This shell command initializes a new Clojure project using the Clojure CLI tool. It specifies the `app` template and sets the project name to `practicalli/gameboard`, providing a quick start for new applications.
```shell
clojure -T:project/new :template app :name practicalli/gameboard
```
--------------------------------
### Creating a ClojureScript Project with Leiningen Chestnut
Source: https://github.com/practicalli/clojurescript/blob/main/docs/om-project-clojurex/create-project.md
This command initializes a new ClojureScript project named 'om-clojurex' using the Leiningen build tool and the 'chestnut' template. The chestnut template provides a pre-configured setup for Om-based ClojureScript applications, including server-side and client-side components.
```Shell
lein new chestnut om-clojurex
```
--------------------------------
### Creating a ClojureScript Project with Clojure CLI
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-main-projects/simple.md
This command initializes a new ClojureScript project using the Clojure CLI tools and the `figwheel-main` template. It creates a `deps.edn` based project named `practicalli/landing-page`.
```Shell
clojure -X:project/new :template figwheel-main :name practicalli/landing-page
```
--------------------------------
### Starting Clojure REPL with Leiningen
Source: https://github.com/practicalli/clojurescript/blob/main/docs/quickstart/dependencies.md
This Leiningen command starts a Clojure REPL (Read-Eval-Print Loop) for the project. It uses the `run` feature to execute `clojure.main` and then `repl.clj`, providing an interactive environment for development without manually managing the classpath, as Leiningen handles it automatically.
```Shell
lein run -m clojure.main repl.clj
```
--------------------------------
### Starting ClojureScript REPL in Spacemacs/Emacs with CIDER
Source: https://github.com/practicalli/clojurescript/blob/main/docs/om-project-clojurex/start-the-repl.md
This snippet provides the Clojure expressions to evaluate within a CIDER REPL buffer. `(go)` initializes the Figwheel server, and `(cljs-repl)` connects the browser-based ClojureScript REPL, enabling live code evaluation and an instant feedback loop for development.
```clojure
(go)
(cljs-repl)
```
--------------------------------
### Starting Figwheel Server (Specific Build)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel/configure-build.md
This shell command starts the Figwheel development server for a designated build. By appending the build's `:id` (e.g., 'example') to `lein figwheel`, developers can explicitly choose which ClojureScript build configuration to use for the hot-reloading server.
```Bash
$ lein figwheel example
```
--------------------------------
### Installing Leiningen on Linux/MacOSX
Source: https://github.com/practicalli/clojurescript/blob/main/docs/install/leiningen.md
This snippet provides the necessary bash commands to make the Leiningen install script executable and then run it for the first time on Linux and MacOSX systems. The `chmod` command grants execute permissions, and `lein` initiates the download of the Leiningen JAR file.
```bash
chmod a+x ~/bin/lein
lein
```
--------------------------------
### Navigating to the Project Directory
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-main-projects/simple.md
This command changes the current working directory to the newly created ClojureScript project, `landing-page`, which is a prerequisite for running project-specific commands.
```Shell
cd landing-page
```
--------------------------------
### Complete HTML Page Structure with Bulma and App Loading
Source: https://github.com/practicalli/clojurescript/blob/main/docs/css/bulma.md
This comprehensive HTML example outlines a basic web page structure, integrating Bulma CSS and Font Awesome via CDN. It includes standard meta tags, a custom stylesheet, an application loading div, and a placeholder for a ClojureScript application, demonstrating a typical setup for a single-page application.
```HTML
Loading the application, hold on tight!
```
--------------------------------
### Interacting with the ClojureScript REPL
Source: https://github.com/practicalli/clojurescript/blob/main/docs/install/chestnut.md
This snippet demonstrates how to start a Leiningen REPL session and then execute commands within it to launch the web server and connect a browser REPL. The `lein repl` command initiates the session, while `(run)` starts the web and Figwheel servers, and `(browser-repl)` connects the browser for live ClojureScript evaluation.
```shell
$ lein repl
```
```clojure
(run)
(browser-repl)
```
--------------------------------
### Running Leiningen Project REPL with Figwheel-main
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-main-projects/reagent.md
This command starts the ClojureScript REPL for a Leiningen project. It uses the `fig` alias to launch Figwheel-main and the `build` task to compile and serve the application, opening a connected browser REPL.
```shell
lein fig:build
```
--------------------------------
### Running Clojure CLI Project REPL with Figwheel-main
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-main-projects/reagent.md
This command starts the ClojureScript REPL for a Clojure CLI project. It uses the `:fig` alias for Figwheel-main and the `:build` task, along with the `:repl/rebel` alias to enable `rebel-readline` for an enhanced REPL experience.
```shell
clojure -M:repl/rebel:fig:build
```
--------------------------------
### Installing Lumo via NPM (Shell)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/install/lumo.md
This command installs the Lumo ClojureScript environment globally using npm. It makes the `lumo` binary available in your system's PATH for command-line execution.
```Shell
npm install -g lumo-cljs
```
--------------------------------
### Running Figwheel Server with Leiningen
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-project/run-figwheel.md
This snippet demonstrates how to start the Figwheel development server using the Leiningen build tool. It initiates the compilation of ClojureScript code and attempts to start a REPL, though the REPL is expected not to start initially.
```Shell
lein figwheel
```
--------------------------------
### Core.async: Asynchronous Go Block Example
Source: https://github.com/practicalli/clojurescript/blob/main/docs/clojurescript-code/index.md
This `core.async` `go` block demonstrates asynchronous execution. It prints a message, then suspends until a value is available from the `events` channel using `` HTML element with the text 'Hello World'. It's a basic example of component creation.
```ClojureScript
(defn hello-world []
[:h1 "Hello World"])
```
--------------------------------
### Cloning GitHub Repository Fork (Shell)
Source: https://github.com/practicalli/clojurescript/blob/main/README.md
Clones a forked GitHub repository to the local machine, allowing for local development and contribution. Users should replace `` and `` with their actual GitHub username and the repository name.
```shell
git clone https://github.com//.git
```
--------------------------------
### Managing Clojure Service with Rich Comment Block
Source: https://github.com/practicalli/clojurescript/blob/main/docs/introduction/repl-workflow.md
This snippet demonstrates how a rich comment block can be used to manage a Clojure service, including starting, stopping, and restarting the application server. It also shows how to access system environment variables and properties, providing a live example of API usage.
```clojure
(ns practicalli.gameboard.service)
(defn app-server-start [port] ,,,)
(defn app-server-start [] ,,,)
(defn app-server-restart [] ,,,)
(defn -main
"Start the service using system components"
[& options] ,,,)
(comment
(-main)
(app-server-start 8888)
(app-server-stop)
(app-server-restart 8888)
(System/getenv "PORT")
(def environment (System/getenv))
(def system-properties (System/getProperties))
) ; End of rich comment block
```
--------------------------------
### Building ClojureScript Project with Clojure CLI
Source: https://github.com/practicalli/clojurescript/blob/main/docs/web-design-basics/clojurebridge-london-website/run-the-project.md
This command initiates the build process for the ClojureScript project using the Clojure CLI tool. It leverages the `:fig:build` alias to start Figwheel Main, which compiles the ClojureScript code and serves the application, typically opening it in a web browser.
```bash
clojure -M:fig:build
```
--------------------------------
### Configuring ClojureScript Deployment Output
Source: https://github.com/practicalli/clojurescript/blob/main/docs/web-design-basics/clojurebridge-london-website/deploy-build.md
This snippet shows the `deploy.cljs.edn` configuration for a ClojureScript build. It specifies the main entry point and directs the compiled JavaScript output to the `docs/cljs-out/dev-main.js` file, which is suitable for GitHub Pages deployment. Dependencies include `clojurebridge-landing-page.core` as the main namespace.
```Clojure
^{:watch-dirs ["test" "src"]
:css-dirs ["resources/public/css"]
:auto-testing true}
{:main clojurebridge-landing-page.core
:output-to "docs/cljs-out/dev-main.js"}
```
--------------------------------
### Starting ClojureScript Auto-Building via Shell
Source: https://github.com/practicalli/clojurescript/blob/main/docs/quickstart/auto-building.md
This shell command executes the `watch.clj` script using `java -cp` to include the ClojureScript JAR and source directory in the classpath. It initiates the auto-building process, allowing the ClojureScript compiler to watch for changes and recompile automatically.
```Shell
java -cp cljs.jar:src clojure.main watch.clj
```
--------------------------------
### Installing Lumo via Homebrew (Shell)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/install/lumo.md
This command installs the Lumo ClojureScript environment on macOS using Homebrew. It provides a convenient way to manage Lumo installations on macOS systems.
```Shell
brew install lumo
```
--------------------------------
### Creating a New Clojure Project with Leiningen (Bash)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/create-a-project/index.md
This command initializes a new Clojure project named `todo-list` using Leiningen, a build automation tool. It sets up the basic directory structure and configuration files required for a Clojure application, including a simple web server setup.
```bash
lein new todo-list
```
--------------------------------
### Building Lumo from Source with Boot (Shell)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/install/lumo.md
This command initiates the build process for Lumo from its source code using Boot. It compiles the ClojureScript project and generates the executable binary, which can be found in the `build/lumo` directory.
```Shell
boot release
```
--------------------------------
### Accessing Vector Elements with Sequence Functions - Clojure
Source: https://github.com/practicalli/clojurescript/blob/main/docs/clojure-syntax/persistent-data-structures-vectors.md
Shows how to use common sequence functions (`first`, `rest`, `last`) to extract elements from a vector, treating it as a sequence. `first` gets the initial element, `rest` gets all but the first, and `last` gets the final element.
```Clojure
(first portfolio)
(rest portfolio)
(last portfolio)
```
--------------------------------
### Implementing Setup and Teardown for Reloadable ClojureScript
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel/re-loadable-code.md
This robust solution for non-React applications defines explicit `setup` and `teardown` functions to manage side effects like event listeners. A `fig-reload-hook` is then defined to call `teardown` before `setup` on each reload, ensuring that listeners are properly removed and re-added, allowing for live-reloading of the event handler logic itself.
```ClojureScript
(defn setup []
(.on ($ "div#app") "click" "a.button" (fn [e] (print "clicked button"))))
(defn teardown []
(.off ($ "div#app") "click" "a.button"))
;; define a reload hook in the
(defn fig-reload-hook []
(teardown)
(setup))
```
--------------------------------
### Creating Basic HTML Page for ClojureScript Output
Source: https://github.com/practicalli/clojurescript/blob/main/docs/quickstart/create-a-web-page.md
This HTML snippet defines a minimal web page (`index.html`) that includes a script tag to load the compiled ClojureScript output file, `out/main.js`. It serves as the entry point for a ClojureScript application in a web browser.
```HTML
```
--------------------------------
### Adding 'Start New Game' Button to Tic-Tac-Toe Component in Clojure
Source: https://github.com/practicalli/clojurescript/blob/main/docs/reagent-projects/tic-tac-toe/button--start-a-new-game.md
This snippet demonstrates how to integrate a 'Start a new game' button into a ClojureScript `tictactoe-game` component. The button's `on-click` handler uses `swap!` to update the `app-state`, specifically resetting the `:board` key with a new empty game board generated by `(game-board board-dimension)`. This allows players to easily restart the game.
```Clojure
(defn tictactoe-game []
[:div
[:div
[:h1 (:text @app-state)]
[:p "Do you want to play a game?"]]
[:button {:on-click (fn new-game-click [e]
(swap! app-state assoc :board (game-board board-dimension)))}
"Start a new game"]
[:center
[:svg {:view-box "0 0 3 3"
:width 500
:height 500}
(for [x-cell (range (count (:board @app-state)))
y-cell (range (count (:board @app-state)))]
(case (get-in @app-state [:board y-cell x-cell])
:empty [cell-empty x-cell y-cell]
:cross [cell-cross x-cell y-cell]
:nought [cell-nought x-cell y-cell]))]]])
```
--------------------------------
### Setting up HTML Host File for ClojureScript Applications
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel/client-side-config.md
This HTML snippet demonstrates how to create a basic `index.html` file to serve a ClojureScript application. It includes a `div` element for the main application content and a script tag to load the compiled ClojureScript output, typically `js/example.js`.
```html
```
--------------------------------
### Starting Figwheel Server (Default Build)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel/configure-build.md
This shell command initiates the Figwheel development server. When executed without a specific build ID, it automatically selects the first `:cljsbuild` configuration that has `:optimizations` set to `:none` or `nil`, enabling hot-reloading and serving the application.
```Bash
$ lein figwheel
```
--------------------------------
### Starting Figwheel Autobuilder (ClojureScript)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel/repl-control.md
This function initiates the Figwheel autobuilder. If no 'id' is provided, it uses the current implicit build IDs. Providing an 'id' will start the autobuilder for that specific build and update the implicit build ID set.
```ClojureScript
(start-autobuild [id ...])
```
--------------------------------
### Organizing System Functions - ClojureScript
Source: https://github.com/practicalli/clojurescript/blob/main/docs/web-design-basics/clojurebridge-london-website/organising-the-code.md
This snippet introduces a 'System' section to logically group core application setup functions. It includes `get-app-element` for retrieving the target DOM element by ID 'app' and the `mount` function, which renders the `landing-page` component into a provided element, centralizing and clarifying system-level operations.
```ClojureScript
;; ------------------------------------------
;; System
(defn get-app-element []
(gdom/getElement "app"))
(defn mount [el]
(reagent/render-component [landing-page] el))
```
--------------------------------
### Accessing Top-Level Map Values with `get` in Clojure
Source: https://github.com/practicalli/clojurescript/blob/main/docs/clojure-syntax/persistent-data-structures-maps.md
This snippet demonstrates using the `get` function to retrieve the value associated with a top-level key (`:luke`) from the `starwars-characters` map. It returns the entire nested map for that character.
```Clojure
(get starwars-characters :luke)
```
--------------------------------
### Creating Clojure CLI Project with Figwheel-main and Reagent
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-main-projects/reagent.md
This command initializes a new ClojureScript project using the Clojure CLI tools. It leverages the `figwheel-main` template and includes the `reagent` library for reactive web development, setting up a Single Page Application (SPA) structure.
```shell
clojure -X:project/new :template figwheel-main :name practicalli/landing-page :args '["--reagent"]'
```
--------------------------------
### Final HTML for Bootstrapping ClojureScript Application (HTML)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/quickstart/google-clojure.md
Shows the complete HTML setup, including loading `goog/base.js` and `main.js`, and crucially, using `goog.require` to explicitly load the application's main ClojureScript namespace (`hello_world.core`). This step initiates the execution of the ClojureScript application logic.
```HTML
```
--------------------------------
### Running Figwheel with Build Alias (Shell)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-workflow/build-project.md
Executes Figwheel using the `:build` alias, which automatically compiles ClojureScript code and starts a development server with live reloading. This is the primary command for starting a ClojureScript development environment.
```shell
clojure -M:fig:build
```
--------------------------------
### Defining ClojureScript Namespace and Om Libraries
Source: https://github.com/practicalli/clojurescript/blob/main/docs/om-project-clojurex/create-project.md
This ClojureScript snippet from `core.cljs` defines the `om-clojurex.core` namespace and requires the `om.core` and `om.dom` libraries. These libraries are aliased as `om` and `dom` respectively, and `include-macros true` ensures that their macros are available for use in the current namespace.
```ClojureScript
(ns om-clojurex.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]))
```
--------------------------------
### Accessing Application State with `get` in Hiccup
Source: https://github.com/practicalli/clojurescript/blob/main/docs/web-design-basics/clojurebridge-london-website/hiccup-for-html.md
This snippet illustrates how to access a value from the `app-state` atom within a Hiccup vector using the `get` function. It retrieves the value associated with the `:text` key from the de-referenced atom to render dynamic content.
```clojure
[:h1 (get @app-state :text)]
```
--------------------------------
### Creating a Clojure CLI Figwheel-main Project with Reagent
Source: https://github.com/practicalli/clojurescript/blob/main/docs/install/clojurescript-project.md
This command uses the Clojure CLI tools with the `:project/new` alias to generate a new ClojureScript project. It leverages the `figwheel-main` template and includes the `--reagent` option to add the Reagent library for reactive web development, creating a project directory named `practicalli/landing-page`.
```Shell
clojure -X:project/new :template figwheel-main :name practicalli/landing-page -- --reagent
```
--------------------------------
### Clojure Function with Starting Line Numbers
Source: https://github.com/practicalli/clojurescript/blob/main/docs/introduction/writing-tips.md
This snippet shows how to display line numbers in a code block, starting from a specified value (e.g., 42) using the `linenums` attribute. This feature is useful for referencing specific lines of code in discussions or explanations.
```clojure
(defn my-function
"With a lovely doc-string"
[arguments]
(map inc [1 2 3]))
```
--------------------------------
### Cloning Github Repository - Git
Source: https://github.com/practicalli/clojurescript/blob/main/work-in-progress.md
This command clones the specified Github repository into a new directory named 'clojure-webapps-example'. It's the initial step to obtain the project's source code locally.
```Git
git clone https://github.com/practicalli/clojurescript-example.git
```
--------------------------------
### Installing Source Map Support for Node.js - Shell
Source: https://github.com/practicalli/clojurescript/blob/main/docs/quickstart/nodejs.md
This command installs the `source-map-support` package via npm. This package is essential for enabling source map support in Node.js, which allows for easier debugging of compiled ClojureScript code by mapping back to the original source files.
```Shell
npm install source-map-support
```
--------------------------------
### Configuring Figwheel-main Test Runner (Clojure EDN)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-workflow/run-tests.md
This ClojureScript EDN configuration (`test.cljs.edn`) defines how the Figwheel-main test runner operates. It specifies an alternative URL (`:open-url`) for the test host page to prevent conflicts with the main application and includes a commented-out example for launching tests in a headless browser environment.
```clojure
^{
;; alternative landing page for the tests to avoid launching the application
:open-url "http://[[server-hostname]]:[[server-port]]/test.html"
;; launch tests in a headless environment - update path to chrome on operating system
;; :launch-js ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" "--headless" "--disable-gpu" "--repl" :open-url]
}
{:main practicalli.test-runner}
```
--------------------------------
### Starting ClojureScript Development Build with Clojure CLI
Source: https://github.com/practicalli/clojurescript/blob/main/docs/reagent-projects/tic-tac-toe/create-project.md
This command initiates the development build of the ClojureScript project. It uses the clojure command with the :figwheel alias to start Figwheel-main and the :build alias to run the development configuration, which includes a Rebel Readline REPL for interactive development.
```Shell
clojure -M:figwheel:build
```
--------------------------------
### Complete Clojure Ring Jetty Web Server Application
Source: https://github.com/practicalli/clojurescript/blob/main/docs/create-a-project/add-a-webserver-function.md
This snippet presents the full Clojure code for a simple web server using Ring and Jetty. It combines the namespace declaration with the `-main` function, demonstrating how to set up the server to listen on a specified port and respond to all requests with a fixed 'Hello, Clojure World' HTML message.
```Clojure
(ns todo-list.core
(:require [ring.adapter.jetty :as jetty]))
(defn -main
"A very simple web server using Ring & Jetty"
[port-number]
(jetty/run-jetty
(fn [request] {:status 200
:body "
Hello, Clojure World
Welcome to your first Clojure app. This message is returned regardless of the request, sorry
"
:headers {}})
{:port (Integer. port-number)}))
```
--------------------------------
### Creating ClojureScript Project with Clojure CLI and Reagent
Source: https://github.com/practicalli/clojurescript/blob/main/docs/web-design-basics/clojurebridge-london-website/create-project.md
This shell command initializes a new ClojureScript project using Clojure CLI tools and the `clj-new` alias. It leverages the `figwheel-main` template and includes the `reagent` library, setting up a basic web application for `clojurebridge/landing-page`. Prerequisites include Clojure CLI and `clj-new` configured with a `:project/new` alias.
```shell
clj -M:project/new figwheel-main clojurebridge/landing-page -- --reagent
```
--------------------------------
### Creating a Practicalli Landing Page Project with Figwheel using Clojure CLI
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-workflow/create-project.md
This command utilizes the `clojure` CLI with the `-T` flag and the `:project/create` alias to generate a new project. It specifically uses the `practicalli/landing-page` template to create a working landing page ClojureScript project with figwheel-main, naming the project `practicalli/landing-page`.
```shell
clojure -T:project/create :template practicalli/landing-page :name practicalli/landing-page
```
--------------------------------
### Starting Figwheel Development Server - Leiningen
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel/flappy-birds-demo.md
This command initiates the Figwheel development server using Leiningen, a build automation tool for Clojure projects. It compiles the ClojureScript code and serves the application, enabling live code reloading in the browser as changes are saved. This command must be executed from within the `flappy-bird-demo` directory.
```Shell
lein figwheel
```
--------------------------------
### Understanding List Evaluation as Function Calls (Failing Example) - Clojure
Source: https://github.com/practicalli/clojurescript/blob/main/docs/clojure-syntax/persistent-data-structures-lists.md
Shows an example of a list that fails to evaluate because its first element, `1`, is treated as a function name, and no function with that name exists. This demonstrates Clojure's unique list evaluation rule where the first element is always invoked as a function.
```Clojure
(1 2 3 4) ;; failing expression
```
--------------------------------
### Defining Figwheel Control Functions
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel/scripting-figwheel.md
This Clojure snippet defines helper functions (`start`, `stop`, `repl`) to encapsulate Figwheel's API calls, making it easier to manage the server and REPL. The `start` function configures and launches Figwheel, `stop` halts it (with an expected `RejectedExecutionException`), and `repl` initiates a ClojureScript REPL.
```Clojure
(require
'[figwheel-sidecar.repl-api :as ra])
(defn start []
(ra/start-figwheel!
{:figwheel-options {} ;; <-- figwheel server config goes here
:build-ids ["dev"] ;; <-- a vector of build ids to start autobuilding
:all-builds ;; <-- supply your build configs here
[{:id "dev"
:figwheel true
:source-paths ["src"]
:compiler {:main "example.core"
:asset-path "out"
:output-to "resources/public/main.js"
:output-dir "resources/public/out"
:verbose true}}]}))
;; Please note that when you stop the Figwheel Server http-kit throws
;; a java.util.concurrent.RejectedExecutionException, this is expected
(defn stop []
(ra/stop-figwheel!))
(defn repl []
(ra/cljs-repl))
```
--------------------------------
### Configuring ClojureScript Build for GitHub/GitLab Pages
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-workflow/pages-deploy.md
This Clojure configuration defines a new build profile for ClojureScript, specifying the main namespace and directing the compiled JavaScript output to the 'docs/js/hello-world.js' path, suitable for static site hosting services.
```Clojure
{:main practicalli.hello-world
:output-to "docs/js/hello-world.js"}
```
--------------------------------
### Example HTML Structure for GitHub/GitLab Pages
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-workflow/pages-deploy.md
This HTML snippet provides a basic `index.html` structure for a ClojureScript application deployed to static pages. It includes meta tags, a stylesheet link, a favicon, a root div for the application, and crucially, a script tag referencing the compiled ClojureScript JavaScript file located in 'js/hello-world.js'.
```HTML
```
--------------------------------
### Displaying Lumo Help (Shell)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/install/lumo.md
This command displays the usage instructions and supported command-line options for the Lumo ClojureScript environment. It's useful for understanding available functionalities and arguments.
```Shell
lumo -h
```
--------------------------------
### Creating a ClojureScript Project with Figwheel-main and Reagent using Clojure CLI
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel-main-projects/index.md
This command uses the Clojure CLI tools with the Practicalli configuration to generate a new ClojureScript project. It leverages the `figwheel-main` template to set up a project named `practicalli/landing-page`, specifically including the `--reagent` option to integrate the Reagent library for UI development. This command is executed in a terminal.
```shell
clojure -T:project/new :template figwheel-main :name practicalli/landing-page :args '["--reagent"]'
```
--------------------------------
### Pushing Initial Deployment to GitHub (Shell)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/web-design-basics/clojurebridge-london-website/github-pages-deploy.md
This command pushes the committed changes from the local `master` branch to the `origin` remote repository on GitHub. This action deploys the content in the `/docs` directory to GitHub Pages.
```shell
git push origin master
```
--------------------------------
### Composing Figwheel and Jetty Server with Component (Clojure)
Source: https://github.com/practicalli/clojurescript/blob/main/docs/figwheel/scripting-with-component.md
This snippet defines a Clojure system using Stuart Sierra's Component library to integrate a Figwheel development server and a Jetty HTTP server. It includes configuration for Figwheel builds, a `Figwheel` record implementing `component/Lifecycle` for starting and stopping Figwheel, a simple Ring handler, and functions to manage the overall system (start, stop, reload, repl). Dependencies include `figwheel-sidecar.repl-api`, `com.stuartsierra.component`, and `ring.component.jetty`.
```Clojure
(require
'[figwheel-sidecar.repl-api :as ra]
'[com.stuartsierra.component :as component]
'[ring.component.jetty :refer [jetty-server]])
(def figwheel-config
{:figwheel-options {} ;; <-- figwheel server config goes here
:build-ids ["dev"] ;; <-- a vector of build ids to start autobuilding
:all-builds ;; <-- supply your build configs here
[{:id "dev"
:figwheel true
:source-paths ["src/main"]
:compiler {:main "example.core"
:asset-path "/out"
:output-to "resources/public/main.js"
:output-dir "resources/public/out"
:verbose true}}]})
(defrecord Figwheel []
component/Lifecycle
(start [config]
(ra/start-figwheel! config)
config)
(stop [config]
;; you may want to restart other components but not Figwheel
;; consider commenting out this next line if that is the case
(ra/stop-figwheel!)
config))
(defn handler [request]
{:status 200
:headers {"Content-Type" "text/plain"}
:body "Hello World"})
(def system
(atom
(component/system-map
:app-server (jetty-server {:app {:handler handler}, :port 3000})
:figwheel (map->Figwheel figwheel-config))))
(defn start []
(swap! system component/start))
(defn stop []
(swap! system component/stop))
(defn reload []
(stop)
(start))
(defn repl []
(ra/cljs-repl))
```
--------------------------------
### Defining a Vector of Keywords - Clojure
Source: https://github.com/practicalli/clojurescript/blob/main/docs/clojure-syntax/persistent-data-structures-vectors.md
Provides an example of defining a vector containing only keywords, useful for enumerating distinct symbolic values.
```Clojure
(def developer-events-vector
[:devoxxuk :devoxxfr :devoxx :hackthetower] )
```