|
|
|
@ -36,12 +36,12 @@ |
|
|
|
([success message & params] |
|
|
|
([success message & params] |
|
|
|
(assoc (create-response success) :message (apply format message params)))) |
|
|
|
(assoc (create-response success) :message (apply format message params)))) |
|
|
|
|
|
|
|
|
|
|
|
(defn- getPath [noteID & description] |
|
|
|
(defn- get-path [noteID & description] |
|
|
|
(if description |
|
|
|
(if description |
|
|
|
(str "/" (storage/get-short-url noteID)) |
|
|
|
(str "/" (storage/get-short-url noteID)) |
|
|
|
(let [[year month day title] (split noteID #" ")] |
|
|
|
(let [[year month day title] (split noteID #" ")] |
|
|
|
(apply str (interpose "/" |
|
|
|
(apply str (interpose "/" |
|
|
|
[year month day (ring.util.codec/url-encode title)]))))) |
|
|
|
[domain year month day (ring.util.codec/url-encode title)]))))) |
|
|
|
|
|
|
|
|
|
|
|
(let [md5Instance (java.security.MessageDigest/getInstance "MD5")] |
|
|
|
(let [md5Instance (java.security.MessageDigest/getInstance "MD5")] |
|
|
|
(defn get-signature |
|
|
|
(defn get-signature |
|
|
|
@ -55,8 +55,8 @@ |
|
|
|
(defn get-note [noteID] |
|
|
|
(defn get-note [noteID] |
|
|
|
(if (storage/note-exists? noteID) |
|
|
|
(if (storage/note-exists? noteID) |
|
|
|
{:note (storage/get-note noteID) |
|
|
|
{:note (storage/get-note noteID) |
|
|
|
:longPath (getPath noteID) |
|
|
|
:longURL (get-path noteID) |
|
|
|
:shortPath (getPath noteID :short) |
|
|
|
:shortURL (get-path noteID :short) |
|
|
|
:statistics (storage/get-note-statistics noteID) |
|
|
|
:statistics (storage/get-note-statistics noteID) |
|
|
|
:status (create-response true)} |
|
|
|
:status (create-response true)} |
|
|
|
(create-response false "noteID '%s' unknown" noteID))) |
|
|
|
(create-response false "noteID '%s' unknown" noteID))) |
|
|
|
@ -88,8 +88,8 @@ |
|
|
|
(storage/add-note noteID note password) |
|
|
|
(storage/add-note noteID note password) |
|
|
|
(storage/create-short-url noteID) |
|
|
|
(storage/create-short-url noteID) |
|
|
|
{:noteID noteID |
|
|
|
{:noteID noteID |
|
|
|
:longPath (getPath noteID) |
|
|
|
:longURL (get-path noteID) |
|
|
|
:shortPath (getPath noteID :short) |
|
|
|
:shortURL (get-path noteID :short) |
|
|
|
:status (create-response true)})) |
|
|
|
:status (create-response true)})) |
|
|
|
{:status (create-response false (first errors))})))) |
|
|
|
{:status (create-response false (first errors))})))) |
|
|
|
|
|
|
|
|
|
|
|
@ -107,7 +107,7 @@ |
|
|
|
(if (empty? errors) |
|
|
|
(if (empty? errors) |
|
|
|
(do |
|
|
|
(do |
|
|
|
(storage/edit-note noteID note) |
|
|
|
(storage/edit-note noteID note) |
|
|
|
{:longPath (getPath noteID) |
|
|
|
{:longURL (get-path noteID) |
|
|
|
:shortPath (getPath noteID :short) |
|
|
|
:shortURL (get-path noteID :short) |
|
|
|
:status (create-response true)}) |
|
|
|
:status (create-response true)}) |
|
|
|
{:status (create-response false (first errors))}))) |
|
|
|
{:status (create-response false (first errors))}))) |
|
|
|
|