roundabout,
created on Tuesday, 4 June 2024, 15:33:23 (1717515203),
received on Monday, 24 June 2024, 15:24:18 (1719242658)
Author identity: vlad <vlad.muntoiu@gmail.com>
55224acadbcfd48e93a86dcd19293ff51244340a
app.py
@@ -545,7 +545,7 @@ def repository_index(username, repository):
def user_avatar(username): server_userdata_location = os.path.join(config.USERDATA_PATH, username) if not os.path.exists(server_userdata_location): return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404return flask.send_from_directory(server_userdata_location, "avatar.png")
@@ -584,7 +584,7 @@ def repository_raw(username, repository, branch, subpath):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
@@ -610,7 +610,7 @@ def repository_raw(username, repository, branch, subpath):
try: repo.git.checkout("-f", ref) except git.exc.GitCommandError: return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404return flask.send_from_directory(config.REPOS_PATH, os.path.join(username, repository, subpath))
@@ -655,7 +655,7 @@ def repository_tree(username, repository, branch, subpath):
try: repo.git.checkout("-f", ref) except git.exc.GitCommandError: return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404branches = repo.heads
@@ -729,7 +729,7 @@ def repository_tree(username, repository, branch, subpath):
path = os.path.join(server_repo_location, subpath) if not os.path.exists(path): return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404mimetype = guess_mime(path) mode = mimetype.split("/", 1)[0]
@@ -786,7 +786,7 @@ def repository_commit(username, repository, sha):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
@@ -893,7 +893,7 @@ def repository_forum(username, repository):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
@@ -931,7 +931,7 @@ def repository_forum_topic(username, repository, id):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first() user = User.query.filter_by(username=flask.session.get("username")).first()
@@ -969,7 +969,7 @@ def repository_forum_new(username, repository):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
@@ -1004,7 +1004,7 @@ def repository_forum_thread(username, repository, post_id):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
@@ -1085,7 +1085,7 @@ def repository_forum_reply(username, repository, post_id):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
@@ -1128,7 +1128,7 @@ def repository_forum_vote(username, repository, post_id, score):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
@@ -1182,7 +1182,7 @@ def repository_favourite(username, repository):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
@@ -1220,7 +1220,7 @@ def repository_users(username, repository):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
@@ -1281,7 +1281,7 @@ def repository_branches(username, repository):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
@@ -1313,7 +1313,7 @@ def repository_log(username, repository, branch):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
@@ -1339,7 +1339,7 @@ def repository_log(username, repository, branch):
try: repo.git.checkout("-f", ref) except git.exc.GitCommandError: return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404branches = repo.heads
@@ -1406,7 +1406,7 @@ def repository_prs(username, repository):
if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404if flask.request.method == "GET": repo = git.Repo(server_repo_location)
@@ -1645,32 +1645,47 @@ def repository_settings_post(username, repository):
@app.errorhandler(404) def e404(error): return flask.render_template("not-found.html"), 404return flask.render_template("errors/not-found.html"), 404@app.errorhandler(401) def e401(error): return flask.render_template("unauthorised.html"), 401return flask.render_template("errors/unauthorised.html"), 401@app.errorhandler(403) def e403(error): return flask.render_template("forbidden.html"), 403return flask.render_template("errors/forbidden.html"), 403@app.errorhandler(418) def e418(error): return flask.render_template("teapot.html"), 418return flask.render_template("errors/teapot.html"), 418@app.errorhandler(405) def e405(error): return flask.render_template("method-not-allowed.html"), 405return flask.render_template("errors/method-not-allowed.html"), 405@app.errorhandler(500) def e500(error): return flask.render_template("server-error.html"), 500return flask.render_template("errors/server-error.html"), 500 @app.errorhandler(400) def e400(error): return flask.render_template("errors/bad-request.html"), 400 @app.errorhandler(410) def e410(error): return flask.render_template("errors/gone.html"), 410 @app.errorhandler(415) def e415(error): return flask.render_template("errors/media-type.html"), 415if __name__ == "__main__":
templates/errors/bad-request.html
@@ -0,0 +1,11 @@
{% extends "error.html" %} {% block error %} {% trans %}400{% endtrans %} {% endblock %} {% block heading %} {% trans %}400 bad request{% endtrans %} {% endblock %} {% block text %} {% trans %}Your request does not contain the information required to process it, or it doesn't make sense.{% endtrans %} {% endblock %} {% block icon %}mdi:close-circle{% endblock %}
templates/errors/forbidden.html
@@ -0,0 +1,11 @@
{% extends "error.html" %} {% block error %} {% trans %}403{% endtrans %} {% endblock %} {% block heading %} {% trans %}403 forbidden{% endtrans %} {% endblock %} {% block text %} {% trans %}You are not authorised to access this resource.{% endtrans %} {% endblock %} {% block icon %}mdi:key-alert{% endblock %}
templates/errors/gone.html
@@ -0,0 +1,11 @@
{% extends "error.html" %} {% block error %} {% trans %}410{% endtrans %} {% endblock %} {% block heading %} {% trans %}410 gone{% endtrans %} {% endblock %} {% block text %} {% trans %}This resource is no longer available. This condition is likely permanent.{% endtrans %} {% endblock %} {% block icon %}mdi:file-alert{% endblock %}
templates/errors/media-type.html
@@ -0,0 +1,11 @@
{% extends "error.html" %} {% block error %} {% trans %}415{% endtrans %} {% endblock %} {% block heading %} {% trans %}415 unsupported media type{% endtrans %} {% endblock %} {% block text %} {% trans %}The server does not support the media type that was sent in the request.{% endtrans %} {% endblock %} {% block icon %}mdi:do-not-disturb-on{% endblock %}
templates/errors/method-not-allowed.html
@@ -0,0 +1,11 @@
{% extends "error.html" %} {% block error %} {% trans %}405{% endtrans %} {% endblock %} {% block heading %} {% trans %}405 method not allowed{% endtrans %} {% endblock %} {% block text %} {% trans %}This resource is not intended to be accessed with the current method.{% endtrans %} {% endblock %} {% block icon %}mdi:swap-horizontal-bold{% endblock %}
templates/errors/not-found.html
@@ -0,0 +1,11 @@
{% extends "error.html" %} {% block error %} {% trans %}404{% endtrans %} {% endblock %} {% block heading %} {% trans %}404 not found{% endtrans %} {% endblock %} {% block text %} {% trans %}The resource you have requested is not available on this server.{% endtrans %} {% endblock %} {% block icon %}mdi:file-alert{% endblock %}
templates/errors/server-error.html
@@ -0,0 +1,11 @@
{% extends "error.html" %} {% block error %} {% trans %}500{% endtrans %} {% endblock %} {% block heading %} {% trans %}500 internal server error{% endtrans %} {% endblock %} {% block text %} {% trans %}The program running on the server has crashed. This is a problem with the program; you did nothing wrong. Please send it to the server administrator.{% endtrans %} {% endblock %} {% block icon %}mdi:cloud-alert{% endblock %}
templates/errors/teapot.html
@@ -0,0 +1,11 @@
{% extends "error.html" %} {% block error %} {% trans %}418{% endtrans %} {% endblock %} {% block heading %} {% trans %}418 I'm a teapot{% endtrans %} {% endblock %} {% block text %} {% trans %}This server does not implement brewing coffee.{% endtrans %} {% endblock %} {% block icon %}mdi:kettle-alert{% endblock %}
templates/errors/unauthorised.html
@@ -0,0 +1,11 @@
{% extends "error.html" %} {% block error %} {% trans %}401{% endtrans %} {% endblock %} {% block heading %} {% trans %}401 unauthorised{% endtrans %} {% endblock %} {% block text %} {% trans %}This resource requires authentication, but you are not authenticated.{% endtrans %} {% endblock %} {% block icon %}mdi:account-alert{% endblock %}
templates/forbidden.html
@@ -1,11 +0,0 @@
{% extends "error.html" %}{% block error %}{% trans %}403{% endtrans %}{% endblock %}{% block heading %}{% trans %}403 forbidden{% endtrans %}{% endblock %}{% block text %}{% trans %}You are not authorised to access this resource.{% endtrans %}{% endblock %}{% block icon %}mdi:key-alert{% endblock %}
templates/method-not-allowed.html
@@ -1,11 +0,0 @@
{% extends "error.html" %}{% block error %}{% trans %}405{% endtrans %}{% endblock %}{% block heading %}{% trans %}405 method not allowed{% endtrans %}{% endblock %}{% block text %}{% trans %}This resource is not intended to be accessed with the current method.{% endtrans %}{% endblock %}{% block icon %}mdi:swap-horizontal-bold{% endblock %}
templates/not-found.html
@@ -1,11 +0,0 @@
{% extends "error.html" %}{% block error %}{% trans %}404{% endtrans %}{% endblock %}{% block heading %}{% trans %}404 not found{% endtrans %}{% endblock %}{% block text %}{% trans %}The resource you have requested is not available on this server.{% endtrans %}{% endblock %}{% block icon %}mdi:cloud-alert{% endblock %}
templates/server-error.html
@@ -1,11 +0,0 @@
{% extends "error.html" %}{% block error %}{% trans %}500{% endtrans %}{% endblock %}{% block heading %}{% trans %}500 internal server error{% endtrans %}{% endblock %}{% block text %}{% trans %}The program running on the server has crashed. This is a problem with the program; you did nothing wrong. Please send it to the server administrator.{% endtrans %}{% endblock %}{% block icon %}mdi:cloud-alert{% endblock %}
templates/task-monitor.html
@@ -61,6 +61,10 @@
{% endif %} {% else %} <h2>{% trans %}Merge simulation went well; continue?{% endtrans %}</h2> <p> {% trans num_commits=result.get()[8]|length %}{{ num_commits }} commits will be added.{% endtrans %} </p> <pre>{{ result.get()[8] | decode }}</pre><a href="{{ result.get()[5] }}/prs/{{ request.args.get('pr-id') }}/merge" class="button">{% trans %}Merge{% endtrans %}</a> {% endif %} {% endif %}
templates/teapot.html
@@ -1,11 +0,0 @@
{% extends "error.html" %}{% block error %}{% trans %}418{% endtrans %}{% endblock %}{% block heading %}{% trans %}418 I'm a teapot{% endtrans %}{% endblock %}{% block text %}{% trans %}This server does not implement brewing coffee.{% endtrans %}{% endblock %}{% block icon %}mdi:kettle-alert{% endblock %}
templates/unauthorised.html
@@ -1,11 +0,0 @@
{% extends "error.html" %}{% block error %}{% trans %}401{% endtrans %}{% endblock %}{% block heading %}{% trans %}401 unauthorised{% endtrans %}{% endblock %}{% block text %}{% trans %}This resource requires authentication, but you are not authenticated.{% endtrans %}{% endblock %}{% block icon %}mdi:account-alert{% endblock %}