Compare commits

..

10 Commits

@ -1,9 +1,12 @@
#+TITLE: RhymeStorm™
#+TITLE: DarkLimericks
* WGU Evaluator Notes
https://darklimericks.com
See [[file:web/README_WGU.org][the WGU Readme]].
The world's largest metal limericks archive on the Web.
This is just meant to be a live demo of a Clojure phonetics library (https://github.com/eihli/phonetics) and a Hidden Markov Model use-case for a Tightly-packed Trie (https://github.com/eihli/clj-tightly-packed-trie).
I also borrowed some functionality from a NLP/rhyme-related codebase that is not yet ready for release (https://github.com/eihli/prhyme).
* How To Initialize Development Environment
@ -18,8 +21,7 @@ See [[file:web/README_WGU.org][the WGU Readme]].
1. Run ~./db/run.sh && ./kv/run.sh~ to start the docker containers for the database and key-value store.
a. The ~run.sh~ scripts only need to run once. They initialize development data containers. Subsequent development can continue with ~docker start db && docker start kv~.
2. Start a Clojure REPL in Emacs, evaluate the ~dev/user.clj~ namespace, and run ~(init)~
3. Visit ~http://localhost:8000/wgu~
3. Visit ~http://localhost:8000~
* How To Run Software Locally
@ -32,21 +34,29 @@ See [[file:web/README_WGU.org][the WGU Readme]].
1. Run ~./db/run.sh && ./kv/run.sh~ to start the docker containers for the database and key-value store.
a. The ~run.sh~ scripts only need to run once. They initialize development data containers. Subsequent development can continue with ~docker start db && docker start kv~.
2. The application's ~jar~ builds with a ~make~ run from the root directory. (See [[file:../Makefile][Makefile]]).
3. Navigate to the root directory of this git repo and run ~java -jar darklimericks.jar~
4. Visit http://localhost:8000/wgu
3. Navigate to the root directory of this git repo and run ~java -jar web/darklimericks.jar~
4. Visit http://localhost:8000
* Development
Requires [[https://github.com/tachyons-css/tachyons/][Tachyons CSS]]. There is a symlink in ~web/resources/public~ to the pre-built ~tachyons.css~ and ~tachyons.min.css~ found in the repo.
Build ~.jar~ with ~clojure -X:depstart uberjar :jar prhyme.jar~.
Build ~.jar~ with ~clojure -X:depstar uberjar :jar prhyme.jar~.
* Deployment
Since I'm developing this independently, it's not a very robust deployment system.
It's nice to have some parts of the repo available on the server; the db/kv scripts for example.
But obviously the album images and the data in the db/kv are going to be different between local and prod.
You can use ~rsync~ with ~--exclude~ to only sync over the code bits.
* TODO
~rsync --exclude '*/data/*' --exclude '*/images/*' -aLP ./ root@darklimericks.com:/root/darklimericks/~
** Use tightly packed trie for limerick generation
Note the ~-L~ to follow symlinks. Locally, I'm symlinking tachyons.css.
** Move limerick-specific code into this repo from Prhyme.
The other shortcut I'm taking is that images are stored and served relative to the path of the running application.
Or maybe into its own repo.
That means you need to launch the jar file from the ~web~ directory.

@ -9,5 +9,5 @@ docker run \
-e POSTGRES_PASSWORD=$POSTGRES_PASSWORD \
-e POSTGRES_USER=$POSTGRES_USER \
-v $PGDATA:/var/lib/postgresql/data \
-p 5432:5432 \
-p 127.0.0.1:5432:5432 \
darklimericks-db

@ -3,5 +3,6 @@
#+begin_src sh
certbot certonly -d darklimericks.com --webroot=/root/darklimericks/web/resources/public
certbot certonly -d darklimericks.com --webroot --webroot-path /root/darklimericks/web/resources/public --keep
cat /etc/letsencrypt/archive/darklimericks.com/privkey.pem >> /etc/letsencrypt/archive/darklimericks.com/fullchain.pem
#+end_src

File diff suppressed because it is too large Load Diff

@ -1,5 +1,5 @@
{
"name": "wgu-app",
"name": "rhymestorm-app",
"version": "0.0.1",
"lockfileVersion": 1,
"requires": true,

@ -1,5 +1,5 @@
{
"name": "wgu-app",
"name": "rhymestorm-app",
"version": "0.0.1",
"private": true,
"devDependencies": {

@ -17,9 +17,9 @@
:builds
{:frontend
{:target :browser
:output-dir "../resources/public/wgu/"
:output-dir "../resources/public/rhymestorm/"
:assets-path "/assets/"
:modules {:main {:init-fn wgu.app/init}}
:modules {:main {:init-fn rhymestorm.app/init}}
:devtools {:preloads [day8.re-frame-10x.preload]}
:dev {:compiler-options
{:closure-defines

@ -1,4 +1,4 @@
(ns wgu.app
(ns rhymestorm.app
(:require ["chart.js/auto" :as chart]
[oz.core :as oz]
[reagent.dom :as rdom]

@ -2,7 +2,7 @@
{:min-level :debug}
:com.darklimericks.server.core/server
{:port 8000 :handler #ig/ref :com.darklimericks.server.handlers/handler}
{:port 8008 :handler #ig/ref :com.darklimericks.server.handlers/handler}
:com.darklimericks.server.worker/limerick-gen
{:kv #ig/ref :com.darklimericks.kv.core/connection

@ -147,7 +147,7 @@
(:template
(reitit/match-by-path
(-> state/system :com.darklimericks.server.router/router)
"/wgu/foo.html"))
"/rhymestorm/foo.html"))
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 87 KiB

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 91 KiB

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

@ -452,7 +452,7 @@
(sort-by (comp - second))
first)))
(defn wgu-lyric-suggestions
(defn rhymestorm-lyric-suggestions
"Returns lyrics rhyming with a seed phrase.
Groups rhymes by quality then orders each grouping by frequency.
@ -493,7 +493,7 @@
(comp - last second second))))))
(comment
(take 5 (wgu-lyric-suggestions "technology"))
(take 5 (lyric-suggestions "technology"))
(phrase->quality-of-rhyme "boss hog" "brain fog")

@ -48,8 +48,8 @@
artists-by-album))})))
(def resource-handler (ring/create-resource-handler {:allow-symlinks? true}))
(def file-handler (ring/create-resource-handler {:allow-symlinks? true
:root "public"}))
(def file-handler (ring/create-file-handler {:allow-symlinks? true
:root "resources/public"}))
(defn limerick-generation-post-handler
[db cache]
@ -256,7 +256,7 @@
{}
(views/submit-limericks request []))})))
(defn wgu [db cache]
(defn rhymestorm [db cache]
(fn [request]
{:status 200
:headers {"Content-Type" "text/html; charset=utf-8"}
@ -264,7 +264,7 @@
{:db db
:request request
:opts {}}
(views/wgu request {}))}))
(views/rhymestorm request {}))}))
(defn rhyming-lyric [db cache]
(fn [request]
@ -329,4 +329,4 @@
:opts {}}
(views/lyrics-from-seed
request
(linguistics/wgu-lyric-suggestions target)))})))
(linguistics/rhymestorm-lyric-suggestions target)))})))

@ -139,9 +139,10 @@
[artist-id album-id] album-artist
album (albums/album db album-id)]
(when (:new-album (meta album-artist))
(identicon/generate (-> (:album/name album)
string/lower-case
(string/replace #" " "-")) 128))
(let [icon (identicon/generate
(-> (:album/name album)
string/lower-case
(string/replace #" " "-")) 128)]))
(db.limericks/insert-user-limerick
db
session-id

@ -34,10 +34,10 @@
:parameters {:path {:artist-id int?}}
:get {:handler (handlers/artist-get-handler db)}}]]
["/assets/*" handlers/file-handler]
["/wgu"
["/rhymestorm"
[""
{:name ::wgu
:get {:handler (handlers/wgu db cache)}
{:name ::rhymestorm
:get {:handler (handlers/rhymestorm db cache)}
:post {:handler (handlers/rhyming-lyric db cache)}}]
["/rhyme"
{:name ::rhyme

@ -280,10 +280,10 @@
(for [line (string/split (:limerick/text limerick) #"\n")]
[:div line])]]))])
(defn wgu
(defn rhymestorm
[request {:keys [rhymes rhyming-lyrics lyrics-from-seed]}]
[:div
[:h1 "WGU Capstone"]
[:h1 "RhymeStorm™"]
[:div
[:h2 "Generate Rhyme"]
@ -371,7 +371,7 @@ prefixes to that rhyming phrase."]
(defn lyric-suggestions
[request suggestions]
[:div
(wgu
(rhymestorm
request
{:rhyming-lyrics
[:table {:style "margin: auto;"}
@ -392,7 +392,7 @@ prefixes to that rhyming phrase."]
(defn show-rhyme-suggestion
[request suggestions]
[:div
(wgu
(rhymestorm
request
{:rhymes
(for [[suggestion p1 freq _ p2 quality] suggestions]
@ -417,7 +417,7 @@ prefixes to that rhyming phrase."]
(juxt (comp - :rhyme-quality)
(comp - :freq))
top-20-by-quality))]
(wgu
(rhymestorm
request
{:rhymes
[:div
@ -513,9 +513,9 @@ Words may appear twice if they have multiple pronunciations."]
(defn lyrics-from-seed
[request seed]
(let [suggestions (linguistics/wgu-lyric-suggestions
(let [suggestions (linguistics/rhymestorm-lyric-suggestions
(-> request :params :seed))]
(wgu
(rhymestorm
request
{:lyrics-from-seed
[:div

@ -106,18 +106,30 @@
(defn generate
"Make a new avatar."
[identifier size]
(let
[tile-size (quot size tiles-per-side)
md5 (digest/md5 identifier)
icon (BufferedImage. size size BufferedImage/TYPE_INT_RGB)
[r g b] (get-color (first (to-numbers md5)))
color (Color. r g b)
draw (.createGraphics icon)]
(let [tile-size (quot size tiles-per-side)
md5 (digest/md5 identifier)
icon (BufferedImage. size size BufferedImage/TYPE_INT_RGB)
[r g b] (get-color (first (to-numbers md5)))
color (Color. r g b)
draw (.createGraphics icon)]
(fill-background draw size)
(.setColor draw color)
(draw-it draw tile-size 0 (to-bools md5))
(ImageIO/write icon "png" (File. (file-name identifier size)))
file-name))
(defn generate-sans-write
"Make a new avatar."
[identifier size]
(let [tile-size (quot size tiles-per-side)
md5 (digest/md5 identifier)
icon (BufferedImage. size size BufferedImage/TYPE_INT_RGB)
[r g b] (get-color (first (to-numbers md5)))
color (Color. r g b)
draw (.createGraphics icon)]
(fill-background draw size)
(.setColor draw color)
(draw-it draw tile-size 0 (to-bools md5))))
(comment
(generate "foobar-bazz" 128))

Loading…
Cancel
Save