robots.txt added; rerouting to 404 errors deleted
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
PrivateMakefile
|
PrivateMakefile
|
||||||
dump.rdb
|
dump.rdb
|
||||||
resources/
|
resources/public/cljs
|
||||||
pom.xml
|
pom.xml
|
||||||
*jar
|
*jar
|
||||||
/lib/
|
/lib/
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
User-agent: *
|
||||||
|
Disallow: /new
|
||||||
+11
-15
@@ -13,7 +13,7 @@
|
|||||||
[hiccup.core]
|
[hiccup.core]
|
||||||
[hiccup.element]
|
[hiccup.element]
|
||||||
[noir.response :only [redirect status content-type]]
|
[noir.response :only [redirect status content-type]]
|
||||||
[noir.core :only [defpage pre-route]]
|
[noir.core :only [defpage]]
|
||||||
[cheshire.core]
|
[cheshire.core]
|
||||||
[noir.statuses])
|
[noir.statuses])
|
||||||
(:import
|
(:import
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
; Converts given markdown to html and wraps with the main layout
|
; Converts given markdown to html and wraps with the main layout
|
||||||
(defn- wrap [short-url params md-text]
|
(defn- wrap [short-url params md-text]
|
||||||
(if md-text
|
(when md-text
|
||||||
(layout params (params :title)
|
(layout params (params :title)
|
||||||
[:article (md-to-html md-text)]
|
[:article (md-to-html md-text)]
|
||||||
(let [links (map #(link-to
|
(let [links (map #(link-to
|
||||||
@@ -54,8 +54,7 @@
|
|||||||
space (apply str (repeat 4 " "))
|
space (apply str (repeat 4 " "))
|
||||||
separator (str space "·" space)
|
separator (str space "·" space)
|
||||||
links (interpose separator links)]
|
links (interpose separator links)]
|
||||||
[:div#panel (map identity links)]))
|
[:div#panel (map identity links)]))))
|
||||||
(response 404)))
|
|
||||||
|
|
||||||
(defn get-date
|
(defn get-date
|
||||||
"Returns today's date"
|
"Returns today's date"
|
||||||
@@ -87,7 +86,7 @@
|
|||||||
[:div.centered.helvetica-neue (md-to-html (get-message :created-by))]))
|
[:div.centered.helvetica-neue (md-to-html (get-message :created-by))]))
|
||||||
|
|
||||||
; New Note Page
|
; New Note Page
|
||||||
(pre-route "/new" {}
|
(defpage "/new" {}
|
||||||
(layout {:js true} (get-message :new-note)
|
(layout {:js true} (get-message :new-note)
|
||||||
[:div.central-element
|
[:div.central-element
|
||||||
(form-to [:post "/post-note"]
|
(form-to [:post "/post-note"]
|
||||||
@@ -112,13 +111,12 @@
|
|||||||
|
|
||||||
; Provides Markdown of the specified note
|
; Provides Markdown of the specified note
|
||||||
(defpage "/:year/:month/:day/:title/export" {:keys [year month day title]}
|
(defpage "/:year/:month/:day/:title/export" {:keys [year month day title]}
|
||||||
(let [md-text (get-note [year month day] title)]
|
(when-let [md-text (get-note [year month day] title)]
|
||||||
(if md-text (content-type "text/plain; charset=utf-8" md-text) (response 404))))
|
(content-type "text/plain; charset=utf-8" md-text)))
|
||||||
|
|
||||||
; Provides the number of views of the specified note
|
; Provides the number of views of the specified note
|
||||||
(defpage "/:year/:month/:day/:title/stats" {:keys [year month day title]}
|
(defpage "/:year/:month/:day/:title/stats" {:keys [year month day title]}
|
||||||
(let [views (get-note-views [year month day] title)]
|
(when-let [views (get-note-views [year month day] title)]
|
||||||
(if views
|
|
||||||
(layout (get-message :statistics)
|
(layout (get-message :statistics)
|
||||||
[:table#stats.helvetica-neue.central-element
|
[:table#stats.helvetica-neue.central-element
|
||||||
[:tr
|
[:tr
|
||||||
@@ -126,8 +124,7 @@
|
|||||||
[:td (interpose "-" [year month day])]]
|
[:td (interpose "-" [year month day])]]
|
||||||
[:tr
|
[:tr
|
||||||
[:td (get-message :article-views)]
|
[:td (get-message :article-views)]
|
||||||
[:td views]]])
|
[:td views]]])))
|
||||||
(response 404))))
|
|
||||||
|
|
||||||
; New Note Posting — the most "complex" function in the entire app ;)
|
; New Note Posting — the most "complex" function in the entire app ;)
|
||||||
(defpage [:post "/post-note"] {:keys [draft session-key session-value]}
|
(defpage [:post "/post-note"] {:keys [draft session-key session-value]}
|
||||||
@@ -163,12 +160,11 @@
|
|||||||
|
|
||||||
; Resolving of a short url
|
; Resolving of a short url
|
||||||
(defpage "/:short-url" {:keys [short-url]}
|
(defpage "/:short-url" {:keys [short-url]}
|
||||||
(let [params (resolve-url short-url)]
|
(when-let [params (resolve-url short-url)]
|
||||||
(if params
|
|
||||||
(let [{:keys [year month day title]} params
|
(let [{:keys [year month day title]} params
|
||||||
rest-params (dissoc params :year :month :day :title)
|
rest-params (dissoc params :year :month :day :title)
|
||||||
core-url (url year month day title)
|
core-url (url year month day title)
|
||||||
long-url (if (empty? rest-params) core-url (util/url core-url rest-params))]
|
long-url (if (empty? rest-params) core-url (util/url core-url rest-params))]
|
||||||
(redirect long-url))
|
(redirect long-url))))
|
||||||
(response 404))))
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user