title derivation improved and added to API

This commit is contained in:
Christian Mueller
2014-01-19 14:23:56 +01:00
parent e20811ca76
commit ad632f96ce
4 changed files with 20 additions and 11 deletions
+13 -6
View File
@@ -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
+1 -1
View File
@@ -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 %)