mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	scripts: Rename inline-email-css to inline_email_css.py.
This is a preparatory step for making it a module that we can import and call from other code.
This commit is contained in:
		@@ -159,7 +159,7 @@ yarn install
 | 
				
			|||||||
sudo mkdir /srv/zulip-emoji-cache
 | 
					sudo mkdir /srv/zulip-emoji-cache
 | 
				
			||||||
sudo chown -R `whoami`: /srv/zulip-emoji-cache
 | 
					sudo chown -R `whoami`: /srv/zulip-emoji-cache
 | 
				
			||||||
./tools/setup/emoji/build_emoji
 | 
					./tools/setup/emoji/build_emoji
 | 
				
			||||||
./scripts/setup/inline-email-css
 | 
					./scripts/setup/inline_email_css.py
 | 
				
			||||||
./tools/setup/build_pygments_data
 | 
					./tools/setup/build_pygments_data
 | 
				
			||||||
./tools/setup/generate_zulip_bots_static_files.py
 | 
					./tools/setup/generate_zulip_bots_static_files.py
 | 
				
			||||||
./scripts/setup/generate_secrets.py --development
 | 
					./scripts/setup/generate_secrets.py --development
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,7 +85,7 @@ EmailMessage instance for each message that would be sent.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Other notes:
 | 
					Other notes:
 | 
				
			||||||
* After changing any HTML email or `email_base.html`, you need to run
 | 
					* After changing any HTML email or `email_base.html`, you need to run
 | 
				
			||||||
  `scripts/setup/inline-email-css` for the changes to be reflected in the dev
 | 
					  `scripts/setup/inline_email_css.py` for the changes to be reflected in the dev
 | 
				
			||||||
  environment. The script generates files like
 | 
					  environment. The script generates files like
 | 
				
			||||||
  `templates/zerver/emails/compiled/<template_prefix>.html`.
 | 
					  `templates/zerver/emails/compiled/<template_prefix>.html`.
 | 
				
			||||||
## Email templates
 | 
					## Email templates
 | 
				
			||||||
@@ -103,13 +103,13 @@ two copies of each email (plain-text and HTML).
 | 
				
			|||||||
So for each email, there are two source templates: the `.txt` version
 | 
					So for each email, there are two source templates: the `.txt` version
 | 
				
			||||||
(for plain-text format) as well as a `.source.html` template.  The
 | 
					(for plain-text format) as well as a `.source.html` template.  The
 | 
				
			||||||
`.txt` version is used directly; while the `.source.html` template is
 | 
					`.txt` version is used directly; while the `.source.html` template is
 | 
				
			||||||
processed by `scripts/setup/inline-email-css` (generating a `.html` template
 | 
					processed by `scripts/setup/inline_email_css.py` (generating a `.html` template
 | 
				
			||||||
under `templates/zerver/emails/compiled`); that tool (powered by
 | 
					under `templates/zerver/emails/compiled`); that tool (powered by
 | 
				
			||||||
`premailer`) injects the CSS we use for styling our emails
 | 
					`premailer`) injects the CSS we use for styling our emails
 | 
				
			||||||
(`templates/zerver/emails/email.css`) into the templates inline.
 | 
					(`templates/zerver/emails/email.css`) into the templates inline.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
What this means is that when you're editing emails, **you need to run
 | 
					What this means is that when you're editing emails, **you need to run
 | 
				
			||||||
`scripts/setup/inline-email-css`** after making changes to see the changes
 | 
					`scripts/setup/inline_email_css.py`** after making changes to see the changes
 | 
				
			||||||
take effect.  Our tooling automatically runs this as part of
 | 
					take effect.  Our tooling automatically runs this as part of
 | 
				
			||||||
`tools/provision` and production deployments; but you should bump
 | 
					`tools/provision` and production deployments; but you should bump
 | 
				
			||||||
`PROVISION_VERSION` when making changes to emails that change test
 | 
					`PROVISION_VERSION` when making changes to emails that change test
 | 
				
			||||||
@@ -132,7 +132,7 @@ translators to not have to deal with multiple versions of each string
 | 
				
			|||||||
in our emails.
 | 
					in our emails.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
One can test whether you did the translating part right by running
 | 
					One can test whether you did the translating part right by running
 | 
				
			||||||
`scripts/setup/inline-email-css && manage.py makemessages` and then searching
 | 
					`scripts/setup/inline_email_css.py && manage.py makemessages` and then searching
 | 
				
			||||||
for the strings in `locale/en/LC_MESSAGES/django.po`; if there
 | 
					for the strings in `locale/en/LC_MESSAGES/django.po`; if there
 | 
				
			||||||
are multiple copies or they contain CSS colors, you did it wrong.
 | 
					are multiple copies or they contain CSS colors, you did it wrong.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,7 +41,7 @@
 | 
				
			|||||||
                </tr>
 | 
					                </tr>
 | 
				
			||||||
                <tr>
 | 
					                <tr>
 | 
				
			||||||
                    <td><a href="/emails">/emails</a></td>
 | 
					                    <td><a href="/emails">/emails</a></td>
 | 
				
			||||||
                    <td><code>./scripts/setup/inline-email-css</code><br/>
 | 
					                    <td><code>./scripts/setup/inline_email_css.py</code><br/>
 | 
				
			||||||
                        Run the command if you made changes to source.html email templates.
 | 
					                        Run the command if you made changes to source.html email templates.
 | 
				
			||||||
                    </td>
 | 
					                    </td>
 | 
				
			||||||
                    <td>View outgoing and example emails.</td>
 | 
					                    <td>View outgoing and example emails.</td>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -134,12 +134,12 @@ def main(options: argparse.Namespace) -> int:
 | 
				
			|||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print("No need to run `tools/setup/build_pygments_data`.")
 | 
					        print("No need to run `tools/setup/build_pygments_data`.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    email_source_paths = ["scripts/setup/inline-email-css", "templates/zerver/emails/email.css"]
 | 
					    email_source_paths = ["scripts/setup/inline_email_css.py", "templates/zerver/emails/email.css"]
 | 
				
			||||||
    email_source_paths += glob.glob('templates/zerver/emails/*.source.html')
 | 
					    email_source_paths += glob.glob('templates/zerver/emails/*.source.html')
 | 
				
			||||||
    if file_or_package_hash_updated(email_source_paths, "last_email_source_files_hash", options.is_force):
 | 
					    if file_or_package_hash_updated(email_source_paths, "last_email_source_files_hash", options.is_force):
 | 
				
			||||||
        run(["scripts/setup/inline-email-css"])
 | 
					        run(["scripts/setup/inline_email_css.py"])
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print("No need to run `scripts/setup/inline-email-css`.")
 | 
					        print("No need to run `scripts/setup/inline_email_css.py`.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if not options.is_production_travis:
 | 
					    if not options.is_production_travis:
 | 
				
			||||||
        # The following block is skipped for the production Travis
 | 
					        # The following block is skipped for the production Travis
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,7 +43,7 @@ setup_node_modules(production=True, stdout=fp, stderr=fp)
 | 
				
			|||||||
run(['./tools/setup/emoji/build_emoji'], stdout=fp, stderr=fp)
 | 
					run(['./tools/setup/emoji/build_emoji'], stdout=fp, stderr=fp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Inline CSS in emails
 | 
					# Inline CSS in emails
 | 
				
			||||||
run(['./scripts/setup/inline-email-css'], stdout=fp, stderr=fp)
 | 
					run(['./scripts/setup/inline_email_css.py'], stdout=fp, stderr=fp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Copy over static files from the zulip_bots package
 | 
					# Copy over static files from the zulip_bots package
 | 
				
			||||||
run(['./tools/setup/generate_zulip_bots_static_files.py'], stdout=fp, stderr=fp)
 | 
					run(['./tools/setup/generate_zulip_bots_static_files.py'], stdout=fp, stderr=fp)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,19 +38,19 @@ def send_custom_email(users: List[UserProfile], options: Dict[str, Any]) -> None
 | 
				
			|||||||
        with open(markdown_email_base_template_path) as base_template:
 | 
					        with open(markdown_email_base_template_path) as base_template:
 | 
				
			||||||
            # Note that we're doing a hacky non-Jinja2 substitution here;
 | 
					            # Note that we're doing a hacky non-Jinja2 substitution here;
 | 
				
			||||||
            # we do this because the normal render_markdown_path ordering
 | 
					            # we do this because the normal render_markdown_path ordering
 | 
				
			||||||
            # doesn't commute properly with inline-email-css.
 | 
					            # doesn't commute properly with inline_email_css.
 | 
				
			||||||
            f.write(base_template.read().replace('{{ rendered_input }}',
 | 
					            f.write(base_template.read().replace('{{ rendered_input }}',
 | 
				
			||||||
                                                 rendered_input))
 | 
					                                                 rendered_input))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with open(subject_path, "w") as f:
 | 
					    with open(subject_path, "w") as f:
 | 
				
			||||||
        f.write(options["subject"])
 | 
					        f.write(options["subject"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Then, we compile the email template using inline-email-css to
 | 
					    # Then, we compile the email template using inline_email_css to
 | 
				
			||||||
    # add our standard styling to the paragraph tags (etc.).
 | 
					    # add our standard styling to the paragraph tags (etc.).
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    # TODO: Ideally, we'd just refactor inline-email-css to
 | 
					    # TODO: Ideally, we'd just refactor inline-email-css to
 | 
				
			||||||
    # compile this one template, not all of them.
 | 
					    # compile this one template, not all of them.
 | 
				
			||||||
    subprocess.check_call(["./scripts/setup/inline-email-css"])
 | 
					    subprocess.check_call(["./scripts/setup/inline_email_css.py"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Finally, we send the actual emails.
 | 
					    # Finally, we send the actual emails.
 | 
				
			||||||
    for user_profile in users:
 | 
					    for user_profile in users:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,7 +50,7 @@ def generate_all_emails(request: HttpRequest) -> HttpResponse:
 | 
				
			|||||||
        # here, since that saves a step when testing out changes to
 | 
					        # here, since that saves a step when testing out changes to
 | 
				
			||||||
        # the email CSS.  But we don't run this inside the test suite,
 | 
					        # the email CSS.  But we don't run this inside the test suite,
 | 
				
			||||||
        # because by role, the tests shouldn't be doing a provision-like thing.
 | 
					        # because by role, the tests shouldn't be doing a provision-like thing.
 | 
				
			||||||
        subprocess.check_call(["./scripts/setup/inline-email-css"])
 | 
					        subprocess.check_call(["./scripts/setup/inline_email_css.py"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # We import the Django test client inside the view function,
 | 
					    # We import the Django test client inside the view function,
 | 
				
			||||||
    # because it isn't needed in production elsewhere, and not
 | 
					    # because it isn't needed in production elsewhere, and not
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user