├── guestbook-datomic ├── figwheel_server.log ├── env │ ├── dev │ │ ├── resources │ │ │ └── config.edn │ │ ├── clj │ │ │ ├── guestbook_datomic │ │ │ │ ├── figwheel.clj │ │ │ │ ├── dev_middleware.clj │ │ │ │ └── env.clj │ │ │ └── user.clj │ │ └── cljs │ │ │ └── guestbook_datomic │ │ │ └── app.cljs │ ├── test │ │ └── resources │ │ │ └── config.edn │ └── prod │ │ ├── resources │ │ ├── config.edn │ │ └── logback.xml │ │ ├── cljs │ │ └── guestbook_datomic │ │ │ └── app.cljs │ │ └── clj │ │ └── guestbook_datomic │ │ └── env.clj ├── Procfile ├── resources │ └── public │ │ ├── favicon.ico │ │ └── img │ │ └── warning_clojure.png ├── .gitignore ├── Dockerfile ├── test │ ├── cljs │ │ └── guestbook_datomic │ │ │ ├── doo_runner.cljs │ │ │ └── core_test.cljs │ └── clj │ │ └── guestbook_datomic │ │ └── test │ │ └── handler.clj ├── src │ ├── clj │ │ └── guestbook_datomic │ │ │ ├── config.clj │ │ │ ├── handler.clj │ │ │ ├── routes │ │ │ └── home.clj │ │ │ ├── layout.clj │ │ │ └── core.clj │ ├── cljc │ │ └── guestbook_datomic │ │ │ └── validation.cljc │ └── cljs │ │ └── guestbook_datomic │ │ └── ajax.cljs ├── README.md ├── test-config.edn ├── dev-config.edn └── Capstanfile ├── guestbook-cljs ├── resources │ ├── public │ │ ├── favicon.ico │ │ └── css │ │ │ └── screen.css │ ├── migrations │ │ ├── 20150719215253-guestbook.down.sql │ │ └── 20150719215253-guestbook.up.sql │ ├── sql │ │ └── queries.sql │ ├── templates │ │ ├── about.html │ │ └── home.html │ └── docs │ │ └── docs.md ├── env │ ├── prod │ │ ├── resources │ │ │ ├── config.edn │ │ │ └── log4j.properties │ │ └── clj │ │ │ └── guestbook │ │ │ └── env.clj │ ├── dev │ │ ├── resources │ │ │ ├── config.edn │ │ │ └── log4j.properties │ │ └── clj │ │ │ ├── user.clj │ │ │ └── guestbook │ │ │ ├── dev_middleware.clj │ │ │ └── env.clj │ └── test │ │ └── resources │ │ └── config.edn ├── Procfile ├── .gitignore ├── dev-config.edn ├── test-config.edn ├── src │ └── clj │ │ └── guestbook │ │ ├── config.clj │ │ ├── db │ │ └── core.clj │ │ ├── handler.clj │ │ └── routes │ │ └── home.clj └── test │ └── clj │ └── guestbook │ └── test │ ├── handler.clj │ └── db │ └── core.clj ├── guestbook ├── env │ ├── dev │ │ ├── resources │ │ │ └── config.edn │ │ └── clj │ │ │ └── guestbook │ │ │ ├── dev_middleware.clj │ │ │ └── env.clj │ ├── test │ │ └── resources │ │ │ └── config.edn │ └── prod │ │ ├── resources │ │ └── config.edn │ │ └── clj │ │ └── guestbook │ │ └── env.clj ├── resources │ ├── migrations │ │ ├── 20190317085139-add-users-table.down.sql │ │ └── 20190317085139-add-users-table.up.sql │ ├── public │ │ ├── favicon.ico │ │ ├── img │ │ │ └── warning_clojure.png │ │ └── css │ │ │ └── screen.css │ ├── html │ │ ├── about.html │ │ ├── home.html │ │ └── error.html │ └── sql │ │ └── queries.sql ├── Procfile ├── Dockerfile ├── .gitignore ├── test-config.edn ├── src │ └── clj │ │ └── guestbook │ │ ├── config.clj │ │ ├── middleware │ │ └── formats.clj │ │ ├── nrepl.clj │ │ ├── db │ │ └── core.clj │ │ ├── handler.clj │ │ ├── layout.clj │ │ └── routes │ │ └── home.clj ├── README.md ├── dev-config.edn ├── Capstanfile └── test │ └── clj │ └── guestbook │ └── test │ ├── handler.clj │ └── db │ └── core.clj ├── reporting-example ├── resources │ ├── public │ │ ├── favicon.ico │ │ └── css │ │ │ └── screen.css │ ├── migrations │ │ ├── 201504171229-add-users-table.down.sql │ │ └── 201504171229-add-users-table.up.sql │ ├── sql │ │ └── queries.sql │ ├── templates │ │ ├── about.html │ │ └── home.html │ └── docs │ │ └── docs.md ├── env │ ├── prod │ │ ├── resources │ │ │ ├── config.edn │ │ │ └── log4j.properties │ │ └── clj │ │ │ └── reporting_example │ │ │ └── config.clj │ └── dev │ │ ├── clj │ │ ├── reporting_example │ │ │ ├── dev_middleware.clj │ │ │ └── config.clj │ │ └── user.clj │ │ └── resources │ │ └── log4j.properties ├── Procfile ├── .gitignore ├── test │ └── clj │ │ └── reporting_example │ │ └── test │ │ ├── handler.clj │ │ └── db │ │ └── core.clj └── src │ └── clj │ └── reporting_example │ ├── db │ └── migrations.clj │ └── reports.clj ├── swagger-service ├── resources │ ├── public │ │ ├── favicon.ico │ │ └── css │ │ │ └── screen.css │ ├── docs │ │ └── docs.md │ └── templates │ │ └── home.html ├── env │ ├── prod │ │ ├── resources │ │ │ ├── config.edn │ │ │ └── log4j.properties │ │ ├── cljs │ │ │ └── swagger_service │ │ │ │ └── prod.cljs │ │ └── clj │ │ │ └── swagger_service │ │ │ └── config.clj │ └── dev │ │ ├── cljs │ │ └── swagger-service │ │ │ └── app.cljs │ │ ├── clj │ │ ├── swagger_service │ │ │ ├── dev_middleware.clj │ │ │ └── config.clj │ │ └── user.clj │ │ └── resources │ │ └── log4j.properties ├── Procfile ├── .gitignore ├── test │ ├── cljs │ │ └── swagger_service │ │ │ ├── doo_runner.cljs │ │ │ └── core_test.cljs │ └── clj │ │ └── swagger_service │ │ └── test │ │ └── handler.clj └── src │ ├── clj │ └── swagger_service │ │ ├── routes │ │ └── home.clj │ │ └── core.clj │ └── cljs │ └── swagger_service │ └── ajax.cljs ├── guestbook-sente ├── env │ ├── dev │ │ ├── resources │ │ │ └── config.edn │ │ ├── clj │ │ │ ├── guestbook │ │ │ │ ├── figwheel.clj │ │ │ │ ├── dev_middleware.clj │ │ │ │ └── env.clj │ │ │ └── user.clj │ │ └── cljs │ │ │ └── guestbook │ │ │ └── app.cljs │ ├── test │ │ └── resources │ │ │ └── config.edn │ └── prod │ │ ├── resources │ │ ├── config.edn │ │ └── logback.xml │ │ ├── cljs │ │ └── guestbook │ │ │ └── app.cljs │ │ └── clj │ │ └── guestbook │ │ └── env.clj ├── Procfile ├── resources │ ├── migrations │ │ ├── 20190317085139-add-users-table.down.sql │ │ └── 20190317085139-add-users-table.up.sql │ ├── public │ │ ├── favicon.ico │ │ ├── img │ │ │ └── warning_clojure.png │ │ └── css │ │ │ └── screen.css │ ├── sql │ │ └── queries.sql │ └── html │ │ ├── error.html │ │ └── home.html ├── src │ ├── cljc │ │ └── guestbook │ │ │ └── validation.cljc │ ├── clj │ │ └── guestbook │ │ │ ├── config.clj │ │ │ ├── middleware │ │ │ └── formats.clj │ │ │ ├── routes │ │ │ └── home.clj │ │ │ ├── nrepl.clj │ │ │ ├── db │ │ │ └── core.clj │ │ │ ├── handler.clj │ │ │ └── layout.clj │ └── cljs │ │ └── guestbook │ │ ├── ajax.cljs │ │ └── ws.cljs ├── test │ ├── cljs │ │ └── guestbook │ │ │ ├── doo_runner.cljs │ │ │ └── core_test.cljs │ └── clj │ │ └── guestbook │ │ └── test │ │ ├── handler.clj │ │ └── db │ │ └── core.clj ├── .gitignore ├── test-config.edn ├── README.md └── dev-config.edn ├── multi-client-ws-aleph ├── env │ ├── dev │ │ ├── resources │ │ │ └── config.edn │ │ ├── clj │ │ │ ├── multi_client_ws_aleph │ │ │ │ ├── figwheel.clj │ │ │ │ ├── dev_middleware.clj │ │ │ │ └── env.clj │ │ │ └── user.clj │ │ └── cljs │ │ │ └── multi_client_ws_aleph │ │ │ └── app.cljs │ ├── test │ │ └── resources │ │ │ └── config.edn │ └── prod │ │ ├── resources │ │ ├── config.edn │ │ └── logback.xml │ │ ├── cljs │ │ └── multi_client_ws_aleph │ │ │ └── app.cljs │ │ └── clj │ │ └── multi_client_ws_aleph │ │ └── env.clj ├── src │ ├── cljc │ │ └── multi_client_ws_aleph │ │ │ └── validation.cljc │ ├── clj │ │ └── multi_client_ws_aleph │ │ │ ├── config.clj │ │ │ ├── middleware │ │ │ └── formats.clj │ │ │ ├── nrepl.clj │ │ │ ├── routes │ │ │ └── home.clj │ │ │ ├── handler.clj │ │ │ └── layout.clj │ └── cljs │ │ └── multi_client_ws_aleph │ │ ├── websockets.cljs │ │ └── core.cljs ├── resources │ ├── public │ │ ├── favicon.ico │ │ ├── img │ │ │ └── warning_clojure.png │ │ └── css │ │ │ └── screen.css │ └── html │ │ └── error.html ├── test-config.edn ├── test │ ├── cljs │ │ └── multi_client_ws_aleph │ │ │ ├── doo_runner.cljs │ │ │ └── core_test.cljs │ └── clj │ │ └── multi_client_ws_aleph │ │ └── test │ │ └── handler.clj ├── dev-config.edn └── README.md ├── README.md ├── multi-client-ws-http-kit ├── env │ ├── dev │ │ ├── resources │ │ │ ├── config.edn │ │ │ └── logback.xml │ │ ├── clj │ │ │ ├── multi_client_ws_http_kit │ │ │ │ ├── figwheel.clj │ │ │ │ ├── dev_middleware.clj │ │ │ │ └── env.clj │ │ │ └── user.clj │ │ └── cljs │ │ │ └── multi_client_ws_http_kit │ │ │ └── app.cljs │ ├── test │ │ └── resources │ │ │ └── config.edn │ └── prod │ │ ├── resources │ │ ├── config.edn │ │ └── logback.xml │ │ ├── cljs │ │ └── multi_client_ws_http_kit │ │ │ └── app.cljs │ │ └── clj │ │ └── multi_client_ws_http_kit │ │ └── env.clj ├── Procfile ├── src │ ├── cljc │ │ └── multi_client_ws_http_kit │ │ │ └── validation.cljc │ ├── clj │ │ └── multi_client_ws_http_kit │ │ │ ├── config.clj │ │ │ ├── middleware │ │ │ └── formats.clj │ │ │ ├── nrepl.clj │ │ │ ├── routes │ │ │ └── home.clj │ │ │ ├── handler.clj │ │ │ └── layout.clj │ └── cljs │ │ └── multi_client_ws_http_kit │ │ ├── websockets.cljs │ │ └── core.cljs ├── resources │ ├── public │ │ ├── favicon.ico │ │ ├── img │ │ │ └── warning_clojure.png │ │ └── css │ │ │ └── screen.css │ └── html │ │ └── error.html ├── .gitignore ├── Dockerfile ├── test-config.edn ├── test │ ├── cljs │ │ └── multi_client_ws_http_kit │ │ │ ├── doo_runner.cljs │ │ │ └── core_test.cljs │ └── clj │ │ └── multi_client_ws_http_kit │ │ └── test │ │ └── handler.clj ├── dev-config.edn ├── README.md └── LICENSE ├── multi-client-ws-immutant ├── env │ ├── dev │ │ ├── resources │ │ │ └── config.edn │ │ ├── clj │ │ │ ├── multi_client_ws_immutant │ │ │ │ ├── figwheel.clj │ │ │ │ ├── dev_middleware.clj │ │ │ │ └── env.clj │ │ │ └── user.clj │ │ └── cljs │ │ │ └── multi_client_ws_immutant │ │ │ └── app.cljs │ ├── test │ │ └── resources │ │ │ └── config.edn │ └── prod │ │ ├── resources │ │ ├── config.edn │ │ └── logback.xml │ │ ├── cljs │ │ └── multi_client_ws_immutant │ │ │ └── app.cljs │ │ └── clj │ │ └── multi_client_ws_immutant │ │ └── env.clj ├── src │ ├── cljc │ │ └── multi_client_ws_immutant │ │ │ └── validation.cljc │ ├── clj │ │ └── multi_client_ws_immutant │ │ │ ├── config.clj │ │ │ ├── middleware │ │ │ └── formats.clj │ │ │ ├── nrepl.clj │ │ │ ├── routes │ │ │ └── home.clj │ │ │ ├── handler.clj │ │ │ └── layout.clj │ └── cljs │ │ └── multi_client_ws_immutant │ │ ├── websockets.cljs │ │ └── core.cljs ├── resources │ ├── public │ │ ├── favicon.ico │ │ ├── img │ │ │ └── warning_clojure.png │ │ └── css │ │ │ └── screen.css │ └── html │ │ └── error.html ├── .gitignore ├── Dockerfile ├── test-config.edn ├── test │ ├── cljs │ │ └── multi_client_ws_immutant │ │ │ ├── doo_runner.cljs │ │ │ └── core_test.cljs │ └── clj │ │ └── multi_client_ws_immutant │ │ └── test │ │ └── handler.clj ├── dev-config.edn └── README.md └── file-upload-progress ├── env ├── prod │ ├── resources │ │ ├── config.edn │ │ └── logback.xml │ └── clj │ │ └── file_upload_progress │ │ └── env.clj ├── dev │ ├── resources │ │ └── config.edn │ └── clj │ │ ├── user.clj │ │ └── file_upload_progress │ │ ├── dev_middleware.clj │ │ └── env.clj └── test │ └── resources │ └── config.edn ├── Procfile ├── resources ├── public │ ├── favicon.ico │ ├── img │ │ └── warning_clojure.png │ ├── css │ │ └── screen.css │ └── js │ │ └── upload.js └── templates │ ├── about.html │ └── home.html ├── .gitignore ├── Dockerfile ├── README.md ├── src └── clj │ └── file_upload_progress │ ├── config.clj │ ├── routes │ └── home.clj │ ├── handler.clj │ └── layout.clj ├── test └── clj │ └── file_upload_progress │ └── test │ └── handler.clj └── Capstanfile /guestbook-datomic/figwheel_server.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /guestbook-cljs/resources/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /guestbook/env/dev/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /guestbook/env/test/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /reporting-example/resources/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /swagger-service/resources/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /guestbook-datomic/env/dev/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /guestbook-sente/env/dev/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /guestbook-sente/env/test/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /guestbook-datomic/env/test/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/env/dev/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/env/test/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A repository of example Luminus applications 2 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/dev/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/test/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/env/dev/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/env/test/resources/config.edn: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /swagger-service/env/prod/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:port 3000} 2 | -------------------------------------------------------------------------------- /reporting-example/env/prod/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:port 3000} 2 | -------------------------------------------------------------------------------- /guestbook/env/prod/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:prod true 2 | :port 3000} 3 | -------------------------------------------------------------------------------- /guestbook-sente/env/prod/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:prod true 2 | :port 3000} 3 | -------------------------------------------------------------------------------- /guestbook-cljs/env/prod/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:production true 2 | :port 3000} 3 | -------------------------------------------------------------------------------- /guestbook-datomic/env/prod/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:prod true 2 | :port 3000} 3 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/env/prod/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:prod true 2 | :port 3000} 3 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/prod/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:prod true 2 | :port 3000} 3 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/env/prod/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:prod true 2 | :port 3000} 3 | -------------------------------------------------------------------------------- /file-upload-progress/env/prod/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:production true 2 | :port 3000} 3 | -------------------------------------------------------------------------------- /guestbook/resources/migrations/20190317085139-add-users-table.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE guestbook; -------------------------------------------------------------------------------- /guestbook-cljs/resources/migrations/20150719215253-guestbook.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE guestbook; 2 | -------------------------------------------------------------------------------- /guestbook-cljs/Procfile: -------------------------------------------------------------------------------- 1 | web: java $JVM_OPTS -cp target/guestbook.jar clojure.main -m guestbook.core 2 | -------------------------------------------------------------------------------- /guestbook-sente/Procfile: -------------------------------------------------------------------------------- 1 | web: java -cp target/uberjar/guestbook.jar clojure.main -m guestbook.core 2 | -------------------------------------------------------------------------------- /guestbook-sente/resources/migrations/20190317085139-add-users-table.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE guestbook; 2 | -------------------------------------------------------------------------------- /reporting-example/resources/migrations/201504171229-add-users-table.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE employee; 2 | -------------------------------------------------------------------------------- /guestbook-sente/src/cljc/guestbook/validation.cljc: -------------------------------------------------------------------------------- 1 | (ns guestbook.validation 2 | (:require [struct.core :as st])) 3 | -------------------------------------------------------------------------------- /swagger-service/Procfile: -------------------------------------------------------------------------------- 1 | web: java $JVM_OPTS -cp target/swagger-service.jar clojure.main -m swagger-service.core 2 | -------------------------------------------------------------------------------- /guestbook-datomic/Procfile: -------------------------------------------------------------------------------- 1 | web: java -cp target/uberjar/guestbook-datomic.jar clojure.main -m guestbook-datomic.core 2 | -------------------------------------------------------------------------------- /reporting-example/Procfile: -------------------------------------------------------------------------------- 1 | web: java $JVM_OPTS -cp target/reporting-example.jar clojure.main -m reporting-example.core 2 | -------------------------------------------------------------------------------- /guestbook/Procfile: -------------------------------------------------------------------------------- 1 | web: java -Dclojure.main.report=stderr -cp target/uberjar/guestbook.jar clojure.main -m guestbook.core 2 | -------------------------------------------------------------------------------- /file-upload-progress/Procfile: -------------------------------------------------------------------------------- 1 | web: java -cp target/uberjar/file-upload-progress.jar clojure.main -m file-upload-progress.core 2 | -------------------------------------------------------------------------------- /guestbook/resources/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/guestbook/resources/public/favicon.ico -------------------------------------------------------------------------------- /multi-client-ws-http-kit/Procfile: -------------------------------------------------------------------------------- 1 | web: java -cp target/uberjar/multi-client-ws-http-kit.jar clojure.main -m multi-client-ws-http-kit.core 2 | -------------------------------------------------------------------------------- /reporting-example/resources/sql/queries.sql: -------------------------------------------------------------------------------- 1 | -- :name read-employees :? :* 2 | -- reads the list of employees 3 | select * from employee 4 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/src/cljc/multi_client_ws_aleph/validation.cljc: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.validation 2 | (:require [struct.core :as st])) 3 | -------------------------------------------------------------------------------- /guestbook-sente/resources/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/guestbook-sente/resources/public/favicon.ico -------------------------------------------------------------------------------- /guestbook-datomic/resources/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/guestbook-datomic/resources/public/favicon.ico -------------------------------------------------------------------------------- /guestbook/resources/html/about.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block content %} 3 | 4 | {% endblock %} 5 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/src/cljc/multi_client_ws_http_kit/validation.cljc: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.validation 2 | (:require [struct.core :as st])) 3 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/src/cljc/multi_client_ws_immutant/validation.cljc: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.validation 2 | (:require [struct.core :as st])) 3 | -------------------------------------------------------------------------------- /file-upload-progress/resources/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/file-upload-progress/resources/public/favicon.ico -------------------------------------------------------------------------------- /guestbook/resources/public/img/warning_clojure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/guestbook/resources/public/img/warning_clojure.png -------------------------------------------------------------------------------- /multi-client-ws-aleph/resources/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/multi-client-ws-aleph/resources/public/favicon.ico -------------------------------------------------------------------------------- /multi-client-ws-http-kit/resources/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/multi-client-ws-http-kit/resources/public/favicon.ico -------------------------------------------------------------------------------- /multi-client-ws-immutant/resources/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/multi-client-ws-immutant/resources/public/favicon.ico -------------------------------------------------------------------------------- /guestbook-cljs/env/dev/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:dev true 2 | :port 3000 3 | ;; when :nrepl-port is set the application starts the nREPL server on load 4 | :nrepl-port 7000} 5 | -------------------------------------------------------------------------------- /guestbook-cljs/env/test/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:test true 2 | :port 3001 3 | :nrepl-port 7001} ;; when :nrepl-port is set the application starts the nREPL server on load 4 | -------------------------------------------------------------------------------- /guestbook-datomic/resources/public/img/warning_clojure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/guestbook-datomic/resources/public/img/warning_clojure.png -------------------------------------------------------------------------------- /guestbook-sente/resources/public/img/warning_clojure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/guestbook-sente/resources/public/img/warning_clojure.png -------------------------------------------------------------------------------- /file-upload-progress/env/dev/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:dev true 2 | :port 3000 3 | ;; when :nrepl-port is set the application starts the nREPL server on load 4 | :nrepl-port 7000} 5 | -------------------------------------------------------------------------------- /guestbook/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-alpine 2 | 3 | COPY target/uberjar/guestbook.jar /guestbook/app.jar 4 | 5 | EXPOSE 3000 6 | 7 | CMD ["java", "-jar", "/guestbook/app.jar"] 8 | -------------------------------------------------------------------------------- /file-upload-progress/env/test/resources/config.edn: -------------------------------------------------------------------------------- 1 | {:dev true 2 | :port 3000 3 | ;; when :nrepl-port is set the application starts the nREPL server on load 4 | :nrepl-port 7000} 5 | -------------------------------------------------------------------------------- /file-upload-progress/resources/public/img/warning_clojure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/file-upload-progress/resources/public/img/warning_clojure.png -------------------------------------------------------------------------------- /guestbook-cljs/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | *.jar 7 | *.class 8 | /.lein-* 9 | profiles.clj 10 | /.env 11 | .nrepl-port 12 | /log 13 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/resources/public/img/warning_clojure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/multi-client-ws-aleph/resources/public/img/warning_clojure.png -------------------------------------------------------------------------------- /file-upload-progress/resources/templates/about.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block content %} 3 | 4 | {% endblock %} 5 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/resources/public/img/warning_clojure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/multi-client-ws-http-kit/resources/public/img/warning_clojure.png -------------------------------------------------------------------------------- /multi-client-ws-immutant/resources/public/img/warning_clojure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luminus-framework/examples/HEAD/multi-client-ws-immutant/resources/public/img/warning_clojure.png -------------------------------------------------------------------------------- /reporting-example/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | *.jar 7 | *.class 8 | /.lein-* 9 | profiles.clj 10 | /.env 11 | .nrepl-port 12 | /log 13 | -------------------------------------------------------------------------------- /swagger-service/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | *.jar 7 | *.class 8 | /.lein-* 9 | profiles.clj 10 | /.env 11 | .nrepl-port 12 | /log 13 | -------------------------------------------------------------------------------- /reporting-example/resources/migrations/201504171229-add-users-table.up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE employee 2 | (name VARCHAR(50), 3 | occupation VARCHAR(50), 4 | place VARCHAR(50), 5 | country VARCHAR(50)); 6 | -------------------------------------------------------------------------------- /guestbook-sente/env/prod/cljs/guestbook/app.cljs: -------------------------------------------------------------------------------- 1 | (ns guestbook.app 2 | (:require [guestbook.core :as core])) 3 | 4 | ;;ignore println statements in prod 5 | (set! *print-fn* (fn [& _])) 6 | 7 | (core/init!) 8 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | *.jar 7 | *.class 8 | /.lein-* 9 | profiles.clj 10 | /.env 11 | .nrepl-port 12 | /node_modules 13 | /log 14 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | *.jar 7 | *.class 8 | /.lein-* 9 | profiles.clj 10 | /.env 11 | .nrepl-port 12 | /node_modules 13 | /log 14 | -------------------------------------------------------------------------------- /guestbook-sente/resources/migrations/20190317085139-add-users-table.up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE guestbook 2 | (id INTEGER PRIMARY KEY AUTO_INCREMENT, 3 | name VARCHAR(30), 4 | message VARCHAR(200), 5 | timestamp TIMESTAMP); 6 | -------------------------------------------------------------------------------- /guestbook-sente/test/cljs/guestbook/doo_runner.cljs: -------------------------------------------------------------------------------- 1 | (ns guestbook.doo-runner 2 | (:require [doo.runner :refer-macros [doo-tests]] 3 | [guestbook.core-test])) 4 | 5 | (doo-tests 'guestbook.core-test) 6 | 7 | -------------------------------------------------------------------------------- /guestbook/resources/migrations/20190317085139-add-users-table.up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE guestbook 2 | (id INTEGER PRIMARY KEY AUTO_INCREMENT, 3 | name VARCHAR(30), 4 | message VARCHAR(200), 5 | timestamp TIMESTAMP(7)); 6 | -------------------------------------------------------------------------------- /guestbook-sente/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | dev-config.edn 7 | test-config.edn 8 | *.jar 9 | *.class 10 | /.lein-* 11 | profiles.clj 12 | /.env 13 | .nrepl-port 14 | /log 15 | -------------------------------------------------------------------------------- /file-upload-progress/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | dev-config.edn 7 | test-config.edn 8 | *.jar 9 | *.class 10 | /.lein-* 11 | profiles.clj 12 | /.env 13 | .nrepl-port 14 | /log 15 | -------------------------------------------------------------------------------- /guestbook-datomic/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | dev-config.edn 7 | test-config.edn 8 | *.jar 9 | *.class 10 | /.lein-* 11 | profiles.clj 12 | /.env 13 | .nrepl-port 14 | /log 15 | -------------------------------------------------------------------------------- /guestbook-datomic/env/prod/cljs/guestbook_datomic/app.cljs: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.app 2 | (:require [guestbook-datomic.core :as core])) 3 | 4 | ;;ignore println statements in prod 5 | (set! *print-fn* (fn [& _])) 6 | 7 | (core/init!) 8 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-alpine 2 | 3 | COPY target/uberjar/multi-client-ws-http-kit.jar /multi-client-ws-http-kit/app.jar 4 | 5 | EXPOSE 3000 6 | 7 | CMD ["java", "-jar", "/multi-client-ws-http-kit/app.jar"] 8 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-alpine 2 | 3 | COPY target/uberjar/multi-client-ws-immutant.jar /multi-client-ws-immutant/app.jar 4 | 5 | EXPOSE 3000 6 | 7 | CMD ["java", "-jar", "/multi-client-ws-immutant/app.jar"] 8 | -------------------------------------------------------------------------------- /guestbook/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | dev-config.edn 7 | test-config.edn 8 | *.jar 9 | *.class 10 | /.lein-* 11 | profiles.clj 12 | /.env 13 | .nrepl-port 14 | 15 | /node_modules 16 | /log 17 | -------------------------------------------------------------------------------- /guestbook-datomic/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8-alpine 2 | MAINTAINER Your Name 3 | 4 | ADD target/uberjar/guestbook-datomic.jar /guestbook-datomic/app.jar 5 | 6 | EXPOSE 3000 7 | 8 | CMD ["java", "-jar", "/guestbook-datomic/app.jar"] 9 | -------------------------------------------------------------------------------- /guestbook-datomic/test/cljs/guestbook_datomic/doo_runner.cljs: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.doo-runner 2 | (:require [doo.runner :refer-macros [doo-tests]] 3 | [guestbook-datomic.core-test])) 4 | 5 | (doo-tests 'guestbook-datomic.core-test) 6 | 7 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/env/prod/cljs/multi_client_ws_aleph/app.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.app 2 | (:require [multi-client-ws-aleph.core :as core])) 3 | 4 | ;;ignore println statements in prod 5 | (set! *print-fn* (fn [& _])) 6 | 7 | (core/init!) 8 | -------------------------------------------------------------------------------- /file-upload-progress/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8-alpine 2 | MAINTAINER Your Name 3 | 4 | ADD target/uberjar/file-upload-progress.jar /file-upload-progress/app.jar 5 | 6 | EXPOSE 3000 7 | 8 | CMD ["java", "-jar", "/file-upload-progress/app.jar"] 9 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/prod/cljs/multi_client_ws_http_kit/app.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.app 2 | (:require [multi-client-ws-http-kit.core :as core])) 3 | 4 | ;;ignore println statements in prod 5 | (set! *print-fn* (fn [& _])) 6 | 7 | (core/init!) 8 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/env/prod/cljs/multi_client_ws_immutant/app.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.app 2 | (:require [multi-client-ws-immutant.core :as core])) 3 | 4 | ;;ignore println statements in prod 5 | (set! *print-fn* (fn [& _])) 6 | 7 | (core/init!) 8 | -------------------------------------------------------------------------------- /guestbook-cljs/resources/migrations/20150719215253-guestbook.up.sql: -------------------------------------------------------------------------------- 1 | -- START:guestbook-table 2 | CREATE TABLE guestbook 3 | (id INTEGER PRIMARY KEY AUTO_INCREMENT, 4 | name VARCHAR(30), 5 | message VARCHAR(200), 6 | timestamp TIMESTAMP); 7 | -- END:guestbook-table 8 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/test-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The test-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:port 3000 6 | } 7 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/test/cljs/multi_client_ws_aleph/doo_runner.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.doo-runner 2 | (:require [doo.runner :refer-macros [doo-tests]] 3 | [multi-client-ws-aleph.core-test])) 4 | 5 | (doo-tests 'multi-client-ws-aleph.core-test) 6 | 7 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/test-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The test-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:port 3000 6 | } 7 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/test-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The test-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:port 3000 6 | } 7 | -------------------------------------------------------------------------------- /guestbook-cljs/dev-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The dev-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:database-url "jdbc:h2:./guestbook_dev.db"} 6 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/test/cljs/multi_client_ws_http_kit/doo_runner.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.doo-runner 2 | (:require [doo.runner :refer-macros [doo-tests]] 3 | [multi-client-ws-http-kit.core-test])) 4 | 5 | (doo-tests 'multi-client-ws-http-kit.core-test) 6 | 7 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/test/cljs/multi_client_ws_immutant/doo_runner.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.doo-runner 2 | (:require [doo.runner :refer-macros [doo-tests]] 3 | [multi-client-ws-immutant.core-test])) 4 | 5 | (doo-tests 'multi-client-ws-immutant.core-test) 6 | 7 | -------------------------------------------------------------------------------- /swagger-service/env/dev/cljs/swagger-service/app.cljs: -------------------------------------------------------------------------------- 1 | (ns ^:figwheel-no-load swagger-service.app 2 | (:require [swagger-service.core :as core] 3 | [devtools.core :as devtools])) 4 | 5 | (enable-console-print!) 6 | 7 | (devtools/install!) 8 | 9 | (core/init!) 10 | -------------------------------------------------------------------------------- /guestbook-cljs/test-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The test-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:database-url "jdbc:h2:./guestbook_test.db"} 6 | -------------------------------------------------------------------------------- /guestbook-sente/env/dev/clj/guestbook/figwheel.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.figwheel 2 | (:require [figwheel-sidecar.repl-api :as ra])) 3 | 4 | (defn start-fw [] 5 | (ra/start-figwheel!)) 6 | 7 | (defn stop-fw [] 8 | (ra/stop-figwheel!)) 9 | 10 | (defn cljs [] 11 | (ra/cljs-repl)) 12 | 13 | -------------------------------------------------------------------------------- /guestbook/test-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The test-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:port 3000 6 | :database-url "jdbc:h2:./guestbook_test.db"} 7 | -------------------------------------------------------------------------------- /guestbook-cljs/resources/sql/queries.sql: -------------------------------------------------------------------------------- 1 | -- :name save-message! :! :n 2 | -- creates a new message 3 | INSERT INTO guestbook 4 | (name, message, timestamp) 5 | VALUES (:name, :message, :timestamp) 6 | 7 | -- :name get-messages :? :* 8 | -- selects all available messages 9 | SELECT * from guestbook 10 | -------------------------------------------------------------------------------- /guestbook-sente/test-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The test-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:port 3000 6 | :database-url "jdbc:h2:./guestbook_test.db"} 7 | -------------------------------------------------------------------------------- /guestbook-datomic/env/dev/clj/guestbook_datomic/figwheel.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.figwheel 2 | (:require [figwheel-sidecar.repl-api :as ra])) 3 | 4 | (defn start-fw [] 5 | (ra/start-figwheel!)) 6 | 7 | (defn stop-fw [] 8 | (ra/stop-figwheel!)) 9 | 10 | (defn cljs [] 11 | (ra/cljs-repl)) 12 | 13 | -------------------------------------------------------------------------------- /guestbook-sente/resources/sql/queries.sql: -------------------------------------------------------------------------------- 1 | -- :name save-message! :! :n 2 | -- :doc creates a new message 3 | INSERT INTO guestbook 4 | (name, message, timestamp) 5 | VALUES (:name, :message, :timestamp) 6 | 7 | -- :name get-messages :? :* 8 | -- :doc selects all available messages 9 | SELECT * FROM guestbook 10 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/env/dev/clj/multi_client_ws_aleph/figwheel.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.figwheel 2 | (:require [figwheel-sidecar.repl-api :as ra])) 3 | 4 | (defn start-fw [] 5 | (ra/start-figwheel!)) 6 | 7 | (defn stop-fw [] 8 | (ra/stop-figwheel!)) 9 | 10 | (defn cljs [] 11 | (ra/cljs-repl)) 12 | 13 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/dev/clj/multi_client_ws_http_kit/figwheel.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.figwheel 2 | (:require [figwheel-sidecar.repl-api :as ra])) 3 | 4 | (defn start-fw [] 5 | (ra/start-figwheel!)) 6 | 7 | (defn stop-fw [] 8 | (ra/stop-figwheel!)) 9 | 10 | (defn cljs [] 11 | (ra/cljs-repl)) 12 | 13 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/env/dev/clj/multi_client_ws_immutant/figwheel.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.figwheel 2 | (:require [figwheel-sidecar.repl-api :as ra])) 3 | 4 | (defn start-fw [] 5 | (ra/start-figwheel!)) 6 | 7 | (defn stop-fw [] 8 | (ra/stop-figwheel!)) 9 | 10 | (defn cljs [] 11 | (ra/cljs-repl)) 12 | 13 | -------------------------------------------------------------------------------- /guestbook/env/prod/clj/guestbook/env.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.env 2 | (:require [clojure.tools.logging :as log])) 3 | 4 | (def defaults 5 | {:init 6 | (fn [] 7 | (log/info "\n-=[guestbook started successfully]=-")) 8 | :stop 9 | (fn [] 10 | (log/info "\n-=[guestbook has shut down successfully]=-")) 11 | :middleware identity}) 12 | -------------------------------------------------------------------------------- /guestbook-sente/env/prod/clj/guestbook/env.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.env 2 | (:require [clojure.tools.logging :as log])) 3 | 4 | (def defaults 5 | {:init 6 | (fn [] 7 | (log/info "\n-=[guestbook started successfully]=-")) 8 | :stop 9 | (fn [] 10 | (log/info "\n-=[guestbook has shut down successfully]=-")) 11 | :middleware identity}) 12 | -------------------------------------------------------------------------------- /guestbook/src/clj/guestbook/config.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.config 2 | (:require 3 | [cprop.core :refer [load-config]] 4 | [cprop.source :as source] 5 | [mount.core :refer [args defstate]])) 6 | 7 | (defstate env 8 | :start 9 | (load-config 10 | :merge 11 | [(args) 12 | (source/from-system-props) 13 | (source/from-env)])) 14 | -------------------------------------------------------------------------------- /guestbook-sente/test/cljs/guestbook/core_test.cljs: -------------------------------------------------------------------------------- 1 | (ns guestbook.core-test 2 | (:require [cljs.test :refer-macros [is are deftest testing use-fixtures]] 3 | [pjstadig.humane-test-output] 4 | [reagent.core :as reagent :refer [atom]] 5 | [guestbook.core :as rc])) 6 | 7 | (deftest test-home 8 | (is (= true true))) 9 | 10 | -------------------------------------------------------------------------------- /guestbook-sente/src/clj/guestbook/config.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.config 2 | (:require [cprop.core :refer [load-config]] 3 | [cprop.source :as source] 4 | [mount.core :refer [args defstate]])) 5 | 6 | (defstate env 7 | :start 8 | (load-config 9 | :merge 10 | [(args) 11 | (source/from-system-props) 12 | (source/from-env)])) 13 | -------------------------------------------------------------------------------- /guestbook-datomic/src/clj/guestbook_datomic/config.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.config 2 | (:require [cprop.core :refer [load-config]] 3 | [cprop.source :as source] 4 | [mount.core :refer [args defstate]])) 5 | 6 | (defstate env 7 | :start 8 | (load-config 9 | :merge 10 | [(args) 11 | (source/from-system-props) 12 | (source/from-env)])) 13 | -------------------------------------------------------------------------------- /guestbook-datomic/test/cljs/guestbook_datomic/core_test.cljs: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.core-test 2 | (:require [cljs.test :refer-macros [is are deftest testing use-fixtures]] 3 | [pjstadig.humane-test-output] 4 | [reagent.core :as reagent :refer [atom]] 5 | [guestbook-datomic.core :as rc])) 6 | 7 | (deftest test-home 8 | (is (= true true))) 9 | 10 | -------------------------------------------------------------------------------- /guestbook-datomic/env/prod/clj/guestbook_datomic/env.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.env 2 | (:require [clojure.tools.logging :as log])) 3 | 4 | (def defaults 5 | {:init 6 | (fn [] 7 | (log/info "\n-=[guestbook-datomic started successfully]=-")) 8 | :stop 9 | (fn [] 10 | (log/info "\n-=[guestbook-datomic has shut down successfully]=-")) 11 | :middleware identity}) 12 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/src/clj/multi_client_ws_aleph/config.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.config 2 | (:require 3 | [cprop.core :refer [load-config]] 4 | [cprop.source :as source] 5 | [mount.core :refer [args defstate]])) 6 | 7 | (defstate env 8 | :start 9 | (load-config 10 | :merge 11 | [(args) 12 | (source/from-system-props) 13 | (source/from-env)])) 14 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/dev-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The dev-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:dev true 6 | :port 3000 7 | ;; when :nrepl-port is set the application starts the nREPL server on load 8 | :nrepl-port 7000 9 | 10 | } 11 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/dev-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The dev-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:dev true 6 | :port 3000 7 | ;; when :nrepl-port is set the application starts the nREPL server on load 8 | :nrepl-port 7000 9 | 10 | } 11 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/src/clj/multi_client_ws_http_kit/config.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.config 2 | (:require 3 | [cprop.core :refer [load-config]] 4 | [cprop.source :as source] 5 | [mount.core :refer [args defstate]])) 6 | 7 | (defstate env 8 | :start 9 | (load-config 10 | :merge 11 | [(args) 12 | (source/from-system-props) 13 | (source/from-env)])) 14 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/dev-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The dev-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:dev true 6 | :port 3000 7 | ;; when :nrepl-port is set the application starts the nREPL server on load 8 | :nrepl-port 7000 9 | 10 | } 11 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/src/clj/multi_client_ws_immutant/config.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.config 2 | (:require 3 | [cprop.core :refer [load-config]] 4 | [cprop.source :as source] 5 | [mount.core :refer [args defstate]])) 6 | 7 | (defstate env 8 | :start 9 | (load-config 10 | :merge 11 | [(args) 12 | (source/from-system-props) 13 | (source/from-env)])) 14 | -------------------------------------------------------------------------------- /file-upload-progress/env/dev/clj/user.clj: -------------------------------------------------------------------------------- 1 | (ns user 2 | (:require 3 | [mount.core :as mount] 4 | file-upload-progress.core)) 5 | 6 | (defn start [] 7 | (mount/start-without #'file-upload-progress.core/repl-server)) 8 | 9 | (defn stop [] 10 | (mount/stop-except #'file-upload-progress.core/repl-server)) 11 | 12 | (defn restart [] 13 | (stop) 14 | (start)) 15 | 16 | 17 | -------------------------------------------------------------------------------- /file-upload-progress/env/prod/clj/file_upload_progress/env.clj: -------------------------------------------------------------------------------- 1 | (ns file-upload-progress.env 2 | (:require [clojure.tools.logging :as log])) 3 | 4 | (def defaults 5 | {:init 6 | (fn [] 7 | (log/info "\n-=[file-upload-progress started successfully]=-")) 8 | :stop 9 | (fn [] 10 | (log/info "\n-=[file-upload-progress has shut down successfully]=-")) 11 | :middleware identity}) 12 | -------------------------------------------------------------------------------- /guestbook/README.md: -------------------------------------------------------------------------------- 1 | # guestbook 2 | 3 | generated using Luminus version "3.77" 4 | 5 | FIXME 6 | 7 | ## Prerequisites 8 | 9 | You will need [Leiningen][1] 2.0 or above installed. 10 | 11 | [1]: https://github.com/technomancy/leiningen 12 | 13 | ## Running 14 | 15 | To start a web server for the application, run: 16 | 17 | lein run 18 | 19 | ## License 20 | 21 | Copyright © 2020 FIXME 22 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/test/cljs/multi_client_ws_aleph/core_test.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.core-test 2 | (:require [cljs.test :refer-macros [is are deftest testing use-fixtures]] 3 | [pjstadig.humane-test-output] 4 | [reagent.core :as reagent :refer [atom]] 5 | [multi-client-ws-aleph.core :as rc])) 6 | 7 | (deftest test-home 8 | (is (= true true))) 9 | 10 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/env/prod/clj/multi_client_ws_aleph/env.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.env 2 | (:require [clojure.tools.logging :as log])) 3 | 4 | (def defaults 5 | {:init 6 | (fn [] 7 | (log/info "\n-=[multi-client-ws-aleph started successfully]=-")) 8 | :stop 9 | (fn [] 10 | (log/info "\n-=[multi-client-ws-aleph has shut down successfully]=-")) 11 | :middleware identity}) 12 | -------------------------------------------------------------------------------- /guestbook-sente/README.md: -------------------------------------------------------------------------------- 1 | # guestbook 2 | 3 | generated using Luminus version "3.10.40" 4 | 5 | FIXME 6 | 7 | ## Prerequisites 8 | 9 | You will need [Leiningen][1] 2.0 or above installed. 10 | 11 | [1]: https://github.com/technomancy/leiningen 12 | 13 | ## Running 14 | 15 | To start a web server for the application, run: 16 | 17 | lein run 18 | 19 | ## License 20 | 21 | Copyright © 2019 FIXME 22 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/test/cljs/multi_client_ws_http_kit/core_test.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.core-test 2 | (:require [cljs.test :refer-macros [is are deftest testing use-fixtures]] 3 | [pjstadig.humane-test-output] 4 | [reagent.core :as reagent :refer [atom]] 5 | [multi-client-ws-http-kit.core :as rc])) 6 | 7 | (deftest test-home 8 | (is (= true true))) 9 | 10 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/test/cljs/multi_client_ws_immutant/core_test.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.core-test 2 | (:require [cljs.test :refer-macros [is are deftest testing use-fixtures]] 3 | [pjstadig.humane-test-output] 4 | [reagent.core :as reagent :refer [atom]] 5 | [multi-client-ws-immutant.core :as rc])) 6 | 7 | (deftest test-home 8 | (is (= true true))) 9 | 10 | -------------------------------------------------------------------------------- /guestbook-datomic/env/dev/clj/guestbook_datomic/dev_middleware.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.dev-middleware 2 | (:require [ring.middleware.reload :refer [wrap-reload]] 3 | [selmer.middleware :refer [wrap-error-page]] 4 | [prone.middleware :refer [wrap-exceptions]])) 5 | 6 | (defn wrap-dev [handler] 7 | (-> handler 8 | wrap-reload 9 | wrap-error-page 10 | wrap-exceptions)) 11 | -------------------------------------------------------------------------------- /guestbook-datomic/env/dev/cljs/guestbook_datomic/app.cljs: -------------------------------------------------------------------------------- 1 | (ns ^:figwheel-no-load guestbook-datomic.app 2 | (:require [guestbook-datomic.core :as core] 3 | [cljs.spec.alpha :as s] 4 | [expound.alpha :as expound] 5 | [devtools.core :as devtools])) 6 | 7 | (set! s/*explain-out* expound/printer) 8 | 9 | (enable-console-print!) 10 | 11 | (devtools/install!) 12 | 13 | (core/init!) 14 | -------------------------------------------------------------------------------- /guestbook/env/dev/clj/guestbook/dev_middleware.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.dev-middleware 2 | (:require 3 | [ring.middleware.reload :refer [wrap-reload]] 4 | [selmer.middleware :refer [wrap-error-page]] 5 | [prone.middleware :refer [wrap-exceptions]])) 6 | 7 | (defn wrap-dev [handler] 8 | (-> handler 9 | wrap-reload 10 | wrap-error-page 11 | (wrap-exceptions {:app-namespaces ['guestbook]}))) 12 | -------------------------------------------------------------------------------- /guestbook/dev-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The dev-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:dev true 6 | :port 3000 7 | ;; when :nrepl-port is set the application starts the nREPL server on load 8 | :nrepl-port 7000 9 | 10 | :database-url "jdbc:h2:./guestbook_dev.db"} 11 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/prod/clj/multi_client_ws_http_kit/env.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.env 2 | (:require [clojure.tools.logging :as log])) 3 | 4 | (def defaults 5 | {:init 6 | (fn [] 7 | (log/info "\n-=[multi-client-ws-http-kit started successfully]=-")) 8 | :stop 9 | (fn [] 10 | (log/info "\n-=[multi-client-ws-http-kit has shut down successfully]=-")) 11 | :middleware identity}) 12 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/env/prod/clj/multi_client_ws_immutant/env.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.env 2 | (:require [clojure.tools.logging :as log])) 3 | 4 | (def defaults 5 | {:init 6 | (fn [] 7 | (log/info "\n-=[multi-client-ws-immutant started successfully]=-")) 8 | :stop 9 | (fn [] 10 | (log/info "\n-=[multi-client-ws-immutant has shut down successfully]=-")) 11 | :middleware identity}) 12 | -------------------------------------------------------------------------------- /file-upload-progress/README.md: -------------------------------------------------------------------------------- 1 | # file-upload-progress 2 | 3 | generated using Luminus version "2.9.12.14" 4 | 5 | FIXME 6 | 7 | ## Prerequisites 8 | 9 | You will need [Leiningen][1] 2.0 or above installed. 10 | 11 | [1]: https://github.com/technomancy/leiningen 12 | 13 | ## Running 14 | 15 | To start a web server for the application, run: 16 | 17 | lein run 18 | 19 | ## License 20 | 21 | Copyright © 2018 FIXME 22 | -------------------------------------------------------------------------------- /file-upload-progress/env/dev/clj/file_upload_progress/dev_middleware.clj: -------------------------------------------------------------------------------- 1 | (ns file-upload-progress.dev-middleware 2 | (:require [ring.middleware.reload :refer [wrap-reload]] 3 | [selmer.middleware :refer [wrap-error-page]] 4 | [prone.middleware :refer [wrap-exceptions]])) 5 | 6 | (defn wrap-dev [handler] 7 | (-> handler 8 | wrap-reload 9 | wrap-error-page 10 | wrap-exceptions)) 11 | -------------------------------------------------------------------------------- /guestbook-sente/dev-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The dev-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:dev true 6 | :port 3000 7 | ;; when :nrepl-port is set the application starts the nREPL server on load 8 | :nrepl-port 7000 9 | 10 | :database-url "jdbc:h2:./guestbook_dev.db"} 11 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/README.md: -------------------------------------------------------------------------------- 1 | # multi-client-ws-aleph 2 | 3 | generated using Luminus version "3.45" 4 | 5 | FIXME 6 | 7 | ## Prerequisites 8 | 9 | You will need [Leiningen][1] 2.0 or above installed. 10 | 11 | [1]: https://github.com/technomancy/leiningen 12 | 13 | ## Running 14 | 15 | To start a web server for the application, run: 16 | 17 | lein run 18 | 19 | ## License 20 | 21 | Copyright © 2019 FIXME 22 | -------------------------------------------------------------------------------- /guestbook-sente/env/dev/clj/guestbook/dev_middleware.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.dev-middleware 2 | (:require [ring.middleware.reload :refer [wrap-reload]] 3 | [selmer.middleware :refer [wrap-error-page]] 4 | [prone.middleware :refer [wrap-exceptions]])) 5 | 6 | (defn wrap-dev [handler] 7 | (-> handler 8 | wrap-reload 9 | wrap-error-page 10 | (wrap-exceptions {:app-namespaces ['guestbook]}))) 11 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/README.md: -------------------------------------------------------------------------------- 1 | # multi-client-ws-http-kit 2 | 3 | generated using Luminus version "3.44" 4 | 5 | FIXME 6 | 7 | ## Prerequisites 8 | 9 | You will need [Leiningen][1] 2.0 or above installed. 10 | 11 | [1]: https://github.com/technomancy/leiningen 12 | 13 | ## Running 14 | 15 | To start a web server for the application, run: 16 | 17 | lein run 18 | 19 | ## License 20 | 21 | Copyright © 2019 FIXME 22 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/README.md: -------------------------------------------------------------------------------- 1 | # multi-client-ws-immutant 2 | 3 | generated using Luminus version "3.44" 4 | 5 | FIXME 6 | 7 | ## Prerequisites 8 | 9 | You will need [Leiningen][1] 2.0 or above installed. 10 | 11 | [1]: https://github.com/technomancy/leiningen 12 | 13 | ## Running 14 | 15 | To start a web server for the application, run: 16 | 17 | lein run 18 | 19 | ## License 20 | 21 | Copyright © 2019 FIXME 22 | -------------------------------------------------------------------------------- /file-upload-progress/src/clj/file_upload_progress/config.clj: -------------------------------------------------------------------------------- 1 | (ns file-upload-progress.config 2 | (:require [cprop.core :refer [load-config]] 3 | [cprop.source :as source] 4 | [mount.core :refer [args defstate]])) 5 | 6 | (defstate env :start (load-config 7 | :merge 8 | [(args) 9 | (source/from-system-props) 10 | (source/from-env)])) 11 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/env/dev/clj/multi_client_ws_aleph/dev_middleware.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.dev-middleware 2 | (:require 3 | [ring.middleware.reload :refer [wrap-reload]] 4 | [selmer.middleware :refer [wrap-error-page]] 5 | [prone.middleware :refer [wrap-exceptions]])) 6 | 7 | (defn wrap-dev [handler] 8 | (-> handler 9 | wrap-reload 10 | wrap-error-page 11 | (wrap-exceptions {:app-namespaces ['multi-client-ws-aleph]}))) 12 | -------------------------------------------------------------------------------- /guestbook-datomic/src/cljc/guestbook_datomic/validation.cljc: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.validation 2 | (:require [struct.core :as st])) 3 | 4 | (def message-schema 5 | [[:name 6 | st/required 7 | st/string] 8 | 9 | [:message 10 | st/required 11 | st/string 12 | {:message "message must contain at least 10 characters" 13 | :validate #(> (count %) 9)}]]) 14 | 15 | (defn validate-message [params] 16 | (first (st/validate params message-schema))) 17 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/dev/clj/multi_client_ws_http_kit/dev_middleware.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.dev-middleware 2 | (:require 3 | [ring.middleware.reload :refer [wrap-reload]] 4 | [selmer.middleware :refer [wrap-error-page]] 5 | [prone.middleware :refer [wrap-exceptions]])) 6 | 7 | (defn wrap-dev [handler] 8 | (-> handler 9 | wrap-reload 10 | wrap-error-page 11 | (wrap-exceptions {:app-namespaces ['multi-client-ws-http-kit]}))) 12 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/env/dev/clj/multi_client_ws_immutant/dev_middleware.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.dev-middleware 2 | (:require 3 | [ring.middleware.reload :refer [wrap-reload]] 4 | [selmer.middleware :refer [wrap-error-page]] 5 | [prone.middleware :refer [wrap-exceptions]])) 6 | 7 | (defn wrap-dev [handler] 8 | (-> handler 9 | wrap-reload 10 | wrap-error-page 11 | (wrap-exceptions {:app-namespaces ['multi-client-ws-immutant]}))) 12 | -------------------------------------------------------------------------------- /guestbook-datomic/README.md: -------------------------------------------------------------------------------- 1 | # guestbook-datomic 2 | 3 | generated using Luminus version "2.9.12.62" 4 | 5 | FIXME 6 | 7 | ## Prerequisites 8 | 9 | You will need [Leiningen][1] 2.0 or above installed. 10 | 11 | [1]: https://github.com/technomancy/leiningen 12 | 13 | ## Running 14 | 15 | To start a web server for the application, run: 16 | 17 | lein run 18 | 19 | Then in a second terminal run: 20 | 21 | lein figwheel 22 | 23 | ## License 24 | 25 | Copyright © 2018 FIXME 26 | -------------------------------------------------------------------------------- /guestbook/env/dev/clj/guestbook/env.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.env 2 | (:require 3 | [selmer.parser :as parser] 4 | [clojure.tools.logging :as log] 5 | [guestbook.dev-middleware :refer [wrap-dev]])) 6 | 7 | (def defaults 8 | {:init 9 | (fn [] 10 | (parser/cache-off!) 11 | (log/info "\n-=[guestbook started successfully using the development profile]=-")) 12 | :stop 13 | (fn [] 14 | (log/info "\n-=[guestbook has shut down successfully]=-")) 15 | :middleware wrap-dev}) 16 | -------------------------------------------------------------------------------- /guestbook-sente/env/dev/clj/guestbook/env.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.env 2 | (:require 3 | [selmer.parser :as parser] 4 | [clojure.tools.logging :as log] 5 | [guestbook.dev-middleware :refer [wrap-dev]])) 6 | 7 | (def defaults 8 | {:init 9 | (fn [] 10 | (parser/cache-off!) 11 | (log/info "\n-=[guestbook started successfully using the development profile]=-")) 12 | :stop 13 | (fn [] 14 | (log/info "\n-=[guestbook has shut down successfully]=-")) 15 | :middleware wrap-dev}) 16 | -------------------------------------------------------------------------------- /guestbook-sente/env/dev/cljs/guestbook/app.cljs: -------------------------------------------------------------------------------- 1 | (ns ^:figwheel-no-load guestbook.app 2 | (:require 3 | [guestbook.core :as core] 4 | [cljs.spec.alpha :as s] 5 | [expound.alpha :as expound] 6 | [devtools.core :as devtools])) 7 | 8 | (extend-protocol IPrintWithWriter 9 | js/Symbol 10 | (-pr-writer [sym writer _] 11 | (-write writer (str "\"" (.toString sym) "\"")))) 12 | 13 | (set! s/*explain-out* expound/printer) 14 | 15 | (enable-console-print!) 16 | 17 | (devtools/install!) 18 | 19 | (core/init!) 20 | -------------------------------------------------------------------------------- /guestbook-datomic/test-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The test-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:port 3000 6 | ; set your test database connection URL here 7 | ; :database-url "datomic:free://localhost:4334/guestbook_datomic_test" 8 | ; Don't forget you can also use the datomic mem db which can be useful when developing 9 | :database-url "datomic:mem://guestbook_datomic_test" 10 | } 11 | -------------------------------------------------------------------------------- /file-upload-progress/test/clj/file_upload_progress/test/handler.clj: -------------------------------------------------------------------------------- 1 | (ns file-upload-progress.test.handler 2 | (:require [clojure.test :refer :all] 3 | [ring.mock.request :refer :all] 4 | [file-upload-progress.handler :refer :all])) 5 | 6 | (deftest test-app 7 | (testing "main route" 8 | (let [response ((app) (request :get "/"))] 9 | (is (= 200 (:status response))))) 10 | 11 | (testing "not-found route" 12 | (let [response ((app) (request :get "/invalid"))] 13 | (is (= 404 (:status response)))))) 14 | -------------------------------------------------------------------------------- /guestbook-datomic/env/dev/clj/guestbook_datomic/env.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.env 2 | (:require [selmer.parser :as parser] 3 | [clojure.tools.logging :as log] 4 | [guestbook-datomic.dev-middleware :refer [wrap-dev]])) 5 | 6 | (def defaults 7 | {:init 8 | (fn [] 9 | (parser/cache-off!) 10 | (log/info "\n-=[guestbook-datomic started successfully using the development profile]=-")) 11 | :stop 12 | (fn [] 13 | (log/info "\n-=[guestbook-datomic has shut down successfully]=-")) 14 | :middleware wrap-dev}) 15 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/env/dev/cljs/multi_client_ws_aleph/app.cljs: -------------------------------------------------------------------------------- 1 | (ns^:figwheel-no-load multi-client-ws-aleph.app 2 | (:require 3 | [multi-client-ws-aleph.core :as core] 4 | [cljs.spec.alpha :as s] 5 | [expound.alpha :as expound] 6 | [devtools.core :as devtools])) 7 | 8 | (extend-protocol IPrintWithWriter 9 | js/Symbol 10 | (-pr-writer [sym writer _] 11 | (-write writer (str "\"" (.toString sym) "\"")))) 12 | 13 | (set! s/*explain-out* expound/printer) 14 | 15 | (enable-console-print!) 16 | 17 | (devtools/install!) 18 | 19 | (core/init!) 20 | -------------------------------------------------------------------------------- /file-upload-progress/env/dev/clj/file_upload_progress/env.clj: -------------------------------------------------------------------------------- 1 | (ns file-upload-progress.env 2 | (:require [selmer.parser :as parser] 3 | [clojure.tools.logging :as log] 4 | [file-upload-progress.dev-middleware :refer [wrap-dev]])) 5 | 6 | (def defaults 7 | {:init 8 | (fn [] 9 | (parser/cache-off!) 10 | (log/info "\n-=[file-upload-progress started successfully using the development profile]=-")) 11 | :stop 12 | (fn [] 13 | (log/info "\n-=[file-upload-progress has shut down successfully]=-")) 14 | :middleware wrap-dev}) 15 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/env/dev/clj/multi_client_ws_aleph/env.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.env 2 | (:require 3 | [selmer.parser :as parser] 4 | [clojure.tools.logging :as log] 5 | [multi-client-ws-aleph.dev-middleware :refer [wrap-dev]])) 6 | 7 | (def defaults 8 | {:init 9 | (fn [] 10 | (parser/cache-off!) 11 | (log/info "\n-=[multi-client-ws-aleph started successfully using the development profile]=-")) 12 | :stop 13 | (fn [] 14 | (log/info "\n-=[multi-client-ws-aleph has shut down successfully]=-")) 15 | :middleware wrap-dev}) 16 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/dev/cljs/multi_client_ws_http_kit/app.cljs: -------------------------------------------------------------------------------- 1 | (ns^:figwheel-no-load multi-client-ws-http-kit.app 2 | (:require 3 | [multi-client-ws-http-kit.core :as core] 4 | [cljs.spec.alpha :as s] 5 | [expound.alpha :as expound] 6 | [devtools.core :as devtools])) 7 | 8 | (extend-protocol IPrintWithWriter 9 | js/Symbol 10 | (-pr-writer [sym writer _] 11 | (-write writer (str "\"" (.toString sym) "\"")))) 12 | 13 | (set! s/*explain-out* expound/printer) 14 | 15 | (enable-console-print!) 16 | 17 | (devtools/install!) 18 | 19 | (core/init!) 20 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/env/dev/cljs/multi_client_ws_immutant/app.cljs: -------------------------------------------------------------------------------- 1 | (ns^:figwheel-no-load multi-client-ws-immutant.app 2 | (:require 3 | [multi-client-ws-immutant.core :as core] 4 | [cljs.spec.alpha :as s] 5 | [expound.alpha :as expound] 6 | [devtools.core :as devtools])) 7 | 8 | (extend-protocol IPrintWithWriter 9 | js/Symbol 10 | (-pr-writer [sym writer _] 11 | (-write writer (str "\"" (.toString sym) "\"")))) 12 | 13 | (set! s/*explain-out* expound/printer) 14 | 15 | (enable-console-print!) 16 | 17 | (devtools/install!) 18 | 19 | (core/init!) 20 | -------------------------------------------------------------------------------- /guestbook/src/clj/guestbook/middleware/formats.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.middleware.formats 2 | (:require 3 | [cognitect.transit :as transit] 4 | [luminus-transit.time :as time] 5 | [muuntaja.core :as m])) 6 | 7 | (def instance 8 | (m/create 9 | (-> m/default-options 10 | (update-in 11 | [:formats "application/transit+json" :decoder-opts] 12 | (partial merge time/time-deserialization-handlers)) 13 | (update-in 14 | [:formats "application/transit+json" :encoder-opts] 15 | (partial merge time/time-serialization-handlers))))) 16 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/dev/clj/multi_client_ws_http_kit/env.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.env 2 | (:require 3 | [selmer.parser :as parser] 4 | [clojure.tools.logging :as log] 5 | [multi-client-ws-http-kit.dev-middleware :refer [wrap-dev]])) 6 | 7 | (def defaults 8 | {:init 9 | (fn [] 10 | (parser/cache-off!) 11 | (log/info "\n-=[multi-client-ws-http-kit started successfully using the development profile]=-")) 12 | :stop 13 | (fn [] 14 | (log/info "\n-=[multi-client-ws-http-kit has shut down successfully]=-")) 15 | :middleware wrap-dev}) 16 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/env/dev/clj/multi_client_ws_immutant/env.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.env 2 | (:require 3 | [selmer.parser :as parser] 4 | [clojure.tools.logging :as log] 5 | [multi-client-ws-immutant.dev-middleware :refer [wrap-dev]])) 6 | 7 | (def defaults 8 | {:init 9 | (fn [] 10 | (parser/cache-off!) 11 | (log/info "\n-=[multi-client-ws-immutant started successfully using the development profile]=-")) 12 | :stop 13 | (fn [] 14 | (log/info "\n-=[multi-client-ws-immutant has shut down successfully]=-")) 15 | :middleware wrap-dev}) 16 | -------------------------------------------------------------------------------- /guestbook-sente/src/clj/guestbook/middleware/formats.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.middleware.formats 2 | (:require 3 | [cognitect.transit :as transit] 4 | [luminus-transit.time :as time] 5 | [muuntaja.core :as m])) 6 | 7 | (def instance 8 | (m/create 9 | (-> m/default-options 10 | (update-in 11 | [:formats "application/transit+json" :decoder-opts] 12 | (partial merge time/time-deserialization-handlers)) 13 | (update-in 14 | [:formats "application/transit+json" :encoder-opts] 15 | (partial merge time/time-serialization-handlers))))) 16 | -------------------------------------------------------------------------------- /guestbook-datomic/src/cljs/guestbook_datomic/ajax.cljs: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.ajax 2 | (:require [ajax.core :as ajax])) 3 | 4 | (defn local-uri? [{:keys [uri]}] 5 | (not (re-find #"^\w+?://" uri))) 6 | 7 | (defn default-headers [request] 8 | (if (local-uri? request) 9 | (-> request 10 | (update :headers #(merge {"x-csrf-token" js/csrfToken} %))) 11 | request)) 12 | 13 | (defn load-interceptors! [] 14 | (swap! ajax/default-interceptors 15 | conj 16 | (ajax/to-interceptor {:name "default headers" 17 | :request default-headers}))) 18 | 19 | 20 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/src/clj/multi_client_ws_aleph/middleware/formats.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.middleware.formats 2 | (:require 3 | [cognitect.transit :as transit] 4 | [luminus-transit.time :as time] 5 | [muuntaja.core :as m])) 6 | 7 | (def instance 8 | (m/create 9 | (-> m/default-options 10 | (update-in 11 | [:formats "application/transit+json" :decoder-opts] 12 | (partial merge time/time-deserialization-handlers)) 13 | (update-in 14 | [:formats "application/transit+json" :encoder-opts] 15 | (partial merge time/time-serialization-handlers))))) 16 | -------------------------------------------------------------------------------- /guestbook-cljs/resources/templates/about.html: -------------------------------------------------------------------------------- 1 | 9 | {% extends "base.html" %} 10 | {% block content %} 11 |

this is the story of guestbook... work in progress

12 | {% endblock %} 13 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/src/clj/multi_client_ws_http_kit/middleware/formats.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.middleware.formats 2 | (:require 3 | [cognitect.transit :as transit] 4 | [luminus-transit.time :as time] 5 | [muuntaja.core :as m])) 6 | 7 | (def instance 8 | (m/create 9 | (-> m/default-options 10 | (update-in 11 | [:formats "application/transit+json" :decoder-opts] 12 | (partial merge time/time-deserialization-handlers)) 13 | (update-in 14 | [:formats "application/transit+json" :encoder-opts] 15 | (partial merge time/time-serialization-handlers))))) 16 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/src/clj/multi_client_ws_immutant/middleware/formats.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.middleware.formats 2 | (:require 3 | [cognitect.transit :as transit] 4 | [luminus-transit.time :as time] 5 | [muuntaja.core :as m])) 6 | 7 | (def instance 8 | (m/create 9 | (-> m/default-options 10 | (update-in 11 | [:formats "application/transit+json" :decoder-opts] 12 | (partial merge time/time-deserialization-handlers)) 13 | (update-in 14 | [:formats "application/transit+json" :encoder-opts] 15 | (partial merge time/time-serialization-handlers))))) 16 | -------------------------------------------------------------------------------- /reporting-example/resources/templates/about.html: -------------------------------------------------------------------------------- 1 | 9 | {% extends "base.html" %} 10 | {% block content %} 11 |

this is the story of reporting-example... work in progress

12 | {% endblock %} 13 | -------------------------------------------------------------------------------- /guestbook-cljs/resources/templates/home.html: -------------------------------------------------------------------------------- 1 | 9 | {% extends "base.html" %} 10 | {% block content %} 11 | 12 |
13 | {% endblock %} 14 | -------------------------------------------------------------------------------- /guestbook-datomic/dev-config.edn: -------------------------------------------------------------------------------- 1 | ;; WARNING 2 | ;; The dev-config.edn file is used for local environment variables, such as database credentials. 3 | ;; This file is listed in .gitignore and will be excluded from version control by Git. 4 | 5 | {:dev true 6 | :port 3000 7 | ;; when :nrepl-port is set the application starts the nREPL server on load 8 | :nrepl-port 7000 9 | 10 | ; set your dev database connection URL here 11 | ; :database-url "datomic:free://localhost:4334/guestbook_datomic_dev" 12 | ; Don't forget you can also use the datomic mem db which can be useful when developing 13 | :database-url "datomic:mem://guestbook_datomic_dev" 14 | } 15 | -------------------------------------------------------------------------------- /swagger-service/env/prod/cljs/swagger_service/prod.cljs: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns swagger-service.app 10 | (:require [swagger-service.core :as core])) 11 | 12 | ;;ignore println statements in prod 13 | (set! *print-fn* (fn [& _])) 14 | 15 | (core/init!) 16 | -------------------------------------------------------------------------------- /guestbook-datomic/env/dev/clj/user.clj: -------------------------------------------------------------------------------- 1 | (ns user 2 | (:require [guestbook-datomic.config :refer [env]] 3 | [clojure.spec.alpha :as s] 4 | [expound.alpha :as expound] 5 | [mount.core :as mount] 6 | [guestbook-datomic.figwheel :refer [start-fw stop-fw cljs]] 7 | [guestbook-datomic.core :refer [start-app]])) 8 | 9 | (alter-var-root #'s/*explain-out* (constantly expound/printer)) 10 | 11 | (defn start [] 12 | (mount/start-without #'guestbook-datomic.core/repl-server)) 13 | 14 | (defn stop [] 15 | (mount/stop-except #'guestbook-datomic.core/repl-server)) 16 | 17 | (defn restart [] 18 | (stop) 19 | (start)) 20 | 21 | 22 | -------------------------------------------------------------------------------- /swagger-service/test/cljs/swagger_service/doo_runner.cljs: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns swagger-service.doo-runner 10 | (:require [doo.runner :refer-macros [doo-tests]] 11 | [swagger-service.core-test])) 12 | 13 | (doo-tests 'swagger-service.core-test) 14 | 15 | -------------------------------------------------------------------------------- /guestbook-cljs/env/prod/clj/guestbook/env.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns guestbook.env 10 | (:require [clojure.tools.logging :as log])) 11 | 12 | (def defaults 13 | {:init 14 | (fn [] 15 | (log/info "\n-=[guestbook started successfully]=-")) 16 | :middleware identity}) 17 | -------------------------------------------------------------------------------- /swagger-service/env/prod/clj/swagger_service/config.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns swagger-service.config 10 | (:require [clojure.tools.logging :as log])) 11 | 12 | (def defaults 13 | {:init 14 | (fn [] 15 | (log/info "\n-=[swagger-service started successfully]=-")) 16 | :middleware identity}) 17 | -------------------------------------------------------------------------------- /reporting-example/env/prod/clj/reporting_example/config.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns reporting-example.config 10 | (:require [clojure.tools.logging :as log])) 11 | 12 | (def defaults 13 | {:init 14 | (fn [] 15 | (log/info "\n-=[reporting-example started successfully]=-")) 16 | :middleware identity}) 17 | -------------------------------------------------------------------------------- /reporting-example/resources/public/css/screen.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 4 | height: 100%; 5 | } 6 | .navbar { 7 | margin-bottom: 10px; 8 | } 9 | .navbar-brand { 10 | float: none; 11 | } 12 | .navbar-nav .nav-item { 13 | float: none; 14 | } 15 | .navbar-divider, 16 | .navbar-nav .nav-item+.nav-item, 17 | .navbar-nav .nav-link + .nav-link { 18 | margin-left: 0; 19 | } 20 | @media (min-width: 34em) { 21 | .navbar-brand { 22 | float: left; 23 | } 24 | .navbar-nav .nav-item { 25 | float: left; 26 | } 27 | .navbar-divider, 28 | .navbar-nav .nav-item+.nav-item, 29 | .navbar-nav .nav-link + .nav-link { 30 | margin-left: 1rem; 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /guestbook-datomic/test/clj/guestbook_datomic/test/handler.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.test.handler 2 | (:require [clojure.test :refer :all] 3 | [ring.mock.request :refer :all] 4 | [guestbook-datomic.handler :refer :all] 5 | [mount.core :as mount])) 6 | 7 | (use-fixtures 8 | :once 9 | (fn [f] 10 | (mount/start #'guestbook-datomic.config/env 11 | #'guestbook-datomic.handler/app) 12 | (f))) 13 | 14 | (deftest test-app 15 | (testing "main route" 16 | (let [response (app (request :get "/"))] 17 | (is (= 200 (:status response))))) 18 | 19 | (testing "not-found route" 20 | (let [response (app (request :get "/invalid"))] 21 | (is (= 404 (:status response)))))) 22 | -------------------------------------------------------------------------------- /guestbook/Capstanfile: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Name of the base image. Capstan will download this automatically from 4 | # Cloudius S3 repository. 5 | # 6 | #base: cloudius/osv 7 | base: cloudius/osv-openjdk8 8 | 9 | # 10 | # The command line passed to OSv to start up the application. 11 | # 12 | cmdline: /java.so -jar /guestbook/app.jar 13 | 14 | # 15 | # The command to use to build the application. 16 | # You can use any build tool/command (make/rake/lein/boot) - this runs locally on your machine 17 | # 18 | # For Leiningen, you can use: 19 | #build: lein uberjar 20 | # For Boot, you can use: 21 | #build: boot build 22 | 23 | # 24 | # List of files that are included in the generated image. 25 | # 26 | files: 27 | /guestbook/app.jar: ./target/uberjar/guestbook.jar 28 | 29 | -------------------------------------------------------------------------------- /swagger-service/test/cljs/swagger_service/core_test.cljs: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns swagger-service.core-test 10 | (:require [cljs.test :refer-macros [is are deftest testing use-fixtures]] 11 | [reagent.core :as reagent :refer [atom]] 12 | [swagger-service.core :as rc])) 13 | 14 | (deftest test-home 15 | (is (= true true))) 16 | 17 | -------------------------------------------------------------------------------- /guestbook-cljs/env/dev/clj/user.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns user 10 | (:require [mount.core :as mount] 11 | guestbook.core)) 12 | 13 | (defn start [] 14 | (mount/start-without #'guestbook.core/repl-server)) 15 | 16 | (defn stop [] 17 | (mount/stop-except #'guestbook.core/repl-server)) 18 | 19 | (defn restart [] 20 | (stop) 21 | (start)) 22 | 23 | 24 | -------------------------------------------------------------------------------- /guestbook-datomic/Capstanfile: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Name of the base image. Capstan will download this automatically from 4 | # Cloudius S3 repository. 5 | # 6 | #base: cloudius/osv 7 | base: cloudius/osv-openjdk8 8 | 9 | # 10 | # The command line passed to OSv to start up the application. 11 | # 12 | cmdline: /java.so -jar /guestbook-datomic/app.jar 13 | 14 | # 15 | # The command to use to build the application. 16 | # You can use any build tool/command (make/rake/lein/boot) - this runs locally on your machine 17 | # 18 | # For Leiningen, you can use: 19 | #build: lein uberjar 20 | # For Boot, you can use: 21 | #build: boot build 22 | 23 | # 24 | # List of files that are included in the generated image. 25 | # 26 | files: 27 | /guestbook-datomic/app.jar: ./target/uberjar/guestbook-datomic.jar 28 | 29 | -------------------------------------------------------------------------------- /guestbook-sente/src/clj/guestbook/routes/home.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.routes.home 2 | (:require 3 | [guestbook.db.core :as db] 4 | [guestbook.layout :as layout] 5 | [guestbook.routes.ws :as ws] 6 | [clojure.java.io :as io] 7 | [guestbook.middleware :as middleware] 8 | [ring.util.http-response :as response])) 9 | 10 | (defn home-page [request] 11 | (layout/render request "home.html")) 12 | 13 | (defn get-messages [_] 14 | (response/ok (db/get-messages))) 15 | 16 | (defn home-routes [] 17 | ["" 18 | {:middleware [middleware/wrap-csrf 19 | middleware/wrap-formats]} 20 | ["/" {:get home-page}] 21 | ["/messages" {:get get-messages}] 22 | ["/ws" {:get (:ajax-get-or-ws-handshake-fn ws/connection) 23 | :post (:ajax-post-fn ws/connection)}]]) 24 | -------------------------------------------------------------------------------- /file-upload-progress/Capstanfile: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Name of the base image. Capstan will download this automatically from 4 | # Cloudius S3 repository. 5 | # 6 | #base: cloudius/osv 7 | base: cloudius/osv-openjdk8 8 | 9 | # 10 | # The command line passed to OSv to start up the application. 11 | # 12 | cmdline: /java.so -jar /file-upload-progress/app.jar 13 | 14 | # 15 | # The command to use to build the application. 16 | # You can use any build tool/command (make/rake/lein/boot) - this runs locally on your machine 17 | # 18 | # For Leiningen, you can use: 19 | #build: lein uberjar 20 | # For Boot, you can use: 21 | #build: boot build 22 | 23 | # 24 | # List of files that are included in the generated image. 25 | # 26 | files: 27 | /file-upload-progress/app.jar: ./target/uberjar/file-upload-progress.jar 28 | 29 | -------------------------------------------------------------------------------- /file-upload-progress/resources/public/css/screen.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 4 | height: 100%; 5 | } 6 | .navbar { 7 | margin-bottom: 10px; 8 | border-radius: 0px; 9 | } 10 | .navbar-brand { 11 | float: none; 12 | } 13 | .navbar-nav .nav-item { 14 | float: none; 15 | } 16 | .navbar-divider, 17 | .navbar-nav .nav-item+.nav-item, 18 | .navbar-nav .nav-link + .nav-link { 19 | margin-left: 0; 20 | } 21 | @media (min-width: 34em) { 22 | .navbar-brand { 23 | float: left; 24 | } 25 | .navbar-nav .nav-item { 26 | float: left; 27 | } 28 | .navbar-divider, 29 | .navbar-nav .nav-item+.nav-item, 30 | .navbar-nav .nav-link + .nav-link { 31 | margin-left: 1rem; 32 | } 33 | } 34 | .row { 35 | margin-bottom: 20px; 36 | } 37 | -------------------------------------------------------------------------------- /guestbook/resources/sql/queries.sql: -------------------------------------------------------------------------------- 1 | -- :name create-user! :! :n 2 | -- :doc creates a new user record 3 | INSERT INTO users 4 | (id, first_name, last_name, email, pass) 5 | VALUES (:id, :first_name, :last_name, :email, :pass) 6 | 7 | -- :name update-user! :! :n 8 | -- :doc update an existing user record 9 | UPDATE users 10 | SET first_name = :first_name, last_name = :last_name, email = :email 11 | WHERE id = :id 12 | 13 | -- :name get-user :? :1 14 | -- :doc retrieve a user given the id. 15 | SELECT * FROM users 16 | WHERE id = :id 17 | 18 | -- :name save-message! :! :n 19 | -- :doc creates a new message 20 | INSERT INTO guestbook 21 | (name, message, timestamp) 22 | VALUES (:name, :message, :timestamp) 23 | 24 | -- :name get-messages :? :* 25 | -- :doc selects all available messages 26 | SELECT * FROM guestbook -------------------------------------------------------------------------------- /guestbook-cljs/env/dev/clj/guestbook/dev_middleware.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns guestbook.dev-middleware 10 | (:require [ring.middleware.reload :refer [wrap-reload]] 11 | [selmer.middleware :refer [wrap-error-page]] 12 | [prone.middleware :refer [wrap-exceptions]])) 13 | 14 | (defn wrap-dev [handler] 15 | (-> handler 16 | wrap-reload 17 | wrap-error-page 18 | wrap-exceptions)) 19 | -------------------------------------------------------------------------------- /guestbook-sente/test/clj/guestbook/test/handler.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.test.handler 2 | (:require 3 | [clojure.test :refer :all] 4 | [ring.mock.request :refer :all] 5 | [guestbook.handler :refer :all] 6 | [guestbook.middleware.formats :as formats] 7 | [muuntaja.core :as m] 8 | [mount.core :as mount])) 9 | 10 | (defn parse-json [body] 11 | (m/decode formats/instance "application/json" body)) 12 | 13 | (use-fixtures 14 | :once 15 | (fn [f] 16 | (mount/start #'guestbook.config/env 17 | #'guestbook.handler/app) 18 | (f))) 19 | 20 | (deftest test-app 21 | (testing "main route" 22 | (let [response (app (request :get "/"))] 23 | (is (= 200 (:status response))))) 24 | 25 | (testing "not-found route" 26 | (let [response (app (request :get "/invalid"))] 27 | (is (= 404 (:status response)))))) 28 | -------------------------------------------------------------------------------- /swagger-service/env/dev/clj/swagger_service/dev_middleware.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns swagger-service.dev-middleware 10 | (:require [ring.middleware.reload :refer [wrap-reload]] 11 | [selmer.middleware :refer [wrap-error-page]] 12 | [prone.middleware :refer [wrap-exceptions]])) 13 | 14 | (defn wrap-dev [handler] 15 | (-> handler 16 | wrap-reload 17 | wrap-error-page 18 | wrap-exceptions)) 19 | -------------------------------------------------------------------------------- /guestbook-cljs/env/dev/clj/guestbook/env.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns guestbook.env 10 | (:require [selmer.parser :as parser] 11 | [clojure.tools.logging :as log] 12 | [guestbook.dev-middleware :refer [wrap-dev]])) 13 | 14 | (def defaults 15 | {:init 16 | (fn [] 17 | (parser/cache-off!) 18 | (log/info "\n-=[guestbook started successfully using the development profile]=-")) 19 | :middleware wrap-dev}) 20 | -------------------------------------------------------------------------------- /guestbook/test/clj/guestbook/test/handler.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.test.handler 2 | (:require 3 | [clojure.test :refer :all] 4 | [ring.mock.request :refer :all] 5 | [guestbook.handler :refer :all] 6 | [guestbook.middleware.formats :as formats] 7 | [muuntaja.core :as m] 8 | [mount.core :as mount])) 9 | 10 | (defn parse-json [body] 11 | (m/decode formats/instance "application/json" body)) 12 | 13 | (use-fixtures 14 | :once 15 | (fn [f] 16 | (mount/start #'guestbook.config/env 17 | #'guestbook.handler/app-routes) 18 | (f))) 19 | 20 | (deftest test-app 21 | (testing "main route" 22 | (let [response ((app) (request :get "/"))] 23 | (is (= 200 (:status response))))) 24 | 25 | (testing "not-found route" 26 | (let [response ((app) (request :get "/invalid"))] 27 | (is (= 404 (:status response)))))) 28 | -------------------------------------------------------------------------------- /reporting-example/env/dev/clj/reporting_example/dev_middleware.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns reporting-example.dev-middleware 10 | (:require [ring.middleware.reload :refer [wrap-reload]] 11 | [selmer.middleware :refer [wrap-error-page]] 12 | [prone.middleware :refer [wrap-exceptions]])) 13 | 14 | (defn wrap-dev [handler] 15 | (-> handler 16 | wrap-reload 17 | wrap-error-page 18 | wrap-exceptions)) 19 | -------------------------------------------------------------------------------- /file-upload-progress/src/clj/file_upload_progress/routes/home.clj: -------------------------------------------------------------------------------- 1 | (ns file-upload-progress.routes.home 2 | (:require [file-upload-progress.layout :as layout] 3 | [compojure.core :refer [defroutes GET POST]] 4 | [ring.util.http-response :as response] 5 | [clojure.java.io :as io])) 6 | 7 | (defn home-page [] 8 | (layout/render 9 | "home.html" {:docs (-> "docs/docs.md" io/resource slurp)})) 10 | 11 | (defn about-page [] 12 | (layout/render "about.html")) 13 | 14 | (defn upload-hanlder [{:keys [filename content-type tempfile size]}] 15 | (io/copy (io/file tempfile) (io/file filename)) 16 | (io/delete-file (.getAbsolutePath tempfile)) 17 | (response/ok {:status :ok})) 18 | 19 | (defroutes home-routes 20 | (GET "/" [] (home-page)) 21 | (GET "/about" [] (about-page)) 22 | (POST "/upload" [file] (upload-hanlder file))) 23 | -------------------------------------------------------------------------------- /guestbook-cljs/src/clj/guestbook/config.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns guestbook.config 10 | (:require [cprop.core :refer [load-config]] 11 | [cprop.source :as source] 12 | [mount.core :refer [args defstate]])) 13 | 14 | (defstate env :start (load-config 15 | :merge 16 | [(args) 17 | (source/from-system-props) 18 | (source/from-env)])) 19 | -------------------------------------------------------------------------------- /swagger-service/env/dev/clj/swagger_service/config.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns swagger-service.config 10 | (:require [selmer.parser :as parser] 11 | [clojure.tools.logging :as log] 12 | [swagger-service.dev-middleware :refer [wrap-dev]])) 13 | 14 | (def defaults 15 | {:init 16 | (fn [] 17 | (parser/cache-off!) 18 | (log/info "\n-=[swagger-service started successfully using the development profile]=-")) 19 | :middleware wrap-dev}) 20 | -------------------------------------------------------------------------------- /reporting-example/env/dev/clj/reporting_example/config.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns reporting-example.config 10 | (:require [selmer.parser :as parser] 11 | [clojure.tools.logging :as log] 12 | [reporting-example.dev-middleware :refer [wrap-dev]])) 13 | 14 | (def defaults 15 | {:init 16 | (fn [] 17 | (parser/cache-off!) 18 | (log/info "\n-=[reporting-example started successfully using the development profile]=-")) 19 | :middleware wrap-dev}) 20 | -------------------------------------------------------------------------------- /reporting-example/env/dev/clj/user.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns user 10 | (:require [reporting-example.handler :refer [app init destroy]] 11 | [luminus.http-server :as http] 12 | [config.core :refer [env]])) 13 | 14 | (defn start [] 15 | (http/start {:handler app 16 | :init init 17 | :port (:port env)})) 18 | 19 | (defn stop [] 20 | (http/stop destroy)) 21 | 22 | (defn restart [] 23 | (stop) 24 | (start)) 25 | 26 | 27 | -------------------------------------------------------------------------------- /swagger-service/env/dev/clj/user.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns user 10 | (:require [swagger-service.handler :refer [app init destroy]] 11 | [luminus.http-server :as http] 12 | [config.core :refer [env]])) 13 | 14 | (defn start [] 15 | (http/start {:handler app 16 | :init init 17 | :port (:port env)})) 18 | 19 | (defn stop [] 20 | (http/stop destroy)) 21 | 22 | (defn restart [] 23 | (stop) 24 | (start)) 25 | 26 | 27 | -------------------------------------------------------------------------------- /swagger-service/src/clj/swagger_service/routes/home.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns swagger-service.routes.home 10 | (:require [swagger-service.layout :as layout] 11 | [compojure.core :refer [defroutes GET]] 12 | [ring.util.http-response :refer [ok]] 13 | [clojure.java.io :as io])) 14 | 15 | (defn home-page [] 16 | (layout/render "home.html")) 17 | 18 | (defroutes home-routes 19 | (GET "/" [] (home-page)) 20 | (GET "/docs" [] (ok (-> "docs/docs.md" io/resource slurp)))) 21 | 22 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/test/clj/multi_client_ws_aleph/test/handler.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.test.handler 2 | (:require 3 | [clojure.test :refer :all] 4 | [ring.mock.request :refer :all] 5 | [multi-client-ws-aleph.handler :refer :all] 6 | [multi-client-ws-aleph.middleware.formats :as formats] 7 | [muuntaja.core :as m] 8 | [mount.core :as mount])) 9 | 10 | (defn parse-json [body] 11 | (m/decode formats/instance "application/json" body)) 12 | 13 | (use-fixtures 14 | :once 15 | (fn [f] 16 | (mount/start #'multi-client-ws-aleph.config/env 17 | #'multi-client-ws-aleph.handler/app-routes) 18 | (f))) 19 | 20 | (deftest test-app 21 | (testing "main route" 22 | (let [response ((app) (request :get "/"))] 23 | (is (= 200 (:status response))))) 24 | 25 | (testing "not-found route" 26 | (let [response ((app) (request :get "/invalid"))] 27 | (is (= 404 (:status response)))))) 28 | -------------------------------------------------------------------------------- /guestbook-cljs/test/clj/guestbook/test/handler.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns guestbook.test.handler 10 | (:require [clojure.test :refer :all] 11 | [ring.mock.request :refer :all] 12 | [guestbook.handler :refer :all])) 13 | 14 | (deftest test-app 15 | (testing "main route" 16 | (let [response (app (request :get "/"))] 17 | (is (= 200 (:status response))))) 18 | 19 | (testing "not-found route" 20 | (let [response (app (request :get "/invalid"))] 21 | (is (= 404 (:status response)))))) 22 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/env/dev/clj/user.clj: -------------------------------------------------------------------------------- 1 | (ns user 2 | "Userspace functions you can run by default in your local REPL." 3 | (:require 4 | [multi-client-ws-aleph.config :refer [env]] 5 | [clojure.spec.alpha :as s] 6 | [expound.alpha :as expound] 7 | [mount.core :as mount] 8 | [multi-client-ws-aleph.figwheel :refer [start-fw stop-fw cljs]] 9 | [multi-client-ws-aleph.core :refer [start-app]])) 10 | 11 | (alter-var-root #'s/*explain-out* (constantly expound/printer)) 12 | 13 | (add-tap (bound-fn* clojure.pprint/pprint)) 14 | 15 | (defn start 16 | "Starts application. 17 | You'll usually want to run this on startup." 18 | [] 19 | (mount/start-without #'multi-client-ws-aleph.core/repl-server)) 20 | 21 | (defn stop 22 | "Stops application." 23 | [] 24 | (mount/stop-except #'multi-client-ws-aleph.core/repl-server)) 25 | 26 | (defn restart 27 | "Restarts application." 28 | [] 29 | (stop) 30 | (start)) 31 | 32 | 33 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/src/cljs/multi_client_ws_aleph/websockets.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws.websockets 2 | (:require [cognitect.transit :as t])) 3 | 4 | (defonce ws-chan (atom nil)) 5 | (def json-reader (t/reader :json)) 6 | (def json-writer (t/writer :json)) 7 | 8 | (defn receive-transit-msg! 9 | [update-fn] 10 | (fn [msg] 11 | (update-fn 12 | (->> msg .-data (t/read json-reader))))) 13 | 14 | (defn send-transit-msg! 15 | [msg] 16 | (if @ws-chan 17 | (.send @ws-chan (t/write json-writer msg)) 18 | (throw (js/Error. "Websocket is not available!")))) 19 | 20 | (defn make-websocket! [url receive-handler] 21 | (println "attempting to connect websocket") 22 | (if-let [chan (js/WebSocket. url)] 23 | (do 24 | (set! (.-onmessage chan) (receive-transit-msg! receive-handler)) 25 | (reset! ws-chan chan) 26 | (println "Websocket connection established with: " url)) 27 | (throw (js/Error. "Websocket connection failed!")))) 28 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/test/clj/multi_client_ws_http_kit/test/handler.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.test.handler 2 | (:require 3 | [clojure.test :refer :all] 4 | [ring.mock.request :refer :all] 5 | [multi-client-ws-http-kit.handler :refer :all] 6 | [multi-client-ws-http-kit.middleware.formats :as formats] 7 | [muuntaja.core :as m] 8 | [mount.core :as mount])) 9 | 10 | (defn parse-json [body] 11 | (m/decode formats/instance "application/json" body)) 12 | 13 | (use-fixtures 14 | :once 15 | (fn [f] 16 | (mount/start #'multi-client-ws-http-kit.config/env 17 | #'multi-client-ws-http-kit.handler/app-routes) 18 | (f))) 19 | 20 | (deftest test-app 21 | (testing "main route" 22 | (let [response ((app) (request :get "/"))] 23 | (is (= 200 (:status response))))) 24 | 25 | (testing "not-found route" 26 | (let [response ((app) (request :get "/invalid"))] 27 | (is (= 404 (:status response)))))) 28 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/test/clj/multi_client_ws_immutant/test/handler.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.test.handler 2 | (:require 3 | [clojure.test :refer :all] 4 | [ring.mock.request :refer :all] 5 | [multi-client-ws-immutant.handler :refer :all] 6 | [multi-client-ws-immutant.middleware.formats :as formats] 7 | [muuntaja.core :as m] 8 | [mount.core :as mount])) 9 | 10 | (defn parse-json [body] 11 | (m/decode formats/instance "application/json" body)) 12 | 13 | (use-fixtures 14 | :once 15 | (fn [f] 16 | (mount/start #'multi-client-ws-immutant.config/env 17 | #'multi-client-ws-immutant.handler/app-routes) 18 | (f))) 19 | 20 | (deftest test-app 21 | (testing "main route" 22 | (let [response ((app) (request :get "/"))] 23 | (is (= 200 (:status response))))) 24 | 25 | (testing "not-found route" 26 | (let [response ((app) (request :get "/invalid"))] 27 | (is (= 404 (:status response)))))) 28 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/src/cljs/multi_client_ws_http_kit/websockets.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws.websockets 2 | (:require [cognitect.transit :as t])) 3 | 4 | (defonce ws-chan (atom nil)) 5 | (def json-reader (t/reader :json)) 6 | (def json-writer (t/writer :json)) 7 | 8 | (defn receive-transit-msg! 9 | [update-fn] 10 | (fn [msg] 11 | (update-fn 12 | (->> msg .-data (t/read json-reader))))) 13 | 14 | (defn send-transit-msg! 15 | [msg] 16 | (if @ws-chan 17 | (.send @ws-chan (t/write json-writer msg)) 18 | (throw (js/Error. "Websocket is not available!")))) 19 | 20 | (defn make-websocket! [url receive-handler] 21 | (println "attempting to connect websocket") 22 | (if-let [chan (js/WebSocket. url)] 23 | (do 24 | (set! (.-onmessage chan) (receive-transit-msg! receive-handler)) 25 | (reset! ws-chan chan) 26 | (println "Websocket connection established with: " url)) 27 | (throw (js/Error. "Websocket connection failed!")))) 28 | -------------------------------------------------------------------------------- /swagger-service/test/clj/swagger_service/test/handler.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns swagger-service.test.handler 10 | (:require [clojure.test :refer :all] 11 | [ring.mock.request :refer :all] 12 | [swagger-service.handler :refer :all])) 13 | 14 | (deftest test-app 15 | (testing "main route" 16 | (let [response (app (request :get "/"))] 17 | (is (= 200 (:status response))))) 18 | 19 | (testing "not-found route" 20 | (let [response (app (request :get "/invalid"))] 21 | (is (= 404 (:status response)))))) 22 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/dev/clj/user.clj: -------------------------------------------------------------------------------- 1 | (ns user 2 | "Userspace functions you can run by default in your local REPL." 3 | (:require 4 | [multi-client-ws-http-kit.config :refer [env]] 5 | [clojure.spec.alpha :as s] 6 | [expound.alpha :as expound] 7 | [mount.core :as mount] 8 | [multi-client-ws-http-kit.figwheel :refer [start-fw stop-fw cljs]] 9 | [multi-client-ws-http-kit.core :refer [start-app]])) 10 | 11 | (alter-var-root #'s/*explain-out* (constantly expound/printer)) 12 | 13 | (add-tap (bound-fn* clojure.pprint/pprint)) 14 | 15 | (defn start 16 | "Starts application. 17 | You'll usually want to run this on startup." 18 | [] 19 | (mount/start-without #'multi-client-ws-http-kit.core/repl-server)) 20 | 21 | (defn stop 22 | "Stops application." 23 | [] 24 | (mount/stop-except #'multi-client-ws-http-kit.core/repl-server)) 25 | 26 | (defn restart 27 | "Restarts application." 28 | [] 29 | (stop) 30 | (start)) 31 | 32 | 33 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/env/dev/clj/user.clj: -------------------------------------------------------------------------------- 1 | (ns user 2 | "Userspace functions you can run by default in your local REPL." 3 | (:require 4 | [multi-client-ws-immutant.config :refer [env]] 5 | [clojure.spec.alpha :as s] 6 | [expound.alpha :as expound] 7 | [mount.core :as mount] 8 | [multi-client-ws-immutant.figwheel :refer [start-fw stop-fw cljs]] 9 | [multi-client-ws-immutant.core :refer [start-app]])) 10 | 11 | (alter-var-root #'s/*explain-out* (constantly expound/printer)) 12 | 13 | (add-tap (bound-fn* clojure.pprint/pprint)) 14 | 15 | (defn start 16 | "Starts application. 17 | You'll usually want to run this on startup." 18 | [] 19 | (mount/start-without #'multi-client-ws-immutant.core/repl-server)) 20 | 21 | (defn stop 22 | "Stops application." 23 | [] 24 | (mount/stop-except #'multi-client-ws-immutant.core/repl-server)) 25 | 26 | (defn restart 27 | "Restarts application." 28 | [] 29 | (stop) 30 | (start)) 31 | 32 | 33 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/src/cljs/multi_client_ws_immutant/websockets.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws.websockets 2 | (:require [cognitect.transit :as t])) 3 | 4 | (defonce ws-chan (atom nil)) 5 | (def json-reader (t/reader :json)) 6 | (def json-writer (t/writer :json)) 7 | 8 | (defn receive-transit-msg! 9 | [update-fn] 10 | (fn [msg] 11 | (update-fn 12 | (->> msg .-data (t/read json-reader))))) 13 | 14 | (defn send-transit-msg! 15 | [msg] 16 | (if @ws-chan 17 | (.send @ws-chan (t/write json-writer msg)) 18 | (throw (js/Error. "Websocket is not available!")))) 19 | 20 | (defn make-websocket! [url receive-handler] 21 | (println "attempting to connect websocket") 22 | (if-let [chan (js/WebSocket. url)] 23 | (do 24 | (set! (.-onmessage chan) (receive-transit-msg! receive-handler)) 25 | (reset! ws-chan chan) 26 | (println "Websocket connection established with: " url)) 27 | (throw (js/Error. "Websocket connection failed!")))) 28 | 29 | -------------------------------------------------------------------------------- /reporting-example/test/clj/reporting_example/test/handler.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns reporting-example.test.handler 10 | (:require [clojure.test :refer :all] 11 | [ring.mock.request :refer :all] 12 | [reporting-example.handler :refer :all])) 13 | 14 | (deftest test-app 15 | (testing "main route" 16 | (let [response (app (request :get "/"))] 17 | (is (= 200 (:status response))))) 18 | 19 | (testing "not-found route" 20 | (let [response (app (request :get "/invalid"))] 21 | (is (= 404 (:status response)))))) 22 | -------------------------------------------------------------------------------- /swagger-service/src/cljs/swagger_service/ajax.cljs: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns swagger-service.ajax 10 | (:require [ajax.core :as ajax])) 11 | 12 | (defn default-headers [request] 13 | (update 14 | request 15 | :headers 16 | #(merge 17 | {"Accept" "application/transit+json" 18 | "x-csrf-token" js/csrfToken} 19 | %))) 20 | 21 | (defn load-interceptors! [] 22 | (swap! ajax/default-interceptors 23 | conj 24 | (ajax/to-interceptor {:name "default headers" 25 | :request default-headers}))) 26 | 27 | 28 | -------------------------------------------------------------------------------- /guestbook-datomic/src/clj/guestbook_datomic/handler.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.handler 2 | (:require 3 | [guestbook-datomic.layout :refer [error-page]] 4 | [guestbook-datomic.routes.home :refer [home-routes]] 5 | [compojure.core :refer [routes wrap-routes]] 6 | [compojure.route :as route] 7 | [guestbook-datomic.env :refer [defaults]] 8 | [mount.core :as mount] 9 | [guestbook-datomic.middleware :as middleware])) 10 | 11 | (mount/defstate init-app 12 | :start ((or (:init defaults) identity)) 13 | :stop ((or (:stop defaults) identity))) 14 | 15 | (mount/defstate app 16 | :start 17 | (middleware/wrap-base 18 | (routes 19 | (-> #'home-routes 20 | (wrap-routes middleware/wrap-csrf) 21 | (wrap-routes middleware/wrap-formats)) 22 | (route/not-found 23 | (:body 24 | (error-page {:status 404 25 | :title "page not found"})))))) 26 | 27 | -------------------------------------------------------------------------------- /file-upload-progress/src/clj/file_upload_progress/handler.clj: -------------------------------------------------------------------------------- 1 | (ns file-upload-progress.handler 2 | (:require [compojure.core :refer [routes wrap-routes]] 3 | [file-upload-progress.layout :refer [error-page]] 4 | [file-upload-progress.routes.home :refer [home-routes]] 5 | [compojure.route :as route] 6 | [file-upload-progress.env :refer [defaults]] 7 | [mount.core :as mount] 8 | [file-upload-progress.middleware :as middleware])) 9 | 10 | (mount/defstate init-app 11 | :start ((or (:init defaults) identity)) 12 | :stop ((or (:stop defaults) identity))) 13 | 14 | (def app-routes 15 | (routes 16 | (-> #'home-routes 17 | (wrap-routes middleware/wrap-csrf) 18 | (wrap-routes middleware/wrap-formats)) 19 | (route/not-found 20 | (:body 21 | (error-page {:status 404 22 | :title "page not found"}))))) 23 | 24 | 25 | (defn app [] (middleware/wrap-base #'app-routes)) 26 | -------------------------------------------------------------------------------- /file-upload-progress/resources/templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block content %} 3 | 4 |
5 |
6 | File Upload Progress Example 7 | 8 | 9 |
10 |
11 |
12 |
13 | 14 |
15 |
16 |
17 |
18 |

upload progress

19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | {% endblock %} 30 | -------------------------------------------------------------------------------- /guestbook/src/clj/guestbook/nrepl.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.nrepl 2 | (:require 3 | [nrepl.server :as nrepl] 4 | [clojure.tools.logging :as log])) 5 | 6 | (defn start 7 | "Start a network repl for debugging on specified port followed by 8 | an optional parameters map. The :bind, :transport-fn, :handler, 9 | :ack-port and :greeting-fn will be forwarded to 10 | clojure.tools.nrepl.server/start-server as they are." 11 | [{:keys [port bind transport-fn handler ack-port greeting-fn]}] 12 | (try 13 | (log/info "starting nREPL server on port" port) 14 | (nrepl/start-server :port port 15 | :bind bind 16 | :transport-fn transport-fn 17 | :handler handler 18 | :ack-port ack-port 19 | :greeting-fn greeting-fn) 20 | 21 | (catch Throwable t 22 | (log/error t "failed to start nREPL") 23 | (throw t)))) 24 | 25 | (defn stop [server] 26 | (nrepl/stop-server server) 27 | (log/info "nREPL server stopped")) 28 | -------------------------------------------------------------------------------- /guestbook-sente/src/clj/guestbook/nrepl.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.nrepl 2 | (:require 3 | [nrepl.server :as nrepl] 4 | [clojure.tools.logging :as log])) 5 | 6 | (defn start 7 | "Start a network repl for debugging on specified port followed by 8 | an optional parameters map. The :bind, :transport-fn, :handler, 9 | :ack-port and :greeting-fn will be forwarded to 10 | clojure.tools.nrepl.server/start-server as they are." 11 | [{:keys [port bind transport-fn handler ack-port greeting-fn]}] 12 | (try 13 | (log/info "starting nREPL server on port" port) 14 | (nrepl/start-server :port port 15 | :bind bind 16 | :transport-fn transport-fn 17 | :handler handler 18 | :ack-port ack-port 19 | :greeting-fn greeting-fn) 20 | 21 | (catch Throwable t 22 | (log/error t "failed to start nREPL") 23 | (throw t)))) 24 | 25 | (defn stop [server] 26 | (nrepl/stop-server server) 27 | (log/info "nREPL server stopped")) 28 | -------------------------------------------------------------------------------- /guestbook-datomic/src/clj/guestbook_datomic/routes/home.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.routes.home 2 | (:require [guestbook-datomic.layout :as layout] 3 | [guestbook-datomic.db.core :as db] 4 | [guestbook-datomic.validation :refer [validate-message]] 5 | [compojure.core :refer [defroutes GET POST]] 6 | [ring.util.http-response :as response] 7 | [clojure.java.io :as io])) 8 | 9 | (defn home-page [] 10 | (layout/render "home.html")) 11 | 12 | (defn save-message! [{:keys [params]}] 13 | (if-let [errors (validate-message params)] 14 | (response/bad-request {:errors errors}) 15 | (try 16 | (db/add-message db/conn params) 17 | (response/ok {:status :ok}) 18 | (catch Exception e 19 | (response/internal-server-error 20 | {:errors {:server-error ["Failed to save message!"]}}))))) 21 | 22 | (defroutes home-routes 23 | (GET "/" [] 24 | (home-page)) 25 | (GET "/messages" [] (response/ok (db/get-messages db/conn))) 26 | (POST "/message" req (save-message! req))) 27 | -------------------------------------------------------------------------------- /guestbook-cljs/src/clj/guestbook/db/core.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns guestbook.db.core 10 | (:require 11 | [conman.core :as conman] 12 | [mount.core :refer [defstate]] 13 | [guestbook.config :refer [env]])) 14 | 15 | (defstate ^:dynamic *db* 16 | :start (conman/connect! 17 | {:datasource 18 | (doto (org.h2.jdbcx.JdbcDataSource.) 19 | (.setURL (env :database-url)) 20 | (.setUser "") 21 | (.setPassword ""))}) 22 | :stop (conman/disconnect! *db*)) 23 | 24 | (conman/bind-connection *db* "sql/queries.sql") 25 | -------------------------------------------------------------------------------- /guestbook/src/clj/guestbook/db/core.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.db.core 2 | (:require 3 | [next.jdbc.date-time] 4 | [next.jdbc.result-set] 5 | [conman.core :as conman] 6 | [mount.core :refer [defstate]] 7 | [guestbook.config :refer [env]])) 8 | 9 | (defstate ^:dynamic *db* 10 | :start (conman/connect! {:jdbc-url (env :database-url)}) 11 | :stop (conman/disconnect! *db*)) 12 | 13 | (conman/bind-connection *db* "sql/queries.sql") 14 | 15 | (extend-protocol next.jdbc.result-set/ReadableColumn 16 | java.sql.Timestamp 17 | (read-column-by-label [^java.sql.Timestamp v _] 18 | (.toLocalDateTime v)) 19 | (read-column-by-index [^java.sql.Timestamp v _2 _3] 20 | (.toLocalDateTime v)) 21 | java.sql.Date 22 | (read-column-by-label [^java.sql.Date v _] 23 | (.toLocalDate v)) 24 | (read-column-by-index [^java.sql.Date v _2 _3] 25 | (.toLocalDate v)) 26 | java.sql.Time 27 | (read-column-by-label [^java.sql.Time v _] 28 | (.toLocalTime v)) 29 | (read-column-by-index [^java.sql.Time v _2 _3] 30 | (.toLocalTime v))) 31 | -------------------------------------------------------------------------------- /guestbook-cljs/src/clj/guestbook/handler.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns guestbook.handler 10 | (:require [compojure.core :refer [routes wrap-routes]] 11 | [guestbook.layout :refer [error-page]] 12 | [guestbook.routes.home :refer [home-routes]] 13 | [compojure.route :as route] 14 | [guestbook.middleware :as middleware])) 15 | 16 | (def app-routes 17 | (routes 18 | (wrap-routes #'home-routes middleware/wrap-csrf) 19 | (route/not-found 20 | (:body 21 | (error-page {:status 404 22 | :title "page not found"}))))) 23 | 24 | (def app (middleware/wrap-base #'app-routes)) 25 | -------------------------------------------------------------------------------- /guestbook-sente/src/cljs/guestbook/ajax.cljs: -------------------------------------------------------------------------------- 1 | (ns guestbook.ajax 2 | (:require 3 | [ajax.core :as ajax] 4 | [luminus-transit.time :as time] 5 | [cognitect.transit :as transit])) 6 | 7 | (defn local-uri? [{:keys [uri]}] 8 | (not (re-find #"^\w+?://" uri))) 9 | 10 | (defn default-headers [request] 11 | (if (local-uri? request) 12 | (-> request 13 | (update :headers #(merge {"x-csrf-token" js/csrfToken} %))) 14 | request)) 15 | 16 | ;; injects transit serialization config into request options 17 | (defn as-transit [opts] 18 | (merge {:raw false 19 | :format :transit 20 | :response-format :transit 21 | :reader (transit/reader :json time/time-deserialization-handlers) 22 | :writer (transit/writer :json time/time-serialization-handlers)} 23 | opts)) 24 | 25 | (defn load-interceptors! [] 26 | (swap! ajax/default-interceptors 27 | conj 28 | (ajax/to-interceptor {:name "default headers" 29 | :request default-headers}))) 30 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/src/clj/multi_client_ws_aleph/nrepl.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.nrepl 2 | (:require 3 | [nrepl.server :as nrepl] 4 | [clojure.tools.logging :as log])) 5 | 6 | (defn start 7 | "Start a network repl for debugging on specified port followed by 8 | an optional parameters map. The :bind, :transport-fn, :handler, 9 | :ack-port and :greeting-fn will be forwarded to 10 | clojure.tools.nrepl.server/start-server as they are." 11 | [{:keys [port bind transport-fn handler ack-port greeting-fn]}] 12 | (try 13 | (log/info "starting nREPL server on port" port) 14 | (nrepl/start-server :port port 15 | :bind bind 16 | :transport-fn transport-fn 17 | :handler handler 18 | :ack-port ack-port 19 | :greeting-fn greeting-fn) 20 | 21 | (catch Throwable t 22 | (log/error t "failed to start nREPL") 23 | (throw t)))) 24 | 25 | (defn stop [server] 26 | (nrepl/stop-server server) 27 | (log/info "nREPL server stopped")) 28 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/src/clj/multi_client_ws_http_kit/nrepl.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.nrepl 2 | (:require 3 | [nrepl.server :as nrepl] 4 | [clojure.tools.logging :as log])) 5 | 6 | (defn start 7 | "Start a network repl for debugging on specified port followed by 8 | an optional parameters map. The :bind, :transport-fn, :handler, 9 | :ack-port and :greeting-fn will be forwarded to 10 | clojure.tools.nrepl.server/start-server as they are." 11 | [{:keys [port bind transport-fn handler ack-port greeting-fn]}] 12 | (try 13 | (log/info "starting nREPL server on port" port) 14 | (nrepl/start-server :port port 15 | :bind bind 16 | :transport-fn transport-fn 17 | :handler handler 18 | :ack-port ack-port 19 | :greeting-fn greeting-fn) 20 | 21 | (catch Throwable t 22 | (log/error t "failed to start nREPL") 23 | (throw t)))) 24 | 25 | (defn stop [server] 26 | (nrepl/stop-server server) 27 | (log/info "nREPL server stopped")) 28 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/src/clj/multi_client_ws_immutant/nrepl.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.nrepl 2 | (:require 3 | [nrepl.server :as nrepl] 4 | [clojure.tools.logging :as log])) 5 | 6 | (defn start 7 | "Start a network repl for debugging on specified port followed by 8 | an optional parameters map. The :bind, :transport-fn, :handler, 9 | :ack-port and :greeting-fn will be forwarded to 10 | clojure.tools.nrepl.server/start-server as they are." 11 | [{:keys [port bind transport-fn handler ack-port greeting-fn]}] 12 | (try 13 | (log/info "starting nREPL server on port" port) 14 | (nrepl/start-server :port port 15 | :bind bind 16 | :transport-fn transport-fn 17 | :handler handler 18 | :ack-port ack-port 19 | :greeting-fn greeting-fn) 20 | 21 | (catch Throwable t 22 | (log/error t "failed to start nREPL") 23 | (throw t)))) 24 | 25 | (defn stop [server] 26 | (nrepl/stop-server server) 27 | (log/info "nREPL server stopped")) 28 | -------------------------------------------------------------------------------- /swagger-service/resources/docs/docs.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### Managing Your Middleware 4 | 5 | Request middleware functions are located under the `swagger-service.middleware` namespace. 6 | 7 | This namespace is reserved for any custom middleware for the application. Some default middleware is 8 | already defined here. The middleware is assembled in the `wrap-base` function. 9 | 10 | Middleware used for development is placed in the `swagger-service.dev-middleware` namespace found in 11 | the `env/dev/clj/` source path. 12 | 13 | ### Here are some links to get started 14 | 15 | 1. [HTML templating](http://www.luminusweb.net/docs/html_templating.md) 16 | 2. [Accessing the database](http://www.luminusweb.net/docs/database.md) 17 | 3. [Setting response types](http://www.luminusweb.net/docs/responses.md) 18 | 4. [Defining routes](http://www.luminusweb.net/docs/routes.md) 19 | 5. [Adding middleware](http://www.luminusweb.net/docs/middleware.md) 20 | 6. [Sessions and cookies](http://www.luminusweb.net/docs/sessions_cookies.md) 21 | 7. [Security](http://www.luminusweb.net/docs/security.md) 22 | 8. [Deploying the application](http://www.luminusweb.net/docs/deployment.md) 23 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Dmitri Sotnikov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /reporting-example/resources/templates/home.html: -------------------------------------------------------------------------------- 1 | 9 | {% extends "base.html" %} 10 | {% block content %} 11 |
12 |
13 |

Select report type:

14 | 22 | {% if error %} 23 |

An error has occurred while generating the report:

24 |
{{error}}
25 | {% endif %} 26 |
27 |
28 | {% endblock %} 29 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/src/clj/multi_client_ws_http_kit/routes/home.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.routes.home 2 | (:require 3 | [clojure.tools.logging :as log] 4 | [multi-client-ws-http-kit.layout :as layout] 5 | [multi-client-ws-http-kit.middleware :as middleware] 6 | [ring.util.http-response :as response] 7 | [org.httpkit.server :refer [send! with-channel on-close on-receive]])) 8 | 9 | (defonce channels (atom #{})) 10 | 11 | (defn notify-clients [msg] 12 | (doseq [channel @channels] 13 | (send! channel msg))) 14 | 15 | (defn connect! [channel] 16 | (log/info "channel open") 17 | (swap! channels conj channel)) 18 | 19 | (defn disconnect! [channel status] 20 | (log/info "channel closed:" status) 21 | (swap! channels #(remove #{channel} %))) 22 | 23 | (defn ws-handler [request] 24 | (with-channel request channel 25 | (connect! channel) 26 | (on-close channel (partial disconnect! channel)) 27 | (on-receive channel notify-clients))) 28 | 29 | (defn home-page [request] 30 | (layout/render request "home.html")) 31 | 32 | (defn home-routes [] 33 | ["" 34 | {:middleware [middleware/wrap-csrf]} 35 | ["/" {:get home-page}] 36 | ["/ws" {:get ws-handler}]]) 37 | 38 | -------------------------------------------------------------------------------- /reporting-example/src/clj/reporting_example/db/migrations.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns reporting-example.db.migrations 10 | (:require 11 | [migratus.core :as migratus] 12 | [config.core :refer [env]] 13 | [to-jdbc-uri.core :refer [to-jdbc-uri]])) 14 | 15 | (defn parse-ids [args] 16 | (map #(Long/parseLong %) (rest args))) 17 | 18 | (defn migrate [args] 19 | (let [config {:store :database 20 | :db {:connection-uri (to-jdbc-uri (:database-url env))}}] 21 | (case (first args) 22 | "migrate" 23 | (if (> (count args) 1) 24 | (apply migratus/up config (parse-ids args)) 25 | (migratus/migrate config)) 26 | "rollback" 27 | (if (> (count args) 1) 28 | (apply migratus/down config (parse-ids args)) 29 | (migratus/rollback config))))) 30 | -------------------------------------------------------------------------------- /guestbook-datomic/env/prod/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | log/guestbook-datomic.log 6 | 7 | log/guestbook-datomic.%d{yyyy-MM-dd}.%i.log 8 | 9 | 100MB 10 | 11 | 12 | 30 13 | 14 | 15 | UTF-8 16 | %date{ISO8601} [%thread] %-5level %logger{36} - %msg %n 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /guestbook-sente/src/clj/guestbook/db/core.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.db.core 2 | (:require 3 | [clojure.java.jdbc :as jdbc] 4 | [conman.core :as conman] 5 | [java-time.pre-java8 :as jt] 6 | [mount.core :refer [defstate]] 7 | [guestbook.config :refer [env]])) 8 | 9 | (defstate ^:dynamic *db* 10 | :start (conman/connect! {:jdbc-url (env :database-url)}) 11 | :stop (conman/disconnect! *db*)) 12 | 13 | (conman/bind-connection *db* "sql/queries.sql") 14 | 15 | 16 | (extend-protocol jdbc/IResultSetReadColumn 17 | java.sql.Timestamp 18 | (result-set-read-column [v _2 _3] 19 | (.toLocalDateTime v)) 20 | java.sql.Date 21 | (result-set-read-column [v _2 _3] 22 | (.toLocalDate v)) 23 | java.sql.Time 24 | (result-set-read-column [v _2 _3] 25 | (.toLocalTime v))) 26 | 27 | (extend-protocol jdbc/ISQLValue 28 | java.util.Date 29 | (sql-value [v] 30 | (java.sql.Timestamp. (.getTime v))) 31 | java.time.LocalTime 32 | (sql-value [v] 33 | (jt/sql-time v)) 34 | java.time.LocalDate 35 | (sql-value [v] 36 | (jt/sql-date v)) 37 | java.time.LocalDateTime 38 | (sql-value [v] 39 | (jt/sql-timestamp v)) 40 | java.time.ZonedDateTime 41 | (sql-value [v] 42 | (jt/sql-timestamp v))) 43 | 44 | -------------------------------------------------------------------------------- /file-upload-progress/env/prod/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | log/file-upload-progress.log 6 | 7 | log/file-upload-progress.%d{yyyy-MM-dd}.%i.log 8 | 9 | 100MB 10 | 11 | 12 | 30 13 | 14 | 15 | UTF-8 16 | %date{ISO8601} [%thread] %-5level %logger{36} - %msg %n 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/src/clj/multi_client_ws_aleph/routes/home.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.routes.home 2 | (:require 3 | [multi-client-ws-aleph.layout :as layout] 4 | [multi-client-ws-aleph.middleware :as middleware] 5 | [ring.util.http-response :as response] 6 | [clojure.tools.logging :as log] 7 | [aleph.http :as http] 8 | [manifold.stream :as s] 9 | [manifold.deferred :as d] 10 | [manifold.bus :as bus])) 11 | 12 | (defn home-page [request] 13 | (layout/render request "home.html")) 14 | 15 | (def events (bus/event-bus)) 16 | 17 | (defn chat-handler [req] 18 | (log/info "got a Websocket request from:" (:uri req)) 19 | (d/let-flow [conn (d/catch 20 | (http/websocket-connection req) 21 | (fn [_] nil))] 22 | (if-not conn 23 | (response/bad-request "Expected a websocket request.") 24 | (do 25 | (s/connect (bus/subscribe events "chat") conn) 26 | (s/consume #(bus/publish! events "chat" %) (s/buffer 100 conn))))) 27 | ;; return nil to Ring handler 28 | nil) 29 | 30 | (defn home-routes [] 31 | ["" 32 | {:middleware [middleware/wrap-csrf 33 | middleware/wrap-formats]} 34 | ["/" {:get home-page}] 35 | ["/ws" {:get chat-handler}]]) 36 | 37 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/prod/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | log/multi-client-ws-http-kit.log 6 | 7 | log/multi-client-ws-http-kit.%d{yyyy-MM-dd}.%i.log 8 | 9 | 100MB 10 | 11 | 12 | 30 13 | 14 | 15 | UTF-8 16 | %date{ISO8601} [%thread] %-5level %logger{36} - %msg %n 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/env/prod/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | log/multi-client-ws-immutant.log 6 | 7 | log/multi-client-ws-immutant.%d{yyyy-MM-dd}.%i.log 8 | 9 | 100MB 10 | 11 | 12 | 30 13 | 14 | 15 | UTF-8 16 | %date{ISO8601} [%thread] %-5level %logger{36} - %msg %n 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /guestbook-sente/env/prod/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | log/guestbook.log 6 | 7 | log/guestbook.%d{yyyy-MM-dd}.%i.log 8 | 9 | 100MB 10 | 11 | 12 | 30 13 | 14 | 15 | UTF-8 16 | %date{ISO8601} [%thread] %-5level %logger{36} - %msg %n 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /guestbook-sente/src/clj/guestbook/handler.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.handler 2 | (:require 3 | [guestbook.middleware :as middleware] 4 | [guestbook.layout :refer [error-page]] 5 | [guestbook.routes.home :refer [home-routes]] 6 | [reitit.ring :as ring] 7 | [ring.middleware.content-type :refer [wrap-content-type]] 8 | [ring.middleware.webjars :refer [wrap-webjars]] 9 | [guestbook.env :refer [defaults]] 10 | [mount.core :as mount])) 11 | 12 | (mount/defstate init-app 13 | :start ((or (:init defaults) identity)) 14 | :stop ((or (:stop defaults) identity))) 15 | 16 | (mount/defstate app 17 | :start 18 | (middleware/wrap-base 19 | (ring/ring-handler 20 | (ring/router 21 | [(home-routes)]) 22 | (ring/routes 23 | (ring/create-resource-handler 24 | {:path "/"}) 25 | (wrap-content-type 26 | (wrap-webjars (constantly nil))) 27 | (ring/create-default-handler 28 | {:not-found 29 | (constantly (error-page {:status 404, :title "404 - Page not found"})) 30 | :method-not-allowed 31 | (constantly (error-page {:status 405, :title "405 - Not allowed"})) 32 | :not-acceptable 33 | (constantly (error-page {:status 406, :title "406 - Not acceptable"}))}))))) 34 | -------------------------------------------------------------------------------- /guestbook-sente/test/clj/guestbook/test/db/core.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.test.db.core 2 | (:require 3 | [guestbook.db.core :refer [*db*] :as db] 4 | [luminus-migrations.core :as migrations] 5 | [clojure.test :refer :all] 6 | [clojure.java.jdbc :as jdbc] 7 | [guestbook.config :refer [env]] 8 | [mount.core :as mount])) 9 | 10 | (use-fixtures 11 | :once 12 | (fn [f] 13 | (mount/start 14 | #'guestbook.config/env 15 | #'guestbook.db.core/*db*) 16 | (migrations/migrate ["migrate"] (select-keys env [:database-url])) 17 | (f))) 18 | 19 | (deftest test-users 20 | (jdbc/with-db-transaction [t-conn *db*] 21 | (jdbc/db-set-rollback-only! t-conn) 22 | (is (= 1 (db/create-user! 23 | t-conn 24 | {:id "1" 25 | :first_name "Sam" 26 | :last_name "Smith" 27 | :email "sam.smith@example.com" 28 | :pass "pass"}))) 29 | (is (= {:id "1" 30 | :first_name "Sam" 31 | :last_name "Smith" 32 | :email "sam.smith@example.com" 33 | :pass "pass" 34 | :admin nil 35 | :last_login nil 36 | :is_active nil} 37 | (db/get-user t-conn {:id "1"}))))) 38 | -------------------------------------------------------------------------------- /guestbook-cljs/resources/public/css/screen.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 4 | height: 100%; 5 | } 6 | .navbar { 7 | margin-bottom: 10px; 8 | } 9 | .navbar-brand { 10 | float: none; 11 | } 12 | .navbar-nav .nav-item { 13 | float: none; 14 | } 15 | .navbar-divider, 16 | .navbar-nav .nav-item+.nav-item, 17 | .navbar-nav .nav-link + .nav-link { 18 | margin-left: 0; 19 | } 20 | @media (min-width: 34em) { 21 | .navbar-brand { 22 | float: left; 23 | } 24 | .navbar-nav .nav-item { 25 | float: left; 26 | } 27 | .navbar-divider, 28 | .navbar-nav .nav-item+.nav-item, 29 | .navbar-nav .nav-link + .nav-link { 30 | margin-left: 1rem; 31 | } 32 | } 33 | /*START:guestbook 34 | */ 35 | .content { 36 | background: white; 37 | width: 520px; 38 | } 39 | form, .error { 40 | width: 520px; 41 | padding: 30px; 42 | margin-bottom: 50px; 43 | position: relative; 44 | background: white; 45 | } 46 | ul { 47 | list-style: none; 48 | } 49 | 50 | li { 51 | position: relative; 52 | font-size: 16px; 53 | padding: 5px; 54 | border-bottom: 1px dotted #ccc; 55 | } 56 | 57 | li:last-child { 58 | border-bottom: none; 59 | } 60 | 61 | li time { 62 | font-size: 12px; 63 | padding-bottom: 20px; 64 | } 65 | /*END:guestbook 66 | */ 67 | 68 | -------------------------------------------------------------------------------- /guestbook/src/clj/guestbook/handler.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.handler 2 | (:require 3 | [guestbook.middleware :as middleware] 4 | [guestbook.layout :refer [error-page]] 5 | [guestbook.routes.home :refer [home-routes]] 6 | [reitit.ring :as ring] 7 | [ring.middleware.content-type :refer [wrap-content-type]] 8 | [ring.middleware.webjars :refer [wrap-webjars]] 9 | [guestbook.env :refer [defaults]] 10 | [mount.core :as mount])) 11 | 12 | (mount/defstate init-app 13 | :start ((or (:init defaults) (fn []))) 14 | :stop ((or (:stop defaults) (fn [])))) 15 | 16 | (mount/defstate app-routes 17 | :start 18 | (ring/ring-handler 19 | (ring/router 20 | [(home-routes)]) 21 | (ring/routes 22 | (ring/create-resource-handler 23 | {:path "/"}) 24 | (wrap-content-type 25 | (wrap-webjars (constantly nil))) 26 | (ring/create-default-handler 27 | {:not-found 28 | (constantly (error-page {:status 404, :title "404 - Page not found"})) 29 | :method-not-allowed 30 | (constantly (error-page {:status 405, :title "405 - Not allowed"})) 31 | :not-acceptable 32 | (constantly (error-page {:status 406, :title "406 - Not acceptable"}))})))) 33 | 34 | (defn app [] 35 | (middleware/wrap-base #'app-routes)) 36 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/resources/public/css/screen.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 4 | } 5 | @font-face { 6 | font-family: 'Material Icons'; 7 | font-style: normal; 8 | font-weight: 400; 9 | src: url(/assets/material-icons/iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */ 10 | src: local('Material Icons'), 11 | local('MaterialIcons-Regular'), 12 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff2) format('woff2'), 13 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff) format('woff'), 14 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.ttf) format('truetype'); 15 | } 16 | .material-icons { 17 | font-family: 'Material Icons'; 18 | font-weight: normal; 19 | font-style: normal; 20 | font-size: 24px; /* Preferred icon size */ 21 | display: inline-block; 22 | line-height: 1; 23 | text-transform: none; 24 | letter-spacing: normal; 25 | word-wrap: normal; 26 | white-space: nowrap; 27 | direction: ltr; 28 | /* Support for all WebKit browsers. */ 29 | -webkit-font-smoothing: antialiased; 30 | /* Support for Safari and Chrome. */ 31 | text-rendering: optimizeLegibility; 32 | /* Support for Firefox. */ 33 | -moz-osx-font-smoothing: grayscale; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/resources/public/css/screen.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 4 | } 5 | @font-face { 6 | font-family: 'Material Icons'; 7 | font-style: normal; 8 | font-weight: 400; 9 | src: url(/assets/material-icons/iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */ 10 | src: local('Material Icons'), 11 | local('MaterialIcons-Regular'), 12 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff2) format('woff2'), 13 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff) format('woff'), 14 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.ttf) format('truetype'); 15 | } 16 | .material-icons { 17 | font-family: 'Material Icons'; 18 | font-weight: normal; 19 | font-style: normal; 20 | font-size: 24px; /* Preferred icon size */ 21 | display: inline-block; 22 | line-height: 1; 23 | text-transform: none; 24 | letter-spacing: normal; 25 | word-wrap: normal; 26 | white-space: nowrap; 27 | direction: ltr; 28 | /* Support for all WebKit browsers. */ 29 | -webkit-font-smoothing: antialiased; 30 | /* Support for Safari and Chrome. */ 31 | text-rendering: optimizeLegibility; 32 | /* Support for Firefox. */ 33 | -moz-osx-font-smoothing: grayscale; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/resources/public/css/screen.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 4 | } 5 | @font-face { 6 | font-family: 'Material Icons'; 7 | font-style: normal; 8 | font-weight: 400; 9 | src: url(/assets/material-icons/iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */ 10 | src: local('Material Icons'), 11 | local('MaterialIcons-Regular'), 12 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff2) format('woff2'), 13 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff) format('woff'), 14 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.ttf) format('truetype'); 15 | } 16 | .material-icons { 17 | font-family: 'Material Icons'; 18 | font-weight: normal; 19 | font-style: normal; 20 | font-size: 24px; /* Preferred icon size */ 21 | display: inline-block; 22 | line-height: 1; 23 | text-transform: none; 24 | letter-spacing: normal; 25 | word-wrap: normal; 26 | white-space: nowrap; 27 | direction: ltr; 28 | /* Support for all WebKit browsers. */ 29 | -webkit-font-smoothing: antialiased; 30 | /* Support for Safari and Chrome. */ 31 | text-rendering: optimizeLegibility; 32 | /* Support for Firefox. */ 33 | -moz-osx-font-smoothing: grayscale; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/env/prod/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | log/multi-client-ws-aleph.log 6 | 7 | log/multi-client-ws-aleph.%d{yyyy-MM-dd}.%i.log 8 | 9 | 100MB 10 | 11 | 12 | 30 13 | 14 | 15 | UTF-8 16 | %date{ISO8601} [%thread] %-5level %logger{36} - %msg %n 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /guestbook/resources/html/home.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% block content %} 3 |
4 |
5 |
6 |

Messages

7 |
    8 | {% for item in messages %} 9 |
  • 10 | 11 |

    {{item.message}}

    12 |

    - {{item.name}}

    13 |
  • 14 | {% endfor %} 15 |
16 |
17 |
18 |
19 |
20 |
21 | {% csrf-field %} 22 |

23 | Name: 24 | 25 |

26 | {% if errors.name %} 27 |
{{errors.name|join}}
28 | {% endif %} 29 |

30 | Message: 31 | 32 |

33 | {% if errors.message %} 34 |
{{errors.message|join}}
35 | {% endif %} 36 | 37 |
38 |
39 |
40 |
41 | {% endblock %} -------------------------------------------------------------------------------- /multi-client-ws-aleph/src/cljs/multi_client_ws_aleph/core.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.core 2 | (:require 3 | [multi-client-ws.websockets :as ws] 4 | [reagent.core :as r])) 5 | 6 | (defonce messages (r/atom [])) 7 | 8 | (defn message-list [] 9 | [:ul 10 | (map-indexed 11 | (fn [id message] 12 | ^{:key id} 13 | [:li message]) 14 | @messages)]) 15 | 16 | (defn message-input [] 17 | (r/with-let [value (r/atom nil)] 18 | [:input.input 19 | {:type :text 20 | :placeholder "type in a message and press enter" 21 | :value @value 22 | :on-change #(reset! value (-> % .-target .-value)) 23 | :on-key-down #(when (= (.-keyCode %) 13) 24 | (ws/send-transit-msg! 25 | {:message @value}) 26 | (reset! value nil))}])) 27 | 28 | (defn home-page [] 29 | [:section.section>div.container>div.content 30 | [message-list] 31 | [:hr] 32 | [message-input]]) 33 | 34 | (defn update-messages! [{:keys [message]}] 35 | (swap! messages #(vec (take 10 (conj % message))))) 36 | 37 | (defn mount-components [] 38 | (r/render [#'home-page] (.getElementById js/document "app"))) 39 | 40 | (defn init! [] 41 | (ws/make-websocket! (str "ws://" (.-host js/location) "/ws") update-messages!) 42 | (mount-components)) 43 | -------------------------------------------------------------------------------- /swagger-service/env/prod/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Web Development with Clojure, Second Edition", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | #--- 9 | ### stdout appender 10 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 11 | log4j.appender.stdout.Target=System.out 12 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.stdout.layout.ConversionPattern=[%d][%p][%c] %m%n 14 | 15 | ### rolling file appender 16 | log4j.appender.R=org.apache.log4j.RollingFileAppender 17 | log4j.appender.R.File=./log/swagger-service.log 18 | 19 | log4j.appender.R.MaxFileSize=100KB 20 | log4j.appender.R.MaxBackupIndex=20 21 | 22 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 23 | log4j.appender.R.layout.ConversionPattern=[%d][%p][%c] %m%n 24 | 25 | ### suppress 3rd party debug logs 26 | log4j.logger.org.xnio.nio=INFO 27 | 28 | 29 | 30 | 31 | ### root logger sets the minimum logging level 32 | ### and aggregates the appenders 33 | log4j.rootLogger=INFO, stdout, R 34 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/src/cljs/multi_client_ws_immutant/core.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.core 2 | (:require 3 | [reagent.core :as r] 4 | [multi-client-ws.websockets :as ws])) 5 | 6 | (defonce messages (r/atom [])) 7 | 8 | (defn message-list [] 9 | [:ul 10 | (for [[i message] (map-indexed vector @messages)] 11 | ^{:key i} 12 | [:li message])]) 13 | 14 | (defn message-input [] 15 | (r/with-let [value (r/atom nil)] 16 | [:input.input 17 | {:type :text 18 | :placeholder "type in a message and press enter" 19 | :value @value 20 | :on-change #(reset! value (-> % .-target .-value)) 21 | :on-key-down #(when (= (.-keyCode %) 13) 22 | (ws/send-transit-msg! 23 | {:message @value}) 24 | (reset! value nil))}])) 25 | 26 | (defn home-page [] 27 | [:section.section>div.container>div.content 28 | [message-list] 29 | [:hr] 30 | [message-input]]) 31 | 32 | (defn mount-components [] 33 | (r/render [#'home-page] (.getElementById js/document "app"))) 34 | 35 | (defn update-messages! [{:keys [message]}] 36 | (swap! messages #(vec (take 10 (conj % message))))) 37 | 38 | (defn init! [] 39 | (ws/make-websocket! (str "ws://" (.-host js/location) "/ws") update-messages!) 40 | (mount-components)) 41 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/src/cljs/multi_client_ws_http_kit/core.cljs: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.core 2 | (:require 3 | [multi-client-ws.websockets :as ws] 4 | [reagent.core :as r])) 5 | 6 | (defonce messages (r/atom [])) 7 | 8 | (defn message-list [] 9 | [:ul 10 | (map-indexed 11 | (fn [id message] 12 | ^{:key id} 13 | [:li message]) 14 | @messages)]) 15 | 16 | (defn message-input [] 17 | (r/with-let [value (r/atom nil)] 18 | [:input.input 19 | {:type :text 20 | :placeholder "type in a message and press enter" 21 | :value @value 22 | :on-change #(reset! value (-> % .-target .-value)) 23 | :on-key-down #(when (= (.-keyCode %) 13) 24 | (ws/send-transit-msg! 25 | {:message @value}) 26 | (reset! value nil))}])) 27 | 28 | (defn home-page [] 29 | [:section.section>div.container>div.content 30 | [message-list] 31 | [:hr] 32 | [message-input]]) 33 | 34 | (defn update-messages! [{:keys [message]}] 35 | (swap! messages #(vec (take 10 (conj % message))))) 36 | 37 | (defn mount-components [] 38 | (r/render [#'home-page] (.getElementById js/document "app"))) 39 | 40 | (defn init! [] 41 | (ws/make-websocket! (str "ws://" (.-host js/location) "/ws") update-messages!) 42 | (mount-components)) 43 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/src/clj/multi_client_ws_immutant/routes/home.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.routes.home 2 | (:require 3 | [clojure.tools.logging :as log] 4 | [immutant.web.async :as async] 5 | [multi-client-ws-immutant.layout :as layout] 6 | [clojure.java.io :as io] 7 | [multi-client-ws-immutant.middleware :as middleware] 8 | [ring.util.http-response :as response])) 9 | 10 | (defonce channels (atom #{})) 11 | 12 | (defn notify-clients! [channel msg] 13 | (doseq [channel @channels] 14 | (async/send! channel msg))) 15 | 16 | (defn connect! [channel] 17 | (log/info "channel open") 18 | (swap! channels conj channel)) 19 | 20 | (defn disconnect! [channel {:keys [code reason]}] 21 | (log/info "close code:" code "reason:" reason) 22 | (swap! channels #(remove #{channel} %))) 23 | 24 | (def websocket-callbacks 25 | "WebSocket callback functions" 26 | {:on-open connect! 27 | :on-close disconnect! 28 | :on-message notify-clients!}) 29 | 30 | (defn ws-handler [request] 31 | (async/as-channel request websocket-callbacks)) 32 | 33 | (defn home-page [request] 34 | (layout/render request "home.html")) 35 | 36 | (defn home-routes [] 37 | ["" 38 | {:middleware [middleware/wrap-csrf 39 | middleware/wrap-formats]} 40 | ["/" {:get home-page}] 41 | ["/ws" {:get ws-handler}]]) 42 | 43 | -------------------------------------------------------------------------------- /swagger-service/env/dev/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Web Development with Clojure, Second Edition", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | #--- 9 | ### stdout appender 10 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 11 | log4j.appender.stdout.Target=System.out 12 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.stdout.layout.ConversionPattern=[%d][%p][%c] %m%n 14 | 15 | ### rolling file appender 16 | log4j.appender.R=org.apache.log4j.RollingFileAppender 17 | log4j.appender.R.File=./log/swagger-service.log 18 | 19 | log4j.appender.R.MaxFileSize=100KB 20 | log4j.appender.R.MaxBackupIndex=20 21 | 22 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 23 | log4j.appender.R.layout.ConversionPattern=[%d][%p][%c] %m%n 24 | 25 | ### suppress 3rd party debug logs 26 | log4j.logger.org.xnio.nio=INFO 27 | log4j.logger.org.apache.http=INFO 28 | 29 | ### root logger sets the minimum logging level 30 | ### and aggregates the appenders 31 | log4j.rootLogger=DEBUG, stdout, R 32 | -------------------------------------------------------------------------------- /guestbook-cljs/env/dev/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Web Development with Clojure, Second Edition", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | #--- 9 | ### stdout appender 10 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 11 | log4j.appender.stdout.Target=System.out 12 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.stdout.layout.ConversionPattern=[%d][%p][%c] %m%n 14 | 15 | ### rolling file appender 16 | log4j.appender.R=org.apache.log4j.RollingFileAppender 17 | log4j.appender.R.File=./log/guestbook.log 18 | 19 | log4j.appender.R.MaxFileSize=100KB 20 | log4j.appender.R.MaxBackupIndex=20 21 | 22 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 23 | log4j.appender.R.layout.ConversionPattern=[%d][%p][%c] %m%n 24 | 25 | ### suppress 3rd party debug logs 26 | log4j.logger.org.xnio.nio=INFO 27 | log4j.logger.com.zaxxer.hikari=INFO 28 | 29 | 30 | 31 | ### root logger sets the minimum logging level 32 | ### and aggregates the appenders 33 | log4j.rootLogger=DEBUG, stdout, R 34 | -------------------------------------------------------------------------------- /guestbook-cljs/env/prod/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Web Development with Clojure, Second Edition", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | #--- 9 | ### stdout appender 10 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 11 | log4j.appender.stdout.Target=System.out 12 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.stdout.layout.ConversionPattern=[%d][%p][%c] %m%n 14 | 15 | ### rolling file appender 16 | log4j.appender.R=org.apache.log4j.RollingFileAppender 17 | log4j.appender.R.File=./log/guestbook.log 18 | 19 | log4j.appender.R.MaxFileSize=100KB 20 | log4j.appender.R.MaxBackupIndex=20 21 | 22 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 23 | log4j.appender.R.layout.ConversionPattern=[%d][%p][%c] %m%n 24 | 25 | ### suppress 3rd party debug logs 26 | log4j.logger.org.xnio.nio=INFO 27 | log4j.logger.com.zaxxer.hikari=INFO 28 | 29 | 30 | 31 | ### root logger sets the minimum logging level 32 | ### and aggregates the appenders 33 | log4j.rootLogger=INFO, stdout, R 34 | -------------------------------------------------------------------------------- /guestbook-sente/env/dev/clj/user.clj: -------------------------------------------------------------------------------- 1 | (ns user 2 | (:require 3 | [guestbook.config :refer [env]] 4 | [clojure.spec.alpha :as s] 5 | [expound.alpha :as expound] 6 | [mount.core :as mount] 7 | [guestbook.figwheel :refer [start-fw stop-fw cljs]] 8 | [guestbook.core :refer [start-app]] 9 | [guestbook.db.core] 10 | [conman.core :as conman] 11 | [luminus-migrations.core :as migrations])) 12 | 13 | (alter-var-root #'s/*explain-out* (constantly expound/printer)) 14 | 15 | (defn start [] 16 | (mount/start-without #'guestbook.core/repl-server)) 17 | 18 | (defn stop [] 19 | (mount/stop-except #'guestbook.core/repl-server)) 20 | 21 | (defn restart [] 22 | (stop) 23 | (start)) 24 | 25 | (defn restart-db [] 26 | (mount/stop #'guestbook.db.core/*db*) 27 | (mount/start #'guestbook.db.core/*db*) 28 | (binding [*ns* 'guestbook.db.core] 29 | (conman/bind-connection guestbook.db.core/*db* "sql/queries.sql"))) 30 | 31 | (defn reset-db [] 32 | (migrations/migrate ["reset"] (select-keys env [:database-url]))) 33 | 34 | (defn migrate [] 35 | (migrations/migrate ["migrate"] (select-keys env [:database-url]))) 36 | 37 | (defn rollback [] 38 | (migrations/migrate ["rollback"] (select-keys env [:database-url]))) 39 | 40 | (defn create-migration [name] 41 | (migrations/create name (select-keys env [:database-url]))) 42 | 43 | 44 | -------------------------------------------------------------------------------- /reporting-example/env/dev/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Web Development with Clojure, Second Edition", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | #--- 9 | ### stdout appender 10 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 11 | log4j.appender.stdout.Target=System.out 12 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.stdout.layout.ConversionPattern=[%d][%p][%c] %m%n 14 | 15 | ### rolling file appender 16 | log4j.appender.R=org.apache.log4j.RollingFileAppender 17 | log4j.appender.R.File=./log/reporting-example.log 18 | 19 | log4j.appender.R.MaxFileSize=100KB 20 | log4j.appender.R.MaxBackupIndex=20 21 | 22 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 23 | log4j.appender.R.layout.ConversionPattern=[%d][%p][%c] %m%n 24 | 25 | ### suppress 3rd party debug logs 26 | log4j.logger.org.xnio.nio=INFO 27 | log4j.logger.com.zaxxer.hikari=INFO 28 | 29 | 30 | 31 | ### root logger sets the minimum logging level 32 | ### and aggregates the appenders 33 | log4j.rootLogger=DEBUG, stdout, R 34 | -------------------------------------------------------------------------------- /reporting-example/env/prod/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | #--- 2 | # Excerpted from "Web Development with Clojure, Second Edition", 3 | # published by The Pragmatic Bookshelf. 4 | # Copyrights apply to this code. It may not be used to create training material, 5 | # courses, books, articles, and the like. Contact us if you are in doubt. 6 | # We make no guarantees that this code is fit for any purpose. 7 | # Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | #--- 9 | ### stdout appender 10 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 11 | log4j.appender.stdout.Target=System.out 12 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.stdout.layout.ConversionPattern=[%d][%p][%c] %m%n 14 | 15 | ### rolling file appender 16 | log4j.appender.R=org.apache.log4j.RollingFileAppender 17 | log4j.appender.R.File=./log/reporting-example.log 18 | 19 | log4j.appender.R.MaxFileSize=100KB 20 | log4j.appender.R.MaxBackupIndex=20 21 | 22 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 23 | log4j.appender.R.layout.ConversionPattern=[%d][%p][%c] %m%n 24 | 25 | ### suppress 3rd party debug logs 26 | log4j.logger.org.xnio.nio=INFO 27 | log4j.logger.com.zaxxer.hikari=INFO 28 | 29 | 30 | 31 | ### root logger sets the minimum logging level 32 | ### and aggregates the appenders 33 | log4j.rootLogger=INFO, stdout, R 34 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/src/clj/multi_client_ws_aleph/handler.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.handler 2 | (:require 3 | [multi-client-ws-aleph.middleware :as middleware] 4 | [multi-client-ws-aleph.layout :refer [error-page]] 5 | [multi-client-ws-aleph.routes.home :refer [home-routes]] 6 | [reitit.ring :as ring] 7 | [ring.middleware.content-type :refer [wrap-content-type]] 8 | [ring.middleware.webjars :refer [wrap-webjars]] 9 | [multi-client-ws-aleph.env :refer [defaults]] 10 | [mount.core :as mount])) 11 | 12 | (mount/defstate init-app 13 | :start ((or (:init defaults) (fn []))) 14 | :stop ((or (:stop defaults) (fn [])))) 15 | 16 | (mount/defstate app-routes 17 | :start 18 | (ring/ring-handler 19 | (ring/router 20 | [(home-routes)]) 21 | (ring/routes 22 | (ring/create-resource-handler 23 | {:path "/"}) 24 | (wrap-content-type 25 | (wrap-webjars (constantly nil))) 26 | (ring/create-default-handler 27 | {:not-found 28 | (constantly (error-page {:status 404, :title "404 - Page not found"})) 29 | :method-not-allowed 30 | (constantly (error-page {:status 405, :title "405 - Not allowed"})) 31 | :not-acceptable 32 | (constantly (error-page {:status 406, :title "406 - Not acceptable"}))})))) 33 | 34 | (defn app [] 35 | (middleware/wrap-base #'app-routes)) 36 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/src/clj/multi_client_ws_http_kit/handler.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.handler 2 | (:require 3 | [multi-client-ws-http-kit.middleware :as middleware] 4 | [multi-client-ws-http-kit.layout :refer [error-page]] 5 | [multi-client-ws-http-kit.routes.home :refer [home-routes]] 6 | [reitit.ring :as ring] 7 | [ring.middleware.content-type :refer [wrap-content-type]] 8 | [ring.middleware.webjars :refer [wrap-webjars]] 9 | [multi-client-ws-http-kit.env :refer [defaults]] 10 | [mount.core :as mount])) 11 | 12 | (mount/defstate init-app 13 | :start ((or (:init defaults) (fn []))) 14 | :stop ((or (:stop defaults) (fn [])))) 15 | 16 | (mount/defstate app-routes 17 | :start 18 | (ring/ring-handler 19 | (ring/router 20 | [(home-routes)]) 21 | (ring/routes 22 | (ring/create-resource-handler 23 | {:path "/"}) 24 | (wrap-content-type 25 | (wrap-webjars (constantly nil))) 26 | (ring/create-default-handler 27 | {:not-found 28 | (constantly (error-page {:status 404, :title "404 - Page not found"})) 29 | :method-not-allowed 30 | (constantly (error-page {:status 405, :title "405 - Not allowed"})) 31 | :not-acceptable 32 | (constantly (error-page {:status 406, :title "406 - Not acceptable"}))})))) 33 | 34 | (defn app [] 35 | (middleware/wrap-base #'app-routes)) 36 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/src/clj/multi_client_ws_immutant/handler.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.handler 2 | (:require 3 | [multi-client-ws-immutant.middleware :as middleware] 4 | [multi-client-ws-immutant.layout :refer [error-page]] 5 | [multi-client-ws-immutant.routes.home :refer [home-routes]] 6 | [reitit.ring :as ring] 7 | [ring.middleware.content-type :refer [wrap-content-type]] 8 | [ring.middleware.webjars :refer [wrap-webjars]] 9 | [multi-client-ws-immutant.env :refer [defaults]] 10 | [mount.core :as mount])) 11 | 12 | (mount/defstate init-app 13 | :start ((or (:init defaults) (fn []))) 14 | :stop ((or (:stop defaults) (fn [])))) 15 | 16 | (mount/defstate app-routes 17 | :start 18 | (ring/ring-handler 19 | (ring/router 20 | [(home-routes)]) 21 | (ring/routes 22 | (ring/create-resource-handler 23 | {:path "/"}) 24 | (wrap-content-type 25 | (wrap-webjars (constantly nil))) 26 | (ring/create-default-handler 27 | {:not-found 28 | (constantly (error-page {:status 404, :title "404 - Page not found"})) 29 | :method-not-allowed 30 | (constantly (error-page {:status 405, :title "405 - Not allowed"})) 31 | :not-acceptable 32 | (constantly (error-page {:status 406, :title "406 - Not acceptable"}))})))) 33 | 34 | (defn app [] 35 | (middleware/wrap-base #'app-routes)) 36 | -------------------------------------------------------------------------------- /guestbook/test/clj/guestbook/test/db/core.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.test.db.core 2 | (:require 3 | [guestbook.db.core :refer [*db*] :as db] 4 | [java-time.pre-java8] 5 | [luminus-migrations.core :as migrations] 6 | [clojure.test :refer :all] 7 | [next.jdbc :as jdbc] 8 | [guestbook.config :refer [env]] 9 | [mount.core :as mount])) 10 | 11 | #_(use-fixtures 12 | :once 13 | (fn [f] 14 | (mount/start 15 | #'guestbook.config/env 16 | #'guestbook.db.core/*db*) 17 | (migrations/migrate ["migrate"] (select-keys env [:database-url])) 18 | (f))) 19 | 20 | (use-fixtures 21 | :once 22 | (fn [f] 23 | (mount/start 24 | #'guestbook.config/env 25 | #'guestbook.db.core/*db*) 26 | (migrations/migrate ["migrate"] (select-keys env [:database-url])) 27 | (f))) 28 | 29 | (deftest test-message 30 | (jdbc/with-transaction [t-conn *db*] 31 | (let [timestamp (java.time.LocalDateTime/now)] 32 | (is (= 1 (db/save-message! 33 | t-conn 34 | {:name "Bob" 35 | :message "Hello, World" 36 | :timestamp timestamp} 37 | {:connection t-conn}))) 38 | (is (= 39 | {:name "Bob" 40 | :message "Hello, World" 41 | :timestamp timestamp} 42 | (-> (db/get-messages t-conn {}) 43 | (first) 44 | (select-keys [:name :message :timestamp]))))))) 45 | 46 | -------------------------------------------------------------------------------- /file-upload-progress/resources/public/js/upload.js: -------------------------------------------------------------------------------- 1 | $("#submit-button").click(function(){ 2 | var data = new FormData(); 3 | data.append("file", document.getElementById("fileselect").files[0]); 4 | $.ajax({ 5 | url: "/upload", 6 | headers: {"x-csrf-token": $("#csrf-token").val()}, 7 | data: data, 8 | cache: false, 9 | contentType: false, 10 | processData: false, 11 | type: "POST", 12 | xhr: function() { 13 | xhr = $.ajaxSettings.xhr(); 14 | if(xhr.upload){ 15 | xhr.upload.addEventListener("progress", 16 | function(e) { 17 | var pc = parseInt(e.loaded / e.total * 100); 18 | $("#upload-progress") 19 | .css("width", pc +"%") 20 | .attr("aria-valuenow", 100 - pc) 21 | .html(pc + "%"); 22 | }, 23 | false); 24 | } 25 | return xhr; 26 | }, 27 | error: function(data) { 28 | $("#status-message") 29 | .removeClass("alert-success") 30 | .toggleClass("alert-danger") 31 | .html("upload error"); 32 | }, 33 | success: function(data){ 34 | $("#status-message") 35 | .removeClass("alert-danger") 36 | .toggleClass("alert-success") 37 | .html("upload success"); 38 | }}); 39 | return false; 40 | }); 41 | -------------------------------------------------------------------------------- /guestbook-sente/src/clj/guestbook/layout.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.layout 2 | (:require 3 | [selmer.parser :as parser] 4 | [selmer.filters :as filters] 5 | [markdown.core :refer [md-to-html-string]] 6 | [ring.util.http-response :refer [content-type ok]] 7 | [ring.util.anti-forgery :refer [anti-forgery-field]] 8 | [ring.middleware.anti-forgery :refer [*anti-forgery-token*]])) 9 | 10 | (parser/set-resource-path! (clojure.java.io/resource "html")) 11 | (parser/add-tag! :csrf-field (fn [_ _] (anti-forgery-field))) 12 | (filters/add-filter! :markdown (fn [content] [:safe (md-to-html-string content)])) 13 | 14 | (defn render 15 | "renders the HTML template located relative to resources/html" 16 | [request template & [params]] 17 | (content-type 18 | (ok 19 | (parser/render-file 20 | template 21 | (assoc params 22 | :page template 23 | :csrf-token *anti-forgery-token*))) 24 | "text/html; charset=utf-8")) 25 | 26 | (defn error-page 27 | "error-details should be a map containing the following keys: 28 | :status - error status 29 | :title - error title (optional) 30 | :message - detailed error message (optional) 31 | 32 | returns a response map with the error page as the body 33 | and the status specified by the status key" 34 | [error-details] 35 | {:status (:status error-details) 36 | :headers {"Content-Type" "text/html; charset=utf-8"} 37 | :body (parser/render-file "error.html" error-details)}) 38 | -------------------------------------------------------------------------------- /guestbook-cljs/resources/docs/docs.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | ### Database Configuration is Required 4 | 5 | If you haven't already, then please follow the steps below to configure your database connection and run the necessary migrations. 6 | 7 | * Run `lein run migrate` in the root of the project to create the tables. 8 | * Restart the application. 9 | 10 |
11 | 12 | 13 | ### Managing Your Middleware 14 | 15 | Request middleware functions are located under the `guestbook.middleware` namespace. 16 | 17 | This namespace is reserved for any custom middleware for the application. Some default middleware is 18 | already defined here. The middleware is assembled in the `wrap-base` function. 19 | 20 | Middleware used for development is placed in the `guestbook.dev-middleware` namespace found in 21 | the `env/dev/clj/` source path. 22 | 23 | ### Here are some links to get started 24 | 25 | 1. [HTML templating](http://www.luminusweb.net/docs/html_templating.md) 26 | 2. [Accessing the database](http://www.luminusweb.net/docs/database.md) 27 | 3. [Setting response types](http://www.luminusweb.net/docs/responses.md) 28 | 4. [Defining routes](http://www.luminusweb.net/docs/routes.md) 29 | 5. [Adding middleware](http://www.luminusweb.net/docs/middleware.md) 30 | 6. [Sessions and cookies](http://www.luminusweb.net/docs/sessions_cookies.md) 31 | 7. [Security](http://www.luminusweb.net/docs/security.md) 32 | 8. [Deploying the application](http://www.luminusweb.net/docs/deployment.md) 33 | -------------------------------------------------------------------------------- /guestbook-sente/src/cljs/guestbook/ws.cljs: -------------------------------------------------------------------------------- 1 | (ns guestbook.ws 2 | (:require [taoensso.sente :as sente])) 3 | 4 | (let [connection (sente/make-channel-socket! "/ws" js/csrfToken {:type :auto})] 5 | (def ch-chsk (:ch-recv connection)) ; ChannelSocket's receive channel 6 | (def send-message! (:send-fn connection))) 7 | 8 | (defn state-handler [{:keys [?data]}] 9 | (.log js/console (str "state changed: " ?data))) 10 | 11 | (defn handshake-handler [{:keys [?data]}] 12 | (.log js/console (str "connection established: " ?data))) 13 | 14 | (defn default-event-handler [ev-msg] 15 | (.log js/console (str "Unhandled event: " (:event ev-msg)))) 16 | 17 | (defn event-msg-handler [& [{:keys [message state handshake] 18 | :or {state state-handler 19 | handshake handshake-handler}}]] 20 | (fn [ev-msg] 21 | (case (:id ev-msg) 22 | :chsk/handshake (handshake ev-msg) 23 | :chsk/state (state ev-msg) 24 | :chsk/recv (message ev-msg) 25 | (default-event-handler ev-msg)))) 26 | 27 | (def router (atom nil)) 28 | 29 | (defn stop-router! [] 30 | (when-let [stop-f @router] (stop-f))) 31 | 32 | (defn start-router! [message-handler] 33 | (stop-router!) 34 | (reset! router (sente/start-chsk-router! 35 | ch-chsk 36 | (event-msg-handler 37 | {:message message-handler 38 | :state state-handler 39 | :handshake handshake-handler})))) 40 | -------------------------------------------------------------------------------- /guestbook/resources/html/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Something Bad Happened 5 | 6 | 7 | {% style "/assets/bulma/css/bulma.min.css" %} 8 | 34 | 35 | 36 |
37 |
38 |

Error: {{status}}

39 |
40 | {% if title %} 41 |

{{title}}

42 | {% endif %} 43 | {% if message %} 44 |

{{message}}

45 | {% endif %} 46 |
47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /guestbook-sente/resources/html/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Something Bad Happened 5 | 6 | 7 | {% style "/assets/bulma/css/bulma.min.css" %} 8 | 34 | 35 | 36 |
37 |
38 |

Error: {{status}}

39 |
40 | {% if title %} 41 |

{{title}}

42 | {% endif %} 43 | {% if message %} 44 |

{{message}}

45 | {% endif %} 46 |
47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/src/clj/multi_client_ws_aleph/layout.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-aleph.layout 2 | (:require 3 | [selmer.parser :as parser] 4 | [selmer.filters :as filters] 5 | [markdown.core :refer [md-to-html-string]] 6 | [ring.util.http-response :refer [content-type ok]] 7 | [ring.util.anti-forgery :refer [anti-forgery-field]] 8 | [ring.middleware.anti-forgery :refer [*anti-forgery-token*]])) 9 | 10 | (parser/set-resource-path! (clojure.java.io/resource "html")) 11 | (parser/add-tag! :csrf-field (fn [_ _] (anti-forgery-field))) 12 | (filters/add-filter! :markdown (fn [content] [:safe (md-to-html-string content)])) 13 | 14 | (defn render 15 | "renders the HTML template located relative to resources/html" 16 | [request template & [params]] 17 | (content-type 18 | (ok 19 | (parser/render-file 20 | template 21 | (assoc params 22 | :page template 23 | :csrf-token *anti-forgery-token*))) 24 | "text/html; charset=utf-8")) 25 | 26 | (defn error-page 27 | "error-details should be a map containing the following keys: 28 | :status - error status 29 | :title - error title (optional) 30 | :message - detailed error message (optional) 31 | 32 | returns a response map with the error page as the body 33 | and the status specified by the status key" 34 | [error-details] 35 | {:status (:status error-details) 36 | :headers {"Content-Type" "text/html; charset=utf-8"} 37 | :body (parser/render-file "error.html" error-details)}) 38 | -------------------------------------------------------------------------------- /multi-client-ws-aleph/resources/html/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Something Bad Happened 5 | 6 | 7 | {% style "/assets/bulma/css/bulma.min.css" %} 8 | 34 | 35 | 36 |
37 |
38 |

Error: {{status}}

39 |
40 | {% if title %} 41 |

{{title}}

42 | {% endif %} 43 | {% if message %} 44 |

{{message}}

45 | {% endif %} 46 |
47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/resources/html/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Something Bad Happened 5 | 6 | 7 | {% style "/assets/bulma/css/bulma.min.css" %} 8 | 34 | 35 | 36 |
37 |
38 |

Error: {{status}}

39 |
40 | {% if title %} 41 |

{{title}}

42 | {% endif %} 43 | {% if message %} 44 |

{{message}}

45 | {% endif %} 46 |
47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/src/clj/multi_client_ws_http_kit/layout.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-http-kit.layout 2 | (:require 3 | [selmer.parser :as parser] 4 | [selmer.filters :as filters] 5 | [markdown.core :refer [md-to-html-string]] 6 | [ring.util.http-response :refer [content-type ok]] 7 | [ring.util.anti-forgery :refer [anti-forgery-field]] 8 | [ring.middleware.anti-forgery :refer [*anti-forgery-token*]])) 9 | 10 | (parser/set-resource-path! (clojure.java.io/resource "html")) 11 | (parser/add-tag! :csrf-field (fn [_ _] (anti-forgery-field))) 12 | (filters/add-filter! :markdown (fn [content] [:safe (md-to-html-string content)])) 13 | 14 | (defn render 15 | "renders the HTML template located relative to resources/html" 16 | [request template & [params]] 17 | (content-type 18 | (ok 19 | (parser/render-file 20 | template 21 | (assoc params 22 | :page template 23 | :csrf-token *anti-forgery-token*))) 24 | "text/html; charset=utf-8")) 25 | 26 | (defn error-page 27 | "error-details should be a map containing the following keys: 28 | :status - error status 29 | :title - error title (optional) 30 | :message - detailed error message (optional) 31 | 32 | returns a response map with the error page as the body 33 | and the status specified by the status key" 34 | [error-details] 35 | {:status (:status error-details) 36 | :headers {"Content-Type" "text/html; charset=utf-8"} 37 | :body (parser/render-file "error.html" error-details)}) 38 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/resources/html/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Something Bad Happened 5 | 6 | 7 | {% style "/assets/bulma/css/bulma.min.css" %} 8 | 34 | 35 | 36 |
37 |
38 |

Error: {{status}}

39 |
40 | {% if title %} 41 |

{{title}}

42 | {% endif %} 43 | {% if message %} 44 |

{{message}}

45 | {% endif %} 46 |
47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /multi-client-ws-immutant/src/clj/multi_client_ws_immutant/layout.clj: -------------------------------------------------------------------------------- 1 | (ns multi-client-ws-immutant.layout 2 | (:require 3 | [selmer.parser :as parser] 4 | [selmer.filters :as filters] 5 | [markdown.core :refer [md-to-html-string]] 6 | [ring.util.http-response :refer [content-type ok]] 7 | [ring.util.anti-forgery :refer [anti-forgery-field]] 8 | [ring.middleware.anti-forgery :refer [*anti-forgery-token*]])) 9 | 10 | (parser/set-resource-path! (clojure.java.io/resource "html")) 11 | (parser/add-tag! :csrf-field (fn [_ _] (anti-forgery-field))) 12 | (filters/add-filter! :markdown (fn [content] [:safe (md-to-html-string content)])) 13 | 14 | (defn render 15 | "renders the HTML template located relative to resources/html" 16 | [request template & [params]] 17 | (content-type 18 | (ok 19 | (parser/render-file 20 | template 21 | (assoc params 22 | :page template 23 | :csrf-token *anti-forgery-token*))) 24 | "text/html; charset=utf-8")) 25 | 26 | (defn error-page 27 | "error-details should be a map containing the following keys: 28 | :status - error status 29 | :title - error title (optional) 30 | :message - detailed error message (optional) 31 | 32 | returns a response map with the error page as the body 33 | and the status specified by the status key" 34 | [error-details] 35 | {:status (:status error-details) 36 | :headers {"Content-Type" "text/html; charset=utf-8"} 37 | :body (parser/render-file "error.html" error-details)}) 38 | -------------------------------------------------------------------------------- /guestbook/src/clj/guestbook/layout.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.layout 2 | (:require 3 | [clojure.java.io] 4 | [selmer.parser :as parser] 5 | [selmer.filters :as filters] 6 | [markdown.core :refer [md-to-html-string]] 7 | [ring.util.http-response :refer [content-type ok]] 8 | [ring.util.anti-forgery :refer [anti-forgery-field]] 9 | [ring.middleware.anti-forgery :refer [*anti-forgery-token*]] 10 | [ring.util.response])) 11 | 12 | (parser/set-resource-path! (clojure.java.io/resource "html")) 13 | (parser/add-tag! :csrf-field (fn [_ _] (anti-forgery-field))) 14 | (filters/add-filter! :markdown (fn [content] [:safe (md-to-html-string content)])) 15 | 16 | (defn render 17 | "renders the HTML template located relative to resources/html" 18 | [request template & [params]] 19 | (content-type 20 | (ok 21 | (parser/render-file 22 | template 23 | (assoc params 24 | :page template 25 | :csrf-token *anti-forgery-token*))) 26 | "text/html; charset=utf-8")) 27 | 28 | (defn error-page 29 | "error-details should be a map containing the following keys: 30 | :status - error status 31 | :title - error title (optional) 32 | :message - detailed error message (optional) 33 | 34 | returns a response map with the error page as the body 35 | and the status specified by the status key" 36 | [error-details] 37 | {:status (:status error-details) 38 | :headers {"Content-Type" "text/html; charset=utf-8"} 39 | :body (parser/render-file "error.html" error-details)}) 40 | -------------------------------------------------------------------------------- /guestbook-datomic/src/clj/guestbook_datomic/layout.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.layout 2 | (:require [selmer.parser :as parser] 3 | [selmer.filters :as filters] 4 | [markdown.core :refer [md-to-html-string]] 5 | [ring.util.http-response :refer [content-type ok]] 6 | [ring.util.anti-forgery :refer [anti-forgery-field]] 7 | [ring.middleware.anti-forgery :refer [*anti-forgery-token*]])) 8 | 9 | 10 | (parser/set-resource-path! (clojure.java.io/resource "templates")) 11 | (parser/add-tag! :csrf-field (fn [_ _] (anti-forgery-field))) 12 | (filters/add-filter! :markdown (fn [content] [:safe (md-to-html-string content)])) 13 | 14 | (defn render 15 | "renders the HTML template located relative to resources/templates" 16 | [template & [params]] 17 | (content-type 18 | (ok 19 | (parser/render-file 20 | template 21 | (assoc params 22 | :page template 23 | :csrf-token *anti-forgery-token*))) 24 | "text/html; charset=utf-8")) 25 | 26 | (defn error-page 27 | "error-details should be a map containing the following keys: 28 | :status - error status 29 | :title - error title (optional) 30 | :message - detailed error message (optional) 31 | 32 | returns a response map with the error page as the body 33 | and the status specified by the status key" 34 | [error-details] 35 | {:status (:status error-details) 36 | :headers {"Content-Type" "text/html; charset=utf-8"} 37 | :body (parser/render-file "error.html" error-details)}) 38 | -------------------------------------------------------------------------------- /guestbook/src/clj/guestbook/routes/home.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook.routes.home 2 | (:require 3 | [guestbook.layout :as layout] 4 | [guestbook.db.core :as db] 5 | [clojure.java.io :as io] 6 | [guestbook.middleware :as middleware] 7 | [ring.util.response] 8 | [ring.util.http-response :as response] 9 | [struct.core :as st])) 10 | 11 | (def message-schema 12 | [[:name 13 | st/required 14 | st/string] 15 | 16 | [:message 17 | st/required 18 | st/string 19 | {:message "message must contain at least 10 characters" 20 | :validate #(> (count %) 9)}]]) 21 | 22 | (defn validate-message [params] 23 | (first (st/validate params message-schema))) 24 | 25 | (defn save-message! [{:keys [params]}] 26 | (if-let [errors (validate-message params)] 27 | (-> (response/found "/") 28 | (assoc :flash (assoc params :errors errors))) 29 | (do 30 | (db/save-message! 31 | (assoc params :timestamp (java.util.Date.))) 32 | (response/found "/")))) 33 | 34 | (defn home-page [{:keys [flash] :as request}] 35 | (layout/render 36 | request 37 | "home.html" 38 | (merge {:messages (db/get-messages)} 39 | (select-keys flash [:name :message :errors])))) 40 | 41 | 42 | 43 | (defn about-page [request] 44 | (layout/render request "about.html")) 45 | 46 | (defn home-routes [] 47 | ["" 48 | {:middleware [middleware/wrap-csrf 49 | middleware/wrap-formats]} 50 | ["/" {:get home-page 51 | :post save-message!}] 52 | ["/about" {:get about-page}]]) 53 | 54 | -------------------------------------------------------------------------------- /reporting-example/src/clj/reporting_example/reports.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns reporting-example.reports 10 | (:require [reporting-example.db.core :as db] 11 | [clj-pdf.core :refer [pdf template]])) 12 | 13 | (def employee-template 14 | (template [$name $occupation $place $country])) 15 | 16 | (def employee-template-paragraph 17 | (template 18 | [:paragraph 19 | [:heading {:style {:size 15}} $name] 20 | [:chunk {:style :bold} "occupation: "] $occupation "\n" 21 | [:chunk {:style :bold} "place: "] $place "\n" 22 | [:chunk {:style :bold} "country: "] $country 23 | [:spacer]])) 24 | 25 | (defn table-report [out] 26 | (pdf 27 | [{:header "Employee List"} 28 | (into [:table 29 | {:border false 30 | :cell-border false 31 | :header [{:backdrop-color [0 150 150]} "Name" "Occupation" "Place" 32 | "Country"]}] 33 | (employee-template (db/read-employees)))] 34 | out)) 35 | 36 | (defn list-report [out] 37 | (pdf 38 | [{} 39 | [:heading {:size 10} "Employees"] 40 | [:line] 41 | [:spacer] 42 | (employee-template-paragraph (db/read-employees))] 43 | out)) 44 | -------------------------------------------------------------------------------- /file-upload-progress/src/clj/file_upload_progress/layout.clj: -------------------------------------------------------------------------------- 1 | (ns file-upload-progress.layout 2 | (:require [selmer.parser :as parser] 3 | [selmer.filters :as filters] 4 | [markdown.core :refer [md-to-html-string]] 5 | [ring.util.http-response :refer [content-type ok]] 6 | [ring.util.anti-forgery :refer [anti-forgery-field]] 7 | [ring.middleware.anti-forgery :refer [*anti-forgery-token*]])) 8 | 9 | (declare ^:dynamic *app-context*) 10 | (parser/set-resource-path! (clojure.java.io/resource "templates")) 11 | (parser/add-tag! :csrf-field (fn [_ _] (anti-forgery-field))) 12 | (filters/add-filter! :markdown (fn [content] [:safe (md-to-html-string content)])) 13 | 14 | (defn render 15 | "renders the HTML template located relative to resources/templates" 16 | [template & [params]] 17 | (content-type 18 | (ok 19 | (parser/render-file 20 | template 21 | (assoc params 22 | :page template 23 | :csrf-token *anti-forgery-token* 24 | :servlet-context *app-context*))) 25 | "text/html; charset=utf-8")) 26 | 27 | (defn error-page 28 | "error-details should be a map containing the following keys: 29 | :status - error status 30 | :title - error title (optional) 31 | :message - detailed error message (optional) 32 | 33 | returns a response map with the error page as the body 34 | and the status specified by the status key" 35 | [error-details] 36 | {:status (:status error-details) 37 | :headers {"Content-Type" "text/html; charset=utf-8"} 38 | :body (parser/render-file "error.html" error-details)}) 39 | -------------------------------------------------------------------------------- /swagger-service/src/clj/swagger_service/core.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns swagger-service.core 10 | (:require [swagger-service.handler :refer [app init destroy]] 11 | [luminus.repl-server :as repl] 12 | [luminus.http-server :as http] 13 | [config.core :refer [env]]) 14 | (:gen-class)) 15 | 16 | (defn parse-port [port] 17 | (when port 18 | (cond 19 | (string? port) (Integer/parseInt port) 20 | (number? port) port 21 | :else (throw (Exception. (str "invalid port value: " port)))))) 22 | 23 | (defn http-port [port] 24 | ;;default production port is set in 25 | ;;env/prod/resources/config.edn 26 | (parse-port (or port (env :port)))) 27 | 28 | (defn stop-app [] 29 | (repl/stop) 30 | (http/stop destroy) 31 | (shutdown-agents)) 32 | 33 | (defn start-app 34 | "e.g. lein run 3000" 35 | [[port]] 36 | (let [port (http-port port)] 37 | (.addShutdownHook (Runtime/getRuntime) (Thread. stop-app)) 38 | (when-let [repl-port (env :nrepl-port)] 39 | (repl/start {:port (parse-port repl-port)})) 40 | (http/start {:handler app 41 | :init init 42 | :port port}))) 43 | 44 | (defn -main [& args] 45 | (start-app args)) 46 | -------------------------------------------------------------------------------- /reporting-example/resources/docs/docs.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | ### Database Configuration is Required 4 | 5 | If you haven't already, then please follow the steps below to configure your database connection and run the necessary migrations. 6 | 7 | * Create the database for your application. 8 | * Update the connection URL in the `profiles.clj` file with your database name and login. 9 | * Run `lein run migrate` in the root of the project to create the tables. 10 | * Restart the application. 11 | 12 |
13 | 14 | 15 | ### Managing Your Middleware 16 | 17 | Request middleware functions are located under the `reporting-example.middleware` namespace. 18 | 19 | This namespace is reserved for any custom middleware for the application. Some default middleware is 20 | already defined here. The middleware is assembled in the `wrap-base` function. 21 | 22 | Middleware used for development is placed in the `reporting-example.dev-middleware` namespace found in 23 | the `env/dev/clj/` source path. 24 | 25 | ### Here are some links to get started 26 | 27 | 1. [HTML templating](http://www.luminusweb.net/docs/html_templating.md) 28 | 2. [Accessing the database](http://www.luminusweb.net/docs/database.md) 29 | 3. [Setting response types](http://www.luminusweb.net/docs/responses.md) 30 | 4. [Defining routes](http://www.luminusweb.net/docs/routes.md) 31 | 5. [Adding middleware](http://www.luminusweb.net/docs/middleware.md) 32 | 6. [Sessions and cookies](http://www.luminusweb.net/docs/sessions_cookies.md) 33 | 7. [Security](http://www.luminusweb.net/docs/security.md) 34 | 8. [Deploying the application](http://www.luminusweb.net/docs/deployment.md) 35 | -------------------------------------------------------------------------------- /swagger-service/resources/public/css/screen.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 4 | height: 100%; 5 | } 6 | .navbar { 7 | margin-bottom: 10px; 8 | } 9 | .navbar-brand { 10 | float: none; 11 | } 12 | .navbar-nav .nav-item { 13 | float: none; 14 | } 15 | .navbar-divider, 16 | .navbar-nav .nav-item+.nav-item, 17 | .navbar-nav .nav-link + .nav-link { 18 | margin-left: 0; 19 | } 20 | @media (min-width: 34em) { 21 | .navbar-brand { 22 | float: left; 23 | } 24 | .navbar-nav .nav-item { 25 | float: left; 26 | } 27 | .navbar-divider, 28 | .navbar-nav .nav-item+.nav-item, 29 | .navbar-nav .nav-link + .nav-link { 30 | margin-left: 1rem; 31 | } 32 | } 33 | 34 | @-moz-keyframes three-quarters-loader { 35 | 0% { 36 | -moz-transform: rotate(0deg); 37 | transform: rotate(0deg); 38 | } 39 | 100% { 40 | -moz-transform: rotate(360deg); 41 | transform: rotate(360deg); 42 | } 43 | } 44 | @-webkit-keyframes three-quarters-loader { 45 | 0% { 46 | -webkit-transform: rotate(0deg); 47 | transform: rotate(0deg); 48 | } 49 | 100% { 50 | -webkit-transform: rotate(360deg); 51 | transform: rotate(360deg); 52 | } 53 | } 54 | @keyframes three-quarters-loader { 55 | 0% { 56 | -moz-transform: rotate(0deg); 57 | -ms-transform: rotate(0deg); 58 | -webkit-transform: rotate(0deg); 59 | transform: rotate(0deg); 60 | } 61 | 100% { 62 | -moz-transform: rotate(360deg); 63 | -ms-transform: rotate(360deg); 64 | -webkit-transform: rotate(360deg); 65 | transform: rotate(360deg); 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /guestbook-datomic/src/clj/guestbook_datomic/core.clj: -------------------------------------------------------------------------------- 1 | (ns guestbook-datomic.core 2 | (:require [guestbook-datomic.handler :as handler] 3 | [luminus.repl-server :as repl] 4 | [luminus.http-server :as http] 5 | [guestbook-datomic.config :refer [env]] 6 | [clojure.tools.cli :refer [parse-opts]] 7 | [clojure.tools.logging :as log] 8 | [mount.core :as mount]) 9 | (:gen-class)) 10 | 11 | (def cli-options 12 | [["-p" "--port PORT" "Port number" 13 | :parse-fn #(Integer/parseInt %)]]) 14 | 15 | (mount/defstate ^{:on-reload :noop} http-server 16 | :start 17 | (http/start 18 | (-> env 19 | (assoc :handler #'handler/app) 20 | (update :io-threads #(or % (* 2 (.availableProcessors (Runtime/getRuntime))))) 21 | (update :port #(or (-> env :options :port) %)))) 22 | :stop 23 | (http/stop http-server)) 24 | 25 | (mount/defstate ^{:on-reload :noop} repl-server 26 | :start 27 | (when (env :nrepl-port) 28 | (repl/start { :bind (env :nrepl-bind) 29 | :port (env :nrepl-port) 30 | })) 31 | :stop 32 | (when repl-server 33 | (repl/stop repl-server))) 34 | 35 | 36 | (defn stop-app [] 37 | (doseq [component (:stopped (mount/stop))] 38 | (log/info component "stopped")) 39 | (shutdown-agents)) 40 | 41 | (defn start-app [args] 42 | (doseq [component (-> args 43 | (parse-opts cli-options) 44 | mount/start-with-args 45 | :started)] 46 | (log/info component "started")) 47 | (.addShutdownHook (Runtime/getRuntime) (Thread. stop-app))) 48 | 49 | (defn -main [& args] 50 | (start-app args)) 51 | -------------------------------------------------------------------------------- /guestbook-sente/resources/public/css/screen.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 4 | } 5 | @font-face { 6 | font-family: 'Material Icons'; 7 | font-style: normal; 8 | font-weight: 400; 9 | src: url(/assets/material-icons/iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */ 10 | src: local('Material Icons'), 11 | local('MaterialIcons-Regular'), 12 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff2) format('woff2'), 13 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff) format('woff'), 14 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.ttf) format('truetype'); 15 | } 16 | .material-icons { 17 | font-family: 'Material Icons'; 18 | font-weight: normal; 19 | font-style: normal; 20 | font-size: 24px; /* Preferred icon size */ 21 | display: inline-block; 22 | line-height: 1; 23 | text-transform: none; 24 | letter-spacing: normal; 25 | word-wrap: normal; 26 | white-space: nowrap; 27 | direction: ltr; 28 | /* Support for all WebKit browsers. */ 29 | -webkit-font-smoothing: antialiased; 30 | /* Support for Safari and Chrome. */ 31 | text-rendering: optimizeLegibility; 32 | /* Support for Firefox. */ 33 | -moz-osx-font-smoothing: grayscale; 34 | } 35 | 36 | ul { 37 | list-style: none; 38 | } 39 | 40 | ul.messages li { 41 | position: relative; 42 | font-size: 16px; 43 | padding: 5px; 44 | border-bottom: 1px dotted #ccc; 45 | } 46 | 47 | li:last-child { 48 | border-bottom: none; 49 | } 50 | 51 | li time { 52 | font-size: 12px; 53 | padding-bottom: 20px; 54 | } 55 | 56 | form, .error { 57 | padding: 30px; 58 | margin-bottom: 50px; 59 | position: relative; 60 | } 61 | -------------------------------------------------------------------------------- /guestbook/resources/public/css/screen.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 4 | } 5 | @font-face { 6 | font-family: 'Material Icons'; 7 | font-style: normal; 8 | font-weight: 400; 9 | src: url(/assets/material-icons/iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */ 10 | src: local('Material Icons'), 11 | local('MaterialIcons-Regular'), 12 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff2) format('woff2'), 13 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.woff) format('woff'), 14 | url(/assets/material-icons/iconfont/MaterialIcons-Regular.ttf) format('truetype'); 15 | } 16 | .material-icons { 17 | font-family: 'Material Icons'; 18 | font-weight: normal; 19 | font-style: normal; 20 | font-size: 24px; /* Preferred icon size */ 21 | display: inline-block; 22 | line-height: 1; 23 | text-transform: none; 24 | letter-spacing: normal; 25 | word-wrap: normal; 26 | white-space: nowrap; 27 | direction: ltr; 28 | /* Support for all WebKit browsers. */ 29 | -webkit-font-smoothing: antialiased; 30 | /* Support for Safari and Chrome. */ 31 | text-rendering: optimizeLegibility; 32 | /* Support for Firefox. */ 33 | -moz-osx-font-smoothing: grayscale; 34 | } 35 | 36 | ul { 37 | list-style: none; 38 | } 39 | 40 | ul.messages li { 41 | position: relative; 42 | font-size: 16px; 43 | padding: 5px; 44 | border-bottom: 1px dotted #ccc; 45 | } 46 | 47 | li:last-child { 48 | border-bottom: none; 49 | } 50 | 51 | li time { 52 | font-size: 12px; 53 | padding-bottom: 20px; 54 | } 55 | 56 | form, .error { 57 | padding: 30px; 58 | margin-bottom: 50px; 59 | position: relative; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /guestbook-cljs/test/clj/guestbook/test/db/core.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns guestbook.test.db.core 10 | (:require [guestbook.db.core :refer [*db*] :as db] 11 | [luminus-migrations.core :as migrations] 12 | [clojure.test :refer :all] 13 | [clojure.java.jdbc :as jdbc] 14 | [guestbook.config :refer [env]] 15 | [mount.core :as mount])) 16 | 17 | (use-fixtures 18 | :once 19 | (fn [f] 20 | (mount/start 21 | #'guestbook.config/env 22 | #'guestbook.db.core/*db*) 23 | (migrations/migrate ["migrate"] (env :database-url)) 24 | (f))) 25 | 26 | (deftest test-message 27 | (jdbc/with-db-transaction [t-conn *db*] 28 | (jdbc/db-set-rollback-only! t-conn) 29 | (let [timestamp (org.joda.time.DateTime. org.joda.time.DateTimeZone/UTC)] 30 | (is (= 1 (db/save-message! 31 | t-conn 32 | {:name "Bob" 33 | :message "Hello, World" 34 | :timestamp timestamp} 35 | {:connection t-conn}))) 36 | (is (= 37 | {:name "Bob" 38 | :message "Hello, World" 39 | :timestamp timestamp} 40 | (-> (db/get-messages t-conn {}) 41 | (first) 42 | (select-keys [:name :message :timestamp]))))))) 43 | -------------------------------------------------------------------------------- /guestbook-sente/resources/html/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Welcome to guestbook 7 | 8 | 9 |
10 |
11 |
12 |
13 |

Welcome to guestbook

14 |

If you're seeing this message, that means you haven't yet compiled your ClojureScript!

15 |

Please run lein figwheel to start the ClojureScript compiler and reload the page.

16 |

For better ClojureScript development experience in Chrome follow these steps:

17 |
    18 |
  • Open DevTools 19 |
  • Go to Settings ("three dots" icon in the upper right corner of DevTools > Menu > Settings F1 > General > Console) 20 |
  • Check-in "Enable custom formatters" 21 |
  • Close DevTools 22 |
  • Open DevTools 23 |
24 |

See ClojureScript documentation for further details.

25 |
26 |
27 |
28 |
29 | 30 | 31 | {% style "/assets/bulma/css/bulma.min.css" %} 32 | {% style "/assets/material-icons/css/material-icons.min.css" %} 33 | {% style "/css/screen.css" %} 34 | 35 | 38 | {% script "/js/app.js" %} 39 | 40 | 41 | -------------------------------------------------------------------------------- /guestbook-cljs/src/clj/guestbook/routes/home.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns guestbook.routes.home 10 | (:require [guestbook.layout :as layout] 11 | [guestbook.db.core :as db] 12 | [bouncer.core :as b] 13 | [bouncer.validators :as v] 14 | [compojure.core :refer [defroutes GET POST]] 15 | [ring.util.http-response :as response])) 16 | 17 | (defn home-page [] 18 | (layout/render "home.html")) 19 | 20 | (defn validate-message [params] 21 | (first 22 | (b/validate 23 | params 24 | :name v/required 25 | :message [v/required [v/min-count 10]]))) 26 | 27 | (defn save-message! [{:keys [params]}] 28 | (if-let [errors (validate-message params)] 29 | (response/bad-request {:errors errors}) 30 | (try 31 | (db/save-message! 32 | (assoc params :timestamp (java.util.Date.))) 33 | (response/ok {:status :ok}) 34 | (catch Exception e 35 | (response/internal-server-error 36 | {:errors {:server-error ["Failed to save message!"]}}))))) 37 | 38 | (defn about-page [] 39 | (layout/render "about.html")) 40 | 41 | (defroutes home-routes 42 | (GET "/" [] (home-page)) 43 | (GET "/messages" [] (response/ok (db/get-messages))) 44 | (POST "/message" req (save-message! req)) 45 | (GET "/about" [] (about-page))) 46 | -------------------------------------------------------------------------------- /reporting-example/test/clj/reporting_example/test/db/core.clj: -------------------------------------------------------------------------------- 1 | ;--- 2 | ; Excerpted from "Web Development with Clojure, Second Edition", 3 | ; published by The Pragmatic Bookshelf. 4 | ; Copyrights apply to this code. It may not be used to create training material, 5 | ; courses, books, articles, and the like. Contact us if you are in doubt. 6 | ; We make no guarantees that this code is fit for any purpose. 7 | ; Visit http://www.pragmaticprogrammer.com/titles/dswdcloj2 for more book information. 8 | ;--- 9 | (ns reporting-example.test.db.core 10 | (:require [reporting-example.db.core :as db] 11 | [reporting-example.db.migrations :as migrations] 12 | [clojure.test :refer :all] 13 | [clojure.java.jdbc :as jdbc] 14 | [conman.core :refer [with-transaction]] 15 | [config.core :refer [env]] 16 | [mount.core :as mount])) 17 | 18 | (use-fixtures 19 | :once 20 | (fn [f] 21 | (mount/start #'reporting-example.db.core/*db*) 22 | (migrations/migrate ["migrate"]) 23 | (f))) 24 | 25 | (deftest test-users 26 | (with-transaction [t-conn db/*db*] 27 | (jdbc/db-set-rollback-only! t-conn) 28 | (is (= 1 (db/create-user! 29 | {:id "1" 30 | :first_name "Sam" 31 | :last_name "Smith" 32 | :email "sam.smith@example.com" 33 | :pass "pass"}))) 34 | (is (= {:id "1" 35 | :first_name "Sam" 36 | :last_name "Smith" 37 | :email "sam.smith@example.com" 38 | :pass "pass" 39 | :admin nil 40 | :last_login nil 41 | :is_active nil} 42 | (db/get-user {:id "1"}))))) 43 | -------------------------------------------------------------------------------- /swagger-service/resources/templates/home.html: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | Welcome to swagger-service 14 | 15 | 16 | 17 |
18 |
19 |
Loading…
20 |

If you're seeing this message, that means you haven't yet compiled your ClojureScript!

21 |

Please run lein figwheel to start the ClojureScript compiler and reload the page.

22 |

See ClojureScript documentation for further details.

23 |
24 |
25 | 26 | 27 | {% style "/assets/bootstrap/css/bootstrap.min.css" %} 28 | {% style "/assets/font-awesome/css/font-awesome.min.css" %} 29 | {% style "/css/screen.css" %} 30 | 31 | 35 | {% script "/js/app.js" %} 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /multi-client-ws-http-kit/env/dev/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | UTF-8 9 | %date{ISO8601} [%thread] %-5level %logger{36} - %msg %n 10 | 11 | 12 | 13 | log/multi-client-ws-http-kit.log 14 | 15 | log/multi-client-ws-http-kit.%d{yyyy-MM-dd}.%i.log 16 | 17 | 100MB 18 | 19 | 20 | 30 21 | 22 | 23 | UTF-8 24 | %date{ISO8601} [%thread] %-5level %logger{36} - %msg %n 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | --------------------------------------------------------------------------------