roundabout,
created on Sunday, 31 March 2024, 08:08:25 (1711872505),
received on Wednesday, 31 July 2024, 06:54:43 (1722408883)
Author identity: vlad <vlad.muntoiu@gmail.com>
ac0c358770c46c67aeacd709a18cd807a5338b6e
app.py
@@ -108,6 +108,14 @@ def main():
return flask.render_template("no-home.html") @app.route("/userstyle") def userstyle(): if flask.session.get("username"): return flask.send_from_directory(os.path.join(config.REPOS_PATH, flask.session.get("username"), ".config"), "theme.css") else: return flask.Response("", mimetype="text/css") @app.route("/about/") def about(): return flask.render_template("about.html", platform=platform, version=__version__)
@@ -383,20 +391,22 @@ def user_avatar(username):
@app.route("/<username>/<repository>/raw/<branch>/<path:subpath>") def repository_raw(username, repository, branch, subpath): server_repo_location = os.path.join(config.REPOS_PATH, username, repository) if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}") flask.abort(404)if not (get_visibility(username, repository) or get_permission_level( flask.session.get("username"), username, repository) is not None): flask.abort(403) serverRepoLocation = os.path.join(config.REPOS_PATH, username, repository)app.logger.info(f"Loading {serverRepoLocation}")app.logger.info(f"Loading {server_repo_location}")if not os.path.exists(serverRepoLocation):app.logger.error(f"Cannot load {serverRepoLocation}")if not os.path.exists(server_repo_location): app.logger.error(f"Cannot load {server_repo_location}")return flask.render_template("not-found.html"), 404 repo = git.Repo(serverRepoLocation)repo = git.Repo(server_repo_location)repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first() if not repo_data.default_branch: if repo.heads:
models.py
@@ -1,3 +1,5 @@
import subprocessfrom app import app, db, bcrypt import git from datetime import datetime
@@ -122,6 +124,11 @@ with (app.app_context()):
avatar.thumbnail(config.AVATAR_SIZE) avatar.save(os.path.join(config.USERDATA_PATH, username, "avatar.png")) # Create the configuration repo config_repo = Repo(self, ".config", 0) db.session.add(config_repo) db.session.commit() class Repo(db.Model): route = db.Column(db.String(98), unique=True, nullable=False, primary_key=True)
@@ -155,6 +162,11 @@ with (app.app_context()):
repo_access = RepoAccess(owner, self, 2) db.session.add(repo_access) # Create the directory if not os.path.exists(os.path.join(config.REPOS_PATH, self.owner_name, self.name)): subprocess.run(["git", "init", self.name], cwd=os.path.join(config.REPOS_PATH, self.owner_name)) class Commit(db.Model): identifier = db.Column(db.String(227), unique=True, nullable=False, primary_key=True)
templates/default.html
@@ -3,6 +3,7 @@
<head> {% block head %} <link rel="stylesheet" href="/static/style.css"> <link rel="stylesheet" href="/userstyle"><title>{% block title %}{% trans %}Roundabout{% endtrans %}{% endblock %}</title> <link rel="apple-touch-icon" sizes="512x512" href="/static/apple-touch-icon.png"> <link rel="manifest" href="/static/site.webmanifest">