Add makefile for deploys

main
Eric Ihli 4 years ago
parent 0fb359c9ec
commit 60caaefa85

@ -1,3 +1,3 @@
((nil . ((cider-ns-refresh-before-fn . "integrant.repl/halt")
(cider-ns-refresh-after-fn . "integrant.repl/init")
(cider-ns-refresh-after-fn . "integrant.repl/go")
(cider-clojure-cli-global-options . "-A:dev:cider-nrepl"))))

@ -0,0 +1,24 @@
##
# Project Title
#
# @file
# @version 0.1
src = $(shell find web -type f -iname *.clj 2>/dev/null)
LottoEmail.jar: $(src)
cd web && clj -A:depstar -M:depstar -m hf.depstar.uberjar \
darklimericks.jar -C -m com.darklimericks.server.core
build: FORCE
cd web && clj -A:depstar -M:depstar -m hf.depstar.uberjar \
darklimericks.jar -C -m com.darklimericks.server.core
FORCE:
push: FORCE
rsync -aP web/LottoEmail.jar root@165.227.27.168:/root
deploy: LottoEmail.jar
ssh root@165.227.27.168 java -jar /root/LottoEmail.jar
# end

Binary file not shown.

@ -0,0 +1,27 @@
;;; refresh.el ends here
;;; refresh.el --- description -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2020 Eric Ihli
;;
;; Author: Eric Ihli <http://github/eihli>
;; Maintainer: Eric Ihli <eihli@owoga.com>
;; Created: December 09, 2020
;; Modified: December 09, 2020
;; Version: 0.0.1
;; Keywords:
;; Homepage: https://github.com/eihli/refresh
;; Package-Requires: ((emacs 27.1) (cl-lib "0.5"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; description
;;
;;; Code:
(setq cider-ns-refresh-before-fn "integrant.repl/suspend"
cider-ns-refresh-after-fn "integrant.repl/resume")
(provide 'refresh)
;;; refresh.el ends here

@ -0,0 +1,21 @@
{:com.darklimericks.logging/logging
{:min-level :debug}
:com.darklimericks.server.core/server
{:port 8000 :handler #ig/ref :com.darklimericks.server.handlers/handler}
:com.darklimericks.server.worker/limerick-gen
{:kv #ig/ref :com.darklimericks.kv.core/connection
:db #ig/ref :com.darklimericks.db.core/connection}
:com.darklimericks.kv.core/connection
{:pool {}
:spec {:uri ""}}
:com.darklimericks.db.core/connection {}
:com.darklimericks.server.router/router
{:db #ig/ref :com.darklimericks.db.core/connection}
:com.darklimericks.server.handlers/handler
{:router #ig/ref :com.darklimericks.server.router/router}}

@ -52,7 +52,6 @@
ig/read-string)]
(ig/load-namespaces config)
(-> config
ig/prep
constantly
repl/set-prep!)
(repl/go)))
@ -60,17 +59,22 @@
(defn reset []
(repl/halt))
(comment
(let [db (-> state/system :com.darklimericks.db.core/connection)
session (java.util.UUID/fromString "47e25213-6cd7-493d-a92a-b5bae635c8f4")]
(db.limericks/limericks-by-session db session))
(require '[taoensso.carmine.ring :as cr])
(let [kv (-> state/system :com.darklimericks.kv.core/connection)]
(cr/carmine-store kv))
(comment
(require '[com.darklimericks.db.limericks :as db.limericks])
(let [session
(java.util.UUID/fromString "4605f687-4e91-47de-abdf-458ef7d47b7e")]
(java.util.UUID/fromString "47e25213-6cd7-493d-a92a-b5bae635c8f4")]
(db.limericks/limericks-by-session
(-> state/system :com.darklimericks.db.core/connection)
session))
(init)
(auto-reset)
(let [db (-> state/system :database.sql/connection)
albums (db.albums/most-recent-albums db)]
(->> albums
@ -89,7 +93,6 @@
(car/wcar
(-> state/system :database.kv/connection)
(car/ping)
(car/set "foo" "bar")
(car/set "baz" "buzz")
(car/get "baz"))
(limericks/get-artist-and-album-for-new-limerick (-> state/system :database.sql/connection))

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>web</groupId>
<artifactId>web</artifactId>
<version>0.1.0</version>
<name>web</name>
<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.10.1</version>
</dependency>
<dependency>
<groupId>metosin</groupId>
<artifactId>muuntaja</artifactId>
<version>0.6.7</version>
</dependency>
<dependency>
<groupId>integrant</groupId>
<artifactId>repl</artifactId>
<version>0.3.2</version>
</dependency>
<dependency>
<groupId>digest</groupId>
<artifactId>digest</artifactId>
<version>1.4.9</version>
</dependency>
<dependency>
<groupId>honeysql</groupId>
<artifactId>honeysql</artifactId>
<version>1.0.444</version>
</dependency>
<dependency>
<groupId>com.taoensso</groupId>
<artifactId>carmine</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.18</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>tools.namespace</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>migratus</groupId>
<artifactId>migratus</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>integrant</groupId>
<artifactId>integrant</artifactId>
<version>0.8.0</version>
</dependency>
<dependency>
<groupId>com.layerware</groupId>
<artifactId>hugsql</artifactId>
<version>0.5.1</version>
</dependency>
<dependency>
<groupId>hiccup</groupId>
<artifactId>hiccup</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>seancorfield</groupId>
<artifactId>next.jdbc</artifactId>
<version>1.1.610</version>
</dependency>
<dependency>
<groupId>environ</groupId>
<artifactId>environ</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.taoensso</groupId>
<artifactId>timbre</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>metosin</groupId>
<artifactId>reitit-http</artifactId>
<version>0.5.10</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.32.3.2</version>
</dependency>
<dependency>
<groupId>metosin</groupId>
<artifactId>reitit</artifactId>
<version>0.5.10</version>
</dependency>
<dependency>
<groupId>ring</groupId>
<artifactId>ring-core</artifactId>
<version>1.8.2</version>
</dependency>
<dependency>
<groupId>metosin</groupId>
<artifactId>reitit-interceptors</artifactId>
<version>0.5.10</version>
</dependency>
<dependency>
<groupId>http-kit</groupId>
<artifactId>http-kit</artifactId>
<version>2.5.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
</build>
<repositories>
<repository>
<id>clojars</id>
<url>https://repo.clojars.org/</url>
</repository>
</repositories>
</project>

@ -1,10 +1,21 @@
{:app/logging {:min-level :debug}
:app/server {:port 80 :handler #ig/ref :app/handler}
:app/cache {}
:worker/limerick-gen {:kv #ig/ref :database.kv/connection
:db #ig/ref :database.sql/connection}
:database.kv/connection {:pool {}
{:com.darklimericks.logging/logging
{:min-level :warning}
:com.darklimericks.server.core/server
{:port 80 :handler #ig/ref :com.darklimericks.server.handlers/handler}
:com.darklimericks.server.worker/limerick-gen
{:kv #ig/ref :com.darklimericks.kv.core/connection
:db #ig/ref :com.darklimericks.db.core/connection}
:com.darklimericks.kv.core/connection
{:pool {}
:spec {:uri ""}}
:database.sql/connection {}
:app/router {:db #ig/ref :database.sql/connection :cache #ig/ref :app/cache}
:app/handler {:router #ig/ref :app/router}}
:com.darklimericks.db.core/connection {}
:com.darklimericks.server.router/router
{:db #ig/ref :com.darklimericks.db.core/connection}
:com.darklimericks.server.handlers/handler
{:router #ig/ref :com.darklimericks.server.router/router}}

@ -61,7 +61,9 @@
(->> (honey.sql/build
:select :*
:from :limerick
:join [:session_limerick [:= :session_limerick.limerick_id :limerick.id]]
:join [:session_limerick [:= :session_limerick.limerick_id :limerick.id]
:album [:= :limerick.album_id :album.id]
:artist [:= :album.artist_id :artist.id]]
:where [:= :session_limerick.session_id session])
honey.sql/format
(jdbc/execute! db)))

@ -227,14 +227,13 @@
(defn submit-limericks-get-handler [db]
(fn [request]
(timbre/info request)
(if-let [session-key (:session/key request)]
(let [session-key (-> session-key
(string/split #":")
(nth 2)
java.util.UUID/fromString)
limericks (db.limericks/limericks-by-session db session-key)]
(println session-key)
(println limericks)
{:status 200
:headers {"Content-Type" "text/html; charset=uft-8"}
:body (views/wrapper
@ -248,4 +247,4 @@
db
request
{}
[:div "Enable cookies to submit limericks."])})))
(views/submit-limericks request []))})))

@ -21,12 +21,16 @@
(def logging-interceptor
{:enter (fn [{:keys [request] :as ctx}]
#_(timbre/info
(str "Entering " (dissoc request ::reitit/match)))
(timbre/debug
(str "Entering "
(-> request
(select-keys [:cookie :headers :session :referer]))))
ctx)
:leave (fn [{:keys [response] :as ctx}]
#_(timbre/info
(str "Exiting " (dissoc response ::reitit/match)))
(timbre/debug
(str "Exiting "
(-> response
(select-keys [:status :content-type :headers]))))
ctx)})
(def coerce-request-interceptor
@ -49,7 +53,7 @@
:cookie-attrs (merge {:path "/"
:http-only true}
(options :cookie-attrs)
(if-let [root (options :root)]
(when-let [root (options :root)]
{:path root}))})
(defn session-interceptor
@ -59,11 +63,12 @@
(let [options (session-options cache options)]
{:enter
(fn [ctx]
(update
(let [new-ctx (update
ctx
:request
ring.middleware.session/session-request
options))
options)]
new-ctx))
:leave
(fn [{:keys [response request] :as ctx}]
(update
@ -71,5 +76,20 @@
:response
ring.middleware.session/session-response
request
options))}))
)
options))})))
;; ([handler]
;; (wrap-session handler {}))
;; ([handler options]
;; (let [options (session-options options)]
;; (fn
;; ([request]
;; (let [request (session-request request options)]
;; (-> (handler request)
;; (session-response request options))))
;; ([request respond raise]
;; (let [request (session-request request options)]
;; (handler request
;; (fn [response]
;; (respond (session-response response request options)))
;; raise)))))))

@ -159,16 +159,30 @@
(defn submit-limericks
[request limericks]
[:div
[:h1 "Submit Limericks"]
[:h1 "Generate Limerick"]
(form/form-to
[:post (util/route-name->path
request
:com.darklimericks.server.router/limerick-generation-task)]
(form/text-field "scheme")
(form/submit-button "Generate dark limerick"))
[:div "Session " (:session/key request)]
(for [limerick limericks]
(form/text-field
{:placeholder "A10 A10 B6 B6 A10"}
"scheme")
(form/submit-button
{:class "ml2"}
"Generate dark limerick"))
(when (:session/key request)
[:p "Session " (-> (:session/key request)
(string/split #":")
(nth 2))])
[:h2 "Generated Limericks"]
(if (empty? limericks)
[:p "None, yet..."]
(for [[i limerick] (map vector (range 1 (inc (count limericks))) limericks)]
[:div
[:h3 (:limerick/name limerick)]
[:h3 (format "%s: %s" i (:limerick/name limerick))]
[:div
[:div (format "artist: %s" (:artist/name limerick))]
[:div (format "album: %s" (:album/name limerick))]]
[:p
(for [line (string/split (:limerick/text limerick) #"\n")]
[:div line])])])
[:div line])]]))])

Loading…
Cancel
Save