mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	templates: Clean up zephyr-mirror.html.
This allows us to eliminate conditionals related to ignoring files and checking indentation.
This commit is contained in:
		@@ -5,30 +5,45 @@
 | 
				
			|||||||
{% block portico_content %}
 | 
					{% block portico_content %}
 | 
				
			||||||
    <h1 style="margin-top:30px;">The Zephyr mirror script (not recommended)</h1>
 | 
					    <h1 style="margin-top:30px;">The Zephyr mirror script (not recommended)</h1>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<p>Webathena is the easiest way to use Zulip.  With Webathena, you don't need
 | 
					    <p>
 | 
				
			||||||
to run any software in a screen session.  Your Athena password never leaves
 | 
					        Webathena is the easiest way to use Zulip.  With Webathena, you don't need
 | 
				
			||||||
your computer and the only access that any Zulip computer ever receives is the
 | 
					        to run any software in a screen session.  Your Athena password never leaves
 | 
				
			||||||
ability to send/receive zephyrs as you.</p>
 | 
					        your computer and the only access that any Zulip computer ever receives is the
 | 
				
			||||||
 | 
					        ability to send/receive zephyrs as you.
 | 
				
			||||||
 | 
					    </p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<p>We recommend that you use Webathena instead of following these instructions.
 | 
					    <p>
 | 
				
			||||||
Please only follow these instructions if you know that you want to run the zephyr
 | 
					        We recommend that you use Webathena instead of following these instructions.
 | 
				
			||||||
mirror script instead of using Webathena.</p>
 | 
					        Please only follow these instructions if you know that you want to run the zephyr
 | 
				
			||||||
 | 
					        mirror script instead of using Webathena.
 | 
				
			||||||
 | 
					    </p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<h3 id="mirror">Running the Zephyr mirror script</h3>
 | 
					    <h3 id="mirror">Running the Zephyr mirror script</h3>
 | 
				
			||||||
    <p>On an Athena dialup
 | 
					 | 
				
			||||||
    (<a href="https://linerva.mit.edu">linerva.mit.edu</a>,
 | 
					 | 
				
			||||||
     <a href="https://athena.dialup.mit.edu">athena.dialup.mit.edu</a>,
 | 
					 | 
				
			||||||
    etc.), run the Zephyr mirroring script inside a screen
 | 
					 | 
				
			||||||
    session.</p>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <p><strong>IMPORTANT: You must keep the Zephyr mirroring script
 | 
					    <p>
 | 
				
			||||||
    always running in a session with unexpired Kerberos
 | 
					        On an Athena dialup
 | 
				
			||||||
    tickets.</strong>  The script forwards personals you receive on
 | 
					        (<a href="https://linerva.mit.edu">linerva.mit.edu</a>,
 | 
				
			||||||
    Zephyr to Zulip, and forwards messages you send in Zulip to
 | 
					        <a href="https://athena.dialup.mit.edu">athena.dialup.mit.edu</a>,
 | 
				
			||||||
    Zephyr.  <strong>If it is not running, only other Zulip users
 | 
					        etc.), run the Zephyr mirroring script inside a screen
 | 
				
			||||||
    will receive messages you send from Zulip!</strong>.  The Zulip
 | 
					        session.
 | 
				
			||||||
    web application will warn you if the Zephyr mirroring script is
 | 
					    </p>
 | 
				
			||||||
    not running.</p>
 | 
					
 | 
				
			||||||
 | 
					    <p>
 | 
				
			||||||
 | 
					        <strong>
 | 
				
			||||||
 | 
					            IMPORTANT: You must keep the Zephyr mirroring script
 | 
				
			||||||
 | 
					            always running in a session with unexpired Kerberos
 | 
				
			||||||
 | 
					            tickets.
 | 
				
			||||||
 | 
					        </strong>
 | 
				
			||||||
 | 
					        The script forwards personals you receive on
 | 
				
			||||||
 | 
					        Zephyr to Zulip, and forwards messages you send in Zulip to
 | 
				
			||||||
 | 
					        Zephyr.
 | 
				
			||||||
 | 
					        <strong>
 | 
				
			||||||
 | 
					            If it is not running, only other Zulip users
 | 
				
			||||||
 | 
					            will receive messages you send from Zulip!
 | 
				
			||||||
 | 
					        </strong>.
 | 
				
			||||||
 | 
					        The Zulip web application will warn you if the Zephyr
 | 
				
			||||||
 | 
					        mirroring script is not running.
 | 
				
			||||||
 | 
					    </p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <p>If you already have BarnOwl running in screen/tmux somewhere,
 | 
					    <p>If you already have BarnOwl running in screen/tmux somewhere,
 | 
				
			||||||
    you can just run:</p>
 | 
					    you can just run:</p>
 | 
				
			||||||
@@ -39,36 +54,46 @@ mirror script instead of using Webathena.</p>
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    <h4>Mirroring without a BarnOwl session</h4>
 | 
					    <h4>Mirroring without a BarnOwl session</h4>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <p>If you are not already running a screen/tmux for BarnOwl, you
 | 
					    <p>
 | 
				
			||||||
    can set up a screen session to run the Zephyr mirroring script by
 | 
					        If you are not already running a screen/tmux for BarnOwl, you
 | 
				
			||||||
    running the following on a dialup such
 | 
					        can set up a screen session to run the Zephyr mirroring script by
 | 
				
			||||||
    as <a href="https://linerva.mit.edu">linerva.mit.edu</a>:</p>
 | 
					        running the following on a dialup such
 | 
				
			||||||
 | 
					        as <a href="https://linerva.mit.edu">linerva.mit.edu</a>:
 | 
				
			||||||
      <ol>
 | 
					    </p>
 | 
				
			||||||
    <li><code>kinit -l7d && aklog</code></li>
 | 
					 | 
				
			||||||
    <li>(Type your password to create 7-day renewable Kerberos tickets)</li>
 | 
					 | 
				
			||||||
    <li><code>env ZEPHYR_SCREEN_CLIENT=/mit/tabbott/zulip/zephyr_mirror.py
 | 
					 | 
				
			||||||
        SCREEN_SESSION_NAME=zulip athrun kchen owl-screen
 | 
					 | 
				
			||||||
    </code></li>
 | 
					 | 
				
			||||||
    </ol>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <p>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:</p>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <ol>
 | 
					    <ol>
 | 
				
			||||||
    <li>Run <code>screen -x zulip</code> to connect to the mirroring
 | 
					        <li><code>kinit -l7d && aklog</code></li>
 | 
				
			||||||
        screen session created above.</li>
 | 
					        <li>(Type your password to create 7-day renewable Kerberos tickets)</li>
 | 
				
			||||||
    <li>The first time, you'll need to type <code>Ctrl-A c</code> to switch to a new terminal in your screen session.</li>
 | 
					        <li>
 | 
				
			||||||
    <li><code>kinit -l7d && aklog</code></li>
 | 
					        <code>env ZEPHYR_SCREEN_CLIENT=/mit/tabbott/zulip/zephyr_mirror.py
 | 
				
			||||||
    <li>(Type type your password to renew your Kerberos tickets).</li>
 | 
					        SCREEN_SESSION_NAME=zulip athrun kchen owl-screen
 | 
				
			||||||
 | 
					        </code>
 | 
				
			||||||
 | 
					        </li>
 | 
				
			||||||
    </ol>
 | 
					    </ol>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <p>Don't run multiple copies of the Zephyr mirroring script;
 | 
					    <p>
 | 
				
			||||||
    doing so will result in messages you sent being forwarded to
 | 
					        This will run the Zephyr mirroring script inside a screen
 | 
				
			||||||
    Zephyr twice.</p>
 | 
					        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:
 | 
				
			||||||
 | 
					    </p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <ol>
 | 
				
			||||||
 | 
					        <li>
 | 
				
			||||||
 | 
					            Run <code>screen -x zulip</code> to connect to the mirroring
 | 
				
			||||||
 | 
					            screen session created above.
 | 
				
			||||||
 | 
					        </li>
 | 
				
			||||||
 | 
					        <li>The first time, you'll need to type <code>Ctrl-A c</code> to switch to a new terminal in your screen session.</li>
 | 
				
			||||||
 | 
					        <li><code>kinit -l7d && aklog</code></li>
 | 
				
			||||||
 | 
					        <li>(Type type your password to renew your Kerberos tickets).</li>
 | 
				
			||||||
 | 
					    </ol>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <p>
 | 
				
			||||||
 | 
					        Don't run multiple copies of the Zephyr mirroring script;
 | 
				
			||||||
 | 
					        doing so will result in messages you sent being forwarded to
 | 
				
			||||||
 | 
					        Zephyr twice.
 | 
				
			||||||
 | 
					    </p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -115,30 +115,11 @@ def check_html_templates(templates: Iterable[str], all_dups: bool, fix: bool) ->
 | 
				
			|||||||
        sys.exit(1)
 | 
					        sys.exit(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for fn in templates:
 | 
					    for fn in templates:
 | 
				
			||||||
        # Many of our Django templates have strange indentation.  The
 | 
					        validate(fn)
 | 
				
			||||||
        # 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))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # 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:
 | 
					    for fn in templates:
 | 
				
			||||||
        if fn not in IGNORE_FILES:
 | 
					        if not validate_indent_html(fn, fix):
 | 
				
			||||||
            if not validate_indent_html(fn, fix):
 | 
					            sys.exit(1)
 | 
				
			||||||
                sys.exit(1)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def check_handlebar_templates(templates: Iterable[str], fix: bool) -> None:
 | 
					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")]
 | 
					    templates = [fn for fn in templates if fn.endswith(".hbs")]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for fn in templates:
 | 
					    for fn in templates:
 | 
				
			||||||
        validate(fn=fn, check_indent=True)
 | 
					        validate(fn)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for fn in templates:
 | 
					    for fn in templates:
 | 
				
			||||||
        if not validate_indent_html(fn, fix):
 | 
					        if not validate_indent_html(fn, fix):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -242,9 +242,7 @@ def indent_level(s: str) -> int:
 | 
				
			|||||||
    return len(s) - len(s.lstrip())
 | 
					    return len(s) - len(s.lstrip())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def validate(
 | 
					def validate(fn: Optional[str] = None, text: Optional[str] = None) -> None:
 | 
				
			||||||
    fn: Optional[str] = None, text: Optional[str] = None, check_indent: bool = True
 | 
					 | 
				
			||||||
) -> None:
 | 
					 | 
				
			||||||
    assert fn or text
 | 
					    assert fn or text
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if fn is None:
 | 
					    if fn is None:
 | 
				
			||||||
@@ -318,7 +316,7 @@ def validate(
 | 
				
			|||||||
            elif start_tag != end_tag:
 | 
					            elif start_tag != end_tag:
 | 
				
			||||||
                problem = "Mismatched 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:
 | 
					                if end_col != start_col:
 | 
				
			||||||
                    problem = "Bad indentation."
 | 
					                    problem = "Bad indentation."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,10 +20,9 @@ class ParserTest(unittest.TestCase):
 | 
				
			|||||||
        error: str,
 | 
					        error: str,
 | 
				
			||||||
        fn: Optional[str] = None,
 | 
					        fn: Optional[str] = None,
 | 
				
			||||||
        text: Optional[str] = None,
 | 
					        text: Optional[str] = None,
 | 
				
			||||||
        check_indent: bool = True,
 | 
					 | 
				
			||||||
    ) -> None:
 | 
					    ) -> None:
 | 
				
			||||||
        with self.assertRaisesRegex(TemplateParserException, error):
 | 
					        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:
 | 
					    def test_is_django_block_tag(self) -> None:
 | 
				
			||||||
        self.assertTrue(is_django_block_tag("block"))
 | 
					        self.assertTrue(is_django_block_tag("block"))
 | 
				
			||||||
@@ -93,7 +92,7 @@ class ParserTest(unittest.TestCase):
 | 
				
			|||||||
                foo
 | 
					                foo
 | 
				
			||||||
                </p>
 | 
					                </p>
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        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:
 | 
					    def test_validate_state_depth(self) -> None:
 | 
				
			||||||
        my_html = """
 | 
					        my_html = """
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user