From 1703e239807e45c74d2a4b6cabba1d2fbc319424 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 21 Apr 2018 22:02:19 -0700 Subject: [PATCH] templates: Move all core app templates into a subdirectory. This should make it easier to find the templates that are actually part of the core webapp, instead of having them all mixed together with the portico pages. --- docs/overview/directory-structure.md | 2 +- docs/subsystems/html-templates.md | 4 +-- docs/subsystems/markdown.md | 2 +- docs/tutorials/new-feature-tutorial.md | 2 +- docs/tutorials/writing-views.md | 2 +- templates/zerver/{ => app}/bankruptcy.html | 0 templates/zerver/{ => app}/compose.html | 0 .../zerver/{ => app}/delete_message.html | 0 .../zerver/{ => app}/deprecation_notice.html | 0 templates/zerver/{ => app}/drafts.html | 0 templates/zerver/{ => app}/home.html | 6 ++-- templates/zerver/{ => app}/index.html | 34 +++++++++---------- templates/zerver/{ => app}/invite_user.html | 0 .../zerver/{ => app}/keyboard_shortcuts.html | 0 templates/zerver/{ => app}/left_sidebar.html | 0 .../zerver/{ => app}/lightbox_overlay.html | 0 templates/zerver/{ => app}/logout.html | 0 templates/zerver/{ => app}/markdown_help.html | 0 .../zerver/{ => app}/message_history.html | 0 templates/zerver/{ => app}/navbar.html | 0 templates/zerver/{ => app}/right_sidebar.html | 0 .../zerver/{ => app}/search_operators.html | 0 .../zerver/{ => app}/settings_overlay.html | 2 +- .../zerver/{ => app}/settings_sidebar.html | 0 templates/zerver/{ => app}/subscriptions.html | 0 .../zerver/{ => app}/topic_is_muted.html | 0 templates/zerver/portico-header-dropdown.html | 2 +- tools/check-templates | 4 +-- tools/linter_lib/custom_check.py | 12 +++---- zerver/views/home.py | 2 +- 30 files changed, 37 insertions(+), 37 deletions(-) rename templates/zerver/{ => app}/bankruptcy.html (100%) rename templates/zerver/{ => app}/compose.html (100%) rename templates/zerver/{ => app}/delete_message.html (100%) rename templates/zerver/{ => app}/deprecation_notice.html (100%) rename templates/zerver/{ => app}/drafts.html (100%) rename templates/zerver/{ => app}/home.html (97%) rename templates/zerver/{ => app}/index.html (87%) rename templates/zerver/{ => app}/invite_user.html (100%) rename templates/zerver/{ => app}/keyboard_shortcuts.html (100%) rename templates/zerver/{ => app}/left_sidebar.html (100%) rename templates/zerver/{ => app}/lightbox_overlay.html (100%) rename templates/zerver/{ => app}/logout.html (100%) rename templates/zerver/{ => app}/markdown_help.html (100%) rename templates/zerver/{ => app}/message_history.html (100%) rename templates/zerver/{ => app}/navbar.html (100%) rename templates/zerver/{ => app}/right_sidebar.html (100%) rename templates/zerver/{ => app}/search_operators.html (100%) rename templates/zerver/{ => app}/settings_overlay.html (99%) rename templates/zerver/{ => app}/settings_sidebar.html (100%) rename templates/zerver/{ => app}/subscriptions.html (100%) rename templates/zerver/{ => app}/topic_is_muted.html (100%) diff --git a/docs/overview/directory-structure.md b/docs/overview/directory-structure.md index 8d4f3fea61..5cf83c7095 100644 --- a/docs/overview/directory-structure.md +++ b/docs/overview/directory-structure.md @@ -46,7 +46,7 @@ See [our docs](../subsystems/html-templates.html) for details on Zulip's templating systems. * `templates/zerver/` For [Jinja2](http://jinja.pocoo.org/) templates - for the backend (for zerver app). + for the backend (for zerver app; logged-in content is in `templates/zerver/app`). * `static/templates/` [Handlebars](http://handlebarsjs.com/) templates for the frontend. diff --git a/docs/subsystems/html-templates.md b/docs/subsystems/html-templates.md index 50576b7091..739925dbce 100644 --- a/docs/subsystems/html-templates.md +++ b/docs/subsystems/html-templates.md @@ -32,8 +32,8 @@ renders the template. For example, if you want to find the context passed to `index.html`, you can do: ``` -$ git grep zerver/index.html '*.py' -zerver/views/home.py: response = render(request, 'zerver/index.html', +$ git grep zerver/app/index.html '*.py' +zerver/views/home.py: response = render(request, 'zerver/app/index.html', ``` The next line in the code being the context definition. diff --git a/docs/subsystems/markdown.md b/docs/subsystems/markdown.md index da8840e7ed..dcbe9f9a20 100644 --- a/docs/subsystems/markdown.md +++ b/docs/subsystems/markdown.md @@ -100,7 +100,7 @@ places: your changes won't be supported in the frontend processor. * If desired, the typeahead logic in `static/js/composebox_typeahead.js`. * The test suite, probably via adding entries to `zerver/tests/fixtures/markdown_test_cases.json`. -* The in-app markdown documentation (`templates/zerver/markdown_help.html`). +* The in-app markdown documentation (`templates/zerver/app/markdown_help.html`). * The list of changes to markdown at the end of this document. Important considerations for any changes are: diff --git a/docs/tutorials/new-feature-tutorial.md b/docs/tutorials/new-feature-tutorial.md index 4c9817d5b5..2ccbf3ba14 100644 --- a/docs/tutorials/new-feature-tutorial.md +++ b/docs/tutorials/new-feature-tutorial.md @@ -121,7 +121,7 @@ feature requires UI changes, you may need to add additional CSS to this file. **Templates:** The initial page structure is rendered via Jinja2 -templates located in `templates/zerver`. For JavaScript, Zulip uses +templates located in `templates/zerver/app`. For JavaScript, Zulip uses Handlebars templates located in `static/templates`. Templates are precompiled as part of the build/deploy process. diff --git a/docs/tutorials/writing-views.md b/docs/tutorials/writing-views.md index 1c8995d866..a9ce556c65 100644 --- a/docs/tutorials/writing-views.md +++ b/docs/tutorials/writing-views.md @@ -101,7 +101,7 @@ def home(request): ### Writing a template Templates for the main website are found in -[templates/zerver](https://github.com/zulip/zulip/blob/master/templates/zerver). +[templates/zerver/app](https://github.com/zulip/zulip/blob/master/templates/zerver/app). ## Writing API REST endpoints diff --git a/templates/zerver/bankruptcy.html b/templates/zerver/app/bankruptcy.html similarity index 100% rename from templates/zerver/bankruptcy.html rename to templates/zerver/app/bankruptcy.html diff --git a/templates/zerver/compose.html b/templates/zerver/app/compose.html similarity index 100% rename from templates/zerver/compose.html rename to templates/zerver/app/compose.html diff --git a/templates/zerver/delete_message.html b/templates/zerver/app/delete_message.html similarity index 100% rename from templates/zerver/delete_message.html rename to templates/zerver/app/delete_message.html diff --git a/templates/zerver/deprecation_notice.html b/templates/zerver/app/deprecation_notice.html similarity index 100% rename from templates/zerver/deprecation_notice.html rename to templates/zerver/app/deprecation_notice.html diff --git a/templates/zerver/drafts.html b/templates/zerver/app/drafts.html similarity index 100% rename from templates/zerver/drafts.html rename to templates/zerver/app/drafts.html diff --git a/templates/zerver/home.html b/templates/zerver/app/home.html similarity index 97% rename from templates/zerver/home.html rename to templates/zerver/app/home.html index fbbf54f5a3..aa11d3ed22 100644 --- a/templates/zerver/home.html +++ b/templates/zerver/app/home.html @@ -131,8 +131,8 @@ -{% include "zerver/message_history.html" %} -{% include "zerver/delete_message.html" %} -{% include "zerver/compose.html" %} +{% include "zerver/app/message_history.html" %} +{% include "zerver/app/delete_message.html" %} +{% include "zerver/app/compose.html" %}
diff --git a/templates/zerver/index.html b/templates/zerver/app/index.html similarity index 87% rename from templates/zerver/index.html rename to templates/zerver/app/index.html index 527d437e3d..1f0f65fa19 100644 --- a/templates/zerver/index.html +++ b/templates/zerver/app/index.html @@ -41,7 +41,7 @@ {{ render_bundle('katex') }} - {% include "zerver/topic_is_muted.html" %} + {% include "zerver/app/topic_is_muted.html" %} {% endblock %} {% block content %} @@ -59,14 +59,14 @@ -{% include "zerver/lightbox_overlay.html" %} -{% include "zerver/subscriptions.html" %} -{% include "zerver/drafts.html" %} +{% include "zerver/app/lightbox_overlay.html" %} +{% include "zerver/app/subscriptions.html" %} +{% include "zerver/app/drafts.html" %} -{% include "zerver/navbar.html" %} +{% include "zerver/app/navbar.html" %}
@@ -105,7 +105,7 @@
- {% include "zerver/left_sidebar.html" %} + {% include "zerver/app/left_sidebar.html" %}
@@ -132,18 +132,18 @@
- {% include "zerver/home.html" %} + {% include "zerver/app/home.html" %}
{% if show_debug %}
- {% include "zerver/debug.html" %} + {% include "zerver/app/debug.html" %}
{% endif %}
- {% include "zerver/right_sidebar.html" %} + {% include "zerver/app/right_sidebar.html" %}
- {% include "zerver/keyboard_shortcuts.html" %} - {% include "zerver/search_operators.html" %} - {% include "zerver/markdown_help.html" %} + {% include "zerver/app/keyboard_shortcuts.html" %} + {% include "zerver/app/search_operators.html" %} + {% include "zerver/app/markdown_help.html" %}
- {% include "zerver/invite_user.html" %} - {% include "zerver/bankruptcy.html" %} - {% include "zerver/logout.html" %} - {% include "zerver/deprecation_notice.html" %} + {% include "zerver/app/invite_user.html" %} + {% include "zerver/app/bankruptcy.html" %} + {% include "zerver/app/logout.html" %} + {% include "zerver/app/deprecation_notice.html" %}
{% endblock %} diff --git a/templates/zerver/invite_user.html b/templates/zerver/app/invite_user.html similarity index 100% rename from templates/zerver/invite_user.html rename to templates/zerver/app/invite_user.html diff --git a/templates/zerver/keyboard_shortcuts.html b/templates/zerver/app/keyboard_shortcuts.html similarity index 100% rename from templates/zerver/keyboard_shortcuts.html rename to templates/zerver/app/keyboard_shortcuts.html diff --git a/templates/zerver/left_sidebar.html b/templates/zerver/app/left_sidebar.html similarity index 100% rename from templates/zerver/left_sidebar.html rename to templates/zerver/app/left_sidebar.html diff --git a/templates/zerver/lightbox_overlay.html b/templates/zerver/app/lightbox_overlay.html similarity index 100% rename from templates/zerver/lightbox_overlay.html rename to templates/zerver/app/lightbox_overlay.html diff --git a/templates/zerver/logout.html b/templates/zerver/app/logout.html similarity index 100% rename from templates/zerver/logout.html rename to templates/zerver/app/logout.html diff --git a/templates/zerver/markdown_help.html b/templates/zerver/app/markdown_help.html similarity index 100% rename from templates/zerver/markdown_help.html rename to templates/zerver/app/markdown_help.html diff --git a/templates/zerver/message_history.html b/templates/zerver/app/message_history.html similarity index 100% rename from templates/zerver/message_history.html rename to templates/zerver/app/message_history.html diff --git a/templates/zerver/navbar.html b/templates/zerver/app/navbar.html similarity index 100% rename from templates/zerver/navbar.html rename to templates/zerver/app/navbar.html diff --git a/templates/zerver/right_sidebar.html b/templates/zerver/app/right_sidebar.html similarity index 100% rename from templates/zerver/right_sidebar.html rename to templates/zerver/app/right_sidebar.html diff --git a/templates/zerver/search_operators.html b/templates/zerver/app/search_operators.html similarity index 100% rename from templates/zerver/search_operators.html rename to templates/zerver/app/search_operators.html diff --git a/templates/zerver/settings_overlay.html b/templates/zerver/app/settings_overlay.html similarity index 99% rename from templates/zerver/settings_overlay.html rename to templates/zerver/app/settings_overlay.html index 2b3f0100c5..96ac3074af 100644 --- a/templates/zerver/settings_overlay.html +++ b/templates/zerver/app/settings_overlay.html @@ -136,6 +136,6 @@ - {% include "zerver/settings_sidebar.html" %} + {% include "zerver/app/settings_sidebar.html" %} diff --git a/templates/zerver/settings_sidebar.html b/templates/zerver/app/settings_sidebar.html similarity index 100% rename from templates/zerver/settings_sidebar.html rename to templates/zerver/app/settings_sidebar.html diff --git a/templates/zerver/subscriptions.html b/templates/zerver/app/subscriptions.html similarity index 100% rename from templates/zerver/subscriptions.html rename to templates/zerver/app/subscriptions.html diff --git a/templates/zerver/topic_is_muted.html b/templates/zerver/app/topic_is_muted.html similarity index 100% rename from templates/zerver/topic_is_muted.html rename to templates/zerver/app/topic_is_muted.html diff --git a/templates/zerver/portico-header-dropdown.html b/templates/zerver/portico-header-dropdown.html index 87611d366d..10afa09d83 100644 --- a/templates/zerver/portico-header-dropdown.html +++ b/templates/zerver/portico-header-dropdown.html @@ -11,7 +11,7 @@
  • - {% include 'zerver/logout.html' %} + {% include 'zerver/app/logout.html' %} diff --git a/tools/check-templates b/tools/check-templates index 80756e7f91..e3ff742c33 100755 --- a/tools/check-templates +++ b/tools/check-templates @@ -100,7 +100,7 @@ def check_html_templates(templates, all_dups): # prevent cleaning them. 'templates/corporate/zephyr-mirror.html', # Can't clean this because of `preserve_spaces` - 'templates/zerver/markdown_help.html', + 'templates/zerver/app/markdown_help.html', ] validate(fn=fn, check_indent=(fn not in bad_files)) @@ -111,7 +111,7 @@ def check_html_templates(templates, all_dups): # to convert it to a /help/ markdown article. 'templates/corporate/zephyr-mirror.html', # Can't clean this because of `preserve_spaces` - 'templates/zerver/markdown_help.html', + 'templates/zerver/app/markdown_help.html', ] # TODO: Clean these files for fn in templates: diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index bffdb1e33d..3dff441520 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -614,7 +614,7 @@ def build_custom_checkers(by_lang): 'bad_lines': ["

    "]}, {'pattern': 'title="[^{\:]', 'exclude_line': set([ - ('templates/zerver/markdown_help.html', + ('templates/zerver/app/markdown_help.html', ':heart:') ]), 'exclude': set(["templates/zerver/emails"]), @@ -622,8 +622,8 @@ def build_custom_checkers(by_lang): {'pattern': '\Walt=["\'][^{"\']', 'description': "alt argument should be enclosed by _() or it should be an empty string.", 'exclude': set(['static/templates/settings/display-settings.handlebars', - 'templates/zerver/keyboard_shortcuts.html', - 'templates/zerver/markdown_help.html']), + 'templates/zerver/app/keyboard_shortcuts.html', + 'templates/zerver/app/markdown_help.html']), 'good_lines': ['{{ _(name) }}', ''], 'bad_lines': ['Foo Image']}, {'pattern': '\Walt=["\']{{ ?["\']', @@ -642,7 +642,7 @@ def build_custom_checkers(by_lang): 'exclude_pattern': r'.*style ?=["' + "'" + '](display: ?none|background: {{|color: {{|background-color: {{).*', 'exclude': set([ # KaTeX output uses style attribute - 'templates/zerver/markdown_help.html', + 'templates/zerver/app/markdown_help.html', # 5xx page doesn't have external CSS 'static/html/5xx.html', # Group PMs color is dynamically calculated @@ -665,14 +665,14 @@ def build_custom_checkers(by_lang): 'templates/zerver/email_log.html', # Probably just needs to be changed to display: none so the exclude works - 'templates/zerver/navbar.html', + 'templates/zerver/app/navbar.html', # Needs the width cleaned up; display: none is fine 'static/templates/settings/account-settings.handlebars', # Inline styling for an svg; could be moved to CSS files? 'templates/zerver/landing_nav.html', - 'templates/zerver/home.html', + 'templates/zerver/app/home.html', 'templates/zerver/features.html', 'templates/zerver/portico-header.html', diff --git a/zerver/views/home.py b/zerver/views/home.py index 3367d7b0b5..ca39fafd02 100644 --- a/zerver/views/home.py +++ b/zerver/views/home.py @@ -236,7 +236,7 @@ def home_real(request: HttpRequest) -> HttpResponse: show_invites = False request._log_data['extra'] = "[%s]" % (register_ret["queue_id"],) - response = render(request, 'zerver/index.html', + response = render(request, 'zerver/app/index.html', context={'user_profile': user_profile, 'page_params': JSONEncoderForHTML().encode(page_params), 'nofontface': is_buggy_ua(request.META.get("HTTP_USER_AGENT", "Unspecified")),