better handling for when there are no visible posts
This commit is contained in:
parent
4286eca04f
commit
8bd20aa40b
|
@ -26,7 +26,9 @@
|
|||
(defn postcount->pagecount
|
||||
([] (postcount->pagecount (posts/count-posts (auth/logged-in?))))
|
||||
([postcount]
|
||||
(int (math/ceil (/ postcount posts/per-page)))))
|
||||
(if (nil? postcount)
|
||||
0
|
||||
(int (math/ceil (/ postcount posts/per-page))))))
|
||||
|
||||
(defn valid-post? [title tags body]
|
||||
(vali/rule (vali/has-value? title)
|
||||
|
@ -39,7 +41,7 @@
|
|||
|
||||
(defn list-page [page]
|
||||
(let [totalpages (postcount->pagecount )
|
||||
lastpage (- totalpages 1)
|
||||
lastpage (make-in-range (- totalpages 1) 0 totalpages)
|
||||
currentpage (make-in-range page 0 lastpage)
|
||||
offset (* currentpage posts/per-page)]
|
||||
(layout/render
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
{% extends "blarg/views/templates/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
{% ifempty posts %}
|
||||
<div>
|
||||
<p class="text-center">There are no posts.</p>
|
||||
</div>
|
||||
{% else %}
|
||||
{% for post in posts %}
|
||||
{% include "blarg/views/templates/posts/post.html" %}
|
||||
{% endfor %}
|
||||
|
@ -21,4 +26,5 @@
|
|||
|
||||
{% include "blarg/views/templates/posts/publishmodal.html" %}
|
||||
{% include "blarg/views/templates/posts/deletemodal.html" %}
|
||||
{% endifempty %}
|
||||
{% endblock %}
|
||||
|
|
Reference in a new issue