diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2023-07-15 11:52:33 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2023-07-15 11:52:33 -0400 |
commit | f71501249904feb88a2d2002a8e55669ab71fa0a (patch) | |
tree | 693bd77b481d888d86600a25b1ad99530d041722 | |
parent | b30265fba6fa396b5450a36033bcd63952217017 (diff) |
-rw-r--r-- | src/lemmold/core.clj | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/lemmold/core.clj b/src/lemmold/core.clj index fb34fdd..1f77135 100644 --- a/src/lemmold/core.clj +++ b/src/lemmold/core.clj @@ -120,12 +120,27 @@ \P (recur (dec offset) comments) (do (println "Unknown command.") (recur offset comments))))) +(defn view-post-body + "Shows the body of the post if available; in that case, ask about viewing comments." + [post] + (let [body (get-in post ["post" "body"])] + (or (empty? body) + (do + (println) + (println "Post contents:") + (println) + (println body) + (println) + (print "BC> ") + (flush) + (= \C (first (read-line))))))) + (defn view-nth-post "Views the index-th post from the current post list." [state posts index] - (view-post - (:instance state) - (nth posts (cond-> (+ 5 index) (:top state) (- 5)))) + (let [post (nth posts (cond-> (+ 5 index) (:top state) (- 5)))] + (when (view-post-body post) + (view-post (:instance state) post))) state) (defn get-post-list |