roundabout,
created on Tuesday, 25 June 2024, 11:47:01 (1719316021),
received on Wednesday, 31 July 2024, 06:54:50 (1722408890)
Author identity: vlad <vlad.muntoiu@gmail.com>
59ddcc6f08eb27ba4edcd1e28bdebb95c72423ea
app.py
@@ -25,6 +25,7 @@ from flask_migrate import Migrate
from PIL import Image from flask_httpauth import HTTPBasicAuth import config import markdownfrom common import git_command from flask_babel import Babel, gettext, ngettext, force_locale from jinja2_fragments.flask import render_block
@@ -1118,6 +1119,80 @@ def repository_forum_reply(username, repository, post_id):
code=303) @repositories.route("/<username>/<repository>/forum/<int:post_id>/edit", methods=["POST"]) def repository_forum_edit(username, repository, post_id): server_repo_location = os.path.join(config.REPOS_PATH, username, repository) if not os.path.exists(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) if not os.path.exists(server_repo_location): return flask.render_template("errors/not-found.html"), 404 repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first() user = User.query.filter_by(username=flask.session.get("username")).first() relationships = RepoAccess.query.filter_by(repo=repo_data) user_relationship = RepoAccess.query.filter_by(repo=repo_data, user=user).first() if not user: flask.abort(401) post = db.session.get(Post, f"/{username}/{repository}/{post_id}") if user != post.owner: flask.abort(403) post.subject = flask.request.form["subject"] post.message = flask.request.form["message"] post.html = markdown.markdown2html(post.message).prettify() post.update_date() db.session.commit() return flask.redirect( flask.url_for(".repository_forum_thread", username=username, repository=repository, post_id=post_id), code=303) @repositories.route("/<username>/<repository>/forum/<int:post_id>/edit", methods=["GET"]) def repository_forum_edit_form(username, repository, post_id): server_repo_location = os.path.join(config.REPOS_PATH, username, repository) if not os.path.exists(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) if not os.path.exists(server_repo_location): return flask.render_template("errors/not-found.html"), 404 repo = git.Repo(server_repo_location) repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first() user = User.query.filter_by(username=flask.session.get("username")).first() relationships = RepoAccess.query.filter_by(repo=repo_data) user_relationship = RepoAccess.query.filter_by(repo=repo_data, user=user).first() if not user: flask.abort(401) post = db.session.get(Post, f"/{username}/{repository}/{post_id}") if user != post.owner: flask.abort(403) return flask.render_template( "repo-forum-edit.html", username=username, repository=repository, repo_data=repo_data, relationships=relationships, repo=repo, user_relationship=user_relationship, post=post, 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.default_branch ) @repositories.route("/<username>/<repository>/forum/<int:post_id>/voteup", defaults={"score": 1}) @repositories.route("/<username>/<repository>/forum/<int:post_id>/votedown",
static/efficient-ui/layout.css
@@ -1,16 +1,16 @@
x-hbox {x-hbox, .hbox {display: flex; flex-direction: row; gap: var(--gap-box); } x-vbox {x-vbox, .vbox {display: flex; flex-direction: column; gap: var(--gap-box); } x-hbox.homogenous > *, x-hbox.homogenous > * {.homogenous > * {flex: 1; }
@@ -42,7 +42,7 @@ x-buttonbox, .buttonbox {
gap: 0; } x-frame {x-frame, .frame {max-width: var(--width, 100%); width: min(var(--width), 100%); min-height: var(--height, 100%);
templates/post.html
@@ -12,11 +12,16 @@
{{ post.html | safe }} </p> {% if logged_in_user %} <x-buttonbox class="box-center segmented"><button onclick="vote({{ post.number }}, 1);" class="vote-button big-button" id="{{ post.number }}-voteup"><iconify-icon icon="mdi:arrow-up"></iconify-icon></button><span style="font-size: 1.5em;" class="vote-score" id="{{ post.number }}-vote">{{ post.voteSum }}</span><button onclick="vote({{ post.number }}, -1);" class="vote-button big-button" id="{{ post.number }}-votedown"><iconify-icon icon="mdi:arrow-down"></iconify-icon></button><script>vote({{ post.number }}, 0);</script><x-buttonbox> <x-buttonbox class="box-center segmented"> <button onclick="vote({{ post.number }}, 1);" class="vote-button big-button" id="{{ post.number }}-voteup"><iconify-icon icon="mdi:arrow-up"></iconify-icon></button> <span style="font-size: 1.5em;" class="vote-score" id="{{ post.number }}-vote">{{ post.voteSum }}</span> <button onclick="vote({{ post.number }}, -1);" class="vote-button big-button" id="{{ post.number }}-votedown"><iconify-icon icon="mdi:arrow-down"></iconify-icon></button> <script>vote({{ post.number }}, 0);</script> </x-buttonbox> {% if post.owner_name == logged_in_user %} <a class="button" href="{{ post.number }}/edit">{% trans %}Edit{% endtrans %}</a> {% endif %}</x-buttonbox> {% endif %} </section>
templates/repository/repo-forum-edit.html
@@ -0,0 +1,30 @@
{% extends "repo.html" %} {% set active_page = "forum" %} {% block title %} {% trans subject=post.subject, username=username, repository=repository %}Editing {{ subject }} in {{ username }}/{{ repository }}{% endtrans %} {% endblock %} {% block content %} <x-vbox style="--gap-box: 0;"> <x-buttonbox id="forum-banner" class="box-center"> <a href="../{{ post.number }}" class="button icon-button"> <iconify-icon icon="mdi:arrow-left"></iconify-icon> </a> <h1>{% trans subject=post.subject %}Editing {{ subject }}{% endtrans %}</h1> </x-buttonbox> <x-frame style="--width: 896px;" class="flexible-space"> <form class="vbox" method="post"> <label> Subject <input type="text" name="subject" value="{{ post.subject }}"> </label> <textarea name="message">{{ post.message }}</textarea> <x-buttonbox class="box-center"> <button type="submit"> {% trans %}Submit{% endtrans %} </button> </x-buttonbox> </form> </x-frame> </x-vbox> {% endblock %}
templates/repository/repo-forum-thread.html
@@ -13,7 +13,6 @@
<iconify-icon icon="mdi:arrow-left"></iconify-icon> </a> <h1>{{ parent.subject }}</h1> {{ max_post_nesting }}<div class="flexible-space"></div>