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
|
(defn postcount->pagecount
|
||||||
([] (postcount->pagecount (posts/count-posts (auth/logged-in?))))
|
([] (postcount->pagecount (posts/count-posts (auth/logged-in?))))
|
||||||
([postcount]
|
([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]
|
(defn valid-post? [title tags body]
|
||||||
(vali/rule (vali/has-value? title)
|
(vali/rule (vali/has-value? title)
|
||||||
|
@ -39,7 +41,7 @@
|
||||||
|
|
||||||
(defn list-page [page]
|
(defn list-page [page]
|
||||||
(let [totalpages (postcount->pagecount )
|
(let [totalpages (postcount->pagecount )
|
||||||
lastpage (- totalpages 1)
|
lastpage (make-in-range (- totalpages 1) 0 totalpages)
|
||||||
currentpage (make-in-range page 0 lastpage)
|
currentpage (make-in-range page 0 lastpage)
|
||||||
offset (* currentpage posts/per-page)]
|
offset (* currentpage posts/per-page)]
|
||||||
(layout/render
|
(layout/render
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "blarg/views/templates/base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% ifempty posts %}
|
||||||
|
<div>
|
||||||
|
<p class="text-center">There are no posts.</p>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
{% for post in posts %}
|
{% for post in posts %}
|
||||||
{% include "blarg/views/templates/posts/post.html" %}
|
{% include "blarg/views/templates/posts/post.html" %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -21,4 +26,5 @@
|
||||||
|
|
||||||
{% include "blarg/views/templates/posts/publishmodal.html" %}
|
{% include "blarg/views/templates/posts/publishmodal.html" %}
|
||||||
{% include "blarg/views/templates/posts/deletemodal.html" %}
|
{% include "blarg/views/templates/posts/deletemodal.html" %}
|
||||||
|
{% endifempty %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Reference in a new issue