diff --git a/bookwyrm/templates/snippets/boost_button.html b/bookwyrm/templates/snippets/boost_button.html new file mode 100644 index 00000000..7133e818 --- /dev/null +++ b/bookwyrm/templates/snippets/boost_button.html @@ -0,0 +1,19 @@ +{% load fr_display %} +{% with activity.id|uuid as uuid %} +
+ {% csrf_token %} + +
+
+ {% csrf_token %} + +
+{% endwith %} diff --git a/bookwyrm/templates/snippets/fav_button.html b/bookwyrm/templates/snippets/fav_button.html new file mode 100644 index 00000000..de41064a --- /dev/null +++ b/bookwyrm/templates/snippets/fav_button.html @@ -0,0 +1,19 @@ +{% load fr_display %} +{% with activity.id|uuid as uuid %} +
+ {% csrf_token %} + +
+
+ {% csrf_token %} + +
+{% endwith %} diff --git a/bookwyrm/templates/snippets/reply_form.html b/bookwyrm/templates/snippets/reply_form.html new file mode 100644 index 00000000..48371f63 --- /dev/null +++ b/bookwyrm/templates/snippets/reply_form.html @@ -0,0 +1,33 @@ +{% load fr_display %} +{% with activity.id|uuid as uuid %} +
+
+ {% csrf_token %} + + +
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+{% endwith %} diff --git a/bookwyrm/templates/snippets/status.html b/bookwyrm/templates/snippets/status.html index 6e249520..9390d39c 100644 --- a/bookwyrm/templates/snippets/status.html +++ b/bookwyrm/templates/snippets/status.html @@ -47,10 +47,8 @@ - {{ status.published_date | naturaltime }} - - {% if status.user == request.user %} + + {% if status.user == request.user %} + - - - - + +
+ + +
{% else %} diff --git a/bookwyrm/templatetags/fr_display.py b/bookwyrm/templatetags/fr_display.py index 2af66a54..73df1db8 100644 --- a/bookwyrm/templatetags/fr_display.py +++ b/bookwyrm/templatetags/fr_display.py @@ -1,6 +1,10 @@ ''' template filters ''' from uuid import uuid4 +from datetime import datetime + +from dateutil.relativedelta import relativedelta from django import template +from django.utils import timezone from bookwyrm import models @@ -133,6 +137,26 @@ def get_uuid(identifier): return '%s%s' % (identifier, uuid4()) +@register.filter(name="post_date") +def time_since(date): + ''' concise time ago function ''' + if not isinstance(date, datetime): + return '' + now = timezone.now() + delta = now - date + + if date < (now - relativedelta(weeks=1)): + return date.strftime('%b %-d') + delta = relativedelta(now, date) + if delta.days: + return '%dd' % delta.days + if delta.hours: + return '%dh' % delta.hours + if delta.minutes: + return '%dm' % delta.minutes + return '%ds' % delta.seconds + + @register.simple_tag(takes_context=True) def shelve_button_identifier(context, book): ''' check what shelf a user has a book on, if any '''