From fda70a54588c4c8727335e07991dba67d414442c Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 22 Oct 2019 22:46:34 -0700 Subject: [PATCH] templates: Use just one webpack entry point per page. Signed-off-by: Anders Kaseorg --- templates/analytics/activity.html | 6 +- templates/analytics/stats.html | 8 +- templates/analytics/support.html | 7 +- .../confirm_preregistrationuser.html | 6 +- templates/corporate/billing.html | 4 +- templates/corporate/jobs.html | 2 +- templates/corporate/upgrade.html | 5 +- templates/corporate/zephyr.html | 2 +- templates/zerver/app/index.html | 6 +- templates/zerver/apps.html | 2 +- templates/zerver/archive/index.html | 8 +- templates/zerver/atlassian.html | 3 +- templates/zerver/base.html | 22 ++--- templates/zerver/dev_login.html | 2 +- templates/zerver/digest_base.html | 5 +- templates/zerver/documentation_main.html | 3 +- templates/zerver/email_log.html | 2 +- templates/zerver/features.html | 5 +- templates/zerver/for-companies.html | 3 +- templates/zerver/for-mystery-hunt.html | 3 +- templates/zerver/for-open-source.html | 2 +- .../for-working-groups-and-communities.html | 3 +- templates/zerver/hello.html | 2 +- templates/zerver/history.html | 3 +- .../integrations/development/dev_panel.html | 4 +- templates/zerver/integrations/index.html | 2 +- templates/zerver/login.html | 6 +- templates/zerver/plans.html | 2 +- templates/zerver/portico.html | 6 +- templates/zerver/portico_signup.html | 6 +- templates/zerver/privacy.html | 2 +- templates/zerver/realm_creation_failed.html | 3 +- templates/zerver/register.html | 7 +- templates/zerver/reset_confirm.html | 5 +- templates/zerver/security.html | 3 +- templates/zerver/team.html | 5 +- templates/zerver/terms.html | 3 +- templates/zerver/why-zulip.html | 3 +- tools/webpack.assets.json | 90 ++++++++++++++++--- tools/webpack.config.ts | 4 +- 40 files changed, 125 insertions(+), 140 deletions(-) diff --git a/templates/analytics/activity.html b/templates/analytics/activity.html index 9b9d9eda83..2fb49123bc 100644 --- a/templates/analytics/activity.html +++ b/templates/analytics/activity.html @@ -1,4 +1,5 @@ {% extends "zerver/base.html" %} +{% set entrypoint = "activity" %} {# User Activity. #} @@ -7,11 +8,6 @@ {% endblock %} -{% block customhead %} -{{ super() }} -{{ bundle('activity') }} -{% endblock %} - {% block content %} {% if not is_home %} diff --git a/templates/analytics/stats.html b/templates/analytics/stats.html index 449f4a25da..b222338533 100644 --- a/templates/analytics/stats.html +++ b/templates/analytics/stats.html @@ -1,15 +1,9 @@ {% extends "zerver/base.html" %} - -{% block customhead %} -{{ bundle('portico') }} -{% endblock %} +{% set entrypoint = "stats" %} {% block content %}
- {{ bundle('translations') }} - {{ bundle('stats') }} -
diff --git a/templates/analytics/support.html b/templates/analytics/support.html index e39faa35b5..c9ce11190c 100644 --- a/templates/analytics/support.html +++ b/templates/analytics/support.html @@ -1,4 +1,5 @@ {% extends "zerver/base.html" %} +{% set entrypoint = "support" %} {# User Activity. #} @@ -7,12 +8,6 @@ {% endblock %} -{% block customhead %} -{{ super() }} -{{ bundle('activity') }} -{{ bundle('support') }} -{% endblock %} - {% block content %}

diff --git a/templates/confirmation/confirm_preregistrationuser.html b/templates/confirmation/confirm_preregistrationuser.html index 9e8b987e4e..3b812d78a6 100644 --- a/templates/confirmation/confirm_preregistrationuser.html +++ b/templates/confirmation/confirm_preregistrationuser.html @@ -1,9 +1,5 @@ {% extends "zerver/base.html" %} - -{% block customhead %} -{{ super() }} -{{ bundle('confirm-preregistrationuser') }} -{% endblock %} +{% set entrypoint = "confirm-preregistrationuser" %} {% block content %} diff --git a/templates/corporate/billing.html b/templates/corporate/billing.html index 26fad6015f..fedb2954a5 100644 --- a/templates/corporate/billing.html +++ b/templates/corporate/billing.html @@ -1,9 +1,8 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "billing" %} {% block customhead %} -{{ bundle('landing-page') }} -{{ bundle('billing') }} {% endblock %} @@ -13,7 +12,6 @@ {% include 'zerver/billing_nav.html' %} - {{ bundle('translations') }}
diff --git a/templates/corporate/jobs.html b/templates/corporate/jobs.html index dd3d96aa33..373809bcd7 100644 --- a/templates/corporate/jobs.html +++ b/templates/corporate/jobs.html @@ -1,4 +1,5 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "landing-page" %} {% block title %} Zulip jobs @@ -6,7 +7,6 @@ {% block customhead %} -{{ bundle('landing-page') }} {% endblock %} {% block portico_content %} diff --git a/templates/corporate/upgrade.html b/templates/corporate/upgrade.html index a4d40c2a44..211ac51568 100644 --- a/templates/corporate/upgrade.html +++ b/templates/corporate/upgrade.html @@ -1,9 +1,8 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "upgrade" %} {% block customhead %} -{{ bundle('landing-page') }} -{{ bundle('upgrade') }} {% endblock %} @@ -13,8 +12,6 @@ {% include 'zerver/billing_nav.html' %} - {{ bundle('translations') }} -
diff --git a/templates/corporate/zephyr.html b/templates/corporate/zephyr.html index 5bd9119513..8f45265c22 100644 --- a/templates/corporate/zephyr.html +++ b/templates/corporate/zephyr.html @@ -1,4 +1,5 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "landing-page" %} {% block title %} Zulip zephyr @@ -6,7 +7,6 @@ {% block customhead %} -{{ bundle('landing-page') }} {% endblock %} {% block portico_content %} diff --git a/templates/zerver/app/index.html b/templates/zerver/app/index.html index 0fbc41ef69..ef17540f9f 100644 --- a/templates/zerver/app/index.html +++ b/templates/zerver/app/index.html @@ -1,4 +1,5 @@ {% extends "zerver/base.html" %} +{% set entrypoint = "app" %} {# The app itself. #} {# Includes some other templates as tabs. #} @@ -6,11 +7,6 @@ {% endblock %} -{% block commonjs %} -{{ bundle('app') }} -{{ bundle('katex') }} -{% endblock %} - {% block customhead %} diff --git a/templates/zerver/apps.html b/templates/zerver/apps.html index 6dbbc63298..0a1ebda1cd 100644 --- a/templates/zerver/apps.html +++ b/templates/zerver/apps.html @@ -1,11 +1,11 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "landing-page" %} {% block customhead %} -{{ bundle('landing-page') }} {% endblock %} {% block portico_content %} diff --git a/templates/zerver/archive/index.html b/templates/zerver/archive/index.html index 7d7417102d..4ef2d694c2 100644 --- a/templates/zerver/archive/index.html +++ b/templates/zerver/archive/index.html @@ -1,4 +1,5 @@ {% extends "zerver/base.html" %} +{% set entrypoint = "archive" %} {% block customhead %} @@ -10,13 +11,6 @@ width: auto; } - - {{ bundle('translations') }} - {{ bundle('katex') }} - {{ bundle('portico') }} - {{ bundle('archive') }} - {{ bundle('archive-styles') }} - {% endblock %} {% block content %} diff --git a/templates/zerver/atlassian.html b/templates/zerver/atlassian.html index 736c2fa6be..a36df97fe8 100644 --- a/templates/zerver/atlassian.html +++ b/templates/zerver/atlassian.html @@ -1,4 +1,5 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "landing-page" %} {% block title %} Migrating from HipChat and Stride @@ -6,8 +7,6 @@ {% block customhead %} -{{ bundle('landing-page') }} - {% endblock %} {% block portico_content %} diff --git a/templates/zerver/base.html b/templates/zerver/base.html index 18f418b0b5..597b28cf75 100644 --- a/templates/zerver/base.html +++ b/templates/zerver/base.html @@ -20,25 +20,13 @@ {% include 'zerver/meta_tags.html' %} {% endif %} - {% macro bundle(name) %} - {{ render_entrypoint(name, 'css', attrs='nonce="%s"' % (csp_nonce,) if csp_nonce else '') }} - {{ render_entrypoint(name, 'js', attrs='defer nonce="%s"' % (csp_nonce,) if csp_nonce else 'defer') }} - {% endmacro %} - - - {% block commonjs %} - {{ bundle('common') }} + {% block webpack %} + {{ render_entrypoint(entrypoint, 'css', attrs='nonce="%s"' % (csp_nonce,) if csp_nonce else '') }} + {{ render_entrypoint(entrypoint, 'js', attrs='defer nonce="%s"' % (csp_nonce,) if csp_nonce else 'defer') }} {% endblock %} + {% block customhead %} {% endblock %} - - {# this is required because we want to put a custom head in - `zerver/portico.html` that isn't overwritten like the - `customhead` #} - {% block porticocustomhead %} - {% endblock %} @@ -49,3 +37,5 @@ + +{% set entrypoint = entrypoint|default("common") %} diff --git a/templates/zerver/dev_login.html b/templates/zerver/dev_login.html index 1f8703d1b5..1a9b5d47e0 100644 --- a/templates/zerver/dev_login.html +++ b/templates/zerver/dev_login.html @@ -1,8 +1,8 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "dev-login" %} {# Login page. #} {% block portico_content %} -{{ bundle('dev-login') }}
diff --git a/templates/zerver/digest_base.html b/templates/zerver/digest_base.html index 9acf1774b7..5081ca7b4a 100644 --- a/templates/zerver/digest_base.html +++ b/templates/zerver/digest_base.html @@ -1,8 +1,5 @@ {% extends "zerver/base.html" %} - -{% block porticocustomhead %} -{{ bundle('portico') }} -{% endblock %} +{% set entrypoint = "digest" %} {% block content %} diff --git a/templates/zerver/documentation_main.html b/templates/zerver/documentation_main.html index 55a99ae60b..1558115618 100644 --- a/templates/zerver/documentation_main.html +++ b/templates/zerver/documentation_main.html @@ -1,4 +1,5 @@ {% extends "zerver/portico-help.html" %} +{% set entrypoint = "help" %} {# Zulip User and API Documentation. #} @@ -27,6 +28,4 @@
- -{{ bundle("help") }} {% endblock %} diff --git a/templates/zerver/email_log.html b/templates/zerver/email_log.html index f29526c9ac..c3241302a7 100644 --- a/templates/zerver/email_log.html +++ b/templates/zerver/email_log.html @@ -1,6 +1,6 @@ {% extends "zerver/base.html" %} +{% set entrypoint = "email-log" %} {% block content %} -{{ bundle('email-log') }}
diff --git a/templates/zerver/features.html b/templates/zerver/features.html index 55711eb1bd..e632a2700c 100644 --- a/templates/zerver/features.html +++ b/templates/zerver/features.html @@ -1,12 +1,9 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "landing-page" %} {% set OPEN_GRAPH_TITLE = 'Zulip Features' %} {% set OPEN_GRAPH_DESCRIPTION = 'First class threading on top of everything you could want from real-time chat.' %} -{% block customhead %} -{{ bundle('landing-page') }} -{% endblock %} - {% block portico_content %} {% include 'zerver/landing_nav.html' %} diff --git a/templates/zerver/for-companies.html b/templates/zerver/for-companies.html index c17aab8f84..d0ed71f7b3 100644 --- a/templates/zerver/for-companies.html +++ b/templates/zerver/for-companies.html @@ -1,4 +1,5 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "landing-page" %} {% block title %} Zulip: the best group chat for companies @@ -6,8 +7,6 @@ {% block customhead %} -{{ bundle('landing-page') }} - {% endblock %} {% block portico_content %} diff --git a/templates/zerver/for-mystery-hunt.html b/templates/zerver/for-mystery-hunt.html index d6bfe2d551..e0f40513c9 100644 --- a/templates/zerver/for-mystery-hunt.html +++ b/templates/zerver/for-mystery-hunt.html @@ -1,4 +1,5 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "landing-page" %} {% block title %} Zephyr reloaded @@ -6,8 +7,6 @@ {% block customhead %} -{{ bundle('landing-page') }} - {% endblock %} {% block portico_content %} diff --git a/templates/zerver/for-open-source.html b/templates/zerver/for-open-source.html index 4e19b42e0d..86308bdefe 100644 --- a/templates/zerver/for-open-source.html +++ b/templates/zerver/for-open-source.html @@ -1,4 +1,5 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "landing-page" %} {% set OPEN_GRAPH_TITLE = 'Modern chat for open source' %} {% set OPEN_GRAPH_DESCRIPTION = 'No message limits, rich moderation features, markdown support, and a conversation model that scales to thousands of users.' %} @@ -9,7 +10,6 @@ {% block customhead %} -{{ bundle('landing-page') }} {% endblock %} {% block portico_content %} diff --git a/templates/zerver/for-working-groups-and-communities.html b/templates/zerver/for-working-groups-and-communities.html index 1bd5fa22e6..3fe88ca15b 100644 --- a/templates/zerver/for-working-groups-and-communities.html +++ b/templates/zerver/for-working-groups-and-communities.html @@ -1,4 +1,5 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "landing-page" %} {% block title %} Zulip: the best group chat for working groups and communities @@ -6,8 +7,6 @@ {% block customhead %} -{{ bundle('landing-page') }} - {% endblock %} {% block portico_content %} diff --git a/templates/zerver/hello.html b/templates/zerver/hello.html index 2b8e25214b..ea93bb68e9 100644 --- a/templates/zerver/hello.html +++ b/templates/zerver/hello.html @@ -1,11 +1,11 @@ {% extends "zerver/portico.html" %} +{% set entrypoint = "landing-page" %} {% block customhead %} -{{ bundle('landing-page') }}