💾 Archived View for thurk.org › blog › 138.gmi captured on 2024-03-21 at 15:58:54. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-07-22)

-=-=-=-=-=-=-

The vector is indexable, eh?

Topics: clojure, martenblog

2011-10-09

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[1]. 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)))

1: http://www.webnoir.org/tutorials/routes

tzifur (Martenblog home)

jenju (Thurk.Org home)

@flavigula@sonomu.club

CC BY-NC-SA 4.0