refactor: Use hooks to load email css files
Previously email.css files were explicitly picked from hardcoded path like public/css/email.css for all apps
This commit is contained in:
parent
4172e1ff97
commit
3c824bb92f
2 changed files with 6 additions and 12 deletions
|
|
@ -292,17 +292,9 @@ def inline_style_in_html(html):
|
|||
'''
|
||||
from premailer import Premailer
|
||||
|
||||
apps = frappe.get_installed_apps()
|
||||
|
||||
# add frappe email css file
|
||||
css_files = ['assets/css/email.css']
|
||||
if 'frappe' in apps:
|
||||
apps.remove('frappe')
|
||||
|
||||
for app in apps:
|
||||
path = 'assets/{0}/css/email.css'.format(app)
|
||||
css_files.append(path)
|
||||
|
||||
# get email css files from hooks
|
||||
css_files = frappe.get_hooks('email_css')
|
||||
css_files = [path.lstrip('/') for path in css_files]
|
||||
css_files = [css_file for css_file in css_files if os.path.exists(os.path.abspath(css_file))]
|
||||
|
||||
p = Premailer(html=html, external_styles=css_files, strip_important=False)
|
||||
|
|
@ -480,4 +472,4 @@ def sanitize_email_header(str):
|
|||
return str.replace('\r', '').replace('\n', '')
|
||||
|
||||
def get_brand_logo(email_account):
|
||||
return email_account.get('brand_logo')
|
||||
return email_account.get('brand_logo')
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ web_include_js = [
|
|||
|
||||
web_include_css = []
|
||||
|
||||
email_css = ['/assets/frappe/build/scss/email.css']
|
||||
|
||||
website_route_rules = [
|
||||
{"from_route": "/blog/<category>", "to_route": "Blog Post"},
|
||||
{"from_route": "/kb/<category>", "to_route": "Help Article"},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue