Verified Commit 12911a10 authored by Jelle van der Waa's avatar Jelle van der Waa 🚧
Browse files

Port homepage intro to fastapi

Port the main home page content to fastapi.
parent 0a3aa40f
Pipeline #9090 passed with stage
in 1 minute and 55 seconds
......@@ -46,3 +46,9 @@ def getboolean(section, option):
def getint(section, option, fallback=None):
return _get_parser().getint(section, option, fallback=fallback)
def get_section(section_name):
for section in _get_parser().sections():
if section == section_name:
return _get_parser()[section]
......@@ -58,6 +58,8 @@ async def language(request: Request,
async def index(request: Request):
""" Homepage route. """
context = make_context(request, "Home")
context['ssh_fingerprints'] = util.get_ssh_fingerprints()
return render_template(request, "index.html", context)
......
......@@ -172,3 +172,13 @@ def add_samesite_fields(response: Response, value: str):
cookie += f"; SameSite={value}"
response.raw_headers[idx] = (header[0], cookie.encode())
return response
def get_ssh_fingerprints():
fingerprints = {}
fingerprint_section = aurweb.config.get_section("fingerprints")
if fingerprint_section:
fingerprints = {key: fingerprint_section[key] for key in fingerprint_section.keys()}
return fingerprints
{% extends 'partials/layout.html' %}
{% block pageContent %}
<div id="intro" class="box">
<h2>AUR {% trans %}Home{% endtrans %}</h2>
<p>
{{ "Welcome to the AUR! Please read the %sAUR User Guidelines%s and %sAUR TU Guidelines%s for more information."
| tr
| format('<a href="https://wiki.archlinux.org/title/AUR_User_Guidelines">', "</a>",
'<a href="https://wiki.archlinux.org/title/AUR_Trusted_User_Guidelines">', "</a>")
| safe
}}
{{ "Contributed PKGBUILDs %smust%s conform to the %sArch Packaging Standards%s otherwise they will be deleted!"
| tr
| format("<strong>", "</strong>",
'<a href="https://wiki.archlinux.org/title/Arch_Packaging_Standards">',
"</a>")
| safe
}}
{% trans %}Remember to vote for your favourite packages!{% endtrans %}
{% trans %}Some packages may be provided as binaries in [community].{% endtrans %}
<p class="important">
{% trans %}DISCLAIMER{% endtrans %}:
{% trans %}AUR packages are user produced content. Any use of the provided files is at your own risk.{% endtrans %}
</p>
<p class="readmore"><a href="https://wiki.archlinux.org/title/AUR">{% trans %}Learn more...{% endtrans %}</a></p>
</p>
</div>
<div id="news">
<h3><a>{% trans %}Support{% endtrans %}</a><span class="arrow"></span></h3>
<h4>{% trans %}Package Requests{% endtrans %}</h4>
<div class="article-content">
<p>
{{ "There are three types of requests that can be filed in the %sPackage Actions%s box on the package details page:"
| tr
| format("<var>", "</var>")
| safe
}}
</p>
<ul>
<li><em>{% trans %}Orphan Request{% endtrans %}</em>: {% trans %}Request a package to be disowned, e.g. when the maintainer is inactive and the package has been flagged out-of-date for a long time.{% endtrans %}</li>
<li><em>{% trans %}Deletion Request{% endtrans %}</em>: {%trans %}Request a package to be removed from the Arch User Repository. Please do not use this if a package is broken and can be fixed easily. Instead, contact the package maintainer and file orphan request if necessary.{% endtrans %}</li>
<li><em>{% trans %}Merge Request{% endtrans %}</em>: {% trans %}Request a package to be merged into another one. Can be used when a package needs to be renamed or replaced by a split package.{% endtrans %}</li>
</ul>
<p>
{{ "If you want to discuss a request, you can use the %saur-requests%s mailing list. However, please do not use that list to file requests."
| tr
| format('<a href="https://mailman.archlinux.org/mailman/listinfo/aur-requests">', "</a>")
| safe
}}
</p>
</div>
<h4>{% trans %}Submitting Packages{% endtrans %}</h4>
<div class="article-content">
<p>
{{ "Git over SSH is now used to submit packages to the AUR. See the %sSubmitting packages%s section of the Arch User Repository ArchWiki page for more details."
| tr
| format('<a href="https://wiki.archlinux.org/title/Arch_User_Repository#Submitting_packages">', "</a>")
| safe
}}
</p>
{% if ssh_fingerprints %}
<p>
{% trans %}The following SSH fingerprints are used for the AUR:{% endtrans %}
<p>
<ul>
{% for keytype in ssh_fingerprints %}
<li><code>{{ keytype }}</code>: <code>{{ ssh_fingerprints[keytype] }}</code>
{% endfor %}
</ul>
{% endif %}
</div>
<h4>{% trans %}Discussion{% endtrans %}</h4>
<div class="article-content">
<p>
{{ "General discussion regarding the Arch User Repository (AUR) and Trusted User structure takes place on %saur-general%s. For discussion relating to the development of the AUR web interface, use the %saur-dev%s mailing list."
| tr
| format('<a href="https://mailman.archlinux.org/mailman/listinfo/aur-general">', "</a>",
'<a href="https://mailman.archlinux.org/mailman/listinfo/aur-dev">', "</a>")
| safe
}}
<p>
</div>
<h4>{% trans %}Bug Reporting{% endtrans %}</h4>
<div class="article-content">
<p>
{{ "If you find a bug in the AUR web interface, please fill out a bug report on our %sbug tracker%s. Use the tracker to report bugs in the AUR web interface %sonly%s. To report packaging bugs contact the package maintainer or leave a comment on the appropriate package page."
| tr
| format('<a href="https://bugs.archlinux.org/index.php?project=2">', "</a>",
"<strong>", "</strong>")
| safe
}}
</p>
</div>
</div>
{% endblock %}
from http import HTTPStatus
from unittest.mock import patch
from fastapi.testclient import TestClient
from aurweb.asgi import app
client = TestClient(app)
def test_homepage():
with client as request:
response = request.get("/")
assert response.status_code == int(HTTPStatus.OK)
@patch('aurweb.util.get_ssh_fingerprints')
def test_homepage_ssh_fingerprints(get_ssh_fingerprints_mock):
fingerprints = {'Ed25519': "SHA256:RFzBCUItH9LZS0cKB5UE6ceAYhBD5C8GeOBip8Z11+4"}
get_ssh_fingerprints_mock.return_value = fingerprints
with client as request:
response = request.get("/")
assert list(fingerprints.values())[0] in response.content.decode()
assert 'The following SSH fingerprints are used for the AUR' in response.content.decode()
@patch('aurweb.util.get_ssh_fingerprints')
def test_homepage_no_ssh_fingerprints(get_ssh_fingerprints_mock):
get_ssh_fingerprints_mock.return_value = {}
with client as request:
response = request.get("/")
assert 'The following SSH fingerprints are used for the AUR' not in response.content.decode()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment