Flavigula

Here lies Martes Flavigula, eternally beneath the splintered earth.


blog | music | poems | lakife | recipes

Blog -

Search
Ruby has found a Clojure.
Clojure
Martenblog
Sheepblog
Sun, 09 Oct, 2011 17.37 UTC

I’ve begun porting Sheepblog (IE, this thing you are looking at right now) from Ruby/Sinatra to Clojure/Noir. I am in the beginning phases, but I believe that the database schema will stay the same for now.

New features

  • When not creating or editing a post, topics will set the session key :topic to the topic’s id. Any look at /rutabaga will show only posts which pertain to the set topic.
  • Multiple user capability. Hopefully Christopher will eventually post something.
  • Comments, by user or anonymous.

First problem!

clojure.contrib.sql no longer exists. Or, rather, it exists in an outdated form which breaks everything in sight with an unsightly getRoot not found or somesuch error. Use clojure.java.jdbc instead.

The vector is indexable, eh?
Clojure
Martenblog
Sun, 09 Oct, 2011 22.24 UTC

Now a certain error is being an irritant. It looks like this:

java.lang.IllegalArgumentException: Key must be integer

Here is the code spouting the error:

(defpage "/expand/:id" {:keys [id]}
  (let [e (entry/get-record id)]
   (normal-entry e)
   (expand-contract-link "contract" e)))

As any observant mustelid can see, there is nothing wrong with that code according to the Noir documentation. I shall pull out pieces of my pancreas for a few more minutes flummoxing myself about it.

I dislike it greatly when a problem solves itself, and especially if it is just from tinkering a bit.

Here is the code:

(defpartial expand-contract-link [which e]
  [:br.clear]
  (link-to {:id (str which (:id e))}
           "#" which)
  [:hr.clear])

(defpartial ajax-hovno []
  [:script "ajax_hovno();"])

(defpartial normal-entry [e]
  (:entry e)
  (expand-contract-link "contract" e)
  (ajax-hovno))

(defpartial truncated-entry [e]
  (trunc (:entry e))
  (expand-contract-link "expand" e)
  (ajax-hovno))

; Ajax paths                                                                    
(defpage "/expand/:id" {:keys [id]}
  (normal-entry (entry/get-record id)))

(defpage "/contract/:id" {:keys [id]}
  (truncated-entry (entry/get-record id)))

Along with martens, goulish goats and the rippling fen -
these writings 1993-2023 by Bob Murry Shelton are licensed under CC BY-NC-SA 4.0

Mastodon Gemini Funkwhale Bandcamp
Fediring