Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new template for legacy blog/newsroom items #8484

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
48 changes: 48 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,48 @@
{% extends 'v1/layouts/layout-2-1.html' %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of inheriting this from layout-2-1, would it make more sense to extend from blog_page.html, and only overwrite the content_intro and content_main blocks? This would avoid having to redefine all of the other blocks that just duplicate what's in blog_page.


{% import 'v1/includes/templates/streamfield-sidefoot.html' as streamfield_sidefoot with context %}

{% block og_type -%}
article
{%- endblock %}

{% block og_article_prefix -%}
article: http://ogp.me/ns/article#
{%- endblock %}

{% block og_article_author -%}
<meta property="article:author"
content="{{ _( 'https://www.facebook.com/CFPB' ) }}">
{%- endblock %}

{% 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 %}

{% block content_sidebar %}
{{ streamfield_sidefoot.render(page.sidefoot) }}
{% if rss_feed %}
<div class="block">
{% import 'v1/includes/molecules/rss-feed.html' as rss %}
{{ rss.render(rss_feed) }}
</div>
{% endif %}
{% 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"
Loading