From 682ba6905efec484cdcb7db0a8e01f739889465b Mon Sep 17 00:00:00 2001 From: gered Date: Fri, 28 Mar 2014 21:40:27 -0400 Subject: [PATCH] finally fix the archive post list sorting bug --- resources/views/posts/listarchive.html | 20 ++++++++++---------- src/blarg/models/posts.clj | 7 +++---- src/blarg/routes/posts.clj | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/resources/views/posts/listarchive.html b/resources/views/posts/listarchive.html index 78553bf..600fd0d 100644 --- a/resources/views/posts/listarchive.html +++ b/resources/views/posts/listarchive.html @@ -7,16 +7,16 @@
-{% for month in months %} -{% for post in month %} -{% if loop.first %} -

{{ post.mmyyyy }}

-{% endif %} -
-
- -
-{% endfor %} +{% set mmyyyy = '' %} +{% for post in posts %} + {% if (mmyyyy != post.mmyyyy) %} + {% set mmyyyy = post.mmyyyy %} +

{{ post.mmyyyy }}

+ {% endif %} +
+
+ +
{% endfor %}
diff --git a/src/blarg/models/posts.clj b/src/blarg/models/posts.clj index f32f450..dd525b7 100644 --- a/src/blarg/models/posts.clj +++ b/src/blarg/models/posts.clj @@ -96,10 +96,9 @@ (if-let [posts (->post-list (couch/with-db posts (couch/get-view "posts" view-name {:descending true})))] - (->> posts - (map #(assoc % :mmyyyy (->nicer-month-year-str (:mmyyyy %)))) - (group-by #(:mmyyyy %)) - (vals))))) + (map + #(assoc % :mmyyyy (->nicer-month-year-str (:mmyyyy %))) + posts)))) (defn count-posts [unpublished?] diff --git a/src/blarg/routes/posts.clj b/src/blarg/routes/posts.clj index 99d0dac..85ec3e2 100644 --- a/src/blarg/routes/posts.clj +++ b/src/blarg/routes/posts.clj @@ -59,7 +59,7 @@ (defn list-archive [] (layout/render "posts/listarchive.html" - :params {:months (posts/list-posts-archive (auth/logged-in?))})) + :params {:posts (posts/list-posts-archive (auth/logged-in?))})) (defn show-post-page [year month day slug] (let [date (str (string->int year) "-" (string->int month) "-" (string->int day))