Compare commits

..

No commits in common. '11e45f8f39663d13c90dca8cec801a0b574a8ae3' and 'e7e66065451e9172ae8ce538ec691df7fa0b0a8a' have entirely different histories.

@ -1,12 +1,9 @@
#+TITLE: DarkLimericks
#+TITLE: RhymeStorm™
https://darklimericks.com
* WGU Evaluator Notes
The world's largest metal limericks archive on the Web.
See [[file:web/README_WGU.org][the WGU Readme]].
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
@ -21,7 +18,8 @@ I also borrowed some functionality from a NLP/rhyme-related codebase that is not
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~
3. Visit ~http://localhost:8000/wgu~
* How To Run Software Locally
@ -34,29 +32,21 @@ I also borrowed some functionality from a NLP/rhyme-related codebase that is not
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 web/darklimericks.jar~
4. Visit http://localhost:8000
3. Navigate to the root directory of this git repo and run ~java -jar darklimericks.jar~
4. Visit http://localhost:8000/wgu
* 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: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.
* Development
But obviously the album images and the data in the db/kv are going to be different between local and prod.
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.
You can use ~rsync~ with ~--exclude~ to only sync over the code bits.
Build ~.jar~ with ~clojure -X:depstart uberjar :jar prhyme.jar~.
~rsync --exclude '*/data/*' --exclude '*/images/*' -aLP ./ root@darklimericks.com:/root/darklimericks/~
* TODO
Note the ~-L~ to follow symlinks. Locally, I'm symlinking tachyons.css.
** Use tightly packed trie for limerick generation
The other shortcut I'm taking is that images are stored and served relative to the path of the running application.
** Move limerick-specific code into this repo from Prhyme.
That means you need to launch the jar file from the ~web~ directory.
Or maybe into its own repo.

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

@ -3,6 +3,5 @@
#+begin_src sh
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
certbot certonly -d darklimericks.com --webroot=/root/darklimericks/web/resources/public
#+end_src

File diff suppressed because it is too large Load Diff

@ -2,7 +2,7 @@
{:min-level :debug}
:com.darklimericks.server.core/server
{:port 8008 :handler #ig/ref :com.darklimericks.server.handlers/handler}
{:port 8000 :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)
"/rhymestorm/foo.html"))
"/wgu/foo.html"))
)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

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

@ -139,10 +139,9 @@
[artist-id album-id] album-artist
album (albums/album db album-id)]
(when (:new-album (meta album-artist))
(let [icon (identicon/generate
(-> (:album/name album)
(identicon/generate (-> (:album/name album)
string/lower-case
(string/replace #" " "-")) 128)]))
(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]
["/rhymestorm"
["/wgu"
[""
{:name ::rhymestorm
:get {:handler (handlers/rhymestorm db cache)}
{:name ::wgu
:get {:handler (handlers/wgu 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 rhymestorm
(defn wgu
[request {:keys [rhymes rhyming-lyrics lyrics-from-seed]}]
[:div
[:h1 "RhymeStorm™"]
[:h1 "WGU Capstone"]
[:div
[:h2 "Generate Rhyme"]
@ -371,7 +371,7 @@ prefixes to that rhyming phrase."]
(defn lyric-suggestions
[request suggestions]
[:div
(rhymestorm
(wgu
request
{:rhyming-lyrics
[:table {:style "margin: auto;"}
@ -392,7 +392,7 @@ prefixes to that rhyming phrase."]
(defn show-rhyme-suggestion
[request suggestions]
[:div
(rhymestorm
(wgu
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))]
(rhymestorm
(wgu
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/rhymestorm-lyric-suggestions
(let [suggestions (linguistics/wgu-lyric-suggestions
(-> request :params :seed))]
(rhymestorm
(wgu
request
{:lyrics-from-seed
[:div

@ -106,7 +106,8 @@
(defn generate
"Make a new avatar."
[identifier size]
(let [tile-size (quot size tiles-per-side)
(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)))
@ -118,18 +119,5 @@
(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))

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

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

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

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