-
Notifications
You must be signed in to change notification settings - Fork 108
/
post-preview.html
216 lines (192 loc) · 9.85 KB
/
post-preview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
{# ==========================================================================
post_preview.render()
==========================================================================
Description:
Render an article when given:
post: An object with specific article information.
post.specific_class.__name__: String used to check for EventPage post type.
post.specific: An object with specific event information.
post.specific.start_dt: A datetime object with the time of the event.
post.specific.venue_city: A string with the event venue city.
post.specific.venue_state: A string with the event venue state.
post.specific.venue_name: A string with the event venue name.
post.specific.live_video_id: YouTube video ID for the event live stream.
post.date_published: A date timestamp to format.
post.categories: An array with the categories for the post.
Maximum length of array is 2.
post.preview_image: A string with the url of the thumbnail image.
post.preview_title: A string with a preview title
if post.title is not set.
post.title: A string with the title of the post.
post.comments_close_date: A datetime object marking the deadline of the
comment period.
post.preview_subheading: A string with the subheading of the post.
post.preview_description: A string with content of post summary.
post.get_authors(): An array with authors of the post.
post.tags: An array with the post tags for the post.
post.secondary_link_url:
post.secondary_link_text:
post.event_start_dt: A datetime object with the time of the event.
post.event_stream_link: A string with livestream link
post.event_venue: A string with the event venue.
post.event_street: A string with the event street.
post.event_city: A string with the event city.
post.event_state: A string with the event state.
post.event_zip: A string with the event zip.
post.preview_link_text: A string with the description text of an external link.
post.preview_link_url: A string with the url of an external link.
controls: Data object from an instance of the
FilterableList StreamField block.
controls.post_date_description: A string of the post publication description.
controls.categories: An array with the categories for the post.
url: A string with the path for the homepage of the pagetype
`/about-us/blog/`, `/about-us/newsroom/`
post_date_description: A string of the post publication description.
show_date: Whether to render a date for this post.
show_tags: Whether to render the tags for this post.
========================================================================== #}
{% import 'macros/time.html' as time %}
{% import 'molecules/archived-pill.html' as archived_pill %}
{% macro render(
post,
controls,
url='',
post_date_description='',
show_date=true,
show_tags=true
) %}
{% set date_desc = controls.post_date_description or post_date_description %}
{% set cat_controls = controls.categories %}
{% set show_categories = cat_controls.show_preview_categories if cat_controls is defined else true %}
<article class="o-post-preview">
<div class="m-meta-header">
{% if show_categories and post.categories.exists() %}
<div class="m-meta-header_left">
{# If rendering a blog post in the newsroom, use the 'Blog' aggregate category instead of the post's true category. #}
{% import 'macros/category-slug.html' as category_slug %}
{% if cat_controls and 'newsroom' in cat_controls.page_type and is_blog(post) %}
{{ category_slug.render(category='blog', href=url) }}
{% else %}
{% for cat in post.categories.all() %}
{% if loop.index > 1 %}
<span class="m-meta-header_separator">|</span>
{% endif %}
<span class="m-meta-header_category">{{ category_slug.render(category=cat.name, href=url) }}</span>
{% endfor %}
{% endif %}
{% if show_date %}
<span class="m-meta-header_separator">|</span>
{% endif %}
</div>
{% endif %}
{% if show_date %}
<div class="m-meta-header_right">
<span class="a-date">
{{ date_desc }}
{% if 'EventPage' in post.specific_class.__name__ %}
{{ time.render(post.specific.start_dt, {'date':true}) }}
{% elif 'EnforcementAction' in post.specific_class.__name__ and post.initial_filing_date %}
{{ time.render(post.initial_filing_date, {'date':true}) }}
{% else %}
{{ time.render(post.date_published, {'date':true}) }}
{% endif %}
</span>
</div>
{% endif %}
</div>
{% cache post.post_preview_cache_key, 'post_preview' %}
{% set post_url = pageurl(post) %}
{% if 'EventPage' in post.specific_class.__name__ %}
{% set event = post.specific %}
{% if event.venue_image_type != 'none' %}
<div class="o-post-preview_image-container">
{% if event.venue_image_type == 'map' %}
{% from 'macros/util/format/url.html' import location_image_url as location_image_url %}
<img class="o-post-preview_image"
src="{{ event.location_image_url() }}"
alt="">
{% elif event.venue_image_type == 'image' and event.venue_image %}
{% set img = image(event.venue_image, 'width-540') %}
<img class="o-post-preview_image"
src="{{ img.url }}"
alt="{{ image_alt_value(img) }}">
{% endif %}
</div>
{% endif %}
{% elif post.preview_image and not post.archived %}
{% set photo = image(post.preview_image, 'original') %}
<div class="o-post-preview_image-container">
<img class="o-post-preview_image"
src="{{ photo.url }}"
alt="{{ image_alt_value(photo) }}">
</div>
{% endif %}
<div class="o-post-preview_content">
{% if 'EventPage' in post.specific_class.__name__ %}
{% set event = post.specific %}
{% if event.start_dt %}
<time class="calendar-icon"
data-month="{{ event.start_dt | date('%b') }}"
data-day="{{ event.start_dt | date('%-d') }}"
datetime="{{ event.start_dt | date('%c') }}"
aria-hidden="true">
</time>
{% endif %}
{% endif %}
<h3 class="o-post-preview_title">
<a href="{{ post_url }}">
{{ post.preview_title | safe if post.preview_title else post.title }}
{{ archived_pill.render( post ) }}
</a>
</h3>
{% if 'EventPage' in post.specific_class.__name__ %}
{% set event = post.specific %}
{% if event.start_dt %}
<div class="o-post-preview_subtitle">
{% if event.venue_city and event.venue_state %}
{{ event.venue_city }}, {{ event.venue_state }}
{% endif %}
{{ event.venue_name if event.venue_name else '' }}
{{ 'Livecast' if event.live_video_id else '' }}
-
{{ time.render(event.start_dt) }}
</div>
{% endif %}
{% endif %}
{% if post.comments_close_date %}
<div class="o-post-preview_subtitle">
Comments close {{ time.render(post.comments_close_date, {'date':true}) }}
</div>
{% endif %}
{% if post.preview_subheading %}
<div class="o-post-preview_subtitle">
{{ post.preview_subheading }}
</div>
{% endif %}
{% if post.preview_description %}
<div class="o-post-preview_description">
{{ post.preview_description | safe }}
</div>
{% endif %}
{% if post.get_authors() %}
<div class="o-post-preview_byline-group">
{% for author in post.get_authors() %}
{% if loop.first %}By {% elif loop.last %}and {% endif %}
<a href="{{ url }}?authors={{ author.slug }}">{{ author.name }}</a>
{%- if loop.length > 2 and loop.index < loop.length %}, {% endif %}
{% endfor %}
</div>
{% endif %}
{% if show_tags and post.tags.exists() %}
{%- import 'tags.html' as tags %}
{{ tags.render(post.related_metadata_tags(), hide_heading=true, is_wagtail=True) }}
{% endif %}
{% if post.secondary_link_url and post.secondary_link_text %}
<a href="{{ post.secondary_link_url }}" class="a-link a-link__jump">
{{ post.secondary_link_text }}
</a>
{% endif %}
</div>
{% endcache %}
</article>
{% endmacro %}