roundabout,
created on Wednesday, 24 January 2024, 07:53:53 (1706082833),
received on Wednesday, 31 July 2024, 06:54:41 (1722408881)
Author identity: vlad <vlad.muntoiu@gmail.com>
8e43cd71897d6631a65e0682e0be2744d12bfa51
app.py
@@ -311,13 +311,13 @@ def logout():
@app.route("/<username>/", methods=["GET", "POST"]) def user_profile(username): old_relationship = UserFollow.query.filter_by(followerUsername=flask.session.get("username"),followedUsername=username).first()old_relationship = UserFollow.query.filter_by(follower_username=flask.session.get("username"), followed_username=username).first()if flask.request.method == "GET": user = User.query.filter_by(username=username).first() match flask.request.args.get("action"): case "repositories": repos = Repo.query.filter_by(ownerName=username, visibility=2)repos = Repo.query.filter_by(owner_name=username, visibility=2)return flask.render_template("user-profile-repositories.html", user=user, repos=repos, relationship=old_relationship) case "followers":
@@ -385,15 +385,15 @@ def repository_raw(username, repository, branch, subpath):
return flask.render_template("not-found.html"), 404 repo = git.Repo(serverRepoLocation) repoData = Repo.query.filter_by(route=f"/{username}/{repository}").first()if not repoData.defaultBranch:repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first() if not repo_data.default_branch:if repo.heads: repoData.defaultBranch = repo.heads[0].namerepo_data.default_branch = repo.heads[0].nameelse: return flask.render_template("empty.html", remote=f"http://{config.BASE_DOMAIN}/git/{username}/{repository}"), 200 if not branch: branch = repoData.defaultBranchbranch = repo_data.default_branchreturn flask.redirect(f"./{branch}", code=302) if branch.startswith("tag:"):
@@ -431,14 +431,14 @@ def repository_tree(username, repository, branch, subpath):
repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first() if not repo_data.defaultBranch:if not repo_data.default_branch:if repo.heads: repo_data.defaultBranch = repo.heads[0].namerepo_data.default_branch = repo.heads[0].nameelse: return flask.render_template("empty.html", remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"), 200remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"), 200if not branch: branch = repo_data.defaultBranchbranch = repo_data.default_branchreturn flask.redirect(f"./{branch}", code=302) if branch.startswith("tag:"):
@@ -494,15 +494,15 @@ def repository_tree(username, repository, branch, subpath):
"shaSize": 7, } special_icon = config.matchIcon(os.path.basename(file))special_icon = config.match_icon(os.path.basename(file))if special_icon: info["icon"] = special_icon elif os.path.isdir(path): info["icon"] = config.folderIconelif mimetypes.guess_type(path)[0] in config.fileIcons:info["icon"] = config.fileIcons[mimetypes.guess_type(path)[0]]info["icon"] = config.folder_icon elif mimetypes.guess_type(path)[0] in config.file_icons: info["icon"] = config.file_icons[mimetypes.guess_type(path)[0]]else: info["icon"] = config.unknownIconinfo["icon"] = config.unknown_iconif os.path.isdir(path): infos.insert(0, info)
@@ -517,7 +517,7 @@ def repository_tree(username, repository, branch, subpath):
subpath=os.path.join("/", subpath), branches=all_refs, current=branch, remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",is_favourite=get_favourite(flask.session.get("username"), username, repository) ) else:
@@ -530,15 +530,15 @@ def repository_tree(username, repository, branch, subpath):
mode = mimetype.split("/", 1)[0] size = human_size(os.path.getsize(path)) special_icon = config.matchIcon(os.path.basename(path))special_icon = config.match_icon(os.path.basename(path))if special_icon: icon = special_icon elif os.path.isdir(path): icon = config.folderIconelif mimetypes.guess_type(path)[0] in config.fileIcons:icon = config.fileIcons[mimetypes.guess_type(path)[0]]icon = config.folder_icon elif mimetypes.guess_type(path)[0] in config.file_icons: icon = config.file_icons[mimetypes.guess_type(path)[0]]else: icon = config.unknownIconicon = config.unknown_iconcontents = None if mode == "text":
@@ -559,7 +559,7 @@ def repository_tree(username, repository, branch, subpath):
subpath=os.path.join("/", subpath), basename=os.path.basename(path), contents=contents, remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",is_favourite=get_favourite(flask.session.get("username"), username, repository) )
@@ -593,9 +593,9 @@ def repository_forum(username, repository):
repo=repo, user_relationship=user_relationship, Post=Post, remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",is_favourite=get_favourite(flask.session.get("username"), username, repository), default_branch=repo_data.defaultBranchdefault_branch=repo_data.default_branch)
@@ -628,9 +628,9 @@ def repository_forum_topic(username, repository, id):
relationships=relationships, user_relationship=user_relationship, post=post, remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",is_favourite=get_favourite(flask.session.get("username"), username, repository), default_branch=repo_data.defaultBranchdefault_branch=repo_data.default_branch)
@@ -690,9 +690,9 @@ def repository_forum_create_topic(username, repository):
repo_data=repo_data, relationships=relationships, user_relationship=user_relationship, remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",is_favourite=get_favourite(flask.session.get("username"), username, repository), default_branch=repo_data.defaultBranchdefault_branch=repo_data.default_branch)
@@ -726,7 +726,7 @@ def repository_forum_thread(username, repository, post_id):
user_relationship=user_relationship, post_id=post_id, max_post_nesting=4, remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",is_favourite=get_favourite(flask.session.get("username"), username, repository) )
@@ -878,7 +878,7 @@ def repository_users(username, repository):
relationships=relationships, repo=repo, user_relationship=user_relationship, remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",is_favourite=get_favourite(flask.session.get("username"), username, repository) ) else:
@@ -927,7 +927,7 @@ def repository_branches(username, repository):
repository=repository, repo_data=repo_data, repo=repo, remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",is_favourite=get_favourite(flask.session.get("username"), username, repository) )
@@ -954,7 +954,7 @@ def repository_log(username, repository, branch):
repo_data.default_branch = repo.heads[0].name else: return flask.render_template("empty.html", remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"), 200remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"), 200if not branch: branch = repo_data.default_branch return flask.redirect(f"./{branch}", code=302)
@@ -995,7 +995,7 @@ def repository_log(username, repository, branch):
repo_data=repo_data, repo=repo, commits=commits, remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",is_favourite=get_favourite(flask.session.get("username"), username, repository) )
celery_tasks.py
@@ -2,6 +2,8 @@ import time
from celery import shared_task from app import db from models import * from smtplib import SMTP import config@shared_task(ignore_result=False)
config.py
@@ -5,6 +5,7 @@ load_dotenv("secrets.env")
DB_PASSWORD: str = os.environ.get("DB_PASSWORD") DB_URI: str = f"postgresql://root:{DB_PASSWORD}@localhost/roundabout" REDIS_URI: str = "redis://localhost" MAIL_SERVER: str = "localhost"REPOS_PATH: str = "./repos" USERDATA_PATH: str = "./userdata"
@@ -18,11 +19,11 @@ AVATAR_SIZE: tuple = (192, 192)
HASHING_ROUNDS: int = 11 RESERVED_NAMES: tuple = ("git", "settings", "logout", "accounts", "info", "notifications", "about", "newrepo", "favourites",) suggestHTTPS: bool = Truesuggest_https: bool = TruefolderIcon: str = "mdi:folder"unknownIcon: str = "mdi:file"fileIcons: dict = {folder_icon: str = "mdi:folder" unknown_icon: str = "mdi:file" file_icons: dict = {"text/plain": "ic:baseline-text-snippet", "text/css": "simple-icons:css3", "text/csv": "mdi:table",
@@ -111,7 +112,7 @@ fileIcons: dict = {
} def matchIcon(name):def match_icon(name):if name.startswith(("LICENCE", "LICENSE", "COPYING")): return "ic:gavel" if name.startswith("README"):
templates/repository/repo-branches.html
@@ -10,11 +10,11 @@
{% for branch in repo.branches %} <article class="card card-horizontal"> <figure style="background-color: var(--color-branch); color: var(--color-branch-text);" class="branch-icon"> <iconify-icon icon="{% if repoData.defaultBranch == branch.name %}mdi:star{% else %}mdi:source-branch{% endif %}"></iconify-icon><iconify-icon icon="{% if repo_data.defaultBranch == branch.name %}mdi:star{% else %}mdi:source-branch{% endif %}"></iconify-icon></figure> <section class="card-main flexible-space"> <h3>{{ branch.name }}</h3> {% if repoData.defaultBranch == branch.name %}<p>Default</p>{% endif %}{% if repo_data.defaultBranch == branch.name %}<p>Default</p>{% endif %}<code>{{ branch.commit.hexsha }}</code> </section> <section>
templates/repository/repo-forum.html
@@ -18,7 +18,7 @@
</x-buttonbox> </x-vbox> </form> {% for post in Post.query.filter_by(repo=repoData, parent=none).order_by(Post.lastUpdated.desc()) %}{% for post in Post.query.filter_by(repo=repo_data, parent=none).order_by(Post.last_updated.desc()) %}<article class="card card-horizontal"> <figure class="branch-icon"> <iconify-icon icon="mdi:note"></iconify-icon>
templates/repository/repo-log.html
@@ -46,14 +46,14 @@
{% for commit in commits | reverse %} <article class="card card-horizontal"> <figure class="branch-icon"> <a href="/{{ commit.ownerName }}"><img src="/info/{{ commit.ownerName }}/avatar" style="width: 48px; height: 48px;"><a href="/{{ commit.owner_name }}"> <img src="/info/{{ commit.owner_name }}/avatar" style="width: 48px; height: 48px;"></a> </figure> <section class="card-main flexible-space"> <h3>{{ commit.message | split("\n") | first }}</h3> <p>by <a href="/{{ commit.ownerName }}">{{ commit.ownerName }}</a>, <span title="{{ commit.authorDate | unixtime }}received on {{ commit.receiveDate | strftime('%A, %e %B %Y, %H:%M:%S') }} ({{ commit.receiveDate | unixtime }})">{{ commit.authorDate | strftime("%A, %e %B %Y, %H:%M:%S") }}</span></p><p>by <a href="/{{ commit.owner_name }}">{{ commit.owner_name }}</a>, <span title="{{ commit.author_date | unixtime }} received on {{ commit.receive_date | strftime('%A, %e %B %Y, %H:%M:%S') }} ({{ commit.receive_date | unixtime }})">{{ commit.author_date | strftime("%A, %e %B %Y, %H:%M:%S") }}</span></p><code>{{ commit.sha }}</code> </section> <section>
templates/repository/repo-users.html
@@ -13,7 +13,7 @@
<img src="/info/{{ relationship.user.username }}/avatar" style="width: 48px; height: 48px;"> </a> </figure> {% if userRelationship.accessLevel == 2 %}{% if user_relationship.accessLevel == 2 %}<section class="card-main flexible-space"> <h3>{{ relationship.user.username }}</h3> {% if relationship.user.username == username %}
@@ -59,7 +59,7 @@
{% endif %} </article> {% endfor %} {% if userRelationship.accessLevel == 2 %}{% if user_relationship.accessLevel == 2 %}<form method="POST"> <x-hbox style="align-items: flex-end;"> <x-vbox class="nopad flexible-space">