|
|
|
@ -104,45 +104,6 @@ |
|
|
|
; Routes |
|
|
|
; Routes |
|
|
|
; ====== |
|
|
|
; ====== |
|
|
|
|
|
|
|
|
|
|
|
(defpage "/" {} |
|
|
|
|
|
|
|
(layout (get-message :page-title) |
|
|
|
|
|
|
|
[:div#hero |
|
|
|
|
|
|
|
[:h1 (get-message :name)] |
|
|
|
|
|
|
|
[:h2 (get-message :title)] |
|
|
|
|
|
|
|
[:br] |
|
|
|
|
|
|
|
[:a.landing-button {:href "/new" :style "color: white"} (get-message :new-page)]] |
|
|
|
|
|
|
|
[:div#dashed-line] |
|
|
|
|
|
|
|
(md-node :article.helvetica.bottom-space |
|
|
|
|
|
|
|
{:style "font-size: 1em"} |
|
|
|
|
|
|
|
(slurp "LANDING.md")) |
|
|
|
|
|
|
|
(md-node :div.centered.helvetica (get-message :footer)))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defpage "/:year/:month/:day/:title/export" {:keys [year month day title]} |
|
|
|
|
|
|
|
(when-let [md-text (:note (api/get-note (api/build-key [year month day] title)))] |
|
|
|
|
|
|
|
(content-type "text/plain; charset=utf-8" md-text))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defpage "/:year/:month/:day/:title/stats" {:keys [year month day title]} |
|
|
|
|
|
|
|
(when-let [stats (:statistics (api/get-note (api/build-key [year month day] title)))] |
|
|
|
|
|
|
|
(layout (get-message :statistics) |
|
|
|
|
|
|
|
[:table#stats.helvetica.central-element |
|
|
|
|
|
|
|
(map |
|
|
|
|
|
|
|
#(when (% stats) |
|
|
|
|
|
|
|
[:tr [:td (str (get-message %) ":")] [:td (% stats)]]) |
|
|
|
|
|
|
|
[:published :edited :publisher :views])]))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defpage "/:year/:month/:day/:title/edit" {:keys [year month day title]} |
|
|
|
|
|
|
|
(let [noteID (api/build-key [year month day] title)] |
|
|
|
|
|
|
|
(input-form "/update-note" :update |
|
|
|
|
|
|
|
(html (hidden-field :noteID noteID)) |
|
|
|
|
|
|
|
(:note (api/get-note noteID)) :enter-passwd))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defpage "/new" {} |
|
|
|
|
|
|
|
(input-form "/post-note" :publish |
|
|
|
|
|
|
|
(html (hidden-field :session (storage/create-session)) |
|
|
|
|
|
|
|
(hidden-field {:id :signature} :signature)) |
|
|
|
|
|
|
|
(get-message :loading) :set-passwd)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defpage [:post "/post-note"] {:keys [session note signature password version]} |
|
|
|
(defpage [:post "/post-note"] {:keys [session note signature password version]} |
|
|
|
(if (= signature (api/get-signature session note)) |
|
|
|
(if (= signature (api/get-signature session note)) |
|
|
|
(let [pid "NoteHub" |
|
|
|
(let [pid "NoteHub" |
|
|
|
@ -177,6 +138,10 @@ |
|
|
|
:headers {"Location" (str url)} |
|
|
|
:headers {"Location" (str url)} |
|
|
|
:body ""}) |
|
|
|
:body ""}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn return-content-type [ctype content] |
|
|
|
|
|
|
|
{:headers {"Content-Type" ctype} |
|
|
|
|
|
|
|
:body content}) |
|
|
|
|
|
|
|
|
|
|
|
(defroutes api-routes |
|
|
|
(defroutes api-routes |
|
|
|
|
|
|
|
|
|
|
|
(GET "/" [] (layout (get-message :api-title) |
|
|
|
(GET "/" [] (layout (get-message :api-title) |
|
|
|
@ -199,7 +164,44 @@ |
|
|
|
|
|
|
|
|
|
|
|
(defroutes app-routes |
|
|
|
(defroutes app-routes |
|
|
|
(context "/api" [] api-routes) |
|
|
|
(context "/api" [] api-routes) |
|
|
|
(GET "/" [] "Hello World") |
|
|
|
|
|
|
|
|
|
|
|
(GET "/" [] |
|
|
|
|
|
|
|
(layout (get-message :page-title) |
|
|
|
|
|
|
|
[:div#hero |
|
|
|
|
|
|
|
[:h1 (get-message :name)] |
|
|
|
|
|
|
|
[:h2 (get-message :title)] |
|
|
|
|
|
|
|
[:br] |
|
|
|
|
|
|
|
[:a.landing-button {:href "/new" :style "color: white"} (get-message :new-page)]] |
|
|
|
|
|
|
|
[:div#dashed-line] |
|
|
|
|
|
|
|
(md-node :article.helvetica.bottom-space |
|
|
|
|
|
|
|
{:style "font-size: 1em"} |
|
|
|
|
|
|
|
(slurp "LANDING.md")) |
|
|
|
|
|
|
|
(md-node :div.centered.helvetica (get-message :footer)))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(GET "/:year/:month/:day/:title/export" [year month day title] |
|
|
|
|
|
|
|
(when-let [md-text (:note (api/get-note (api/build-key [year month day] title)))] |
|
|
|
|
|
|
|
(return-content-type "text/plain; charset=utf-8" md-text))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(GET "/:year/:month/:day/:title/stats" [year month day title] |
|
|
|
|
|
|
|
(when-let [stats (:statistics (api/get-note (api/build-key [year month day] title)))] |
|
|
|
|
|
|
|
(layout (get-message :statistics) |
|
|
|
|
|
|
|
[:table#stats.helvetica.central-element |
|
|
|
|
|
|
|
(map |
|
|
|
|
|
|
|
#(when (% stats) |
|
|
|
|
|
|
|
[:tr [:td (str (get-message %) ":")] [:td (% stats)]]) |
|
|
|
|
|
|
|
[:published :edited :publisher :views])]))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(GET "/:year/:month/:day/:title/edit" [year month day title] |
|
|
|
|
|
|
|
(let [noteID (api/build-key [year month day] title)] |
|
|
|
|
|
|
|
(input-form "/update-note" :update |
|
|
|
|
|
|
|
(html (hidden-field :noteID noteID)) |
|
|
|
|
|
|
|
(:note (api/get-note noteID)) :enter-passwd))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(GET "/new" [] |
|
|
|
|
|
|
|
(input-form "/post-note" :publish |
|
|
|
|
|
|
|
(html (hidden-field :session (storage/create-session)) |
|
|
|
|
|
|
|
(hidden-field {:id :signature} :signature)) |
|
|
|
|
|
|
|
(get-message :loading) :set-passwd)) |
|
|
|
|
|
|
|
|
|
|
|
(GET "/:year/:month/:day/:title" [year month day title :as params] |
|
|
|
(GET "/:year/:month/:day/:title" [year month day title :as params] |
|
|
|
(let [params (assoc (:query-params params) |
|
|
|
(let [params (assoc (:query-params params) |
|
|
|
|