Commit aef76c98 authored by Leonidas Spyropoulos's avatar Leonidas Spyropoulos
Browse files
parent dbbafc15
...@@ -18,7 +18,7 @@ from aurweb.auth import BasicAuthBackend ...@@ -18,7 +18,7 @@ from aurweb.auth import BasicAuthBackend
from aurweb.db import get_engine, query from aurweb.db import get_engine, query
from aurweb.models.accepted_term import AcceptedTerm from aurweb.models.accepted_term import AcceptedTerm
from aurweb.models.term import Term from aurweb.models.term import Term
from aurweb.routers import accounts, auth, errors, html, sso, trusted_user from aurweb.routers import accounts, auth, errors, html, packages, sso, trusted_user
# Setup the FastAPI app. # Setup the FastAPI app.
app = FastAPI(exception_handlers=errors.exceptions) app = FastAPI(exception_handlers=errors.exceptions)
...@@ -50,6 +50,7 @@ async def app_startup(): ...@@ -50,6 +50,7 @@ async def app_startup():
app.include_router(auth.router) app.include_router(auth.router)
app.include_router(accounts.router) app.include_router(accounts.router)
app.include_router(trusted_user.router) app.include_router(trusted_user.router)
app.include_router(packages.router)
# Initialize the database engine and ORM. # Initialize the database engine and ORM.
get_engine() get_engine()
......
from http import HTTPStatus
from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import HTMLResponse
from aurweb import db
from aurweb.models.package import Package
from aurweb.models.package_base import PackageBase
from aurweb.templates import make_variable_context, render_template
router = APIRouter()
ITEMS_PER_PAGE = 50 # Paged table size.
async def package_template(request: Request,
coff: int = 0, # current offset
poff: int = 0):
context = await make_variable_context(request, "Packages")
current_off, past_off = coff, poff
context["pp"] = pp = ITEMS_PER_PAGE
packages = db.query(Package).join(PackageBase).order_by(PackageBase.Popularity.desc())
context["pkglist_count"] = packages.count()
context["pkglist"] = list(packages.limit(pp).offset(current_off))
context["current_off"] = current_off
context["q"] = '&'.join([f"coff={current_off}", f"poff={past_off}"])
return render_template(request, "package/packages.html", context)
@router.get("/packages", response_class=HTMLResponse)
async def package(request: Request,
coff: int = 0, # current offset
poff: int = 0): # past offset
return await package_template(request, coff, poff)
@router.get("/packages/{package}")
async def package_single(request: Request, package: str,
coff: int = 0, # current offset
poff: int = 0): # past offset
context = await make_variable_context(request, "Packages")
current_off, past_off = coff, poff
pkg = db.query(Package).join(PackageBase).filter(PackageBase.Name == package).first()
if not pkg:
raise HTTPException(status_code=int(HTTPStatus.NOT_FOUND))
context["package"] = pkg
context["current_off"] = current_off
context["q"] = '&'.join([f"coff={current_off}", f"poff={past_off}"])
return render_template(request, "package/packages.html", context)
...@@ -58,6 +58,11 @@ def generate_nginx_config(): ...@@ -58,6 +58,11 @@ def generate_nginx_config():
pid {os.path.join(temporary_dir, "nginx.pid")}; pid {os.path.join(temporary_dir, "nginx.pid")};
http {{ http {{
access_log /dev/stdout; access_log /dev/stdout;
client_body_temp_path {os.path.join(temporary_dir, "client_body")};
proxy_temp_path {os.path.join(temporary_dir, "proxy")};
fastcgi_temp_path {os.path.join(temporary_dir, "fastcgi")}1 2;
uwsgi_temp_path {os.path.join(temporary_dir, "uwsgi")};
scgi_temp_path {os.path.join(temporary_dir, "scgi")};
server {{ server {{
listen {aur_location_parts.netloc}; listen {aur_location_parts.netloc};
location / {{ location / {{
......
{% extends "partials/layout.html" %}
{% block pageContent %}
{% include "partials/packages/search.html" %}
{% if pkglist %}
{% set off = current_off %}
{% set off_param = "coff" %}
{% set results = pkglist %}
{% set results_count = pkglist_count %}
{% set table_class = "pkglist-stats" %}
{% include "partials/packages/pkglist.html" %}
{% else %}
{% set result = package %}
{% include "partials/packages/pkgdetails.html" %}
{% endif %}
{% endblock %}
<div id="pkgdetails" class="box">
<h2>Package Details: {{ result.Name }} {{ result.Version }}</h2>
<div id="detailslinks" class="listing">
<div id="actionlist">
<h4>Package Actions</h4>
<ul class="small">
<li>
<a href="/cgit/aur.git/tree/PKGBUILD?h=zyuganovs">View PKGBUILD</a> /
<a href="/cgit/aur.git/log/?h=zyuganovs">View Changes</a>
</li>
<li><a href="/cgit/aur.git/snapshot/zyuganovs.tar.gz">Download snapshot</a>
<li><a href="https://wiki.archlinux.org/title/Special:Search?search=zyuganovs">Search wiki</a></li>
<li><span class="flagged"></span></li>
<li><a href="http://127.0.0.1:8080/login/?referer=http%3A%2F%2F127.0.0.1%3A8080%2Fpkgbase%2Fzyuganovs%2Fflag%2F">Flag package out-of-date</a></li>
<li><a href="http://127.0.0.1:8080/login/">Vote for this package</a></li>
<li><a href="http://127.0.0.1:8080/login/">Enable notifications</a></li>
<li><span class="flagged"></span></li>
<li><a href="http://127.0.0.1:8080/login/?referer=http%3A%2F%2F127.0.0.1%3A8080%2Fpkgbase%2Fzyuganovs%2Frequest%2F">Submit Request</a></li>
</ul>
</div>
</div>
<table id="pkginfo">
<tr>
<th>Git Clone URL: </th>
<td>
<a class="copy" href="https://aur.archlinux.org/{{ result.Name }}.git">https://aur.archlinux.org/{{ result.Name }}.git</a> (read-only, click to copy)
</td>
</tr>
<tr>
<th>Package Base: </th>
<td class="wrap"><a href="/pkgbase/{{ result.PackageBase.Name }}/">{{ result.PackageBase.Name }}</a></td>
</tr>
<tr>
<th>Description: </th>
<td class="wrap">{{ result.Description }}</td>
</tr>
<tr>
<th>Upstream URL: </th>
<td class="wrap">{{ result.URL }}</td>
</tr>
<tr>
<th>Conflicts: TODO</th>
<td class="wrap relatedto"><span class="related">anglicise,</span><span class="related">cruiser,</span><span class="related">mego</span></td>
</tr>
<tr>
<th>Provides: TODO</th>
<td class="wrap relatedto"><span class="related">b,</span><span class="related">comportment,</span><span class="related">dementedly,</span><span class="related">mannikin</span></td>
</tr>
<tr>
<th>Submitter: </th>
<td>{{ result.PackageBase.Submitter.Username | default("None") }}</td>
</tr>
<tr>
<th>Maintainer: </th>
<td>{{ result.PackageBase.Maintainer.Username | default("None") }}</td>
</tr>
<tr>
<th>Last Packager: </th>
<td>{{ result.PackageBase.Packager.Username | default("None") }}</td>
</tr>
<tr>
<th>Votes: </th>
<td>{{ result.PackageBase.NumVotes }}</td>
</tr>
<tr>
<th>Popularity: </th>
<td>{{ '%0.2f' % result.PackageBase.Popularity | float }}</td>
</tr>
<tr>
<th>First Submitted: </th>
<td>{{ result.PackageBase.SubmittedTS }}</td>
</tr>
<tr>
<th>Last Updated: </th>
<td>2021-06-18 07:44</td>
</tr>
</table>
<div id="metadata">
<div id="pkgdeps" class="listing">
<h3>Dependencies (7)</h3>
<ul id="pkgdepslist">
<li><a href="/packages/acadias/" title="View packages details for acadias">acadias</a> <span class="virtual-dep">(<a href="/packages/unfitnesss/" title="View packages details for unfitnesss">unfitnesss</a>, <a href="/packages/dawns/" title="View packages details for dawns">dawns</a>)</span></li>
<li><a href="/packages/discordance/" title="View packages details for discordance">discordance</a> <span class="virtual-dep">(<a href="/packages/bankrolls/" title="View packages details for bankrolls">bankrolls</a>)</span></li>
<li><a href="/packages/damian/" title="View packages details for damian">damian</a> <span class="virtual-dep">(<a href="/packages/tallowy/" title="View packages details for tallowy">tallowy</a>, <a href="/packages/starch/" title="View packages details for starch">starch</a>)</span> <em>(check)</em></li>
<li><a href="/packages/ambassador/" title="View packages details for ambassador">ambassador</a> <span class="virtual-dep">(<a href="/packages/stabilitys/" title="View packages details for stabilitys">stabilitys</a>, <a href="/packages/squiggle/" title="View packages details for squiggle">squiggle</a>, <a href="/packages/ebullitions/" title="View packages details for ebullitions">ebullitions</a>)</span> <em>(make)</em></li>
<li><span class="broken">convocation: for budweiser</span> <em>(optional)</em></li>
<li><span class="broken">illusions: for tishri</span> <em>(optional)</em></li>
<li><span class="broken">yuppie: for hiccough</span> <em>(optional)</em></li>
</ul>
</div>
<div id="pkgreqs" class="listing">
<h3>Required by (30)</h3>
<ul id="pkgreqslist">
<li><a href="/packages/abet/" title="View packages details for abet">abet</a> <span class="virtual-dep">(requires comportment)</span> <em>(make)</em></li>
<li><a href="/packages/abscesss/" title="View packages details for abscesss">abscesss</a> <span class="virtual-dep">(requires mannikin)</span> <em>(check)</em></li>
<li><a href="/packages/attaches/" title="View packages details for attaches">attaches</a> <span class="virtual-dep">(requires mannikin)</span> <em>(check)</em></li>
<li><a href="/packages/bedeck/" title="View packages details for bedeck">bedeck</a> <span class="virtual-dep">(requires b)</span> <em>(make)</em></li>
<li><a href="/packages/blu/" title="View packages details for blu">blu</a> <span class="virtual-dep">(requires mannikin)</span> <em>(make)</em></li>
<li><a href="/packages/catacomb/" title="View packages details for catacomb">catacomb</a> <span class="virtual-dep">(requires dementedly)</span> <em>(make)</em></li>
<li><a href="/packages/combatted/" title="View packages details for combatted">combatted</a> <span class="virtual-dep">(requires b)</span></li>
<li><a href="/packages/confidentiality/" title="View packages details for confidentiality">confidentiality</a> <span class="virtual-dep">(requires b)</span></li>
<li><a href="/packages/enos/" title="View packages details for enos">enos</a> <span class="virtual-dep">(requires mannikin)</span> <em>(make)</em></li>
<li><a href="/packages/eosinophil/" title="View packages details for eosinophil">eosinophil</a> <span class="virtual-dep">(requires dementedly)</span> <em>(check)</em></li>
<li><a href="/packages/extrusion/" title="View packages details for extrusion">extrusion</a> <span class="virtual-dep">(requires comportment)</span> <em>(check)</em></li>
<li><a href="/packages/horses/" title="View packages details for horses">horses</a> <span class="virtual-dep">(requires b)</span></li>
<li><a href="/packages/legalistically/" title="View packages details for legalistically">legalistically</a> <span class="virtual-dep">(requires comportment)</span></li>
<li><a href="/packages/minoans/" title="View packages details for minoans">minoans</a> <span class="virtual-dep">(requires dementedly)</span></li>
<li><a href="/packages/occupy/" title="View packages details for occupy">occupy</a> <span class="virtual-dep">(requires comportment)</span> <em>(check)</em></li>
<li><a href="/packages/osteopathy/" title="View packages details for osteopathy">osteopathy</a> <span class="virtual-dep">(requires dementedly)</span></li>
<li><a href="/packages/pickers/" title="View packages details for pickers">pickers</a> <span class="virtual-dep">(requires comportment)</span> <em>(make)</em></li>
<li><a href="/packages/pilferage/" title="View packages details for pilferage">pilferage</a> <em>(check)</em></li>
<li><a href="/packages/playstation/" title="View packages details for playstation">playstation</a> <span class="virtual-dep">(requires comportment)</span></li>
<li><a href="/packages/playtime/" title="View packages details for playtime">playtime</a> <span class="virtual-dep">(requires mannikin)</span> <em>(check)</em></li>
<li><a href="/packages/postmasters/" title="View packages details for postmasters">postmasters</a> <span class="virtual-dep">(requires dementedly)</span> <em>(check)</em></li>
<li><a href="/packages/prissinesss/" title="View packages details for prissinesss">prissinesss</a> <span class="virtual-dep">(requires dementedly)</span> <em>(make)</em></li>
<li><a href="/packages/puzo/" title="View packages details for puzo">puzo</a></li>
<li><a href="/packages/radiotelegraphys/" title="View packages details for radiotelegraphys">radiotelegraphys</a> <span class="virtual-dep">(requires dementedly)</span> <em>(check)</em></li>
<li><a href="/packages/rankling/" title="View packages details for rankling">rankling</a> <span class="virtual-dep">(requires mannikin)</span></li>
<li><a href="/packages/smoochy/" title="View packages details for smoochy">smoochy</a> <span class="virtual-dep">(requires comportment)</span></li>
<li><a href="/packages/spooled/" title="View packages details for spooled">spooled</a> <em>(check)</em></li>
<li><a href="/packages/surprisings/" title="View packages details for surprisings">surprisings</a> <span class="virtual-dep">(requires mannikin)</span> <em>(check)</em></li>
<li><a href="/packages/untruer/" title="View packages details for untruer">untruer</a> <em>(check)</em></li>
<li><a href="/packages/whittiers/" title="View packages details for whittiers">whittiers</a> <span class="virtual-dep">(requires b)</span> <em>(make)</em></li>
</ul>
</div>
<div id="pkgfiles" class="listing">
<h3>Sources (2)</h3>
</div>
<div>
<ul id="pkgsrcslist">
<li><a href="http://www.zyuganovs.org/src/extinguishes-9.14-5.tar.gz">http://www.zyuganovs.org/src/extinguishes-9.14-5.tar.gz</a></li>
<li><a href="http://www.zyuganovs.tw/files/hibernations-4.16-4.tar.gz">http://www.zyuganovs.tw/files/hibernations-4.16-4.tar.gz</a></li>
</ul>
</div>
</div>
</div>
<div id="pkglist-results" class="box">
{% if not results %}
<p>{% trans %}No results found.{% endtrans %}</p>
{% else %}
<div class="pkglist-stats">
<p>{{ results_count }} packages found. Page x of y.</p>
<p class="pkglist-nav">
<span class="page">1</span>
<a class="page" href="/packages/?SB=p&amp;SO=d&amp;O=50">2</a>
<a class="page" href="/packages/?SB=p&amp;SO=d&amp;O=100">3</a>
<a class="page" href="/packages/?SB=p&amp;SO=d&amp;O=150">4</a>
<a class="page" href="/packages/?SB=p&amp;SO=d&amp;O=200">5</a>
<a class="page" href="/packages/?SB=p&amp;SO=d&amp;O=250">6</a>
<span class="page">... </span>
<a class="page" href="/packages/?SB=p&amp;SO=d&amp;O=50">Next &rsaquo;</a>
<a class="page" href="/packages/?SB=p&amp;SO=d&amp;O=2450">Last &raquo;</a>
</p>
</div>
<form id="pkglist-results-form" method="post" action="/pkgbase/?">
<table class="results {{ table_class }}">
<thead>
<tr>
{% if request.user.is_authenticated() %}
<th>&nbsp;</th>
{% endif %}
<th><a href="?SB=n&amp;SO=a">{{ "Name" | tr }}</a></th>
<th>{{ "Version" | tr }}</th>
<th><a href="?SB=v&amp;SO=a">{{ "Votes" | tr }}</a></th>
<th><a href="?SB=p&amp;SO=a">{{ "Popularity" | tr }}</a><span title="Popularity is calculated as the sum of all votes with each vote being weighted with a factor of 0.98 per day since its creation." class="hover-help"><sup>?</sup></span></th>
{% if request.user.is_authenticated() %}
<th>{{ "Voted" | tr }}</th>
<th>{{ "Notify" | tr }}</th>
{% endif %}
<th>{{ "Description" | tr }}</th>
<th><a href="?SB=m&amp;SO=a">{{ "Maintainer" | tr }}</a></th>
</tr>
</thead>
<tbody>
{% for result in results %}
{% set cls = "even" if loop.index % 2 else "odd" %}
<tr class="{{ cls }}">
{% if request.user.is_authenticated() %}
{# TODO fix this IDs name checkbox #}
<td><input type="checkbox" name="IDs[63297]" value="1" /></td>
{% endif %}
<td><a href="/packages/{{ result.Name }}/">{{ result.Name }}</a></td>
<td>{{ result.Version }}</td>
<td>{{ result.PackageBase.NumVotes }}</td>
<td>{{ '%0.2f' % result.PackageBase.Popularity | float }}</td>
{% if request.user.is_authenticated() %}
<td>{{ result.Voted }}</td>
<td>{{ result.Notify }}</td>
{% endif %}
<td>{{ result.PackageBase.Description }}</td>
<td>{{ result.PackageBase.Packager.Username }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</form>
{% endif %}
</div>
<div id="pkglist-search" class="box filter-criteria">
<h2>{% trans %}Search Criteria{% endtrans %}</h2>
<form action='/packages/' method='get'>
<p><input type='hidden' name='O' value='0'/></p>
<fieldset>
<legend>Enter search criteria</legend>
<div>
<label for="id_method">Search by</label>
<select name='SeB'>
<option value="nd">Name, Description</option>
<option value="n">Name Only</option>
<option value="b">Package Base</option>
<option value="N">Exact Name</option>
<option value="B">Exact Package Base</option>
<option value="k">Keywords</option>
<option value="m">Maintainer</option>
<option value="c">Co-maintainer</option>
<option value="M">Maintainer, Co-maintainer</option>
<option value="s">Submitter</option>
</select>
</div>
<div>
<label for="id_q">Keywords</label>
<input type='text' name='K' size='30' value="" maxlength='35'/>
</div>
<div>
<label for="id_out_of_date">Out of Date</label>
<select name='outdated'>
<option value=''>All</option>
<option value='on'>Flagged</option>
<option value='off'>Not Flagged</option>
</select>
</div>
<div>
<label for="id_sort_by">Sort by</label>
<select name='SB'>
<option value='n'>Name</option>
<option value='v'>Votes</option>
<option value='p'>Popularity</option>
<option value='w'>Voted</option>
<option value='o'>Notify</option>
<option value='m'>Maintainer</option>
<option value='l'>Last modified</option>
</select>
</div>
<div>
<label for="id_order_by">Sort order</label>
<select name='SO'>
<option value='a'>Ascending</option>
<option value='d'>Descending</option>
</select>
</div>
<div>
<label for="id_per_page">Per page</label>
<select name='PP'>
<option value="50">50</option>
<option value="100">100</option>
<option value="250">250</option>
</select>
</div>
<div>
<label>&nbsp;</label>
<input type='submit' class='button' name='do_Search' value='Go'/>
<input type='submit' class='button' name='do_Orphans' value='Orphans'/>
</div>
</fieldset>
</form>
</div>
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