From d3125f59e1b0ab244bdabee85ad08215efcd3d56 Mon Sep 17 00:00:00 2001 From: Rishi Gupta Date: Sun, 10 Feb 2019 22:03:55 -0800 Subject: [PATCH] open graph: Omit .code-section navigation from open graph. --- zerver/middleware.py | 4 ++++ zerver/tests/test_middleware.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/zerver/middleware.py b/zerver/middleware.py index 6cacc3b3ea..a4a0d4edb9 100644 --- a/zerver/middleware.py +++ b/zerver/middleware.py @@ -460,6 +460,10 @@ class FinalizeOpenGraphDescription(MiddlewareMixin): for tag in bs.find_all('div', class_="admonition"): tag.clear() + # Skip code-sections, which just contains navigation instructions. + for tag in bs.find_all('div', class_="code-section"): + tag.clear() + text = '' for paragraph in bs.find_all('p'): # .text converts it from HTML to text diff --git a/zerver/tests/test_middleware.py b/zerver/tests/test_middleware.py index c8847574de..b385573c31 100644 --- a/zerver/tests/test_middleware.py +++ b/zerver/tests/test_middleware.py @@ -103,7 +103,9 @@ class OpenGraphTest(ZulipTestCase): '/help/logging-out', "Logging out (Zulip Help Center)", # Ideally we'd do something better here - ["Click on the gear () icon in", "Click Log out. Tap the menu"], []) + ["We're here to help! Email us at zulip-admin@example.com with questions, feedback, or " + + "feature requests."], + ["Click on the gear"]) def test_index_pages(self) -> None: self.check_title_and_description(