title derivation improved and added to API
This commit is contained in:
+13
-6
@@ -25,6 +25,11 @@
|
||||
[[year month day] title]
|
||||
(print-str year month day title))
|
||||
|
||||
(defn derive-title [md-text]
|
||||
(apply str
|
||||
(remove #{\# \_ \*}
|
||||
(first (split-lines md-text)))))
|
||||
|
||||
(defn get-date
|
||||
"Returns today's date"
|
||||
[]
|
||||
@@ -54,12 +59,14 @@
|
||||
|
||||
(defn get-note [noteID]
|
||||
(if (storage/note-exists? noteID)
|
||||
{:note (storage/get-note noteID)
|
||||
:longURL (get-path noteID)
|
||||
:shortURL (get-path noteID :short)
|
||||
:statistics (storage/get-note-statistics noteID)
|
||||
:status (create-response true)
|
||||
:publisher (storage/get-publisher noteID)}
|
||||
(let [note (storage/get-note noteID)]
|
||||
{:note note
|
||||
:title (derive-title note)
|
||||
:longURL (get-path noteID)
|
||||
:shortURL (get-path noteID :short)
|
||||
:statistics (storage/get-note-statistics noteID)
|
||||
:status (create-response true)
|
||||
:publisher (storage/get-publisher noteID)})
|
||||
(create-response false "noteID '%s' unknown" noteID)))
|
||||
|
||||
(defn post-note
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
; Converts given markdown to html and wraps with the main layout
|
||||
(defn- wrap [short-url params md-text]
|
||||
(when md-text
|
||||
(layout params (params :title)
|
||||
(layout params (api/derive-title md-text)
|
||||
[:article.bottom-space.markdown md-text]
|
||||
(let [links (map #(link-to
|
||||
(if (= :short-url %)
|
||||
|
||||
Reference in New Issue
Block a user