templates: Rename OPEN_GRAPH variables to PAGE or PAGE_METADATA.

Renames existing template variables starting with `OPEN_GRAPH` to be
either `PAGE` or `PAGE_METADATA` since these variables are used for
adding both open graph metdata and page titles/descriptions for SEO.
This commit is contained in:
Lauryn Menard
2022-09-05 16:12:21 +02:00
committed by Tim Abbott
parent 18b401f476
commit 049302fe61
15 changed files with 46 additions and 46 deletions

View File

@@ -5,8 +5,8 @@
<title>Zulip attributions</title> <title>Zulip attributions</title>
{% endblock %} {% endblock %}
{% set OPEN_GRAPH_TITLE = 'Zulip website attributions' %} {% set PAGE_TITLE = 'Zulip website attributions' %}
{% set OPEN_GRAPH_DESCRIPTION = '' %} {% set PAGE_DESCRIPTION = '' %}
{% block customhead %} {% block customhead %}
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />

View File

@@ -1,8 +1,8 @@
{% extends "zerver/portico.html" %} {% extends "zerver/portico.html" %}
{% set entrypoint = "landing-page" %} {% set entrypoint = "landing-page" %}
{% set OPEN_GRAPH_TITLE = 'The Zulip development community' %} {% set PAGE_TITLE = 'The Zulip development community' %}
{% set OPEN_GRAPH_DESCRIPTION = 'Join the Zulip community to contribute, ask questions, or provide feedback to the creators of Zulip.' %} {% set PAGE_DESCRIPTION = 'Join the Zulip community to contribute, ask questions, or provide feedback to the creators of Zulip.' %}
{% block title %} {% block title %}
<title>The Zulip development community</title> <title>The Zulip development community</title>

View File

@@ -1,8 +1,8 @@
{% extends "zerver/portico.html" %} {% extends "zerver/portico.html" %}
{% set entrypoint = "landing-page" %} {% set entrypoint = "landing-page" %}
{% set OPEN_GRAPH_TITLE = 'Zulip features' %} {% set PAGE_TITLE = 'Zulip features' %}
{% set OPEN_GRAPH_DESCRIPTION = 'First class threading on top of everything you could want from real-time chat.' %} {% set PAGE_DESCRIPTION = 'First class threading on top of everything you could want from real-time chat.' %}
{% block portico_content %} {% block portico_content %}

View File

@@ -1,8 +1,8 @@
{% extends "zerver/portico.html" %} {% extends "zerver/portico.html" %}
{% set entrypoint = "landing-page" %} {% set entrypoint = "landing-page" %}
{% set OPEN_GRAPH_TITLE = 'Teach a course with Zulip.' %} {% set PAGE_TITLE = 'Teach a course with Zulip.' %}
{% set OPEN_GRAPH_DESCRIPTION = 'Online, in-person, and anything in between' %} {% set PAGE_DESCRIPTION = 'Online, in-person, and anything in between' %}
{% block title %} {% block title %}
<title>Teach a course with Zulip for Education: Online, in-person, and anything in between</title> <title>Teach a course with Zulip for Education: Online, in-person, and anything in between</title>

View File

@@ -1,8 +1,8 @@
{% extends "zerver/portico.html" %} {% extends "zerver/portico.html" %}
{% set entrypoint = "landing-page" %} {% set entrypoint = "landing-page" %}
{% set OPEN_GRAPH_TITLE = 'Zulip for conferences and events' %} {% set PAGE_TITLE = 'Zulip for conferences and events' %}
{% set OPEN_GRAPH_DESCRIPTION = 'Conferences, workshops, hackathons. In-person, online, and anything in between.' %} {% set PAGE_DESCRIPTION = 'Conferences, workshops, hackathons. In-person, online, and anything in between.' %}
{% block title %} {% block title %}
<title>Zulip for conferences and events: Conferences, workshops, hackathons. In-person, online, and anything in between.</title> <title>Zulip for conferences and events: Conferences, workshops, hackathons. In-person, online, and anything in between.</title>

View File

@@ -1,8 +1,8 @@
{% extends "zerver/portico.html" %} {% extends "zerver/portico.html" %}
{% set entrypoint = "landing-page" %} {% set entrypoint = "landing-page" %}
(% set OPEN_GRAPH_TITLE = 'Modern chat for open source' %} (% set PAGE_TITLE = 'Modern chat for open source' %}
{% set OPEN_GRAPH_DESCRIPTION = 'Zulip is the only modern team chat app that is ideal for both live and asynchronous conversations. Discuss issues, pull requests and feature ideas, engage with users, answer questions, and onboard new contributors.' %} {% set PAGE_DESCRIPTION = 'Zulip is the only modern team chat app that is ideal for both live and asynchronous conversations. Discuss issues, pull requests and feature ideas, engage with users, answer questions, and onboard new contributors.' %}
{% block title %} {% block title %}
<title>Zulip: the best group chat for open-source projects</title> <title>Zulip: the best group chat for open-source projects</title>

View File

@@ -1,8 +1,8 @@
{% extends "zerver/portico.html" %} {% extends "zerver/portico.html" %}
{% set entrypoint = "landing-page" %} {% set entrypoint = "landing-page" %}
{% set OPEN_GRAPH_TITLE = 'Zulip for research' %} {% set PAGE_TITLE = 'Zulip for research' %}
{% set OPEN_GRAPH_DESCRIPTION = 'Chat for your project, research group, department or scientific field' %} {% set PAGE_DESCRIPTION = 'Chat for your project, research group, department or scientific field' %}
{% block title %} {% block title %}
<title>Zulip for research: Chat for your project, research group, department or scientific field</title> <title>Zulip for research: Chat for your project, research group, department or scientific field</title>

View File

@@ -1,8 +1,8 @@
{% extends "zerver/portico.html" %} {% extends "zerver/portico.html" %}
{% set entrypoint = "landing-page" %} {% set entrypoint = "landing-page" %}
{% set OPEN_GRAPH_TITLE = 'Zulip plans and pricing' %} {% set PAGE_TITLE = 'Zulip plans and pricing' %}
{% set OPEN_GRAPH_DESCRIPTION = 'Get started today.' %} {% set PAGE_DESCRIPTION = 'Get started today.' %}
{% block title %} {% block title %}
<title>Zulip plans and pricing</title> <title>Zulip plans and pricing</title>

View File

@@ -1,8 +1,8 @@
{% extends "zerver/portico.html" %} {% extends "zerver/portico.html" %}
{% set entrypoint = "landing-page" %} {% set entrypoint = "landing-page" %}
{% set OPEN_GRAPH_TITLE = 'Self-host Zulip today.' %} {% set PAGE_TITLE = 'Self-host Zulip today.' %}
{% set OPEN_GRAPH_DESCRIPTION = 'Open-source software that provides enterprise-grade reliability and security.' %} {% set PAGE_DESCRIPTION = 'Open-source software that provides enterprise-grade reliability and security.' %}
{% block title %} {% block title %}
<title>Self-host Zulip today. Open-source software that provides enterprise-grade reliability and security.</title> <title>Self-host Zulip today. Open-source software that provides enterprise-grade reliability and security.</title>

View File

@@ -1,8 +1,8 @@
{% extends "zerver/portico.html" %} {% extends "zerver/portico.html" %}
{% set entrypoint = "landing-page" %} {% set entrypoint = "landing-page" %}
{% set OPEN_GRAPH_TITLE = 'Team chat with first-class threading' %} {% set PAGE_TITLE = 'Team chat with first-class threading' %}
{% set OPEN_GRAPH_DESCRIPTION = 'Most team chats are overwhelming to keep up with. Zulip takes a different approach.' %} {% set PAGE_DESCRIPTION = 'Most team chats are overwhelming to keep up with. Zulip takes a different approach.' %}
{% block title %} {% block title %}
<title>The best group chat</title> <title>The best group chat</title>

View File

@@ -9,8 +9,8 @@
{% if user_profile and user_profile.realm.name %} {% if user_profile and user_profile.realm.name %}
<title>{{user_profile.realm.name}} - Zulip</title> <title>{{user_profile.realm.name}} - Zulip</title>
{% else %} {% else %}
{% if OPEN_GRAPH_TITLE %} {% if PAGE_TITLE %}
<title>{{ OPEN_GRAPH_TITLE }}</title> <title>{{ PAGE_TITLE }}</title>
{% else %} {% else %}
<title>Zulip</title> <title>Zulip</title>
{% endif %} {% endif %}

View File

@@ -3,7 +3,7 @@
{# Zulip user and API documentation. #} {# Zulip user and API documentation. #}
{% block title %} {% block title %}
<title>{{ OPEN_GRAPH_TITLE }}</title> <title>{{ PAGE_TITLE }}</title>
{% endblock %} {% endblock %}
{% block portico_content %} {% block portico_content %}

View File

@@ -1,7 +1,7 @@
<!-- Google / search engine tags --> <!-- Google / search engine tags -->
{% if allow_search_engine_indexing %} {% if allow_search_engine_indexing %}
{% if OPEN_GRAPH_DESCRIPTION %} {% if PAGE_DESCRIPTION %}
<meta name="description" content="{{ OPEN_GRAPH_DESCRIPTION }}" /> <meta name="description" content="{{ PAGE_DESCRIPTION }}" />
{% else %} {% else %}
<meta name="description" content="Zulip combines the immediacy of real-time chat with an email threading model. With Zulip, you can catch up on important conversations while ignoring irrelevant ones." /> <meta name="description" content="Zulip combines the immediacy of real-time chat with an email threading model. With Zulip, you can catch up on important conversations while ignoring irrelevant ones." />
{% endif %} {% endif %}
@@ -10,18 +10,18 @@
{% endif %} {% endif %}
<!-- Open Graph / Facebook / Twitter meta tags --> <!-- Open Graph / Facebook / Twitter meta tags -->
<meta property="og:url" content="{{ OPEN_GRAPH_URL }}" /> <meta property="og:url" content="{{ PAGE_METADATA_URL }}" />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:site_name" content="Zulip" /> <meta property="og:site_name" content="Zulip" />
{% if OPEN_GRAPH_TITLE %} {% if PAGE_TITLE %}
<meta property="og:title" content="{{ OPEN_GRAPH_TITLE }}" /> <meta property="og:title" content="{{ PAGE_TITLE }}" />
<meta property="og:description" content="{{ OPEN_GRAPH_DESCRIPTION }}" /> <meta property="og:description" content="{{ PAGE_DESCRIPTION }}" />
{% else %} {% else %}
<meta property="og:title" content="Chat for distributed teams" /> <meta property="og:title" content="Chat for distributed teams" />
<meta property="og:description" content="Zulip combines the immediacy of real-time chat with an email threading model. With Zulip, you can catch up on important conversations while ignoring irrelevant ones." /> <meta property="og:description" content="Zulip combines the immediacy of real-time chat with an email threading model. With Zulip, you can catch up on important conversations while ignoring irrelevant ones." />
{% endif %} {% endif %}
{% if OPEN_GRAPH_IMAGE %} {% if PAGE_METADATA_IMAGE %}
<meta property="og:image" content="{{ OPEN_GRAPH_IMAGE }}" /> <meta property="og:image" content="{{ PAGE_METADATA_IMAGE }}" />
{% else %} {% else %}
<meta property="og:image" content="{{ realm_uri }}/static/images/logo/zulip-icon-128x128.png" /> <meta property="og:image" content="{{ realm_uri }}/static/images/logo/zulip-icon-128x128.png" />
{% endif %} {% endif %}

View File

@@ -180,9 +180,9 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
"corporate_enabled": corporate_enabled, "corporate_enabled": corporate_enabled,
} }
context["OPEN_GRAPH_URL"] = f"{realm_uri}{request.path}" context["PAGE_METADATA_URL"] = f"{realm_uri}{request.path}"
if realm is not None and realm.icon_source == realm.ICON_UPLOADED: if realm is not None and realm.icon_source == realm.ICON_UPLOADED:
context["OPEN_GRAPH_IMAGE"] = urljoin(realm_uri, realm_icon) context["PAGE_METADATA_IMAGE"] = urljoin(realm_uri, realm_icon)
return context return context
@@ -211,8 +211,8 @@ def login_context(request: HttpRequest) -> Dict[str, Any]:
} }
if realm is not None and realm.description: if realm is not None and realm.description:
context["OPEN_GRAPH_TITLE"] = realm.name context["PAGE_TITLE"] = realm.name
context["OPEN_GRAPH_DESCRIPTION"] = get_realm_text_description(realm) context["PAGE_DESCRIPTION"] = get_realm_text_description(realm)
# Add the keys for our standard authentication backends. # Add the keys for our standard authentication backends.
no_auth_enabled = True no_auth_enabled = True

View File

@@ -198,21 +198,21 @@ class MarkdownDirectoryView(ApiURLView):
elif ( elif (
self.path_template == "/zerver/api/%s.md" and "{generate_api_header(" in first_line self.path_template == "/zerver/api/%s.md" and "{generate_api_header(" in first_line
): ):
api_operation = context["OPEN_GRAPH_URL"].split("/api/")[1] api_operation = context["PAGE_METADATA_URL"].split("/api/")[1]
endpoint_name, endpoint_method = get_endpoint_from_operationid(api_operation) endpoint_name, endpoint_method = get_endpoint_from_operationid(api_operation)
article_title = get_openapi_summary(endpoint_name, endpoint_method) article_title = get_openapi_summary(endpoint_name, endpoint_method)
else: else:
article_title = first_line.lstrip("#").strip() article_title = first_line.lstrip("#").strip()
endpoint_name = endpoint_method = None endpoint_name = endpoint_method = None
if context["not_index_page"]: if context["not_index_page"]:
context["OPEN_GRAPH_TITLE"] = f"{article_title} ({title_base})" context["PAGE_TITLE"] = f"{article_title} ({title_base})"
else: else:
context["OPEN_GRAPH_TITLE"] = title_base context["PAGE_TITLE"] = title_base
request_notes = RequestNotes.get_notes(self.request) request_notes = RequestNotes.get_notes(self.request)
request_notes.placeholder_open_graph_description = ( request_notes.placeholder_open_graph_description = (
f"REPLACEMENT_OPEN_GRAPH_DESCRIPTION_{int(2**24 * random.random())}" f"REPLACEMENT_PAGE_DESCRIPTION_{int(2**24 * random.random())}"
) )
context["OPEN_GRAPH_DESCRIPTION"] = request_notes.placeholder_open_graph_description context["PAGE_DESCRIPTION"] = request_notes.placeholder_open_graph_description
context["sidebar_index"] = sidebar_index context["sidebar_index"] = sidebar_index
# An "article" might require the api_uri_context to be rendered # An "article" might require the api_uri_context to be rendered
@@ -264,17 +264,17 @@ def add_integrations_open_graph_context(context: Dict[str, Any], request: HttpRe
if path_name in INTEGRATIONS: if path_name in INTEGRATIONS:
integration = INTEGRATIONS[path_name] integration = INTEGRATIONS[path_name]
context["OPEN_GRAPH_TITLE"] = f"Connect {integration.display_name} to Zulip" context["PAGE_TITLE"] = f"Connect {integration.display_name} to Zulip"
context["OPEN_GRAPH_DESCRIPTION"] = description context["PAGE_DESCRIPTION"] = description
elif path_name in CATEGORIES: elif path_name in CATEGORIES:
category = CATEGORIES[path_name] category = CATEGORIES[path_name]
context["OPEN_GRAPH_TITLE"] = f"Connect your {category} tools to Zulip" context["PAGE_TITLE"] = f"Connect your {category} tools to Zulip"
context["OPEN_GRAPH_DESCRIPTION"] = description context["PAGE_DESCRIPTION"] = description
elif path_name == "integrations": elif path_name == "integrations":
context["OPEN_GRAPH_TITLE"] = "Connect the tools you use to Zulip" context["PAGE_TITLE"] = "Connect the tools you use to Zulip"
context["OPEN_GRAPH_DESCRIPTION"] = description context["PAGE_DESCRIPTION"] = description
class IntegrationView(ApiURLView): class IntegrationView(ApiURLView):