roundabout,
created on Tuesday, 13 February 2024, 19:35:21 (1707852921),
received on Wednesday, 31 July 2024, 06:54:41 (1722408881)
Author identity: vlad <vlad.muntoiu@gmail.com>
aebbc71bda0c683c5acd5e81dd650752f9761813
app.py
@@ -65,6 +65,7 @@ def default():
"unread": UserNotification.query.filter_by(user_username=username).filter( UserNotification.attention_level > 0).count(), "config": config, "Markup": Markup,}
@@ -372,7 +373,7 @@ def repository_tree(username, repository, branch, subpath):
repo_data.default_branch = repo.heads[0].name else: return flask.render_template("empty.html", remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"), 200remote=f"{config.www_protocol}://{config.BASE_DOMAIN}/git/{username}/{repository}"), 200if not branch: branch = repo_data.default_branch return flask.redirect(f"./{branch}", code=302)
celery_tasks.py
@@ -19,13 +19,14 @@ def send_notification(notification_id, users, level):
if db.session.get(User, user).email: with (SMTP(config.MAIL_SERVER) as mail): if notification.data.get("type") == "welcome": message = ("Subject:Welcome"+ email_send.render_email_template("welcome.html", username=user))mail.sendmail(config.NOTIFICATION_EMAIL,db.session.get(User, user).email,message,)message = email_send.make_multipart_message( f"Welcome, {user}", config.NOTIFICATION_EMAIL, db.session.get(User, user).email, "welcome", username=user) mail.sendmail(config.NOTIFICATION_EMAIL, db.session.get(User, user).email, message)db.session.commit() return 0 # notification sent successfully
config.py
@@ -121,3 +121,27 @@ def match_icon(name):
return "mdi:book-information-variant" if name.startswith(".gitignore"): return "simple-icons:git" footer = """ <x-hbox> <a href="/help">Help</a> <a href="mailto:{{ config.CONTACT_EMAIL }}">Contact Us</a> </x-hbox> <hr> <p> Alpha testing. Not for production use. </p> <p> Application © 2023 Roundabout developers. Content belongs to the repository contributors, unless otherwise stated. </p> <p> Made in Romania 🇷🇴 </p> <p> <a href="/about">Powered by Roundabout (alpha testing)</a> </p> """ www_protocol = f"http{'s' if suggest_https else ''}"
email_send.py
@@ -1,11 +1,26 @@
import config from jinja2 import Environment, FileSystemLoader, select_autoescape import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMETextdef render_email_template(template, **kwargs):env = Environment(def make_multipart_message(subject, sender, receiver, template, **kwargs): env_html = Environment(loader=FileSystemLoader("email_templates"), autoescape=select_autoescape(["html", "xml"]) ) template = env.get_template(template)return template.render(**kwargs, config=config)env_plain = Environment(loader=FileSystemLoader("email_templates")) message = MIMEMultipart("alternative") message["Subject"] = subject message["From"] = sender message["To"] = receiver text = MIMEText(env_html.get_template(template+".txt").render(**kwargs, config=config), "plain") html = MIMEText(env_html.get_template(template+".html").render(**kwargs, config=config), "html") message.attach(text) message.attach(text) return message.as_string()
email_templates/mail.html
@@ -0,0 +1,22 @@
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <header> </header> <main> {% block content %} {% endblock %} </main> <footer> <small> For any inquiries, write to <a href="mailto:{{ config.CONTACT_EMAIL }}"></a><br>. To adjust your email notification preferences, log in to your account in a browser and visit <a href="{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/settings">your user settings</a>. </small> </footer> </body> </html>
email_templates/mail.txt
@@ -0,0 +1,8 @@
{% block content %} {% endblock %} --- For any inquiries, write to <{{ config.CONTACT_EMAIL }}>. To adjust your email notification preferences, log in to your account in a browser and visit your user settings at <{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/settings>.
email_templates/welcome.html
@@ -1,7 +1,14 @@
<h1>Hello, {{ username }}</h1><p>Welcome to the roundabout. Make yourself at home.</p><small>For any inquiries, write to <a href="mailto:{{ config.CONTACT_EMAIL }}"></a><br></small>{% extends "mail.html" %} {% block content %} <h1>Hello, {{ username }}!</h1> <p> Welcome to the roundabout. Make yourself at home. </p> <p> You've just registered for an account at this server. If it wasn't you, write to us and we'll remove this email from our database. </p> <p> No email verification is required; email notifications are provided only for your convenience. </p> {% endblock %}
email_templates/welcome.txt
@@ -0,0 +1,11 @@
{% extends "mail.txt" %} {% block content %} # Hello, {{ username }}! Welcome to the roundabout. Make yourself at home. You've just registered for an account at this server. If it wasn't you, write to us and we'll remove this email from our database. No email verification is required; email notifications are provided only for your convenience. {% endblock %}
templates/default.html
@@ -109,21 +109,7 @@
{% endblock %} </main> <footer> <x-hbox><a href="/help">Help</a><a href="mailto:{{ config.CONTACT_EMAIL }}">Contact Us</a></x-hbox><hr><p>Alpha testing. Not for production use.</p><p>Application © 2023 Roundabout developers. Content belongs to the repository contributors,unless otherwise stated.</p><p><a href="/about">Powered by Roundabout (alpha testing)</a></p>{{ Markup(config.footer) }}</footer> </x-vbox> </x-hbox>