roundabout,
created on Wednesday, 6 December 2023, 19:33:17 (1701891197),
received on Wednesday, 31 July 2024, 06:54:39 (1722408879)
Author identity: vlad <vlad.muntoiu@gmail.com>
ce02f6a230490df5259acb52ce8c34a2817c7188
app.py
@@ -150,7 +150,7 @@ with app.app_context():
repoName = db.Column(db.String(97), db.ForeignKey("repo.route"), nullable=False) ownerName = db.Column(db.String(32), db.ForeignKey("user.username"), nullable=False) ownerIdentity = db.Column(db.String(321)) receiveDate = db.Column(db.DateTime, default=datetime.utcnow)receiveDate = db.Column(db.DateTime, default=datetime.now)authorDate = db.Column(db.DateTime) message = db.Column(db.UnicodeText) repo = db.relationship("Repo", back_populates="commits")
@@ -189,6 +189,7 @@ def getVisibility(username, repository):
import gitHTTP import jinjaUtilsdef humanSize(value, decimals=2, scale=1024,
@@ -610,7 +611,19 @@ def repositoryLog(username, repository):
repository) is not None): flask.abort(403) return flask.render_template("repo-log.html", username=username, repository=repository)serverRepoLocation = os.path.join(config.REPOS_PATH, os.path.join(username, repository)) app.logger.info(f"Loading {serverRepoLocation}") if not os.path.exists(serverRepoLocation): app.logger.error(f"Cannot load {serverRepoLocation}") return flask.render_template("not-found.html"), 404 repo = git.Repo(serverRepoLocation) repoData = Repo.query.filter_by(route=f"/{username}/{repository}").first() commits = Commit.query.filter_by(repo=repoData) return flask.render_template("repo-log.html", username=username, repository=repository, repoData=repoData, repo=repo, commits=commits)@app.route("/<username>/<repository>/settings/")
jinjaUtils.py
@@ -0,0 +1,17 @@
from app import app from datetime import datetime @app.template_filter("split") def split(value: str, separator=" ", maxsplit: int = -1): return value.split(separator, maxsplit) @app.template_filter("strftime") def strftime(value: datetime, syntax: str): return value.strftime(syntax) @app.template_filter("unixtime") def strftime(value: datetime): return round(value.timestamp())
templates/repo-log.html
@@ -0,0 +1,30 @@
{% extends "repo.html" %} {% block content %} <x-vbox> <x-frame style="--width: 896px;" class="flexible-space"> <h2>Branches</h2> <x-vbox> {% for commit in commits %} <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> </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> <code>{{ commit.sha }}</code> </section> <section> <x-buttonbox style="align-items: center; height: 100%;"> <a class="button" href="/{{ username }}/{{ repository }}/tree/~{{ commit.sha }}">View tree</a> </x-buttonbox> </section> </article> {% endfor %} </x-vbox> </x-frame> </x-vbox> {% endblock %}