From 2134a268734b558cffb8f2630dc17d5f8203d69c Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Wed, 24 Nov 2021 13:25:30 +0000 Subject: [PATCH] templates: Clean up zephyr-mirror.html. This allows us to eliminate conditionals related to ignoring files and checking indentation. --- templates/corporate/zephyr-mirror.html | 121 +++++++++++++++---------- tools/check-templates | 27 +----- tools/lib/template_parser.py | 6 +- tools/tests/test_template_parser.py | 5 +- 4 files changed, 81 insertions(+), 78 deletions(-) diff --git a/templates/corporate/zephyr-mirror.html b/templates/corporate/zephyr-mirror.html index de2c445cd9..07095e6b44 100644 --- a/templates/corporate/zephyr-mirror.html +++ b/templates/corporate/zephyr-mirror.html @@ -5,30 +5,45 @@ {% block portico_content %}

The Zephyr mirror script (not recommended)

-

Webathena is the easiest way to use Zulip. With Webathena, you don't need -to run any software in a screen session. Your Athena password never leaves -your computer and the only access that any Zulip computer ever receives is the -ability to send/receive zephyrs as you.

+

+ Webathena is the easiest way to use Zulip. With Webathena, you don't need + to run any software in a screen session. Your Athena password never leaves + your computer and the only access that any Zulip computer ever receives is the + ability to send/receive zephyrs as you. +

-

We recommend that you use Webathena instead of following these instructions. -Please only follow these instructions if you know that you want to run the zephyr -mirror script instead of using Webathena.

+

+ We recommend that you use Webathena instead of following these instructions. + Please only follow these instructions if you know that you want to run the zephyr + mirror script instead of using Webathena. +

-

Running the Zephyr mirror script

-

On an Athena dialup - (linerva.mit.edu, - athena.dialup.mit.edu, - etc.), run the Zephyr mirroring script inside a screen - session.

+

Running the Zephyr mirror script

-

IMPORTANT: You must keep the Zephyr mirroring script - always running in a session with unexpired Kerberos - tickets. The script forwards personals you receive on - Zephyr to Zulip, and forwards messages you send in Zulip to - Zephyr. If it is not running, only other Zulip users - will receive messages you send from Zulip!. The Zulip - web application will warn you if the Zephyr mirroring script is - not running.

+

+ On an Athena dialup + (linerva.mit.edu, + athena.dialup.mit.edu, + etc.), run the Zephyr mirroring script inside a screen + session. +

+ +

+ + IMPORTANT: You must keep the Zephyr mirroring script + always running in a session with unexpired Kerberos + tickets. + + The script forwards personals you receive on + Zephyr to Zulip, and forwards messages you send in Zulip to + Zephyr. + + If it is not running, only other Zulip users + will receive messages you send from Zulip! + . + The Zulip web application will warn you if the Zephyr + mirroring script is not running. +

If you already have BarnOwl running in screen/tmux somewhere, you can just run:

@@ -39,36 +54,46 @@ mirror script instead of using Webathena.

Mirroring without a BarnOwl session

-

If you are not already running a screen/tmux for BarnOwl, you - can set up a screen session to run the Zephyr mirroring script by - running the following on a dialup such - as linerva.mit.edu:

- -
    -
  1. kinit -l7d && aklog
  2. -
  3. (Type your password to create 7-day renewable Kerberos tickets)
  4. -
  5. env ZEPHYR_SCREEN_CLIENT=/mit/tabbott/zulip/zephyr_mirror.py - SCREEN_SESSION_NAME=zulip athrun kchen owl-screen -
  6. -
- -

This will run the Zephyr mirroring script inside a screen - session, and use `/mit/kchen/bin/cont-renew-notify` to continually - renew your Kerberos tickets for up to a week; each week, it will - send you a Zephyr/Zulip letting you know that you need to renew - your tickets. To do so, log in to the server that you set up the - screen session on and use the following procedure:

+

+ If you are not already running a screen/tmux for BarnOwl, you + can set up a screen session to run the Zephyr mirroring script by + running the following on a dialup such + as linerva.mit.edu: +

    -
  1. Run screen -x zulip to connect to the mirroring - screen session created above.
  2. -
  3. The first time, you'll need to type Ctrl-A c to switch to a new terminal in your screen session.
  4. -
  5. kinit -l7d && aklog
  6. -
  7. (Type type your password to renew your Kerberos tickets).
  8. +
  9. kinit -l7d && aklog
  10. +
  11. (Type your password to create 7-day renewable Kerberos tickets)
  12. +
  13. + env ZEPHYR_SCREEN_CLIENT=/mit/tabbott/zulip/zephyr_mirror.py + SCREEN_SESSION_NAME=zulip athrun kchen owl-screen + +
-

Don't run multiple copies of the Zephyr mirroring script; - doing so will result in messages you sent being forwarded to - Zephyr twice.

+

+ This will run the Zephyr mirroring script inside a screen + session, and use `/mit/kchen/bin/cont-renew-notify` to continually + renew your Kerberos tickets for up to a week; each week, it will + send you a Zephyr/Zulip letting you know that you need to renew + your tickets. To do so, log in to the server that you set up the + screen session on and use the following procedure: +

+ +
    +
  1. + Run screen -x zulip to connect to the mirroring + screen session created above. +
  2. +
  3. The first time, you'll need to type Ctrl-A c to switch to a new terminal in your screen session.
  4. +
  5. kinit -l7d && aklog
  6. +
  7. (Type type your password to renew your Kerberos tickets).
  8. +
+ +

+ Don't run multiple copies of the Zephyr mirroring script; + doing so will result in messages you sent being forwarded to + Zephyr twice. +

{% endblock %} diff --git a/tools/check-templates b/tools/check-templates index d3809a1417..e8e985da85 100755 --- a/tools/check-templates +++ b/tools/check-templates @@ -115,30 +115,11 @@ def check_html_templates(templates: Iterable[str], all_dups: bool, fix: bool) -> sys.exit(1) for fn in templates: - # Many of our Django templates have strange indentation. The - # indentation errors are often harmless, even stylistically - # harmless, but they tend to be in files that might be old - # and might eventually require more scrutiny for things like - # localization. See GitHub #1236. - bad_files = [ - # These use various whitespace-dependent formatting that - # prevent cleaning them. - "templates/corporate/zephyr-mirror.html", - ] - validate(fn=fn, check_indent=(fn not in bad_files)) + validate(fn) - # Ignore these files since these have not been cleaned yet :/ - IGNORE_FILES = [ - # zephyr-mirror.html has some whitespace-dependent formatting - # for code blocks that prevent cleaning it. Might make sense - # to convert it to a /help/ Markdown article. - "templates/corporate/zephyr-mirror.html", - ] - # TODO: Clean these files for fn in templates: - if fn not in IGNORE_FILES: - if not validate_indent_html(fn, fix): - sys.exit(1) + if not validate_indent_html(fn, fix): + sys.exit(1) def check_handlebar_templates(templates: Iterable[str], fix: bool) -> None: @@ -146,7 +127,7 @@ def check_handlebar_templates(templates: Iterable[str], fix: bool) -> None: templates = [fn for fn in templates if fn.endswith(".hbs")] for fn in templates: - validate(fn=fn, check_indent=True) + validate(fn) for fn in templates: if not validate_indent_html(fn, fix): diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.py index c829f3ceb4..f5e9692c11 100644 --- a/tools/lib/template_parser.py +++ b/tools/lib/template_parser.py @@ -242,9 +242,7 @@ def indent_level(s: str) -> int: return len(s) - len(s.lstrip()) -def validate( - fn: Optional[str] = None, text: Optional[str] = None, check_indent: bool = True -) -> None: +def validate(fn: Optional[str] = None, text: Optional[str] = None) -> None: assert fn or text if fn is None: @@ -318,7 +316,7 @@ def validate( elif start_tag != end_tag: problem = "Mismatched tag." - if not problem and check_indent and (end_line > start_line + max_lines): + if not problem and (end_line > start_line + max_lines): if end_col != start_col: problem = "Bad indentation." diff --git a/tools/tests/test_template_parser.py b/tools/tests/test_template_parser.py index 09acbd68f3..11b7c89d47 100644 --- a/tools/tests/test_template_parser.py +++ b/tools/tests/test_template_parser.py @@ -20,10 +20,9 @@ class ParserTest(unittest.TestCase): error: str, fn: Optional[str] = None, text: Optional[str] = None, - check_indent: bool = True, ) -> None: with self.assertRaisesRegex(TemplateParserException, error): - validate(fn=fn, text=text, check_indent=check_indent) + validate(fn=fn, text=text) def test_is_django_block_tag(self) -> None: self.assertTrue(is_django_block_tag("block")) @@ -93,7 +92,7 @@ class ParserTest(unittest.TestCase): foo

""" - self._assert_validate_error("Bad indentation.", text=my_html, check_indent=True) + self._assert_validate_error("Bad indentation.", text=my_html) def test_validate_state_depth(self) -> None: my_html = """