finally fix the archive post list sorting bug

This commit is contained in:
Gered 2014-03-28 21:40:27 -04:00
parent 71d62355d2
commit 682ba6905e
3 changed files with 14 additions and 15 deletions

View file

@ -7,16 +7,16 @@
</div> </div>
<div> <div>
{% for month in months %} {% set mmyyyy = '' %}
{% for post in month %} {% for post in posts %}
{% if loop.first %} {% if (mmyyyy != post.mmyyyy) %}
<h3>{{ post.mmyyyy }}</h3> {% set mmyyyy = post.mmyyyy %}
{% endif %} <h3>{{ post.mmyyyy }}</h3>
<div class="row"> {% endif %}
<div class="span2 muted text-right"><time title="{{ post.created_at|to_fulltime }}">{{ post.created_at|to_month_day }}</time></div> <div class="row">
<div class="span9"><a href="{{ path(post|post_url) }}">{{ post.title }}</a></div> <div class="span2 muted text-right"><time title="{{ post.created_at|to_fulltime }}">{{ post.created_at|to_month_day }}</time></div>
</div> <div class="span9"><a href="{{ path(post|post_url) }}">{{ post.title }}</a></div>
{% endfor %} </div>
{% endfor %} {% endfor %}
</div> </div>

View file

@ -96,10 +96,9 @@
(if-let [posts (->post-list (if-let [posts (->post-list
(couch/with-db posts (couch/with-db posts
(couch/get-view "posts" view-name {:descending true})))] (couch/get-view "posts" view-name {:descending true})))]
(->> posts (map
(map #(assoc % :mmyyyy (->nicer-month-year-str (:mmyyyy %)))) #(assoc % :mmyyyy (->nicer-month-year-str (:mmyyyy %)))
(group-by #(:mmyyyy %)) posts))))
(vals)))))
(defn count-posts (defn count-posts
[unpublished?] [unpublished?]

View file

@ -59,7 +59,7 @@
(defn list-archive [] (defn list-archive []
(layout/render (layout/render
"posts/listarchive.html" "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] (defn show-post-page [year month day slug]
(let [date (str (string->int year) "-" (string->int month) "-" (string->int day)) (let [date (str (string->int year) "-" (string->int month) "-" (string->int day))