roundabout,
created on Monday, 18 December 2023, 15:15:50 (1702912550),
received on Wednesday, 31 July 2024, 06:54:39 (1722408879)
Author identity: vlad <vlad.muntoiu@gmail.com>
8c058f0397a313cde7155586a915b2a621a2d46e
app.py
@@ -533,7 +533,7 @@ def repositoryTree(username, repository, branch, subpath):
repoData.defaultBranch = repo.heads[0].name
else:
return flask.render_template("empty.html",
remote=f"http://{config.BASE_DOMAIN}/git/{username}/{repository}"), 200
remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"), 200
if not branch:
branch = repoData.defaultBranch
return flask.redirect(f"./{branch}", code=302)
@@ -613,7 +613,8 @@ def repositoryTree(username, repository, branch, subpath):
files=infos,
subpath=os.path.join("/", subpath),
branches=allRefs,
current=branch
current=branch,
remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"
)
else:
path = os.path.join(serverRepoLocation, subpath)
@@ -653,7 +654,8 @@ def repositoryTree(username, repository, branch, subpath):
icon=icon,
subpath=os.path.join("/", subpath),
basename=os.path.basename(path),
contents=contents
contents=contents,
remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"
)
@@ -677,7 +679,17 @@ def repositoryForum(username, repository):
relationships = RepoAccess.query.filter_by(repo=repoData)
userRelationship = RepoAccess.query.filter_by(repo=repoData, user=user).first()
return flask.render_template("repo-forum.html", username=username, repository=repository, repoData=repoData, relationships=relationships, repo=repo, userRelationship=userRelationship, Post=Post)
return flask.render_template(
"repo-forum.html",
username=username,
repository=repository,
repoData=repoData,
relationships=relationships,
repo=repo,
userRelationship=userRelationship,
Post=Post,
remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"
)
@app.route("/<username>/<repository>/forum/new", methods=["POST"])
@@ -728,7 +740,19 @@ def repositoryForumThread(username, repository, postID):
relationships = RepoAccess.query.filter_by(repo=repoData)
userRelationship = RepoAccess.query.filter_by(repo=repoData, user=user).first()
return flask.render_template("repo-forum-thread.html", username=username, repository=repository, repoData=repoData, relationships=relationships, repo=repo, userRelationship=userRelationship, Post=Post, postID=postID, maxPostNesting=4)
return flask.render_template(
"repo-forum-thread.html",
username=username,
repository=repository,
repoData=repoData,
relationships=relationships,
repo=repo,
userRelationship=userRelationship,
Post=Post,
postID=postID,
maxPostNesting=4,
remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"
)
@app.route("/<username>/<repository>/forum/<int:postID>/reply", methods=["POST"])
@@ -834,7 +858,16 @@ def repositoryUsers(username, repository):
userRelationship = RepoAccess.query.filter_by(repo=repoData, user=user).first()
if flask.request.method == "GET":
return flask.render_template("repo-users.html", username=username, repository=repository, repoData=repoData, relationships=relationships, repo=repo, userRelationship=userRelationship)
return flask.render_template(
"repo-users.html",
username=username,
repository=repository,
repoData=repoData,
relationships=relationships,
repo=repo,
userRelationship=userRelationship,
remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"
)
else:
if getPermissionLevel(flask.session.get("username"), username, repository) != 2:
flask.abort(401)
@@ -875,7 +908,14 @@ def repositoryBranches(username, repository):
repo = git.Repo(serverRepoLocation)
repoData = Repo.query.filter_by(route=f"/{username}/{repository}").first()
return flask.render_template("repo-branches.html", username=username, repository=repository, repoData=repoData, repo=repo)
return flask.render_template(
"repo-branches.html",
username=username,
repository=repository,
repoData=repoData,
repo=repo,
remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"
)
@app.route("/<username>/<repository>/log/")
@@ -896,7 +936,15 @@ def repositoryLog(username, repository):
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)
return flask.render_template(
"repo-log.html",
username=username,
repository=repository,
repoData=repoData,
repo=repo,
commits=commits,
remote=f"http{'s' if config.suggestHTTPS else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}"
)
@app.route("/<username>/<repository>/settings/")
config.py
@@ -17,6 +17,8 @@ AVATAR_SIZE: tuple = (192, 192)
HASHING_ROUNDS: int = 11
RESERVED_NAMES: tuple = ("git", "settings", "logout", "accounts", "info", "alerts", "notifications", "about", "newrepo")
suggestHTTPS: bool = True
folderIcon: str = "mdi:folder"
unknownIcon: str = "mdi:file"
fileIcons: dict = {
static/efficient-ui/buttons.css
@@ -34,7 +34,7 @@ iconify-icon {
border: var(--border-flat-button);
border-radius: var(--radius-flat-button);
background-color: transparent;
color: var(--color-primary) !important;
color: var(--color-flat-button-text) !important;
box-shadow: var(--shadow-flat-button);
}
@@ -42,12 +42,16 @@ iconify-icon {
border: var(--border-button-hover);
box-shadow: var(--shadow-button-hover);
background-color: var(--color-button-hover);
color: var(--color-button-hover-text);
color: var(--color-flat-button-hover-text);
}
:is(button, .button, input[type=button], input[type=submit], input[type=reset], input[type="file"]::file-selector-button).button-flat:hover {
:is(button, .button, input[type=button], input[type=submit], input[type=reset], input[type="file"]::file-selector-button):is(.button-flat, .button-neutral):hover {
border: var(--border-flat-button-hover);
box-shadow: var(--shadow-flat-button-hover);
background-color: var(--color-flat-button-hover);
color: var(--color-flat-button-hover-text);
}
:is(button, .button, input[type=button], input[type=submit], input[type=reset], input[type="file"]::file-selector-button).button-neutral {
color: inherit !important;
}
static/efficient-ui/cards.css
@@ -11,7 +11,7 @@
height: 100%;
}
.card > :is(section, header, footer) {
.card > :is(section, header, footer):not(.card-top) {
padding: var(--padding-card);
}
@@ -19,7 +19,7 @@
padding: var(--padding-card-figcaption);
}
.card:not(:has(figure)) {
.card:not(:has(:is(figure, .card-top))) {
padding-top: var(--padding-card-top); /* Figures should be flush with the top */
}
@@ -38,12 +38,12 @@ figcaption {
flex-flow: row nowrap;
}
.card-horizontal > figure {
.card-horizontal > :is(figure, .card-top) {
height: auto;
max-width: var(--figure-max-size-horizontal-card);
}
.card-horizontal > figure ~ :is(section, header, footer) {
.card-horizontal > :is(figure, .card-top) ~ :is(section, header, footer) {
/* Beside figure */
padding-top: var(--padding-card-top);
}
static/efficient-ui/navbar.css
@@ -16,6 +16,8 @@
display: flex;
list-style: none;
gap: var(--gap-navbar);
padding: 0;
margin: 0 !important;
}
.navbar {
static/style.css
@@ -154,4 +154,13 @@ body > footer hr {
dd {
margin-left: 2em;
}
.navbar-mini {
--height-navbar: 48px;
}
.dialog-tools {
position: relative;
left: 8px;
}
templates/repo.html
@@ -8,6 +8,28 @@
{% endblock %}
{% block nav %}
<dialog id="clone-info">
<article class="card">
<header class="card-top">
<div class="navbar navbar-mini">
<ul>
<li><b>Clone</b></li>
</ul>
<x-buttonbox class="dialog-tools">
<button class="button-flat button-neutral big-button" type="submit" form="clone-form"><iconify-icon icon="mdi:close"></iconify-icon></button>
</x-buttonbox>
</div>
</header>
<section class="card-main">
<form id="clone-form">
<x-vbox class="nopad">
<label for="clone-url">Clone over HTTP</label>
<input id="clone-url" readonly value="{{ remote }}" size="80">
</x-vbox>
</form>
</section>
</article>
</dialog>
<nav id="repo-nav" class="navbar">
<ul id="repo-tabs">
<li><a href="/{{ username }}/{{ repository }}/tree">Tree</a></li>
@@ -26,21 +48,21 @@
<x-buttonbox>
{% if loggedInUser %}
<button>
<iconify-icon icon="mdi:star-plus"></iconify-icon>
star
<iconify-icon icon="mdi:star"></iconify-icon>
Favourite
</button>
<button>
<iconify-icon icon="mdi:chat-alert"></iconify-icon>
follow
</button>
<button>
<iconify-icon icon="mdi:briefcase-download"></iconify-icon>
clone
</button>
<button>
<iconify-icon icon="mdi:directions-fork"></iconify-icon>
fork
<!-- <button>-->
<!-- <iconify-icon icon="mdi:chat-alert"></iconify-icon>-->
<!-- follow-->
<!-- </button>-->
<button onclick="document.getElementById('clone-info').showModal();">
<iconify-icon icon="mdi:swap-vertical-bold"></iconify-icon>
Clone
</button>
<!-- <button>-->
<!-- <iconify-icon icon="mdi:directions-fork"></iconify-icon>-->
<!-- fork-->
<!-- </button>-->
</x-buttonbox>
{% endif %}
</nav>