expected note title feature added

This commit is contained in:
Christian Müller
2014-12-25 15:56:10 +01:00
parent a0373fee81
commit aad64bc256
4 changed files with 48 additions and 8 deletions
+7 -4
View File
@@ -75,6 +75,12 @@
:publisher (storage/get-publisher noteID)})
{:status (create-response false "noteID '%s' unknown" noteID)}))
(defn propose-title [note]
(let [raw-title (filter #(or (= \- %) (Character/isLetterOrDigit %))
(-> note derive-title trim (sreplace " " "-") lower-case))
max-length (get-setting :max-title-length #(Integer/parseInt %) 80)]
(apply str (take max-length raw-title))))
(defn post-note
[{:keys [note pid signature password hostURL] :as params}]
;(log "post-note: %s" {:pid pid :signature signature :password password :note note})
@@ -86,10 +92,7 @@
(if (empty? errors)
(let [[year month day] (map str (get-date))
params (select-keys params [:text-size :header-size :text-font :header-font :theme])
raw-title (filter #(or (= \- %) (Character/isLetterOrDigit %))
(-> note derive-title trim (sreplace " " "-") lower-case))
max-length (get-setting :max-title-length #(Integer/parseInt %) 80)
proposed-title (apply str (take max-length raw-title))
proposed-title (propose-title note)
title (first (drop-while #(storage/note-exists? (build-key year month day %))
(cons proposed-title
(map #(str proposed-title "-" (+ 2 %)) (range)))))
+6
View File
@@ -59,6 +59,12 @@
(GET "/" [] landing-page)
(POST "/propose-title" {body :body}
(let [note (slurp body)]
(return-content-type
"text/plain; charset=utf-8"
(api/propose-title note))))
(GET "/:year/:month/:day/:title/export" [year month day title]
(when-let [md-text (:note (api/get-note {:noteID (api/build-key year month day title)}))]
(return-content-type "text/plain; charset=utf-8" md-text)))
+7 -3
View File
@@ -60,10 +60,14 @@
fields
(text-area :note content)
[:fieldset#input-elems {:class css-class}
(text-field {:class "ui-elem" :placeholder (get-message passwd-msg)}
:plain-password)
(text-field {:class "ui-elem"
:placeholder (get-message passwd-msg)}
:plain-password) "&nbsp"
(submit-button {:class "button ui-elem"
:id :publish-button} (get-message command))])])))
:id :publish-button} (get-message command))
[:br]
[:br]
[:div#proposed-title {:style "color: #aaa; font-size: 0.8em"}]])])))
(def landing-page
(layout :no-js {} (get-message :page-title)