Added Signature draft
This commit is contained in:
8
README.md
Normal file
8
README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
python main.py \
|
||||
-n "Max Mustermann" \
|
||||
-P "Entwickler" \
|
||||
-t "+49 123 456789" \
|
||||
-u "maxuser" \
|
||||
-l "maxlinkedin" \
|
||||
-a "Musterstraße 1, 12345 Musterstadt" \
|
||||
-o signature.html
|
64
main.py
Normal file
64
main.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import argparse
|
||||
import base64
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
import os
|
||||
|
||||
def encode_file(path, mime_type):
|
||||
"""Liest eine Datei ein und gibt eine data-uri zurück."""
|
||||
with open(path, 'rb') as f:
|
||||
data = f.read()
|
||||
return f"data:{mime_type};base64,{base64.b64encode(data).decode('utf-8')}"
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Generiere eine HTML-E-Mail-Signatur für das CyMaIS Projekt"
|
||||
)
|
||||
parser.add_argument('-n', '--name', required=True, help="Vollständiger Name")
|
||||
parser.add_argument('-P', '--position', required=True, help="Position / Titel")
|
||||
parser.add_argument('-t', '--phone', required=True, help="Telefonnummer")
|
||||
parser.add_argument('-u', '--username', required=True, help="Allgemeiner Nutzername für E-Mail, WordPress, Mastodon, etc.")
|
||||
parser.add_argument('-l', '--linkedin', required=True, help="LinkedIn-Nutzername (ohne URL)")
|
||||
parser.add_argument('-a', '--address', default='', help="Anschrift (optional)")
|
||||
parser.add_argument('-o', '--output', default='signature.html', help="Zieldatei für die generierte Signatur")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Basis-Kontext
|
||||
context = {
|
||||
'name': args.name,
|
||||
'position': args.position,
|
||||
'company': 'CyMaIS Projekt',
|
||||
'address': args.address,
|
||||
'phone': args.phone,
|
||||
'email': f"{args.username}@cymais.cloud",
|
||||
'website_url': 'https://www.cymais.cloud/',
|
||||
'socials': {
|
||||
'LinkedIn': f'https://www.linkedin.com/in/{args.linkedin}',
|
||||
'WordPress': 'https://www.cymais.cloud/',
|
||||
'Mastodon': f'https://mastodon.social/@{args.username}',
|
||||
'PeerTube': f'https://peertube.video/channel/{args.username}',
|
||||
'PixelFed': f'https://pixelfed.social/@{args.username}',
|
||||
}
|
||||
}
|
||||
|
||||
# Pfad zum Template-Verzeichnis
|
||||
env = Environment(loader=FileSystemLoader(os.path.dirname(__file__)))
|
||||
template = env.get_template('signature_template.j2')
|
||||
|
||||
# Logo und Icons einbetten
|
||||
context['logo'] = encode_file(os.path.join(os.path.dirname(__file__), 'logo.png'), 'image/png')
|
||||
context['icons'] = {}
|
||||
for name, url in context['socials'].items():
|
||||
filename = name.lower() + ('.png' if name == 'LinkedIn' else '.svg')
|
||||
mime = 'image/png' if name == 'LinkedIn' else 'image/svg+xml'
|
||||
context['icons'][name] = encode_file(os.path.join(os.path.dirname(__file__), filename), mime)
|
||||
|
||||
# Rendern und speichern
|
||||
output = template.render(**context)
|
||||
with open(args.output, 'w', encoding='utf-8') as f:
|
||||
f.write(output)
|
||||
|
||||
print(f"Signatur erfolgreich generiert: {args.output}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
33
signature_template.j2
Normal file
33
signature_template.j2
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head><meta charset="UTF-8"><title>E-Mail Signatur</title></head>
|
||||
<body>
|
||||
<table cellpadding="0" cellspacing="0" style="font-family:Arial,sans-serif;color:#333;font-size:14px;line-height:1.5;">
|
||||
<tr>
|
||||
<td style="vertical-align:top;padding-right:10px;">
|
||||
<img src="{{ logo }}" alt="CyMaIS Projekt Logo" style="width:60px;height:auto;display:block; vertical-align:bottom;">
|
||||
</td>
|
||||
<td style="vertical-align:top;">
|
||||
<div>
|
||||
<span style="font-size:18px;font-weight:bold;color:#1a0dab;">{{ name }}</span><br>
|
||||
<span style="font-size:14px;font-style:italic;color:#555;">{{ position }}</span><br>
|
||||
<span style="font-weight:bold;color:#1a0dab;">{{ company }}</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="padding-top:8px;">
|
||||
{% if address %}<div style="margin-bottom:4px;">{{ address }}</div>{% endif %}
|
||||
<div style="margin-bottom:4px;"><strong>Telefon:</strong> {{ phone }}</div>
|
||||
<div style="margin-bottom:4px;"><strong>E-Mail:</strong> <a href="mailto:{{ email }}" style="color:#1a0dab;text-decoration:none;">{{ email }}</a></div>
|
||||
<div style="margin-bottom:8px;"><strong>Web:</strong> <a href="{{ website_url }}" style="color:#1a0dab;text-decoration:none;">{{ website_url.replace('https://','') }}</a></div>
|
||||
<hr style="margin:0 0 8px 0;border:none;border-top:1px solid #ccc;width:100%;">
|
||||
<span style="margin-right:8px;font-size:14px;color:#333;">Folge mir auf</span>
|
||||
{% for network in icons.keys() %}
|
||||
<img src="{{ icons[network] }}" alt="{{ network }}" style="width:24px;height:auto;display:inline-block;vertical-align:middle;margin-right:8px;">
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user