-
-
Notifications
You must be signed in to change notification settings - Fork 183
/
base_chapter.html
287 lines (264 loc) · 13.1 KB
/
base_chapter.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
{% extends "%s/2019/base.html" % lang %}
{% set chapter_image_dir = ("/static/images/2019/%s" % metadata.chapter) %}
{% block image_url %}https://almanac.httparchive.org{{ chapter_image_dir }}/hero_lg.jpg{% endblock %}
{% block image_height %}433{% endblock %}
{% block image_width %}866{% endblock %}
{% block date_published %}{{ metadata.get('published','2019-11-04') + 'T12:00:00.000Z' }}{% endblock %}
{% block date_modified %}{{ metadata.get('last_updated','2019-11-04') + 'T12:00:00.000Z' }}{% endblock %}
{% block author_structured_data %}
{% for author in metadata.get('authors') %}{% if loop.length > 1 and loop.index == 1 %}[{% endif -%}
{% set authordata = config.contributors[author] if author in config.contributors else None -%}
{% if authordata -%}
{
"@type": "Person",
"sameas": [
"https://almanac.httparchive.org{{ url_for('contributors', year=year, lang=lang, _anchor=author) }}"
{% if authordata.twitter %},"https://twitter.com/{{ authordata.twitter }}"{% endif %}
{% if authordata.github %},"https://github.com/{{ authordata.github }}"{% endif %}
],
"name": "{{ authordata.name if authordata.name else author }}"
}{% if loop.index < loop.length %},{% endif %}
{%- endif %}{% if loop.index > 1 and loop.index == loop.length %}]{% endif -%}
{% endfor %}
{% endblock %}
{% block styles %}
{{ super() }}
<link rel="stylesheet" href="/static/css/page.css?v=20200708202040">
{% endblock %}
{% block scripts %}
{{ super() }}
{{ self.index_menu_script() }}
<script nonce="{{ csp_nonce() }}">
document.addEventListener("keyup", function onPress(event) {
if (event.key === 'p' || event.key === 'P' || event.key === ',' || event.key === '<' || event.key === 'ArrowLeft') {
var previous = document.getElementById('previous-chapter');
if (previous) {
previous.click();
}
}
if (event.key === 'n' || event.key === 'N' || event.key === '.' || event.key === '>' || event.key === 'ArrowRight') {
var next = document.getElementById('next-chapter');
if (next) {
next.click();
}
}
});
window.discussion_url="https://discuss.httparchive.org/t/{{ metadata.get('discuss') }}.json";
</script>
<script src="/static/js/chapter.js?v=20200527181403" defer></script>
{% endblock %}
{# Calls to action for readers who want to engage more with this chapter. #}
{% macro render_actions() %}
<a class="alt btn" href="https://discuss.httparchive.org/t/{{ metadata.get('discuss') }}">
<svg width="18" height="18" role="img">
<title>{{ self.discuss_this_chapter() }}</title>
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#comment"></use>
</svg>
<span id="num_comments"></span> <span data-translation id="comment-singular">{{ self.comment() }}</span>
<span data-translation id="comment-plural">{{ self.comments() }}</span>
</a>
<a class="alt btn" href="{{ metadata.get('results') }}/">
<svg width="18" height="18" role="img" aria-hidden="true">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#bar-chart"></use>
</svg>
{{ self.results() }}
</a>
<a class="alt btn" href="https://github.com/HTTPArchive/almanac.httparchive.org/tree/main/sql/{{ year }}/{{ metadata.get('queries') }}/">
<svg width="18" height="18" role="img" aria-hidden="true">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sql"></use>
</svg>
{{ self.queries() }}
</a>
{% endmacro %}
{% macro render_byline() %}
<div class="byline">{{ self.written_by_before() }}
{% for author in metadata.get('authors') %}
<a class="author" href="{{ url_for('contributors', year=year, lang=lang, _anchor=author) }}">{{ config.contributors[author].name if author in config.contributors else author }}</a>{% if loop.index != loop.length and loop.length != 2 %},{% endif %}
{% if loop.index == loop.length - 1 %}{{ self.and() }}{% endif %}
{% endfor %}{{ self.written_by_after() }}
</div>
<div class="byline reviewers">{{ self.reviewed_by_before() }}
{% for reviewer in metadata.get('reviewers') %}
<a class="reviewer" href="{{ url_for('contributors', year=year, lang=lang, _anchor=reviewer) }}">{{ config.contributors[reviewer].name if reviewer in config.contributors else reviewer }}</a>{% if loop.index != loop.length and loop.length != 2 %},{% endif %}
{% if loop.index == loop.length - 1 %}{{ self.and() }}{% endif %}
{% endfor %}{{ self.reviewed_by_after() }}
</div>
{% if metadata.get('translators') | length >= 1 %}
<div class="byline translators">{{ self.translated_by_before() }}
{% for translator in metadata.get('translators') %}
<a class="translator" href="{{ url_for('contributors', year=year, lang=lang, _anchor=translator) }}">{{ config.contributors[translator].name if translator in config.contributors else translator }}</a>{% if loop.index != loop.length and loop.length != 2 %},{% endif %}
{% if loop.index == loop.length - 1 %}{{ self.and() }}{% endif %}
{% endfor %}{{ self.translated_by_after() }}
</div>
{% endif %}
{% endmacro %}
{% macro render_authors() %}
{% for author in metadata.get('authors') %}
{% if loop.index == 1 %}
<h2 id="authors">
<a href="#authors" class="anchor-link">
{% if loop.length == 1 %}{{ self.author() }}{% endif -%}
{% if loop.length > 1 and loop.index == 1 %}{{ self.authors() }}{% endif %}
</a>
</h2>
<ul>
{% endif %}
{% set authordata = config.contributors[author] if author in config.contributors else None %}
{% if authordata %}
<li>
<div aria-hidden="true">
<a href="{{ url_for('contributors', year=year, lang=lang, _anchor=author) }}" tabindex="-1">
<img class="avatar" alt="{{ authordata.name }} avatar" src="{{ authordata.avatar_url }}" height="200" width="200" loading="lazy" />
</a>
</div>
<div class="info">
<a href="{{ url_for('contributors', year=year, lang=lang, _anchor=author) }}"><span class="name">{{ authordata.name if authordata.name else author }}</span></a>
{% if authordata.twitter or authordata.github %}
<span class="social">
{% if authordata.twitter %}
<a class="twitter" href="https://twitter.com/{{ authordata.twitter }}" aria-labelledby="author-{{ author }}-twitter">
<svg width="22" height="22" role="img">
<title id="author-{{ author }}-twitter">{{ onTwitter(authordata.twitter) }}</title>
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#twitter"></use>
</svg>
</a>
{% endif %}
{% if authordata.github %}
<a class="github" href="https://github.com/{{ authordata.github }}" aria-labelledby="author-{{ author }}-github">
<svg width="22" height="22" role="img">
<title id="author-{{ author }}-github">{{ onGitHub(authordata.github) }}</title>
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#github"></use>
</svg>
</a>
{% endif %}
{% if authordata.website %}
<a class="website" href="{{ authordata.website }}" aria-labelledby="author-{{ author }}-website">
<svg width="22" height="22" role="img">
<title id="author-{{ author }}-website">{{ website(authordata.name) }}</title>
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#globe"></use>
</svg>
</a>
{% endif %}
</span>
{% endif %}
{% if authordata.tagline %}
<div class="tagline">
{{ authordata.tagline }}
</div>
{% endif %}
<div class="bio">
{{ localizedContributors[author] | safe if localizedContributors[author]|length }}
</div>
</div>
</li>
{% else %}
<li>
<div class="info">
<span class="name">{{ author }}</span>
</div>
</li>
{% endif %}
{% endfor %}
</ul>
{% endmacro %}
{% macro render_prevnext() %}
{% if prev_chapter %}
{% if chapter_lang_exists(lang, year, prev_chapter['slug']) %}
<a id="previous-chapter" title="{{ self.previous() }}" href="/{{lang}}/{{year}}/{{prev_chapter['slug']}}">
<span class="arrow" aria-hidden="true">⌃</span>
<span class="chapter-no">
{{ self.chapter() }} {{ prev_chapter['chapter'] }}
</span>
<span class="chapter-title">
{{ localizedChapterTitles[prev_chapter['title']] if localizedChapterTitles[prev_chapter['title']]|length else prev_chapter['title'] }}
</span>
</a>
{% else %}
<a id="previous-chapter" title="{{ self.previous() }}" href="/en/{{year}}/{{prev_chapter['slug']}}">
<span class="arrow" aria-hidden="true">⌃</span>
<span class="chapter-no">
{{ self.chapter() }} {{ prev_chapter['chapter'] }}
</span>
<span class="chapter-title">
{{ localizedChapterTitles[prev_chapter['title']] if localizedChapterTitles[prev_chapter['title']]|length else prev_chapter['title'] }}
</span>
<span class="not-translated">
({{ self.translation_not_available() }})
</span>
</a>
{% endif %}
{% endif %}
{% if next_chapter %}
{% if chapter_lang_exists(lang, year, next_chapter['title'].lower().replace(' ', '-').replace('/', '') ) %}
<a id="next-chapter" title="{{ self.next() }}" href="/{{lang}}/{{year}}/{{next_chapter['title'].lower().replace(' ', '-').replace('/', '')}}">
<span class="arrow" aria-hidden="true">⌃</span>
<span class="chapter-no">
{{ self.chapter() }} {{ next_chapter['chapter'] }}
</span>
<span class="chapter-title">
{{ localizedChapterTitles[next_chapter['title']] if localizedChapterTitles[next_chapter['title']]|length else next_chapter['title'] }}
</span>
</a>
{% else %}
<a id="next-chapter" title="{{ self.next() }}" href="/en/{{year}}/{{next_chapter['title'].lower().replace(' ', '-').replace('/', '')}}">
<span class="arrow" aria-hidden="true">⌃</span>
<span class="chapter-no">
{{ self.chapter() }} {{ next_chapter['chapter'] }}
</span>
<span class="chapter-title">
{{ localizedChapterTitles[next_chapter['title']] if localizedChapterTitles[next_chapter['title']]|length else next_chapter['title'] }}
</span>
<span class="not-translated">
({{ self.translation_not_available() }})
</span>
</a>
{% endif %}
{% endif %}
{% endmacro %}
{% block main %}
<main id="chapter" class="main">
<nav aria-label="{{ self.index_nav_title() }}" class="index">
<div class="index-box floating-card">
<h2 class="header">
<button class="index-btn" aria-expanded="false" aria-label="{{ self.open_the_index() }}">{{ self.index_title() }}</button>
<span class="no-button">{{ self.index_title() }}</span>
</h2>
{{ self.index() }}
</div>
</nav>
<div class="content">
<article id="maincontent" class="body">
<div class="subtitle">
{{ self.part() }} {{ metadata.get('part_number') }} {{ self.chapter() }} {{ metadata.get('chapter_number') }}
</div>
<h1 class="title title-lg">
{{ metadata.get('title') }}
{% if metadata.get('unedited', false) %}
<span class="chapter-unedited">{{ self.unedited() }}</span>
{% endif %}
</h1>
<!-- Show large image for large screens and high density screens and use webp when supported -->
<picture>
<source media="(min-width: 327px)" type="image/webp" srcset="{{ chapter_image_dir }}/hero_lg.webp" />
<source media="(min-width: 327px)" type="image/jpeg" srcset="{{ chapter_image_dir }}/hero_lg.jpg" />
<source type="image/webp" srcset="{{ chapter_image_dir }}/hero_lg.webp 2x" />
<source type="image/jpeg" srcset="{{ chapter_image_dir }}/hero_lg.jpg 2x" />
<source type="image/webp" srcset="{{ chapter_image_dir }}/hero_sm.webp" />
<source type="image/jpeg" srcset="{{ chapter_image_dir }}/hero_sm.jpg" />
<img src="{{ chapter_image_dir }}/hero_lg.jpg" class="content-banner" alt="" width="866" height="433" loading="eager" />
</picture>
{{ render_byline() }}
{{ self.main_content() }}
</article>
<div class="chapter_links">
{{ render_actions() }}
</div>
<section class="authors">
{{ render_authors() }}
</section>
<nav aria-label="{{ self.prev_next_title() }}" id="chapter-navigation">
{{ render_prevnext() }}
</nav>
</div>
</main>
{% endblock %}