commit 83d18859141c954dfd760421c2350db0c22daacf Author: Kevin Veen-Birkenbach Date: Mon Jun 30 12:28:24 2025 +0200 Added Signature draft diff --git a/README.md b/README.md new file mode 100644 index 0000000..b5af78c --- /dev/null +++ b/README.md @@ -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 diff --git a/main.py b/main.py new file mode 100644 index 0000000..0baef74 --- /dev/null +++ b/main.py @@ -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() \ No newline at end of file diff --git a/signature_template.j2 b/signature_template.j2 new file mode 100644 index 0000000..fe6329c --- /dev/null +++ b/signature_template.j2 @@ -0,0 +1,33 @@ + + +E-Mail Signatur + + + + + + + + + +
+ CyMaIS Projekt Logo + +
+ {{ name }}
+ {{ position }}
+ {{ company }} +
+
+ {% if address %}
{{ address }}
{% endif %} +
Telefon: {{ phone }}
+
E-Mail: {{ email }}
+ +
+ Folge mir auf + {% for network in icons.keys() %} + {{ network }} + {% endfor %} +
+ + \ No newline at end of file