diff --git a/.gitignore b/.gitignore index a0fd20b..f04e53c 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ requirements.txt video/ scss/bs5/*.css* scss/bs4/*.css* +mail/*.html +jellyfin_accounts/data/*.html diff --git a/jellyfin_accounts/data/email.html b/jellyfin_accounts/data/email.html deleted file mode 100644 index 8478d6a..0000000 --- a/jellyfin_accounts/data/email.html +++ /dev/null @@ -1,20 +0,0 @@ -
Jellyfin

Hi {{ username }},

Someone has recently requested a password reset on Jellyfin.

If this was you, enter the below pin into the prompt.

The code will expire on {{ expiry_date }}, at {{ expiry_time }}, which is in {{ expires_in }}.

If this wasn't you, please ignore this email.

{{ pin }}

{{ message }}
\ No newline at end of file diff --git a/jellyfin_accounts/data/invite-email.html b/jellyfin_accounts/data/invite-email.html deleted file mode 100644 index b994c80..0000000 --- a/jellyfin_accounts/data/invite-email.html +++ /dev/null @@ -1,20 +0,0 @@ -
Jellyfin

Hi,

You've been invited to Jellyfin.

To join, click the button below.

This invite will expire on {{ expiry_date }}, at {{ expiry_time }}, which is in {{ expires_in }}, so act quick.

Setup your account
{{ message }}
\ No newline at end of file diff --git a/jellyfin_accounts/data/notification.mjml b/jellyfin_accounts/data/notification.mjml deleted file mode 100644 index d3648f3..0000000 --- a/jellyfin_accounts/data/notification.mjml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - Jellyfin - - - - - -

Hi {{ username }},

-

Someone has recently requested a password reset on Jellyfin.

-

If this was you, enter the below pin into the prompt.

-

The code will expire on {{ expiry_date }}, at {{ expiry_time }}, which is in {{ expires_in }}.

-

If this wasn't you, please ignore this email.

-
- {{ pin }} -
-
- - - - {{ message }} - - - - -
\ No newline at end of file diff --git a/jellyfin_accounts/data/email.mjml b/mail/email.mjml similarity index 100% rename from jellyfin_accounts/data/email.mjml rename to mail/email.mjml diff --git a/jellyfin_accounts/data/email.txt b/mail/email.txt similarity index 100% rename from jellyfin_accounts/data/email.txt rename to mail/email.txt diff --git a/mail/generate.py b/mail/generate.py new file mode 100755 index 0000000..825c16e --- /dev/null +++ b/mail/generate.py @@ -0,0 +1,34 @@ +import subprocess +import shutil +from pathlib import Path + +def runcmd(cmd): + proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) + return proc.communicate() + +local_path = Path(__file__).resolve().parent +node_bin = local_path.parent / 'node_modules' / '.bin' + +for mjml in [f for f in local_path.iterdir() if f.is_file() and 'mjml' in f.suffix]: + print(f'Compiling {mjml.name}') + fname = mjml.with_suffix(".html") + runcmd(f'{str(node_bin / "mjml")} {str(mjml)} -o {str(fname)}') + if fname.is_file(): + print('Done.') + +html = [f for f in local_path.iterdir() if f.is_file() and 'html' in f.suffix] + +output = local_path.parent / 'jellyfin_accounts' / 'data' + +for f in html: + shutil.copy(str(f), + str(output / f.name)) + print(f'Copied {f.name} to {str(output / f.name)}') + txtfile = f.with_suffix('.txt') + if txtfile.is_file(): + shutil.copy(str(txtfile), + str(output / txtfile.name)) + print(f'Copied {txtfile.name} to {str(output / txtfile.name)}') + else: + print(f'Warning: {txtfile.name} does not exist. Text versions of emails should be supplied.') + diff --git a/jellyfin_accounts/data/invite-email.mjml b/mail/invite-email.mjml similarity index 100% rename from jellyfin_accounts/data/invite-email.mjml rename to mail/invite-email.mjml diff --git a/jellyfin_accounts/data/invite-email.txt b/mail/invite-email.txt similarity index 100% rename from jellyfin_accounts/data/invite-email.txt rename to mail/invite-email.txt diff --git a/pyproject.toml b/pyproject.toml index c63fea2..6faee59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,8 +8,8 @@ license = "MIT" homepage = "https://github.com/hrfee/jellyfin-accounts" repository = "https://github.com/hrfee/jellyfin-accounts" keywords = ["jellyfin", "jf-accounts"] -include = ["jellyfin_accounts/data/*", "jellyfin_accounts/data/static/*.css"] -exclude = ["images/*", "scss/*"] +include = ["jellyfin_accounts/data/*", "jellyfin_accounts/data/static/*.css", "jellyfin_accounts/data/*.html"] +exclude = ["images/*", "scss/*", "mail/*"] classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", @@ -43,6 +43,8 @@ jf-accounts = 'jellyfin_accounts:main' pre_compile-css = "task get-npm-deps" compile-css = "python scss/compile.py" get-npm-deps = "python scss/get_node_deps.py" +pre_generate-emails = "task get-npm-deps" +generate-emails = "python mail/generate.py" [build-system] requires = ["poetry>=0.12"]