Skip to content

Commit

Permalink
Merge pull request #8484 from cfpb/legacy-page-template
Browse files Browse the repository at this point in the history
Create new template for legacy blog/newsroom items
  • Loading branch information
csebianlander authored Oct 7, 2024
2 parents d3f57ae + cb3913d commit b787e51
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,19 @@
{% if effective_start_date and effective_end_date %}
{% set date_message = 'You are viewing a previous version of the FIG, effective ' + effective_start_date + ' to ' + effective_end_date + '.' %}
{% endif %}
{% set banner_modification = ' o-banner--dark' if version_status == 'Archived' else '' %}

{% block banner_top %}
{% if version_status %}
{% import 'v1/includes/molecules/notification.html' as notification with context %}
<div class="o-banner{{ banner_modification }}">
<div class="wrapper
wrapper--match-content">
{{ notification.render(
'warning',
true,
version_message,
date_message,
[ {
'text': 'View all versions of the FIG.',
'url': '../'
} ]
) }}
</div>
</div>
{% set is_banner_dark = true if version_status == 'Archived' else false %}
{% import 'v1/includes/molecules/banner.html' as banner %}
{{- banner.render(
is_banner_dark,
version_message,
date_message,
[ {
'text': 'View all versions of the FIG',
'url': '../'
} ]
) }}
{% endif %}
{% endblock %}

Expand Down
23 changes: 23 additions & 0 deletions cfgov/v1/jinja2/v1/blog/legacy_blog_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends 'v1/blog/blog_page.html' %}

{% block content_intro scoped -%}
{% import 'v1/includes/molecules/banner.html' as banner %}
{% set canonical_archive_url = 'https://wayback.archive-it.org/23462/20241001120000/' ~ request.build_absolute_uri(request.path) | lower %}
{{- banner.render(
true,
'Archived content',
'This content has been archived, and its original formatting has been removed.',
[ {
'text': 'View this page as it was originally published',
'url': canonical_archive_url
} ]
) }}
{%- endblock %}

{% block content_main %}

{% include 'v1/includes/article.html' %}
{% block post_article_content %}

{% endblock %}
{% endblock %}
42 changes: 42 additions & 0 deletions cfgov/v1/jinja2/v1/includes/molecules/banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{# ==========================================================================

banner.render()

==========================================================================

Description:

Builds banner markup when given:

is_dark: Whether the banner is dark or not. Default is false.

message: Text to display within the banner's notification markup.

explanation: Text to display as an explanation
within the banner's notification markup.
Defaults to none.

links: Array of link objects, which each contain:
- text (required): text of link.
- url: link url.
- is_link_boldface: sets bold formatting.
- open_link_in_new_window: opens the link in a new window
Defaults to an empty array.

========================================================================== #}

{% macro render(is_dark, message, explanation, links) %}
<div class="o-banner{{ ' o-banner--dark' if is_dark else '' }}">
<div class="wrapper wrapper--match-content">
{% import 'v1/includes/molecules/notification.html' as notification %}
{{ notification.render(
'warning',
true,
message,
explanation,
links
) }}
</div>
</div>
{% endmacro %}

19 changes: 7 additions & 12 deletions cfgov/v1/jinja2/v1/includes/organisms/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,17 @@
<header class="o-header{% if mega_menu_content %} o-header--mega-menu{% endif %}">

{% if flag_enabled('BETA_NOTICE') %}
{% import 'v1/includes/molecules/notification.html' as notification with context %}
<div class="o-banner">
<div class="wrapper
wrapper--match-content">
{{ notification.render(
'warning',
true,
'This beta site is a work in progress. Our regular site continues to be
<a href="https://www.consumerfinance.gov/">www.consumerfinance.gov</a>.' | safe
) }}
</div>
</div>
{% import 'v1/includes/molecules/banner.html' as banner %}
{{- banner.render(
false,
'This beta site is a work in progress. Our regular site continues to be
<a href="https://www.consumerfinance.gov/">www.consumerfinance.gov</a>.' | safe
) }}
{% endif %}

{% if banners %}
{% for banner in banners %}
{# TODO: Update this to use the banner.html template. #}
<div class="o-banner">
<div class="wrapper
wrapper--match-content">
Expand Down
2 changes: 1 addition & 1 deletion cfgov/v1/models/blog_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ class LegacyBlogPage(AbstractFilterPage):
edit_handler = AbstractFilterPage.generate_edit_handler(
content_panel=FieldPanel("content")
)
template = "v1/blog/blog_page.html"
template = "v1/blog/legacy_blog_page.html"
2 changes: 1 addition & 1 deletion cfgov/v1/models/newsroom_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class NewsroomPage(BlogPage):


class LegacyNewsroomPage(LegacyBlogPage):
template = "v1/newsroom/newsroom-page.html"
template = "v1/blog/legacy_blog_page.html"

0 comments on commit b787e51

Please sign in to comment.