-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add byline support to Text Introductions
This commit adds support for bylines to the Text Introduction block in the same way that Item Introduction blocks support them. To avoid duplication, the common byline functionality has been pulled out into a new byline template (although not into a new Wagtail block). All three of the affected templates (byline, item introduction, text introduction) can be previewed using this repository's template debug functionality at these URLs: - http://localhost:8000/admin/template_debug/v1/byline/ - http://localhost:8000/admin/template_debug/v1/item_introduction/ - http://localhost:8000/admin/template_debug/v1/text_introduction/ Like Item Introduction bylines, Text Introduction bylines can have zero or more authors and an optional date. This commit also includes some minor cleanup around the way that item introduction blocks have been manually rendered on various page types. As far as I can tell this special handling is no longer needed, if it ever was. Affected page types and example pages to verify this: - BlogPage: http://localhost:8000/about-us/blog/why-were-modernizing-how-we-collect-credit-card-data/ - DocumentDetailPage: http://localhost:8000/compliance/supervisory-guidance/bulletin-phone-pay-fees/ - EnforcementActionPage: http://localhost:8000/enforcement/actions/capital-one-bank/ - LearnPage: http://localhost:8000/enforcement/information-industry-whistleblowers/privacy-act-statement/ - NewsroomPage: http://localhost:8000/about-us/newsroom/cfpb-issues-guidance-to-address-shoddy-investigation-practices-by-consumer-reporting-companies/ - HMDAHistoricDataPage: http://localhost:8000/data-research/hmda/historic-data/ This commit also adds a few new Python unit tests to validate the intended template rendering.
- Loading branch information
Showing
19 changed files
with
379 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{# ========================================================================== | ||
|
||
Create a byline when given: | ||
|
||
value.authors: List of author names. | ||
|
||
value.date: Publication date. | ||
|
||
========================================================================== #} | ||
|
||
{%- macro render( value ) %} | ||
{%- if value.authors or value.date -%} | ||
<div class="a-byline"> | ||
{% if value.authors %} | ||
<span class="byline"> | ||
{%- for author in value.authors -%} | ||
{% if loop.first %}By {% elif loop.last %} and {% endif -%} | ||
{{ author }} | ||
{%- if loop.length > 2 and loop.index < loop.length %}, {% endif %} | ||
{%- endfor -%} | ||
</span> | ||
{% endif -%} | ||
|
||
{% if value.authors and value.date -%} | ||
– | ||
{%- endif %} | ||
|
||
{%- if value.date %} | ||
<span class="a-date"> | ||
{% import 'macros/time.html' as time %} | ||
{{ time.render( value.date, { 'date': true } ) }} | ||
</span> | ||
{% endif %} | ||
</div> | ||
{%- endif %} | ||
{%- endmacro %} | ||
|
||
|
||
{%- if value %} | ||
|
||
{% if page and not "authors" in value %} | ||
{% do value.update( | ||
{ "authors": page.authors.values_list( "name", flat=True ) } | ||
) %} | ||
{% endif %} | ||
|
||
{{- render( value ) -}} | ||
|
||
{% endif -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.