diff --git a/src/blarg/datetime.clj b/src/blarg/datetime.clj index 6d99363..02729a9 100644 --- a/src/blarg/datetime.clj +++ b/src/blarg/datetime.clj @@ -82,6 +82,14 @@ (= minutes 1) "1 minute ago" :else "just now")))) +(defn ->month-day-str + "Returns a date string in the format 'MMM d' from the given date object or + string timestamp" + [date] + (if (string? date) + (->month-day-str (clj-time.local/to-local-date-time date)) + (clj-time.format/unparse (clj-time.format/formatter "MMM d") date))) + (defn ->nicer-month-year-str "Given a date in 'MM-yyyy' format (numeric month), returns the same date in 'MMM yyyy' format (name of month)" diff --git a/src/blarg/routes/posts.clj b/src/blarg/routes/posts.clj index 379a674..3fc0990 100644 --- a/src/blarg/routes/posts.clj +++ b/src/blarg/routes/posts.clj @@ -55,6 +55,10 @@ "posts/listbytag.html" {:posts (posts/list-posts-by-tag (auth/logged-in?) tag) :tag tag})) +(defn list-archive [] + (layout/render + "posts/listarchive.html" {:months (posts/list-posts-archive (auth/logged-in?))})) + (defn show-post-page [year month day slug] (let [date (str year "-" month "-" day) post (posts/get-post-by-date-slug date slug)] @@ -117,6 +121,7 @@ [year month day slug] (show-post-page year month day slug)) (GET "/tag/:tag" [tag] (list-by-tag tag)) + (GET "/archive" [] (list-archive)) (restricted GET "/newpost" [] (new-post-page)) (restricted POST "/newpost" [title tags body] (handle-new-post title tags body)) (restricted GET "/editpost/:id" [id] (edit-post-page id)) diff --git a/src/blarg/views/templates/posts/listarchive.html b/src/blarg/views/templates/posts/listarchive.html new file mode 100644 index 0000000..5293af4 --- /dev/null +++ b/src/blarg/views/templates/posts/listarchive.html @@ -0,0 +1,23 @@ +{% extends "blarg/views/templates/base.html" %} + +{% block content %} + +