Skip to content

Commit 55af91f

Browse files
SaptakStunetheweb
andauthored
Adds 2024 base templates (#3789)
* Adds 2024 base templates * Removes methodology for no * Add 2024 base template files * Updated link of last chapter to 2022 instead of 2023 * Does not update stats or dates * Update stats * Update year * Teamplate cleanup * Better previous year handling * Clean up * More cleanup --------- Co-authored-by: Barry Pollard <barrypollard@google.com>
1 parent 17c9d87 commit 55af91f

70 files changed

Lines changed: 524 additions & 47 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/config/2024.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"settings": [
33
{
4-
"is_live": false,
5-
"supported_languages": ["en"],
4+
"is_live": true,
5+
"supported_languages": ["en","es","fr","hi","it","ja","nl","pt","ru","tr","uk","zh-CN","zh-TW"],
66
"ebook_languages": []
77
}
88
],

src/server/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ def update_config():
9090
elif ".json" in file:
9191
config_files.append(file[0:4])
9292

93+
# Sort the config files so read in year order
94+
config_files.sort()
95+
9396
for year in config_files:
9497
config_filename = "config/%s.json" % year
9598
with open(config_filename, "r") as config_file:

src/server/helpers.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,24 @@
1515
import logging
1616

1717

18+
# This gets the previous year as can no longer assume it's this year -1 as
19+
# skip some years (e.g. 2024)
20+
def get_previous_year(year):
21+
if year in SUPPORTED_YEARS:
22+
year_index = SUPPORTED_YEARS.index(year)
23+
if year_index > 0:
24+
return SUPPORTED_YEARS[year_index - 1]
25+
else:
26+
return None # No previous year if it's the first one
27+
else:
28+
return None # Return None if the year is not in the list
29+
30+
1831
def render_template(template, *args, **kwargs):
1932
# If the year has already been set (e.g. for error pages) then use that
2033
# Otherwise the requested year, otherwise the default year
2134
year = kwargs.get("year", request.view_args.get("year", DEFAULT_YEAR))
35+
previous_year = get_previous_year(year)
2236
config = kwargs.get("config", get_config(year))
2337

2438
# If the lang has already been set (e.g. for error pages) then use that
@@ -79,6 +93,7 @@ def render_template(template, *args, **kwargs):
7993

8094
kwargs.update(
8195
year=year,
96+
previous_year=previous_year,
8297
lang=lang,
8398
language=language,
8499
supported_languages=template_supported_languages,

src/server/tests/helpers_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
convert_old_image_path,
1111
add_footnote_links,
1212
year_live,
13+
get_previous_year,
1314
strip_accents,
1415
accentless_sort,
1516
render_template,
@@ -283,6 +284,22 @@ def test_year_live_2020():
283284
assert year_live("2020") is True
284285

285286

287+
def test_previous_year_2018():
288+
assert get_previous_year("2018") is None
289+
290+
291+
def test_previous_year_2019():
292+
assert get_previous_year("2019") is None
293+
294+
295+
def test_previous_year_2022():
296+
assert get_previous_year("2022") == "2021"
297+
298+
299+
def test_previous_year_2024():
300+
assert get_previous_year("2024") == "2022"
301+
302+
286303
def test_strip_accents_fr_edition():
287304
assert strip_accents("Édition") == "Edition"
288305

src/templates/base/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ <h2>{{ self.intro_sub_title() }}</h2>
6161
{{ self.start_exploring() }}
6262
</a>
6363
{% else %}
64-
<a href="{{ url_for('table_of_contents', year=year|int -1, lang=lang) }}" class="btn">
64+
<a href="{{ url_for('table_of_contents', year=previous_year, lang=lang) }}" class="btn">
6565
{{ self.read_last_years_almanac() }}
6666
</a>
6767
{% endif %}
@@ -147,7 +147,7 @@ <h3>{{ localizedChapterTitles[featured_chapter] }}</h3>
147147
{{ read_chapter(localizedChapterTitles[featured_chapter]) }}
148148
</a>
149149
{% else %}
150-
<a href="{{ url_for('chapter', year=year|int -1, chapter=featured_chapter, lang=lang) }}" class="btn">
150+
<a href="{{ url_for('chapter', year=previous_year, chapter=featured_chapter, lang=lang) }}" class="btn">
151151
{{ read_last_years_chapter(localizedChapterTitles[featured_chapter]) }}
152152
</a>
153153
{% endif %}
@@ -161,10 +161,10 @@ <h3>{{ localizedChapterTitles[featured_chapter] }}</h3>
161161
{% include "en/%s/featured_chapters.html" % year %}
162162
{% endif %}
163163
{% else %}
164-
{% if featured_chapters_exists(lang, year|int -1) %}
165-
{% include "%s/%s/featured_chapters.html" % (lang, year|int -1) %}
166-
{% elif featured_chapters_exists('en', year|int -1) %}
167-
{% include "en/%s/featured_chapters.html" % (year|int -1) %}
164+
{% if featured_chapters_exists(lang, previous_year) %}
165+
{% include "%s/%s/featured_chapters.html" % (lang, previous_year) %}
166+
{% elif featured_chapters_exists('en', previous_year) %}
167+
{% include "en/%s/featured_chapters.html" % previous_year %}
168168
{% endif %}
169169
{% endif %}
170170
{% endblock %}

src/templates/en/2024/base.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{% extends "%s/base.html" % lang %}
2+
3+
{% block methodology_stat_1 %}16.9M{% endblock %}
4+
{% block methodology_stat_2 %}82.61 TB{% endblock %}
5+
{% block total_websites %}nearly 17 million{% endblock %}
6+
{% block dataset %}June 2024{% endblock %}
7+
8+
{% block foreword %}
9+
{# TODO #}
10+
{% endblock %}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{% extends "base/contributors.html" %}
2+
3+
{% block title %}{{ year }} Contributors | The Web Almanac by HTTP Archive{% endblock %}
4+
5+
{% block description %}The {{ config.contributors.items() | length }} people who contributed to the {{ year }} Web Almanac as Analysts, Authors, Designers, Developers, Editors, Leaders, Reviewers and Translators.{% endblock %}
6+
7+
{% block filter_by_team %}Filter by team: <span id="filtered-contributors">{{ self.contributors() }}</span><span id="contributors-total-text" class="hidden"> of <span id="contributors-total">{{ config.contributors.items() | length }}</span></span> contributors.{% endblock %}
8+
{% block filter_by %}Filter by{% endblock %}
9+
10+
{% block join_the_team_title%}Join the Web Almanac team{% endblock %}
11+
{% block join_the_team_text%}Join the team!{% endblock %}

src/templates/en/2024/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% extends "base/index.html" %}
2+
3+
{% block title %}The {{ year }} Web Almanac{% endblock %}
4+
{% block description %}The Web Almanac is an annual state of the web report combining the expertise of the web community with the data and trends of the HTTP Archive.{% endblock %}
5+
6+
{% block twitter_image_alt %}The {{ year }} Web Almanac{% endblock %}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% extends "base/table_of_contents.html" %}
2+
3+
{% block title %}Table of Contents | Web Almanac {{ year }}{% endblock %}
4+
5+
{% block description %}Table of Contents for the {{ year }} Web Almanac, listing each section: Page Contents, User Experience, Content Publishing, Content Distribution.{% endblock %}
6+
7+
{% block twitter_image_alt %}{{ year }} Web Almanac methodology{% endblock %}

src/templates/en/base.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</p>
2525
{% endblock %}
2626

27-
{% block read_last_years_almanac %}Read the {{ year | int - 1 }} Web Almanac{% endblock %}
27+
{% block read_last_years_almanac %}Read the {{ previous_year }} Web Almanac{% endblock %}
2828

2929
{% block http_archive_link %}HTTP Archive home{% endblock %}
3030

@@ -124,14 +124,14 @@
124124
{% block rss_feed %}RSS Feed{% endblock %}
125125

126126
{% block featured_chapter %}Featured Chapter{% endblock %}
127-
{% block featured_chapter_last_year %}Featured Chapter<br>from the {{ year|int -1 }} Web Almanac{% endblock %}
127+
{% block featured_chapter_last_year %}Featured Chapter<br>from the {{ previous_year }} Web Almanac{% endblock %}
128128

129129
{# Check if read_chapter already defined in child template as macros can't be overridden #}
130130
{% if not read_chapter %}
131131
{% macro read_chapter(chapter) %}Read the <span class="featured-chapter-name">{{ chapter }}</span> chapter{% endmacro %}
132132
{% endif %}
133133
{% if not read_last_years_chapter %}
134-
{% macro read_last_years_chapter(chapter) %}Read the {{ year|int-1 }} <span class="featured-chapter-name">{{ chapter }}</span> chapter{% endmacro %}
134+
{% macro read_last_years_chapter(chapter) %}Read the {{ previous_year }} <span class="featured-chapter-name">{{ chapter }}</span> chapter{% endmacro %}
135135
{% endif %}
136136

137137
{% block contributors_description %}

0 commit comments

Comments
 (0)