summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2020-08-07 21:50:48 -0400
committerluxagraf <sng@luxagraf.net>2020-08-07 21:50:48 -0400
commitd456f97a4e00605b13150b8e02467013fd84f33c (patch)
tree6a13ea82fccba282a379d58e2a963297dcdbd635 /app
parentfe912293dcd912cac7f24a488b4faf8f5b275de7 (diff)
added a class name to pad fieldnotes amidst photos
Diffstat (limited to 'app')
-rw-r--r--app/fieldnotes/templates/fieldnotes/fieldnote_list.html7
-rw-r--r--app/lib/templatetags/templatetags/get_next.py25
2 files changed, 30 insertions, 2 deletions
diff --git a/app/fieldnotes/templates/fieldnotes/fieldnote_list.html b/app/fieldnotes/templates/fieldnotes/fieldnote_list.html
index 915d21f..37cd0ca 100644
--- a/app/fieldnotes/templates/fieldnotes/fieldnote_list.html
+++ b/app/fieldnotes/templates/fieldnotes/fieldnote_list.html
@@ -1,5 +1,6 @@
{% extends 'base.html' %}
{% load typogrify_tags %}
+{% load get_next %}
{% load html5_datetime %}
{% load pagination_tags %}
{% block pagetitle %} Field Notes | luxagraf {% endblock %}
@@ -13,7 +14,9 @@
</div>
{% autopaginate object_list 30 %}
<ul class="fancy-archive-list">{% for object in object_list %}{% if object.get_object_type == "fieldnote" %}
- <li class="h-entry hentry field-note-item" itemscope itemType="http://schema.org/Article">
+ {% with next_element=object_list|next:forloop.counter0 %}
+ {% with prev_element=object_list|previous:forloop.counter0 %}
+ <li class="h-entry hentry {% if not next_element.get_object_type == "fieldnote"%}note-pad-bottom{%endif%} {% if not prev_element.get_object_type == "fieldnote"%}note-pad-top{%endif%}" itemscope itemType="http://schema.org/Article">
<a href="{{object.get_absolute_url}}" class="u-url">
{% if object.featured_image %}<div class="circle-img-wrapper"><img src="{{object.featured_image.get_thumbnail_url}}" alt="{{object.featured_image.alt}}" class="u-photo" /></div>{%endif%}
<span class="datei">Field Note: </span><span class="date dt-published">{{object.pub_date|date:"F d, Y"}}</span>
@@ -28,7 +31,7 @@
<data class="p-latitude" value="{{object.latitude}}"></data>
<data class="p-longitude" value="{{object.longitude}}"></data>
</h4>{% endif %}
- </li>{%else%}
+ </li>{%endwith%}{%endwith%}{%else%}
<li class="field-photo-item">
<figure class="daily-figure">
{% include 'lib/img_picwide.html' with image=object caption=False exif=False is_cluster=False cluster_class='' extra='' %}
diff --git a/app/lib/templatetags/templatetags/get_next.py b/app/lib/templatetags/templatetags/get_next.py
new file mode 100644
index 0000000..97159f5
--- /dev/null
+++ b/app/lib/templatetags/templatetags/get_next.py
@@ -0,0 +1,25 @@
+from django import template
+
+register = template.Library()
+
+@register.filter
+def next(some_list, current_index):
+ """
+ Returns the next element of the list using the current index if it exists.
+ Otherwise returns an empty string.
+ """
+ try:
+ return some_list[int(current_index) + 1] # access the next element
+ except:
+ return '' # return empty string in case of exception
+
+@register.filter
+def previous(some_list, current_index):
+ """
+ Returns the previous element of the list using the current index if it exists.
+ Otherwise returns an empty string.
+ """
+ try:
+ return some_list[int(current_index) - 1] # access the previous element
+ except:
+ return '' # return empty string in case of exception