summaryrefslogtreecommitdiff
path: root/sw/templates/get_user_inbox_page.json
diff options
context:
space:
mode:
authorTom Harley2021-08-01 14:27:21 +0000
committerTom Harley2021-08-02 14:41:06 +0000
commitbafe42275e65b98951dd3335342e38d7bf1b1db5 (patch)
tree69af3fd0d1ff77baea81a3396a45c7287afdecc0 /sw/templates/get_user_inbox_page.json
parentSupport dev environment via nix-shell (diff)
downloadswap-untested.tar.gz
swap-untested.zip

Utilise jinja inheritance to streamline in/outbox

untested

Using jinja’s templating extensions, we can recreate the activitypub inheritance hierarchy without using clunky python OO.

Extending from multiple template files in sequence might cause unnecesary IO to slow response times; if this ever becomes an issue, it should be possible to pre-process some of the templating since a lot of it will be based on constant expressions (such as @context and type).

I think some formatting fixes leaked into this commit; oops! I’m leaving this note here in the hopes that if I ever want to clean this up, I can locate this commit easier.

Diffstat (limited to 'sw/templates/get_user_inbox_page.json')
-rw-r--r--sw/templates/get_user_inbox_page.json21
1 files changed, 10 insertions, 11 deletions
diff --git a/sw/templates/get_user_inbox_page.json b/sw/templates/get_user_inbox_page.json
index 96bf9e8..886aeda 100644
--- a/sw/templates/get_user_inbox_page.json
+++ b/sw/templates/get_user_inbox_page.json
@@ -1,20 +1,19 @@
-{% extends "base.json" %}
-
-{% block content %}
-"type": "OrderedCollectionPage",
+{% extends "ap/ordered_collection_page.json" %}
+{% block nav %}
"id": "{{ url_for('.get_user_inbox_page', username=user['username'], max_id=max_id) }}",
+"current": "{{ url_for('.get_user_inbox_page', username=user['username']) }}",
+"partOf": "{{ url_for('.get_user_inbox', username=user['username']) }}",
{% if items %}
"next": "{{ url_for('.get_user_inbox_page', username=user['username'], max_id=(min_id-1)) }}",
"prev": "{{ url_for('.get_user_inbox_page', username=user['username'], min_id=(max_id+1)) }}",
{% endif %}
-"current": "{{ url_for('.get_user_inbox_page', username=user['username']) }}",
-"partOf": "{{ url_for('.get_user_inbox', username=user['username']) }}",
-"items": [
- {% for item in items %}
- "{{ item }}"{{ ',' if not loop.last }}
- {% endfor %}
-],
+{% endblock %}
+
+{% block item_info scoped %}
+
+"{{ item }}"
+
{% endblock %}