From 942f4372f0fc448ed4f676adc9154ce79577ec3e Mon Sep 17 00:00:00 2001 From: aryanshridhar Date: Wed, 23 Jun 2021 21:36:10 +0530 Subject: [PATCH] info_overlay: Render keyboard shortcuts using info_overlay. This commits ports the `keyboard_shortcuts.html` file from using the Django template to handlebars, essentially creating a new file as `keyboard_shortcuts.hbs` within /static/templates which is then rendered using info_overlays.js. Fixes part of #18792. --- static/js/info_overlay.js | 4 + .../templates/keyboard_shortcuts.hbs | 142 +++++++++--------- templates/zerver/app/index.html | 1 - tools/linter_lib/custom_check.py | 9 +- zerver/tests/test_home.py | 2 - 5 files changed, 81 insertions(+), 77 deletions(-) rename templates/zerver/app/keyboard_shortcuts.html => static/templates/keyboard_shortcuts.hbs (62%) diff --git a/static/js/info_overlay.js b/static/js/info_overlay.js index ec6add35cc..e3601033d1 100644 --- a/static/js/info_overlay.js +++ b/static/js/info_overlay.js @@ -1,5 +1,6 @@ import $ from "jquery"; +import render_keyboard_shortcut from "../templates/keyboard_shortcuts.hbs"; import render_markdown_help from "../templates/markdown_help.hbs"; import * as browser_history from "./browser_history"; @@ -164,6 +165,9 @@ export function set_up_toggler() { }); $(".informational-overlays .overlay-body").append($markdown_help); + const $keyboard_shortcuts = $(render_keyboard_shortcut()); + $(".informational-overlays .overlay-body").append($keyboard_shortcuts); + const opts = { selected: 0, child_wants_focus: true, diff --git a/templates/zerver/app/keyboard_shortcuts.html b/static/templates/keyboard_shortcuts.hbs similarity index 62% rename from templates/zerver/app/keyboard_shortcuts.html rename to static/templates/keyboard_shortcuts.hbs index 68096d984b..bf523487bc 100644 --- a/templates/zerver/app/keyboard_shortcuts.html +++ b/static/templates/keyboard_shortcuts.hbs @@ -1,59 +1,59 @@ diff --git a/templates/zerver/app/index.html b/templates/zerver/app/index.html index 228ea2019f..0f5b3a9e7d 100644 --- a/templates/zerver/app/index.html +++ b/templates/zerver/app/index.html @@ -140,7 +140,6 @@
- {% include "zerver/app/keyboard_shortcuts.html" %} {% include "zerver/app/search_operators.html" %}
diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index 4161352e03..ad3fc90825 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -633,9 +633,12 @@ html_rules: List["Rule"] = [ { "pattern": r"""\Walt=["'][^{"']""", "description": "alt argument should be enclosed by _() or it should be an empty string.", - "exclude": { - "static/templates/settings/display_settings.hbs", - "templates/zerver/app/keyboard_shortcuts.html", + "exclude_line": { + ( + # Emoji should not be tagged for translation. + "static/templates/keyboard_shortcuts.hbs", + ':thumbs_up:', ''], "bad_lines": ['Foo Image'], diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index 23c214803f..04bec21869 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -256,8 +256,6 @@ class HomeTest(ZulipTestCase): "Exclude messages with topic", "Keyboard shortcuts", "Loading...", - "Narrow to topic", - "Next message", "Filter streams", # Verify that the app styles get included "app-stubentry.js",