Skip to content

Commit

Permalink
Add authors index
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Jan 9, 2024
1 parent 9664fb9 commit d551e65
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 32 deletions.
4 changes: 0 additions & 4 deletions app/templates/authors/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
{%- from 'components/card/macro.html' import tnaCard -%}
{%- from 'macros/feedback.html' import feedback -%}

{% block beforeContent %}
<!-- TEMP -->
{% endblock %}

{% block content %}
<article>
<header class="tna-container tna-section etna-author-header">
Expand Down
32 changes: 21 additions & 11 deletions app/templates/authors/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends 'base.html' %}

{%- from 'macros/feedback.html' import feedback -%}
{%- from 'components/card/macro.html' import tnaCard -%}

{% block content %}
<section class="tna-section">
Expand All @@ -10,17 +11,26 @@ <h1 class="tna-heading-xl">{{ page_data['title'] }}</h1>
{{ page_data['intro'] | safe }}
</div>
</div>
<div class="tna-container">
<div class="tna-column tna-column--full">
<ul>
{% for child in children %}
<li>
<a href="{{ child['meta']['html_url'] }}">{{ child['title'] }}</a>
</li>
{% endfor %}
</ul>
</div>
</div>
<ul class="tna-ul tna-ul--plain tna-container">
{% for child in children %}
<li class="tna-column tna-column--width-1-3 tna-column--width-1-2-medium tna-column--width-1-2-small tna-column--full-tiny tna-!--margin-bottom-l">
{{ tnaCard({
'title': child['title'],
'headingLevel': 2,
'body': child['role'],
'href': child['meta']['html_url'],
'imageSrc': child['teaser_image_jpg']['full_url'],
'imageAlt': child['teaser_image_jpg']['alt'],
'imageWidth': child['teaser_image_jpg']['width'],
'imageHeight': child['teaser_image_jpg']['height'],
'htmlElement': 'article',
'classes': 'tna-!--margin-top-l'
}) }}


</li>
{% endfor %}
</ul>
</section>
{{ feedback() }}
{% endblock %}
32 changes: 16 additions & 16 deletions app/wagtail/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,34 @@ def breadcrumbs(page_id):
)


def page_details(page_id):
def page_details(page_id, params={}):
uri = f"pages/{page_id}/"
return wagtail_request_handler(uri)
return wagtail_request_handler(uri, params)


def page_details_by_uri(page_uri):
def page_details_by_uri(page_uri, params={}):
uri = "pages/find/"
params = {"html_path": page_uri}
params = params | {"html_path": page_uri}
return wagtail_request_handler(uri, params)


def page_children(page_id):
def page_children(page_id, params={}):
uri = "pages/"
params = {"child_of": page_id}
params = params | {"child_of": page_id}
return wagtail_request_handler(uri, params)


def page_ancestors(page_id):
def page_ancestors(page_id, params={}):
uri = "pages/"
params = {"ancestor_of": page_id}
params = params | {"ancestor_of": page_id}
return wagtail_request_handler(uri, params)


def page_children_paginated(page_id, page, children_per_page):
def page_children_paginated(page_id, page, children_per_page, params={}):
offset = (page - 1) * children_per_page
uri = "pages/"
order = "-first_published_at"
params = {
params = params | {
"child_of": page_id,
"offset": offset,
"limit": children_per_page,
Expand All @@ -112,17 +112,17 @@ def page_children_paginated(page_id, page, children_per_page):
return wagtail_request_handler(uri, params)


def image_details(image_id):
def image_details(image_id, params={}):
uri = f"images/{image_id}/"
return wagtail_request_handler(uri)
return wagtail_request_handler(uri, params)


def media_details(media_id):
def media_details(media_id, params={}):
uri = f"media/{media_id}/"
return wagtail_request_handler(uri)
return wagtail_request_handler(uri, params)


def page_preview(content_type, token):
def page_preview(content_type, token, params={}):
uri = "page_preview/1/"
params = {"content_type": content_type, "token": token}
params = params | {"content_type": content_type, "token": token}
return wagtail_request_handler(uri, params)
3 changes: 2 additions & 1 deletion app/wagtail/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ def highlight_gallery_page(page_data):

def author_index_page(page_data):
try:
children_data = page_children(page_data["id"])
# children_data = page_children(page_data["id"], {"fields": "_,title,teaser_image_jpg,role"})
children_data = page_children(page_data["id"], {"order": "title"})
children = [
page_details(child["id"]) for child in children_data["items"]
]
Expand Down

0 comments on commit d551e65

Please sign in to comment.